Improved check of interface IPs

master
Uriel Fanelli 2023-08-14 12:05:35 +02:00
parent 1991b9183b
commit f1c46ed9f1
1 changed files with 7 additions and 6 deletions

View File

@ -190,17 +190,18 @@ func (b *AbstractBridge) IsAssigned() bool {
log.Printf("Error is: %s\n", err.Error())
return false
}
if len(addrs) < 1 {
log.Printf("Interface has NO ip addresses")
return false
}
for _, addr := range addrs { // get ipv4 address
if ipv4Addr = addr.(*net.IPNet).IP.To4(); ipv4Addr != nil {
log.Printf("Error reading IPs for interface %s\n", interfaceName)
log.Printf("Error is: %s\n", err.Error())
break
}
}
if ipv4Addr == nil {
log.Printf("interface %s don't have an ipv4 address\n", interfaceName)
return false
}
}
for _, addr := range addrs {
if addr.String() == bridgeip {