make sure hosts use the correct IP addresses when relaying

This commit is contained in:
JackDoan
2025-10-10 13:28:22 -05:00
parent 9bf9fb14bc
commit d2cb854bff
4 changed files with 98 additions and 81 deletions

View File

@@ -1425,7 +1425,7 @@ func (d *NebulaMetaDetails) GetRelays() []netip.Addr {
return relays
}
// FindNetworkUnion returns the first netip.Addr contained in the list of provided netip.Prefix, if able
// findNetworkUnion returns the first netip.Addr of addrs contained in the list of provided netip.Prefix, if able
func findNetworkUnion(prefixes []netip.Prefix, addrs []netip.Addr) (netip.Addr, bool) {
for i := range prefixes {
for j := range addrs {
@@ -1450,3 +1450,13 @@ func (d *NebulaMetaDetails) GetVpnAddrAndVersion() (netip.Addr, cert.Version, er
return netip.Addr{}, cert.Version1, ErrBadDetailsVpnAddr
}
}
func (d *NebulaControl) GetRelayFrom() netip.Addr {
if d.OldRelayFromAddr != 0 {
b := [4]byte{}
binary.BigEndian.PutUint32(b[:], d.OldRelayFromAddr)
return netip.AddrFrom4(b)
} else {
return protoAddrToNetAddr(d.RelayFromAddr)
}
}