net/interfaces: add debugging code for crawshaw

This commit is contained in:
Josh Bleecher Snyder 2021-01-14 17:18:59 -08:00
parent 6e4231c03c
commit 7823f665ad
2 changed files with 8 additions and 1 deletions

View File

@ -6,6 +6,9 @@
import (
"errors"
"fmt"
"io"
"os"
"os/exec"
"go4.org/mem"
@ -46,8 +49,10 @@ func likelyHomeRouterIPDarwinExec() (ret netaddr.IP, ok bool) {
}
defer cmd.Wait()
fmt.Println("netstat output:")
tee := io.TeeReader(stdout, os.Stdout)
var f []mem.RO
lineread.Reader(stdout, func(lineb []byte) error {
lineread.Reader(tee, func(lineb []byte) error {
line := mem.B(lineb)
if !mem.Contains(line, mem.S("default")) {
return nil

View File

@ -105,6 +105,7 @@
import (
"encoding/binary"
"fmt"
"inet.af/netaddr"
)
@ -116,6 +117,7 @@ func init() {
func likelyHomeRouterIPDarwinSyscall() (ret netaddr.IP, ok bool) {
ip := C.privateGatewayIP()
if ip < 255 {
fmt.Println("privateGatewayIP failure:", ip)
return netaddr.IP{}, false
}
var q [4]byte