mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-23 03:17:43 +00:00
tailcfg: add Endpoint, EndpointType, MapRequest.EndpointType
Track endpoints internally with a new tailcfg.Endpoint type that includes a typed netaddr.IPPort (instead of just a string) and includes a type for how that endpoint was discovered (STUN, local, etc). Use []tailcfg.Endpoint instead of []string internally. At the last second, send it to the control server as the existing []string for endpoints, but also include a new parallel MapRequest.EndpointType []tailcfg.EndpointType, so the control server can start filtering out less-important endpoint changes from new-enough clients. Notably, STUN-discovered endpoints can be filtered out from 1.6+ clients, as they can discover them amongst each other via CallMeMaybe disco exchanges started over DERP. And STUN endpoints change a lot, causing a lot of MapResposne updates. But portmapped endpoints are worth keeping for now, as they they work right away without requiring the firewall traversal extra RTT dance. End result will be less control->client bandwidth. (despite negligible increase in client->control bandwidth) Updates tailscale/corp#1543 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:

committed by
Brad Fitzpatrick

parent
b91f3c4191
commit
34d2f5a3d9
@@ -636,6 +636,42 @@ type RegisterResponse struct {
|
||||
AuthURL string // if set, authorization pending
|
||||
}
|
||||
|
||||
// EndpointType distinguishes different sources of MapRequest.Endpoint values.
|
||||
type EndpointType int
|
||||
|
||||
const (
|
||||
EndpointUnknownType = EndpointType(0)
|
||||
EndpointLocal = EndpointType(1)
|
||||
EndpointSTUN = EndpointType(2)
|
||||
EndpointPortmapped = EndpointType(3)
|
||||
EndpointSTUN4LocalPort = EndpointType(4) // hard NAT: STUN'ed IPv4 address + local fixed port
|
||||
)
|
||||
|
||||
func (et EndpointType) String() string {
|
||||
switch et {
|
||||
case EndpointUnknownType:
|
||||
return "?"
|
||||
case EndpointLocal:
|
||||
return "local"
|
||||
case EndpointSTUN:
|
||||
return "stun"
|
||||
case EndpointPortmapped:
|
||||
return "portmap"
|
||||
case EndpointSTUN4LocalPort:
|
||||
return "stun4localport"
|
||||
}
|
||||
return "other"
|
||||
}
|
||||
|
||||
// Endpoint is an endpoint IPPort and an associated type.
|
||||
// It doesn't currently go over the wire as is but is instead
|
||||
// broken up into two parallel slices in MapReqeust, for compatibility
|
||||
// reasons. But this type is used in the codebase.
|
||||
type Endpoint struct {
|
||||
Addr netaddr.IPPort
|
||||
Type EndpointType
|
||||
}
|
||||
|
||||
// MapRequest is sent by a client to start a long-poll network map updates.
|
||||
// The request includes a copy of the client's current set of WireGuard
|
||||
// endpoints and general host information.
|
||||
@@ -655,11 +691,15 @@ type MapRequest struct {
|
||||
KeepAlive bool // whether server should send keep-alives back to us
|
||||
NodeKey NodeKey
|
||||
DiscoKey DiscoKey
|
||||
Endpoints []string // caller's endpoints (IPv4 or IPv6)
|
||||
IncludeIPv6 bool `json:",omitempty"` // include IPv6 endpoints in returned Node Endpoints (for Version 4 clients)
|
||||
Stream bool // if true, multiple MapResponse objects are returned
|
||||
IncludeIPv6 bool `json:",omitempty"` // include IPv6 endpoints in returned Node Endpoints (for Version 4 clients)
|
||||
Stream bool // if true, multiple MapResponse objects are returned
|
||||
Hostinfo *Hostinfo
|
||||
|
||||
// Endpoints are the client's magicsock UDP ip:port endpoints (IPv4 or IPv6).
|
||||
Endpoints []string
|
||||
// EndpointTypes are the types of the corresponding endpoints in Endpoints.
|
||||
EndpointTypes []EndpointType `json:",omitempty"`
|
||||
|
||||
// ReadOnly is whether the client just wants to fetch the
|
||||
// MapResponse, without updating their Endpoints. The
|
||||
// Endpoints field will be ignored and LastSeen will not be
|
||||
|
Reference in New Issue
Block a user