mirror of
https://github.com/openp2p-cn/openp2p.git
synced 2026-11-24 12:42:58 +08:00
Update config.go
Stop writing ServerPort in init because it is never used and will be overwritten in parseParams. Give FlagSet value written by init. Correct the behavior of notVerbose.
This commit is contained in:
@@ -267,8 +267,6 @@ func init() {
|
||||
gConf.LogLevel = int(LvINFO)
|
||||
gConf.Network.ShareBandwidth = 10
|
||||
gConf.Network.ServerHost = "api.openp2p.cn"
|
||||
gConf.Network.ServerPort = WsPort
|
||||
|
||||
}
|
||||
|
||||
func (c *Config) load() error {
|
||||
@@ -380,7 +378,7 @@ type NetworkConfig struct {
|
||||
|
||||
func parseParams(subCommand string, cmd string) {
|
||||
fset := flag.NewFlagSet(subCommand, flag.ExitOnError)
|
||||
serverHost := fset.String("serverhost", "api.openp2p.cn", "server host ")
|
||||
serverHost := fset.String("serverhost", gConf.Network.ServerHost, "server host ")
|
||||
serverPort := fset.Int("serverport", WsPort, "server port ")
|
||||
// serverHost := flag.String("serverhost", "127.0.0.1", "server host ") // for debug
|
||||
token := fset.Uint64("token", 0, "token")
|
||||
@@ -396,11 +394,11 @@ func parseParams(subCommand string, cmd string) {
|
||||
punchPriority := fset.Int("punch_priority", 0, "bitwise DisableTCP|DisableUDP|UDPFirst 0:tcp and udp both enable, tcp first")
|
||||
appName := fset.String("appname", "", "app name")
|
||||
relayNode := fset.String("relaynode", "", "relaynode")
|
||||
shareBandwidth := fset.Int("sharebandwidth", 10, "N mbps share bandwidth limit, private network no limit")
|
||||
shareBandwidth := fset.Int("sharebandwidth", gConf.Network.ShareBandwidth, "N mbps share bandwidth limit, private network no limit")
|
||||
daemonMode := fset.Bool("d", false, "daemonMode")
|
||||
notVerbose := fset.Bool("nv", false, "not log console")
|
||||
newconfig := fset.Bool("newconfig", false, "not load existing config.json")
|
||||
logLevel := fset.Int("loglevel", 1, "0:debug 1:info 2:warn 3:error")
|
||||
logLevel := fset.Int("loglevel", gConf.LogLevel, "0:debug 1:info 2:warn 3:error")
|
||||
maxLogSize := fset.Int("maxlogsize", 1024*1024, "default 1MB")
|
||||
if cmd == "" {
|
||||
if subCommand == "" { // no subcommand
|
||||
@@ -490,7 +488,7 @@ func parseParams(subCommand string, cmd string) {
|
||||
gConf.Network.UDPPort2 = UDPPort2
|
||||
gLog.setLevel(LogLevel(gConf.LogLevel))
|
||||
if *notVerbose {
|
||||
gLog.setMode(LogFile)
|
||||
gLog.setMode(gLog.Mode() &^ LogConsole)
|
||||
}
|
||||
// gConf.mtx.Unlock()
|
||||
gConf.save()
|
||||
|
||||
Reference in New Issue
Block a user