This repository has been archived by the owner on May 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
111 lines (99 loc) · 1.8 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package main
import (
"fmt"
"os"
"bitbucket.org/minerstats/miners/bminer"
"bitbucket.org/minerstats/miners/ccminer"
"bitbucket.org/minerstats/miners/claymore"
"bitbucket.org/minerstats/miners/ethminer"
"bitbucket.org/minerstats/miners/enemy"
"bitbucket.org/minerstats/miners/ewbf"
"bitbucket.org/minerstats/miners/xmrig"
"bitbucket.org/minerstats/miners/xmrstak"
"bitbucket.org/minerstats/miners/zm"
"bitbucket.org/minerstats/output"
"bitbucket.org/minerstats/sniff"
)
var buf []byte
var host string
//var port string
func usage() {
var usage string = `minerstats
usage:
minerstats takes no arguments
it can detect the following miners:
bminer
ccminer
claymore
dtsm
enemy
ewbf
xmrig-nvidia
xmr-stak
`
fmt.Println(usage)
}
func hitMiner(miner string, port string) {
switch miner {
case "ccminer":
{
ccminer.HitCCMiner(host, port, &buf)
}
case "ccminer-enemy":
{
enemy.HitEnemy(host, port, &buf)
}
case "bminer":
{
bminer.HitBminer(host, port, &buf)
}
case "ewbf":
{
ewbf.HitEwbf(host, port, &buf)
}
case "zm":
{
zm.HitZM(host, port, &buf)
}
case "claymore":
{
claymore.HitClaymore(host, port, &buf)
}
case "ethminer":
{
ethminer.HitEthminer(host, port, &buf)
}
case "xmrig":
{
xmrig.HitXMRig(host, port, &buf)
}
case "xmrstak":
{
xmrstak.HitXMRStak(host, port, &buf)
}
default:
{
fmt.Println("ERROR! miner argument not recognized!")
os.Exit(1)
}
}
fmt.Println(string(buf))
}
func main() {
args := os.Args[1:]
if len(args) > 0 {
usage()
os.Exit(1)
}
host = "localhost"
op, err := sniff.SniffMiner()
// FIXME: return JSON with error
if err != nil {
// fmt.Println(err.Error())
fmt.Println(string(output.MakeJSONError("", err)))
os.Exit(1)
}
for _, v := range op {
hitMiner(v.Name, v.Port)
}
}