mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 21:15:39 +00:00
a16a793605
iOS doesn't let you run subprocesses, which means we can't use netstat to get routing information. Instead, use syscalls and grub around in the results. We keep the old netstat version around, both for use in non-cgo builds, and for use testing the syscall-based version. Note that iOS doesn't ship route.h, so we include a copy here from the macOS 10.15 SDK (which is itself unchanged from the 10.14 SDK). I have tested manually that this yields the correct gateway IP address on my own macOS and iOS devices. More coverage would be most welcome. Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
21 lines
567 B
Go
21 lines
567 B
Go
// Copyright (c) 2020 Tailscale Inc & AUTHORS All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// +build cgo,darwin
|
|
|
|
package interfaces
|
|
|
|
import "testing"
|
|
|
|
func TestLikelyHomeRouterIPSyscallExec(t *testing.T) {
|
|
syscallIP, syscallOK := likelyHomeRouterIPDarwinSyscall()
|
|
netstatIP, netstatOK := likelyHomeRouterIPDarwinExec()
|
|
if syscallOK != netstatOK || syscallIP != netstatIP {
|
|
t.Errorf("syscall() = %v, %v, netstat = %v, %v",
|
|
syscallIP, syscallOK,
|
|
netstatIP, netstatOK,
|
|
)
|
|
}
|
|
}
|