Skip to content

Commit 3676969

Browse files
committed
more
1 parent 4ffa6d7 commit 3676969

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

net/interfaces/interfaces.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
// which HTTP proxy the system should use.
2525
var LoginEndpointForProxyDetermination = "https://controlplane.tailscale.com/"
2626

27-
// Tailscale returns the current machine's Tailscale interface, if any.
27+
// Tailscale returns the current machine's Coder interface, if any.
2828
// If none is found, all zero values are returned.
2929
// A non-nil error is only returned on a problem listing the system interfaces.
3030
func Tailscale() ([]netip.Addr, *net.Interface, error) {
@@ -58,12 +58,10 @@ func Tailscale() ([]netip.Addr, *net.Interface, error) {
5858
}
5959

6060
// maybeTailscaleInterfaceName reports whether s is an interface
61-
// name that might be used by Tailscale.
61+
// name that might be used by Coder.
6262
func maybeTailscaleInterfaceName(s string) bool {
63-
return s == "Tailscale" ||
64-
strings.HasPrefix(s, "wg") ||
65-
strings.HasPrefix(s, "ts") ||
66-
strings.HasPrefix(s, "tailscale") ||
63+
return s == "Coder" ||
64+
strings.HasPrefix(s, "coder") ||
6765
strings.HasPrefix(s, "utun")
6866
}
6967

@@ -496,8 +494,8 @@ func isTailscaleInterface(name string, ips []netip.Prefix) bool {
496494
// macOS NetworkExtensions and utun devices.
497495
return true
498496
}
499-
return name == "Tailscale" || // as it is on Windows
500-
strings.HasPrefix(name, "tailscale") // TODO: use --tun flag value, etc; see TODO in method doc
497+
return name == "Coder" || // as it is on Windows
498+
strings.HasPrefix(name, "coder") // TODO: use --tun flag value, etc; see TODO in method doc
501499
}
502500

503501
// getPAC, if non-nil, returns the current PAC file URL.

net/netmon/netmon_darwin.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ func (m *darwinRouteMon) skipRouteMessage(msg *route.RouteMessage) bool {
137137
// dst = fe80::b476:66ff:fe30:c8f6%15
138138
return true
139139
}
140+
if msg.Type == unix.RTM_GET {
141+
// Skip RTM_GET messages, which are used to query the routing table
142+
// See nets_darwin.go
143+
return true
144+
}
140145
return false
141146
}
142147

net/netns/netns_darwin.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,14 @@ func controlLogf(logf logger.Logf, netMon *netmon.Monitor, network, address stri
5454
return nil
5555
}
5656

57-
return bindConnToInterface(c, network, address, idx, logf)
57+
// Verify that we didn't just choose the Coder interface.
58+
_, tsif, err2 := interfaces.Tailscale()
59+
if err2 == nil && tsif != nil && tsif.Index == idx {
60+
return fmt.Errorf("netns_darwin: refusing bind to Coder interface %q (index %d) for address %q", tsif.Name, tsif.Index, address)
61+
}
62+
63+
// Let the OS decide
64+
return nil
5865
}
5966

6067
func getInterfaceIndex(logf logger.Logf, netMon *netmon.Monitor, address string) (int, error) {
@@ -98,7 +105,8 @@ func getInterfaceIndex(logf logger.Logf, netMon *netmon.Monitor, address string)
98105
// If the address doesn't parse, use the default index.
99106
addr, err := netip.ParseAddr(host)
100107
if err != nil {
101-
logf("[unexpected] netns: error parsing address %q: %v", host, err)
108+
// Log removed to prevent noise when the address is `:0`
109+
// logf("[unexpected] netns: error parsing address %q: %v", host, err)
102110
return defaultIdx()
103111
}
104112

@@ -108,14 +116,6 @@ func getInterfaceIndex(logf logger.Logf, netMon *netmon.Monitor, address string)
108116
return defaultIdx()
109117
}
110118

111-
// Verify that we didn't just choose the Tailscale interface;
112-
// if so, we fall back to binding from the default.
113-
_, tsif, err2 := interfaces.Tailscale()
114-
if err2 == nil && tsif != nil && tsif.Index == idx {
115-
logf("[unexpected] netns: interfaceIndexFor returned Tailscale interface")
116-
return defaultIdx()
117-
}
118-
119119
return idx, err
120120
}
121121

net/tsaddr/tsaddr.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,6 @@ const (
7878
// IsTailscaleIP reports whether ip is an IP address in a range that
7979
// Coder assigns from.
8080
func IsTailscaleIP(ip netip.Addr) bool {
81-
if ip.Is4() {
82-
return CGNATRange().Contains(ip) && !ChromeOSVMRange().Contains(ip)
83-
}
8481
return TailscaleULARange().Contains(ip)
8582
}
8683

0 commit comments

Comments
 (0)