Use environment variable in frontend
This commit is contained in:
parent
a79b0cd92c
commit
eb977532c0
@ -1,8 +1,10 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"flag"
|
"flag"
|
||||||
"strings"
|
"strings"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
var settingServers []string
|
var settingServers []string
|
||||||
@ -12,17 +14,50 @@ var settingWhoisServer string
|
|||||||
var settingListen string
|
var settingListen string
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
serversPtr := flag.String("servers", "", "server name prefixes, separated by comma")
|
serversDefault := ""
|
||||||
domainPtr := flag.String("domain", "", "server name domain suffixes")
|
domainDefault := ""
|
||||||
portPtr := flag.Int("port", 8000, "port bird-lgproxy is running on")
|
proxyPortDefault := 8000
|
||||||
whoisPtr := flag.String("whois", "whois.verisign-grs.com", "whois server for queries")
|
whoisDefault := "whois.verisign-grs.com"
|
||||||
listenPortPtr := flag.String("listen", ":5000", "address bird-lg is listening on")
|
listenDefault := ":5000"
|
||||||
|
|
||||||
|
if serversEnv := os.Getenv("BIRDLG_SERVERS"); serversEnv != "" {
|
||||||
|
serversDefault = serversEnv
|
||||||
|
}
|
||||||
|
if domainEnv := os.Getenv("BIRDLG_DOMAIN"); domainEnv != "" {
|
||||||
|
domainDefault = domainEnv
|
||||||
|
}
|
||||||
|
if proxyPortEnv := os.Getenv("BIRDLG_PROXY_PORT"); proxyPortEnv != "" {
|
||||||
|
var err error
|
||||||
|
proxyPortDefault, err = strconv.Atoi(proxyPortEnv)
|
||||||
|
if err != nil{
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if whoisEnv := os.Getenv("BIRDLG_WHOIS"); whoisEnv != "" {
|
||||||
|
whoisDefault = whoisEnv
|
||||||
|
}
|
||||||
|
if listenEnv := os.Getenv("BIRDLG_LISTEN"); listenEnv != "" {
|
||||||
|
listenDefault = listenEnv
|
||||||
|
}
|
||||||
|
|
||||||
|
serversPtr := flag.String("servers", serversDefault, "server name prefixes, separated by comma")
|
||||||
|
domainPtr := flag.String("domain", domainDefault, "server name domain suffixes")
|
||||||
|
proxyPortPtr := flag.Int("proxy-port", proxyPortDefault, "port bird-lgproxy is running on")
|
||||||
|
whoisPtr := flag.String("whois", whoisDefault, "whois server for queries")
|
||||||
|
listenPtr := flag.String("listen", listenDefault, "address bird-lg is listening on")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if *serversPtr == "" {
|
||||||
|
panic("no server set")
|
||||||
|
} else if *domainPtr == "" {
|
||||||
|
panic("no base domain set")
|
||||||
|
}
|
||||||
|
|
||||||
settingServers = strings.Split(*serversPtr, ",")
|
settingServers = strings.Split(*serversPtr, ",")
|
||||||
settingServersDomain = *domainPtr
|
settingServersDomain = *domainPtr
|
||||||
settingServersPort = *portPtr
|
settingServersPort = *proxyPortPtr
|
||||||
settingWhoisServer = *whoisPtr
|
settingWhoisServer = *whoisPtr
|
||||||
settingListen = *listenPortPtr
|
settingListen = *listenPtr
|
||||||
|
|
||||||
webServerStart()
|
webServerStart()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user