mirror of
https://github.com/tailscale/tailscale.git
synced 2025-01-05 14:57:49 +00:00
net/{interfaces,netcheck}: rename some fields, funcs
Split out of Denton's #2164, to make that diff smaller to review. This change has no behavior changes. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
03311bb0d6
commit
1ae35b6c59
@ -213,9 +213,9 @@ type State struct {
|
||||
InterfaceIPs map[string][]netaddr.IPPrefix
|
||||
Interface map[string]Interface
|
||||
|
||||
// HaveV6Global is whether this machine has an IPv6 global address
|
||||
// on some non-Tailscale interface that's up.
|
||||
HaveV6Global bool
|
||||
// HaveV6 is whether this machine has an IPv6 Global or Unique Local Address
|
||||
// which might provide connectivity on a non-Tailscale interface that's up.
|
||||
HaveV6 bool
|
||||
|
||||
// HaveV4 is whether the machine has some non-localhost,
|
||||
// non-link-local IPv4 address on a non-Tailscale interface that's up.
|
||||
@ -289,7 +289,7 @@ func (s *State) String() string {
|
||||
if s.PAC != "" {
|
||||
fmt.Fprintf(&sb, " pac=%s", s.PAC)
|
||||
}
|
||||
fmt.Fprintf(&sb, " v4=%v v6global=%v}", s.HaveV4, s.HaveV6Global)
|
||||
fmt.Fprintf(&sb, " v4=%v v6=%v}", s.HaveV4, s.HaveV6)
|
||||
return sb.String()
|
||||
}
|
||||
|
||||
@ -302,7 +302,7 @@ func (s *State) EqualFiltered(s2 *State, filter func(i Interface, ips []netaddr.
|
||||
if s == nil || s2 == nil {
|
||||
return false
|
||||
}
|
||||
if s.HaveV6Global != s2.HaveV6Global ||
|
||||
if s.HaveV6 != s2.HaveV6 ||
|
||||
s.HaveV4 != s2.HaveV4 ||
|
||||
s.IsExpensive != s2.IsExpensive ||
|
||||
s.DefaultRouteInterface != s2.DefaultRouteInterface ||
|
||||
@ -362,7 +362,7 @@ func (s *State) HasPAC() bool { return s != nil && s.PAC != "" }
|
||||
|
||||
// AnyInterfaceUp reports whether any interface seems like it has Internet access.
|
||||
func (s *State) AnyInterfaceUp() bool {
|
||||
return s != nil && (s.HaveV4 || s.HaveV6Global)
|
||||
return s != nil && (s.HaveV4 || s.HaveV6)
|
||||
}
|
||||
|
||||
func hasTailscaleIP(pfxs []netaddr.IPPrefix) bool {
|
||||
@ -410,7 +410,7 @@ func GetState() (*State, error) {
|
||||
if pfx.IP().IsLoopback() || pfx.IP().IsLinkLocalUnicast() {
|
||||
continue
|
||||
}
|
||||
s.HaveV6Global = s.HaveV6Global || isGlobalV6(pfx.IP())
|
||||
s.HaveV6 = s.HaveV6 || isUsableV6(pfx.IP())
|
||||
s.HaveV4 = s.HaveV4 || pfx.IP().Is4()
|
||||
}
|
||||
}); err != nil {
|
||||
@ -503,7 +503,7 @@ func isPrivateIP(ip netaddr.IP) bool {
|
||||
return private1.Contains(ip) || private2.Contains(ip) || private3.Contains(ip)
|
||||
}
|
||||
|
||||
func isGlobalV6(ip netaddr.IP) bool {
|
||||
func isUsableV6(ip netaddr.IP) bool {
|
||||
return v6Global1.Contains(ip) ||
|
||||
(tsaddr.IsULA(ip) && !tsaddr.TailscaleULARange().Contains(ip))
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ func TestLikelyHomeRouterIP(t *testing.T) {
|
||||
t.Logf("myIP = %v; gw = %v", my, gw)
|
||||
}
|
||||
|
||||
func TestIsGlobalV6(t *testing.T) {
|
||||
func TestIsUsableV6(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
ip string
|
||||
@ -61,8 +61,8 @@ func TestIsGlobalV6(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
if got := isGlobalV6(netaddr.MustParseIP(test.ip)); got != test.want {
|
||||
t.Errorf("isGlobalV6(%s) = %v, want %v", test.name, got, test.want)
|
||||
if got := isUsableV6(netaddr.MustParseIP(test.ip)); got != test.want {
|
||||
t.Errorf("isUsableV6(%s) = %v, want %v", test.name, got, test.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -336,7 +336,7 @@ func makeProbePlan(dm *tailcfg.DERPMap, ifState *interfaces.State, last *Report)
|
||||
if last == nil || len(last.RegionLatency) == 0 {
|
||||
return makeProbePlanInitial(dm, ifState)
|
||||
}
|
||||
have6if := ifState.HaveV6Global
|
||||
have6if := ifState.HaveV6
|
||||
have4if := ifState.HaveV4
|
||||
plan = make(probePlan)
|
||||
if !have4if && !have6if {
|
||||
@ -425,7 +425,7 @@ func makeProbePlanInitial(dm *tailcfg.DERPMap, ifState *interfaces.State) (plan
|
||||
if ifState.HaveV4 && nodeMight4(n) {
|
||||
p4 = append(p4, probe{delay: delay, node: n.Name, proto: probeIPv4})
|
||||
}
|
||||
if ifState.HaveV6Global && nodeMight6(n) {
|
||||
if ifState.HaveV6 && nodeMight6(n) {
|
||||
p6 = append(p6, probe{delay: delay, node: n.Name, proto: probeIPv6})
|
||||
}
|
||||
}
|
||||
@ -808,7 +808,7 @@ func (c *Client) GetReport(ctx context.Context, dm *tailcfg.DERPMap) (*Report, e
|
||||
go c.readPackets(ctx, u4)
|
||||
}
|
||||
|
||||
if ifState.HaveV6Global {
|
||||
if ifState.HaveV6 {
|
||||
if f := c.GetSTUNConn6; f != nil {
|
||||
rs.pc6 = f()
|
||||
} else {
|
||||
|
@ -443,8 +443,8 @@ func TestMakeProbePlan(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
ifState := &interfaces.State{
|
||||
HaveV6Global: tt.have6if,
|
||||
HaveV4: !tt.no4,
|
||||
HaveV6: tt.have6if,
|
||||
HaveV4: !tt.no4,
|
||||
}
|
||||
got := makeProbePlan(tt.dm, ifState, tt.last)
|
||||
if !reflect.DeepEqual(got, tt.want) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user