Commit Graph

68 Commits (fc4b25d9fde215745dc416a9437950915be998e8)

Author SHA1 Message Date
Brad Fitzpatrick 19b0cfe89e all: prepare for GOOS=ios in Go 1.16
Work with either way for now on iOS (darwin/arm64 vs ios/arm64).

In February when Go 1.16 comes out we'll have a universal binary for
darwin/arm64 (macOS) and will drop support for Go 1.15 and its
darwin/amd64 meaning iOS. (it'll mean macOS).

Context:

* https://tip.golang.org/doc/go1.16#darwin
* https://github.com/golang/go/issues/38485
* https://github.com/golang/go/issues/42100
4 years ago
Brad Fitzpatrick 4a92fc9dc5 portlist: fix tests on Windows when not running as Administrator
Updates #50
4 years ago
Josh Bleecher Snyder a570c27577 portlist: reduce log spam on macOS
Running tailscaled on my machine yields lots of entries like:

weird: missing {tcp 6060}

parsePortsNetstat is filtering out loopback addresses as uninteresting.
Then addProcesses is surprised to discover these listening ports,
which results in spurious logging.
Teach addProcesses to also ignore loopback addresses.

Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
4 years ago
Brad Fitzpatrick 77cad13c70 portlist: avoid syscall audit violation logspam on Android
If we don't have access, don't try, don't log, don't continue trying.

Fixes #521
4 years ago
Brad Fitzpatrick 2ca2389c5f portlist: set SysProcAttr.HideWindow on Windows
Prevents annoying shell window flashes when running /server by hand.
4 years ago
Avery Pennarun 806de4ac94 portlist: fix "readdirent: no such file or directory" errors on Linux.
This could happen when a process disappeared while we were reading its
file descriptor list.

I was able to replicate the problem by running this in another
terminal:

    while :; do for i in $(seq 10); do
      /bin/true & done >&/dev/null; wait >&/dev/null;
    done

And then running the portlist tests thousands of times.

Fixes #339.

Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
4 years ago
Brad Fitzpatrick 64f6104e63 portlist: reduce log spam/scariness for portlist in mac sandbox
Fixes tailscale/corp#235
4 years ago
Wendi Yu fde384b359 Fix macOS build
staticcheck used to fail on macOS (and presumably windows) due to a
variable declared in a common package that was only used by the Linux
build, which would prevent `redo pr` from passing on Mac. Moved variable
declaration from the common file to the Linux-specific one to resolve
the compiler complaint.

Signed-off-by: Wendi Yu <wendi.yu@yahoo.ca>
4 years ago
Brad Fitzpatrick 3b546dc29a portlist: make two error paths have unique messages
For debugging #339
4 years ago
David Anderson 9396024bd7 portlist: move code around to avoid unused function warnings. 4 years ago
Brad Fitzpatrick 2776209e49 portlist: don't depend on osexec package on ios, even if it's unused
Continuation of 5bb14c07dc.

The earlier commit provided the space savings (as the linker could see
through that osexec was unused at runtime), but it didn't clean up the
dep graph (from go list -json or godepgraph).

This removes the netstat.go file from the build too, just so the dep list
looks more reasonable.
4 years ago
Brad Fitzpatrick 5bb14c07dc portlist: don't depend on tempfork/osexec on iOS, saves 90KB
This gives us 90KB more of memory on iOS, as it shrinks the
NetworkExtension binary by 90KB.

The netstat binary isn't available in the network extension anyway, so
no point pulling in the osexec package which'll just fail to find
netstat anyway.
4 years ago
Brad Fitzpatrick ec0cd60fc3 portlist: fail earlier, more nicely on iOS 4 years ago
Brad Fitzpatrick f8d67bb591 portlist: ignore ports bound to localhost
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
4 years ago
Brad Fitzpatrick 120273d7f6 portlist: document, clean up, fix an open fd spike, optimize a bit
I noticed portlist when looking at some profiles and hadn't looked at
the code much before. This is a first pass over it. It allocates a
fair bit. More love remains, but this does a bit:

name       old time/op    new time/op    delta
GetList-8    9.92ms ± 8%    9.64ms ±12%     ~     (p=0.247 n=10+10)

name       old alloc/op   new alloc/op   delta
GetList-8     931kB ± 0%     869kB ± 0%   -6.70%  (p=0.000 n=10+10)

name       old allocs/op  new allocs/op  delta
GetList-8     4.59k ± 0%     3.69k ± 1%  -19.71%  (p=0.000 n=10+10)

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
4 years ago
David Anderson 9ac1dda0d9 portlist: add a lint ignore for unused function.
The function is indeed unused on linux, but we want it around
so that unit tests exercise the netstat logic even on linux,
even if it's only used on !linux.

Signed-off-by: David Anderson <dave@natulte.net>
4 years ago
David Anderson 520e96afd1 portlist: simplify slice expression.
Signed-off-by: David Anderson <dave@natulte.net>
4 years ago
Earl Lee a8d8b8719a Move Linux client & common packages into a public repo. 4 years ago