Change-Id: I242111289aeb0c9a0ff843d698bc26168e336165
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
bradfitz/ios_ish
Brad Fitzpatrick 3 months ago
parent 0cc1b2ff76
commit 032d425a41

@ -75,6 +75,9 @@ import (
// defaultTunName returns the default tun device name for the platform. // defaultTunName returns the default tun device name for the platform.
func defaultTunName() string { func defaultTunName() string {
if runtime.GOOS == "linux" && distro.Get() == distro.ISH {
return "userspace-networking"
}
switch runtime.GOOS { switch runtime.GOOS {
case "openbsd": case "openbsd":
return "tun" return "tun"
@ -207,6 +210,8 @@ func main() {
os.Args = []string{"tailscaled", "be-child", "plan9-netshell"} os.Args = []string{"tailscaled", "be-child", "plan9-netshell"}
} }
println("XX distro:", distro.Get())
if len(os.Args) > 1 { if len(os.Args) > 1 {
sub := os.Args[1] sub := os.Args[1]
if fp, ok := subCommands[sub]; ok { if fp, ok := subCommands[sub]; ok {

@ -9,6 +9,7 @@ package netmon
import ( import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt"
"net/netip" "net/netip"
"runtime" "runtime"
"sync" "sync"
@ -18,6 +19,7 @@ import (
"tailscale.com/util/clientmetric" "tailscale.com/util/clientmetric"
"tailscale.com/util/eventbus" "tailscale.com/util/eventbus"
"tailscale.com/util/set" "tailscale.com/util/set"
"tailscale.com/version/distro"
) )
// pollWallTimeInterval is how often we check the time to check // pollWallTimeInterval is how often we check the time to check
@ -118,6 +120,9 @@ type ChangeDelta struct {
// The returned monitor is inactive until it's started by the Start method. // The returned monitor is inactive until it's started by the Start method.
// Use RegisterChangeCallback to get notified of network changes. // Use RegisterChangeCallback to get notified of network changes.
func New(bus *eventbus.Bus, logf logger.Logf) (*Monitor, error) { func New(bus *eventbus.Bus, logf logger.Logf) (*Monitor, error) {
if distro.Get() == distro.ISH {
return NewStatic(), nil // netlink doesn't work in iSH
}
logf = logger.WithPrefix(logf, "monitor: ") logf = logger.WithPrefix(logf, "monitor: ")
m := &Monitor{ m := &Monitor{
logf: logf, logf: logf,
@ -129,7 +134,7 @@ func New(bus *eventbus.Bus, logf logger.Logf) (*Monitor, error) {
m.changed = eventbus.Publish[*ChangeDelta](m.b) m.changed = eventbus.Publish[*ChangeDelta](m.b)
st, err := m.interfaceStateUncached() st, err := m.interfaceStateUncached()
if err != nil { if err != nil {
return nil, err return nil, fmt.Errorf("interface state: %w", err)
} }
m.ifState = st m.ifState = st

@ -17,6 +17,7 @@ import (
"tailscale.com/net/tsaddr" "tailscale.com/net/tsaddr"
"tailscale.com/types/logger" "tailscale.com/types/logger"
"tailscale.com/util/eventbus" "tailscale.com/util/eventbus"
"tailscale.com/version/distro"
) )
var debugNetlinkMessages = envknob.RegisterBool("TS_DEBUG_NETLINK") var debugNetlinkMessages = envknob.RegisterBool("TS_DEBUG_NETLINK")
@ -57,6 +58,10 @@ type nlConn struct {
} }
func newOSMon(bus *eventbus.Bus, logf logger.Logf, m *Monitor) (osMon, error) { func newOSMon(bus *eventbus.Bus, logf logger.Logf, m *Monitor) (osMon, error) {
if distro.Get() == distro.ISH {
println("XXX hi from ish")
return newPollingMon(logf, m)
}
conn, err := netlink.Dial(unix.NETLINK_ROUTE, &netlink.Config{ conn, err := netlink.Dial(unix.NETLINK_ROUTE, &netlink.Config{
// Routes get us most of the events of interest, but we need // Routes get us most of the events of interest, but we need
// address as well to cover things like DHCP deciding to give // address as well to cover things like DHCP deciding to give

@ -33,6 +33,7 @@ const (
Alpine = Distro("alpine") Alpine = Distro("alpine")
UBNT = Distro("ubnt") // Ubiquiti Networks UBNT = Distro("ubnt") // Ubiquiti Networks
JetKVM = Distro("jetkvm") JetKVM = Distro("jetkvm")
ISH = Distro("ish") // iOS iSH app
) )
var distro lazy.SyncValue[Distro] var distro lazy.SyncValue[Distro]
@ -102,6 +103,11 @@ func linuxDistro() Distro {
return WDMyCloud return WDMyCloud
case have("/etc/unraid-version"): case have("/etc/unraid-version"):
return Unraid return Unraid
case runtime.GOARCH == "386":
v, _ := os.ReadFile("/proc/cpuinfo")
if bytes.Contains(v, []byte(": iSH")) {
return ISH
}
case have("/etc/alpine-release"): case have("/etc/alpine-release"):
return Alpine return Alpine
case runtime.GOARCH == "arm" && isDeviceModel("JetKVM"): case runtime.GOARCH == "arm" && isDeviceModel("JetKVM"):

Loading…
Cancel
Save