Fix name resolution for host names in config (#431)
This commit is contained in:
parent
64d8e5aa96
commit
1499be3e40
10
main.go
10
main.go
|
@ -299,19 +299,17 @@ func Main(config *Config, configTest bool, buildVersion string, logger *logrus.L
|
||||||
if ok {
|
if ok {
|
||||||
for _, v := range vals {
|
for _, v := range vals {
|
||||||
ip, port, err := parseIPAndPort(fmt.Sprintf("%v", v))
|
ip, port, err := parseIPAndPort(fmt.Sprintf("%v", v))
|
||||||
if err == nil {
|
if err != nil {
|
||||||
lightHouse.AddRemote(ip2int(vpnIp), NewUDPAddr(ip, port), true)
|
|
||||||
} else {
|
|
||||||
return nil, NewContextualError("Static host address could not be parsed", m{"vpnIp": vpnIp}, err)
|
return nil, NewContextualError("Static host address could not be parsed", m{"vpnIp": vpnIp}, err)
|
||||||
}
|
}
|
||||||
|
lightHouse.AddRemote(ip2int(vpnIp), NewUDPAddr(ip, port), true)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ip, port, err := parseIPAndPort(fmt.Sprintf("%v", v))
|
ip, port, err := parseIPAndPort(fmt.Sprintf("%v", v))
|
||||||
if err == nil {
|
if err != nil {
|
||||||
lightHouse.AddRemote(ip2int(vpnIp), NewUDPAddr(ip, port), true)
|
|
||||||
} else {
|
|
||||||
return nil, NewContextualError("Static host address could not be parsed", m{"vpnIp": vpnIp}, err)
|
return nil, NewContextualError("Static host address could not be parsed", m{"vpnIp": vpnIp}, err)
|
||||||
}
|
}
|
||||||
|
lightHouse.AddRemote(ip2int(vpnIp), NewUDPAddr(ip, port), true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
14
udp_all.go
14
udp_all.go
|
@ -56,7 +56,15 @@ func parseIPAndPort(s string) (net.IP, uint16, error) {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
iPort, err := strconv.Atoi(sPort)
|
addr, err := net.ResolveIPAddr("ip", rIp)
|
||||||
ip := net.ParseIP(rIp)
|
if err != nil {
|
||||||
return ip, uint16(iPort), nil
|
return nil, 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
iPort, err := strconv.Atoi(sPort)
|
||||||
|
if err != nil {
|
||||||
|
return nil, 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return addr.IP, uint16(iPort), nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue