forked from btfak/sniper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
global.go
77 lines (63 loc) · 2.09 KB
/
global.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
package main
import (
"fmt"
"os"
)
//work variant
var over chan struct{}
var home = os.Getenv("HOME")
var maxRecvSize int
//var maxReqSize int
const (
recvSizeOffset = 64
)
//config variant
var sniperLog = "/usr/local/var/sniper.log"
var sniperc = home + "/.sniperc"
var record Record
type Record struct {
trans chan *transaction
}
//function variant
var sniperUsage = func() {
fmt.Println(sniperUsageInfo)
os.Exit(2)
}
var sniperVersion = func() {
fmt.Println(sniperVersionInfo)
os.Exit(2)
}
var sniperConfig = func() {
config.Command.sniperc = sniperc
config.parseConfigFile()
sniperShowConfig()
os.Exit(2)
}
var sniperShowConfig = func() {
fmt.Println("CURRENT SNIPER CONFIGURATION")
fmt.Println("Edit the config file to change the settings")
fmt.Println(`--------------------------------------------`)
fmt.Printf("version: %s\n", config.Protocol.version)
fmt.Printf("connection: %s\n", config.Protocol.connection)
fmt.Printf("accept-encoding: %s\n", config.Protocol.acceptEncoding)
fmt.Printf("user-agent: %s\n", config.Protocol.userAgent)
fmt.Printf("timeout: %d\n", config.Process.timeout)
fmt.Printf("failures: %d\n", config.Process.failures)
fmt.Printf("login: %s\n", config.Authenticate.login)
fmt.Printf("ssl-cert: %s\n", config.Ssl.cert)
fmt.Printf("ssl-key: %s\n", config.Ssl.key)
fmt.Printf("ssl-timeout: %d\n", config.Ssl.timeout)
//fmt.Printf("ssl-ciphers: %s\n", config.Ssl.ciphers)
//fmt.Printf("proxy-host: %s\n", config.Proxy.host)
//fmt.Printf("proxy-port: %s\n", config.Proxy.port)
//fmt.Printf("proxy-login: %s\n", config.Proxy.login)
fmt.Println(`--------------------------------------------`)
}
var sniperNoData = func() {
fmt.Println(sniperNoDataInfo)
os.Exit(2)
}
var sniperOpenFileError = func() {
fmt.Println(sniperOpenFileErrorInfo)
os.Exit(2)
}