mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-29 18:33:05 +00:00
Check that IP is set before parsing
Machine is saved to db before it is assigned an ip, so we might have empty ip fields coming back.
This commit is contained in:
parent
eda6e560c3
commit
73207decfd
1 changed files with 7 additions and 5 deletions
12
utils.go
12
utils.go
|
@ -121,12 +121,14 @@ func (h *Headscale) getUsedIPs() ([]netaddr.IP, error) {
|
|||
|
||||
ips := make([]netaddr.IP, len(addresses))
|
||||
for index, addr := range addresses {
|
||||
ip, err := netaddr.ParseIP(addr)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to parse ip from database, %w", err)
|
||||
}
|
||||
if addr != "" {
|
||||
ip, err := netaddr.ParseIP(addr)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to parse ip from database, %w", err)
|
||||
}
|
||||
|
||||
ips[index] = ip
|
||||
ips[index] = ip
|
||||
}
|
||||
}
|
||||
|
||||
return ips, nil
|
||||
|
|
Loading…
Reference in a new issue