From aeef2afb2e90bd2f53eaa616c4317b79dd66ada0 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Tue, 18 Nov 2014 14:04:24 +0800 Subject: [PATCH] . --- conf/wide.go | 18 +++++++++++++++++- main.go | 4 +++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/conf/wide.go b/conf/wide.go index f1067ad..5d5ecf2 100644 --- a/conf/wide.go +++ b/conf/wide.go @@ -266,7 +266,7 @@ func Save() bool { } // Load loads the configurations from wide.json. -func Load(confPath, confIP, confPort string) { +func Load(confPath, confIP, confPort, confServer, confChannel string) { bytes, _ := ioutil.ReadFile(confPath) err := json.Unmarshal(bytes, &Wide) @@ -302,11 +302,27 @@ func Load(confPath, confIP, confPort string) { } Wide.Server = strings.Replace(Wide.Server, "{IP}", Wide.IP, 1) + if "" != confServer { + Wide.Server = confServer + } + Wide.StaticServer = strings.Replace(Wide.StaticServer, "{IP}", Wide.IP, 1) Wide.EditorChannel = strings.Replace(Wide.EditorChannel, "{IP}", Wide.IP, 1) + if "" != confChannel { + Wide.EditorChannel = confChannel + } Wide.OutputChannel = strings.Replace(Wide.OutputChannel, "{IP}", Wide.IP, 1) + if "" != confChannel { + Wide.OutputChannel = confChannel + } Wide.ShellChannel = strings.Replace(Wide.ShellChannel, "{IP}", Wide.IP, 1) + if "" != confChannel { + Wide.ShellChannel = confChannel + } Wide.SessionChannel = strings.Replace(Wide.SessionChannel, "{IP}", Wide.IP, 1) + if "" != confChannel { + Wide.SessionChannel = confChannel + } Wide.Server = strings.Replace(Wide.Server, "{Port}", Wide.Port, 1) Wide.StaticServer = strings.Replace(Wide.StaticServer, "{Port}", Wide.Port, 1) diff --git a/main.go b/main.go index aecb792..4861c69 100644 --- a/main.go +++ b/main.go @@ -43,6 +43,8 @@ func init() { confPath := flag.String("conf", "conf/wide.json", "path of wide.json") confIP := flag.String("ip", "", "ip to visit") confPort := flag.String("port", "", "port to visit") + confServer := flag.String("server", "", "this will overwrite Wide.Server if specified") + confChannel := flag.String("channel", "", "this will overwrite Wide.XXXChannel if specified") flag.Set("logtostderr", "true") flag.Set("v", "3") @@ -52,7 +54,7 @@ func init() { event.Load() - conf.Load(*confPath, *confIP, *confPort) + conf.Load(*confPath, *confIP, *confPort, *confServer, *confChannel) conf.FixedTimeCheckEnv() conf.FixedTimeSave()