mirror of
https://github.com/tailscale/tailscale.git
synced 2025-05-29 10:48:31 +00:00
ipn/ipnlocal: allow Peer API access via either V4MasqAddr or V6MasqAddr when both are set
This doesn't seem to have any immediate impact, but not allowing access via the IPv6 masquerade address when an IPv4 masquerade address is also set seems like a bug. Updates #cleanup Updates #14570 (found when working on it) Signed-off-by: Nick Khyl <nickk@tailscale.com>
This commit is contained in:
parent
cfda1ff709
commit
66269dc934
@ -233,11 +233,13 @@ func (h *peerAPIHandler) logf(format string, a ...any) {
|
|||||||
// isAddressValid reports whether addr is a valid destination address for this
|
// isAddressValid reports whether addr is a valid destination address for this
|
||||||
// node originating from the peer.
|
// node originating from the peer.
|
||||||
func (h *peerAPIHandler) isAddressValid(addr netip.Addr) bool {
|
func (h *peerAPIHandler) isAddressValid(addr netip.Addr) bool {
|
||||||
if v, ok := h.peerNode.SelfNodeV4MasqAddrForThisPeer().GetOk(); ok {
|
if !addr.IsValid() {
|
||||||
return v == addr
|
return false
|
||||||
}
|
}
|
||||||
if v, ok := h.peerNode.SelfNodeV6MasqAddrForThisPeer().GetOk(); ok {
|
v4MasqAddr, hasMasqV4 := h.peerNode.SelfNodeV4MasqAddrForThisPeer().GetOk()
|
||||||
return v == addr
|
v6MasqAddr, hasMasqV6 := h.peerNode.SelfNodeV6MasqAddrForThisPeer().GetOk()
|
||||||
|
if hasMasqV4 || hasMasqV6 {
|
||||||
|
return addr == v4MasqAddr || addr == v6MasqAddr
|
||||||
}
|
}
|
||||||
pfx := netip.PrefixFrom(addr, addr.BitLen())
|
pfx := netip.PrefixFrom(addr, addr.BitLen())
|
||||||
return views.SliceContains(h.selfNode.Addresses(), pfx)
|
return views.SliceContains(h.selfNode.Addresses(), pfx)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user