Skip to content

Commit

Permalink
ipn/mh: unconditionally re-add names, addrs on refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
ignoramous committed Mar 24, 2024
1 parent d108715 commit c9a608d
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions intra/ipn/multihost/multihost.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ func (h *MH) Addrs() []netip.Addr {
}

func (h *MH) Len() int {
h.RLock()
defer h.RUnlock()
// names may exist without addrs and vice versa
return max(len(h.addrs), len(h.names))
}
Expand All @@ -58,16 +60,12 @@ func (h *MH) addrlen() int {
return len(h.addrs)
}

// Refresh re-adds the list of IPs, hostnames, and re-resolves the hostname.
func (h *MH) Refresh() int {
totips := 0
if len(h.names) > 0 { // resolve ip from domain names
h.With(h.names)
totips = len(h.addrs)
}
if totips <= 0 { // re-add existing ips, if any
h.With(h.straddrs())
}
return len(h.addrs)
// resolve ip from domain names
h.With(h.names)
// re-add existing ips, if any
return h.Add(h.straddrs())
}

// Add appends the list of IPs, hostnames, and hostname's IPs as resolved.
Expand Down

0 comments on commit c9a608d

Please sign in to comment.