Fail with a better error message if lh a hosts is unparsable

This commit is contained in:
Nate Brown
2019-12-09 16:53:56 -08:00
parent 1a2c961368
commit 1640a9bc77
4 changed files with 22 additions and 12 deletions

15
main.go
View File

@ -190,16 +190,25 @@ func Main(configPath string, configTest bool, buildVersion string) {
amLighthouse := config.GetBool("lighthouse.am_lighthouse", false)
// warn if am_lighthouse is enabled but upstream lighthouses exists
lighthouseHosts := config.GetStringSlice("lighthouse.hosts", []string{})
if amLighthouse && len(lighthouseHosts) != 0 {
rawLighthouseHosts := config.GetStringSlice("lighthouse.hosts", []string{})
if amLighthouse && len(rawLighthouseHosts) != 0 {
l.Warn("lighthouse.am_lighthouse enabled on node but upstream lighthouses exist in config")
}
lighthouseHosts := make([]uint32, len(rawLighthouseHosts))
for i, host := range rawLighthouseHosts {
ip := net.ParseIP(host)
if ip == nil {
l.WithField("host", host).Fatalf("Unable to parse lighthouse host entry %v", i+1)
}
lighthouseHosts[i] = ip2int(ip)
}
serveDns := config.GetBool("lighthouse.serve_dns", false)
lightHouse := NewLightHouse(
amLighthouse,
ip2int(tunCidr.IP),
config.GetStringSlice("lighthouse.hosts", []string{}),
lighthouseHosts,
//TODO: change to a duration
config.GetInt("lighthouse.interval", 10),
port,