frontend multi listen
This commit is contained in:
@@ -12,7 +12,7 @@ type settingType struct {
|
|||||||
domain string
|
domain string
|
||||||
proxyPort int
|
proxyPort int
|
||||||
whoisServer string
|
whoisServer string
|
||||||
listen string
|
listen []string
|
||||||
dnsInterface string
|
dnsInterface string
|
||||||
netSpecificMode string
|
netSpecificMode string
|
||||||
titleBrand string
|
titleBrand string
|
||||||
@@ -35,15 +35,16 @@ func main() {
|
|||||||
parseSettings()
|
parseSettings()
|
||||||
ImportTemplates()
|
ImportTemplates()
|
||||||
|
|
||||||
|
for _, listenAddr := range setting.listen {
|
||||||
|
go func(listenAddr string) {
|
||||||
var l net.Listener
|
var l net.Listener
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
if strings.HasPrefix(setting.listen, "/") {
|
if strings.HasPrefix(listenAddr, "/") {
|
||||||
// Delete existing socket file, ignore errors (will fail later anyway)
|
// Delete existing socket file, ignore errors (will fail later anyway)
|
||||||
os.Remove(setting.listen)
|
os.Remove(listenAddr)
|
||||||
l, err = net.Listen("unix", setting.listen)
|
l, err = net.Listen("unix", listenAddr)
|
||||||
} else {
|
} else {
|
||||||
listenAddr := setting.listen
|
|
||||||
if !strings.Contains(listenAddr, ":") {
|
if !strings.Contains(listenAddr, ":") {
|
||||||
listenAddr = ":" + listenAddr
|
listenAddr = ":" + listenAddr
|
||||||
}
|
}
|
||||||
@@ -55,4 +56,8 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
webServerStart(l)
|
webServerStart(l)
|
||||||
|
}(listenAddr)
|
||||||
|
}
|
||||||
|
|
||||||
|
select {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ type viperSettingType struct {
|
|||||||
Domain string `mapstructure:"domain"`
|
Domain string `mapstructure:"domain"`
|
||||||
ProxyPort int `mapstructure:"proxy_port"`
|
ProxyPort int `mapstructure:"proxy_port"`
|
||||||
WhoisServer string `mapstructure:"whois"`
|
WhoisServer string `mapstructure:"whois"`
|
||||||
Listen string `mapstructure:"listen"`
|
Listen []string `mapstructure:"listen"`
|
||||||
DNSInterface string `mapstructure:"dns_interface"`
|
DNSInterface string `mapstructure:"dns_interface"`
|
||||||
NetSpecificMode string `mapstructure:"net_specific_mode"`
|
NetSpecificMode string `mapstructure:"net_specific_mode"`
|
||||||
TitleBrand string `mapstructure:"title_brand"`
|
TitleBrand string `mapstructure:"title_brand"`
|
||||||
@@ -52,7 +52,7 @@ func parseSettings() {
|
|||||||
pflag.String("whois", "whois.verisign-grs.com", "whois server for queries")
|
pflag.String("whois", "whois.verisign-grs.com", "whois server for queries")
|
||||||
viper.BindPFlag("whois", pflag.Lookup("whois"))
|
viper.BindPFlag("whois", pflag.Lookup("whois"))
|
||||||
|
|
||||||
pflag.String("listen", "5000", "address or unix socket bird-lg is listening on")
|
pflag.StringSlice("listen", []string{"5000"}, "address or unix socket bird-lg is listening on")
|
||||||
viper.BindPFlag("listen", pflag.Lookup("listen"))
|
viper.BindPFlag("listen", pflag.Lookup("listen"))
|
||||||
|
|
||||||
pflag.String("dns-interface", "asn.cymru.com", "dns zone to query ASN information")
|
pflag.String("dns-interface", "asn.cymru.com", "dns zone to query ASN information")
|
||||||
|
|||||||
Reference in New Issue
Block a user