-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
56 lines (42 loc) · 1.5 KB
/
config.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
package main
import (
"bigw-voting/util"
flag "github.com/spf13/pflag"
)
var (
flagIntermediateIP string
flagIntermediatePort int
flagPeerIP string
flagVotepackFilename string
flagExternalIP string
flagLogFile bool
flagNoUPNP bool
flagTrusteeExport bool
)
func parseCommandline() {
flag.StringVarP(&flagIntermediateIP, "intermediateIP", "i", "", "The IPv4 address of the intermediate to connect through")
flag.IntVarP(&flagIntermediatePort, "intermediatePort", "o", 42069, "The UDP port of the intermediate to connect through")
flag.StringVarP(&flagPeerIP, "peerIP", "p", "", "The IPv4 address of the peer to begin connecting with")
flag.StringVarP(&flagVotepackFilename, "votepack", "v", "", "The filename of the votepack to use")
flag.StringVar(&flagExternalIP, "externalIP", "", "An external IP to use instead of discovering one")
flag.BoolVar(&flagLogFile, "log", false, "Should messages be written to debug.log")
flag.BoolVar(&flagNoUPNP, "noUPNP", false, "Disable UPNP port forwarding")
flag.BoolVar(&flagTrusteeExport, "exportTrusteeVote", false, "Export a new trustee vote")
flag.Parse()
// Check for config errors
if flagVotepackFilename == "" {
panic("a votepack must be specified")
}
if !flagTrusteeExport {
if flagIntermediateIP == "" {
panic("intermediate IP address is a required flag")
}
if flagPeerIP == "" {
panic("peer IP address is a required flag")
}
}
// Check whether we should start the debug log
if flagLogFile {
util.SetDualLogging()
}
}