Skip to content

Commit

Permalink
tighter loop
Browse files Browse the repository at this point in the history
  • Loading branch information
JackDoanRivian committed Oct 15, 2024
1 parent 59eb108 commit 6e55c1d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions hostmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,18 +456,19 @@ func (hm *HostMap) QueryVpnAddrsRelayFor(targetIps []netip.Addr, relayHostIp net
hm.RLock()
defer hm.RUnlock()

for _, targetIp := range targetIps {
h, ok := hm.Hosts[relayHostIp]
if !ok {
return nil, nil, errors.New("unable to find host")
}
for h != nil {
h, ok := hm.Hosts[relayHostIp]
if !ok {
return nil, nil, errors.New("unable to find host")
}

for h != nil {
for _, targetIp := range targetIps {
r, ok := h.relayState.QueryRelayForByIp(targetIp)
if ok && r.State == Established {
return h, r, nil
}
h = h.next
}
h = h.next
}

return nil, nil, errors.New("unable to find host with relay")
Expand Down

0 comments on commit 6e55c1d

Please sign in to comment.