forked from Cliffbreak/tsviewer
Merge branch 'master' of https://git.cliffbreak.de/Cliffbreak/tsviewer
This commit is contained in:
commit
8bd0e85e17
1 changed files with 37 additions and 0 deletions
|
@ -2,6 +2,7 @@ package config
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
|
@ -47,6 +48,8 @@ func New() (*Config, error) {
|
|||
jsonParser := json.NewDecoder(configFile)
|
||||
jsonParser.Decode(&config)
|
||||
|
||||
config.overrideWithFlags()
|
||||
|
||||
return &config, nil
|
||||
}
|
||||
|
||||
|
@ -75,3 +78,37 @@ func defaults() Config {
|
|||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (config *Config) overrideWithFlags() {
|
||||
username := flag.String("ts3_name", "", "TS3Query username")
|
||||
password := flag.String("ts3_pw", "", "TS3Query user password")
|
||||
tsIP := flag.String("ts3_ip", "", "TS3 IP address")
|
||||
tsPort := flag.Uint64("ts3_port", 65536, "TS3 port")
|
||||
tsQuery := flag.Uint64("ts3_query", 65536, "TS3 query port")
|
||||
webPort := flag.Uint64("web_port", 65536, "Webserver port")
|
||||
flag.Parse()
|
||||
|
||||
if *username != "" {
|
||||
config.User.Name = *username
|
||||
}
|
||||
|
||||
if *password != "" {
|
||||
config.User.Password = *password
|
||||
}
|
||||
|
||||
if *tsIP != "" {
|
||||
config.ServerTS.IP = *tsIP
|
||||
}
|
||||
|
||||
if *tsPort <= 65535 {
|
||||
config.ServerTS.PortServer = uint16(*tsPort)
|
||||
}
|
||||
|
||||
if *tsQuery <= 65535 {
|
||||
config.ServerTS.PortQuery = uint16(*tsQuery)
|
||||
}
|
||||
|
||||
if *webPort <= 65535 {
|
||||
config.ServerWeb.Port = uint16(*webPort)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue