mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-06 04:42:42 +00:00
ipn/ipnlocal: fix peerapi6 port being report as 0 in netstack mode
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
@@ -218,11 +218,19 @@ func (s *peerAPIServer) listen(ip netaddr.IP, ifState *interfaces.State) (ln net
|
||||
}
|
||||
|
||||
type peerAPIListener struct {
|
||||
ps *peerAPIServer
|
||||
ip netaddr.IP
|
||||
ln net.Listener // or nil for 2nd+ address family in netstack mdoe
|
||||
lb *LocalBackend
|
||||
ps *peerAPIServer
|
||||
ip netaddr.IP
|
||||
lb *LocalBackend
|
||||
|
||||
// ln is the Listener. It can be nil in netstack mode if there are more than
|
||||
// 1 local addresses (e.g. both an IPv4 and IPv6). When it's nil, port
|
||||
// and urlStr are still populated.
|
||||
ln net.Listener
|
||||
|
||||
// urlStr is the base URL to access the peer API (http://ip:port/).
|
||||
urlStr string
|
||||
// port is just the port of urlStr.
|
||||
port int
|
||||
}
|
||||
|
||||
func (pln *peerAPIListener) Close() error {
|
||||
@@ -232,17 +240,6 @@ func (pln *peerAPIListener) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pln *peerAPIListener) Port() int {
|
||||
if pln.ln == nil {
|
||||
return 0
|
||||
}
|
||||
ta, ok := pln.ln.Addr().(*net.TCPAddr)
|
||||
if !ok {
|
||||
return 0
|
||||
}
|
||||
return ta.Port
|
||||
}
|
||||
|
||||
func (pln *peerAPIListener) serve() {
|
||||
if pln.ln == nil {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user