Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client/web: use Tailscale IP known by peer node #10603

Merged
merged 1 commit into from
Dec 14, 2023

Conversation

soniaappasamy
Copy link
Member

Throughout the web UI, we present the tailscale addresses for the self node. In the case of the node being shared out with a user from another tailnet, the peer viewer may actually know the node by a different IP than the node knows itself as (Tailscale IPs can be configured as desired on a tailnet level). This change includes two fixes:

  1. Present the self node's addresses in the frontend as the addresses the viewing node knows it as (i.e. the addresses the viewing node uses to access the web client).

  2. We currently redirect the viewer to the Tailscale IPv4 address if viewing it by MagicDNS name, or any other name that maps to the Tailscale node. When doing this redirect, which is primarily added for DNS rebinding protection, we now check the address the peer knows this node as, and redirect to specifically that IP.

Fixes tailscale/corp#16402

if ip.Is6() && r.Host == fmt.Sprintf("[%s]:%d", ip, ListenPort) {
return false
}
ipv4, ipv6 := s.selfNodeAddresses(r, st)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considered caching the "known IPs" for this node, but because it changes based on peer, opted to do the safer thing and look them up each time. It's a little more expensive than what we had before: now calling Status instead of StatusWithoutPeers, and calling WhoIs and extra time on the request.

client/web/web.go Outdated Show resolved Hide resolved
ipn/ipnstate/ipnstate.go Outdated Show resolved Hide resolved
client/web/web.go Outdated Show resolved Hide resolved
client/web/web.go Show resolved Hide resolved
client/web/web.go Outdated Show resolved Hide resolved
Copy link
Member

@willnorris willnorris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no comments aside from the things Maisem pointed out

Throughout the web UI, we present the tailscale addresses for the
self node. In the case of the node being shared out with a user
from another tailnet, the peer viewer may actually know the node
by a different IP than the node knows itself as (Tailscale IPs
can be configured as desired on a tailnet level). This change
includes two fixes:

1. Present the self node's addresses in the frontend as the addresses
   the viewing node knows it as (i.e. the addresses the viewing node
   uses to access the web client).

2. We currently redirect the viewer to the Tailscale IPv4 address if
   viewing it by MagicDNS name, or any other name that maps to the
   Tailscale node. When doing this redirect, which is primarily added
   for DNS rebinding protection, we now check the address the peer
   knows this node as, and redirect to specifically that IP.

Fixes tailscale/corp#16402

Signed-off-by: Sonia Appasamy <sonia@tailscale.com>
@soniaappasamy soniaappasamy merged commit c6a2746 into main Dec 14, 2023
47 checks passed
@soniaappasamy soniaappasamy deleted the soniaappasamy/shared-ip-fix branch December 14, 2023 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants