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,24 +35,29 @@ func main() {
|
|||||||
parseSettings()
|
parseSettings()
|
||||||
ImportTemplates()
|
ImportTemplates()
|
||||||
|
|
||||||
var l net.Listener
|
for _, listenAddr := range setting.listen {
|
||||||
var err error
|
go func(listenAddr string) {
|
||||||
|
var l net.Listener
|
||||||
|
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
|
}
|
||||||
}
|
l, err = net.Listen("tcp", listenAddr)
|
||||||
l, err = net.Listen("tcp", listenAddr)
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
webServerStart(l)
|
||||||
|
}(listenAddr)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
select {}
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
webServerStart(l)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,25 +9,25 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type viperSettingType struct {
|
type viperSettingType struct {
|
||||||
Servers string `mapstructure:"servers"`
|
Servers string `mapstructure:"servers"`
|
||||||
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"`
|
||||||
NavBarBrand string `mapstructure:"navbar_brand"`
|
NavBarBrand string `mapstructure:"navbar_brand"`
|
||||||
NavBarBrandURL string `mapstructure:"navbar_brand_url"`
|
NavBarBrandURL string `mapstructure:"navbar_brand_url"`
|
||||||
NavBarAllServer string `mapstructure:"navbar_all_servers"`
|
NavBarAllServer string `mapstructure:"navbar_all_servers"`
|
||||||
NavBarAllURL string `mapstructure:"navbar_all_url"`
|
NavBarAllURL string `mapstructure:"navbar_all_url"`
|
||||||
BgpmapInfo string `mapstructure:"bgpmap_info"`
|
BgpmapInfo string `mapstructure:"bgpmap_info"`
|
||||||
TelegramBotName string `mapstructure:"telegram_bot_name"`
|
TelegramBotName string `mapstructure:"telegram_bot_name"`
|
||||||
ProtocolFilter string `mapstructure:"protocol_filter"`
|
ProtocolFilter string `mapstructure:"protocol_filter"`
|
||||||
NameFilter string `mapstructure:"name_filter"`
|
NameFilter string `mapstructure:"name_filter"`
|
||||||
TimeOut int `mapstructure:"timeout"`
|
TimeOut int `mapstructure:"timeout"`
|
||||||
ConnectionTimeOut int `mapstructure:"connection_timeout"`
|
ConnectionTimeOut int `mapstructure:"connection_timeout"`
|
||||||
TrustProxyHeaders bool `mapstructure:"trust_proxy_headers"`
|
TrustProxyHeaders bool `mapstructure:"trust_proxy_headers"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse settings with viper, and convert to legacy setting format
|
// Parse settings with viper, and convert to legacy setting format
|
||||||
@@ -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