net/interfaces: add func LikelyHomeRouterIP

For discovering where we might direct NAT-PMP/PCP/UPnP queries at in
the future.
This commit is contained in:
Brad Fitzpatrick
2020-07-06 10:34:52 -07:00
parent c3c607e78a
commit 32156330a8
8 changed files with 222 additions and 1 deletions

View File

@@ -18,6 +18,7 @@ import (
"github.com/peterbourgon/ff/v2/ffcli"
"tailscale.com/derp/derpmap"
"tailscale.com/net/dnscache"
"tailscale.com/net/interfaces"
"tailscale.com/net/netcheck"
"tailscale.com/tailcfg"
"tailscale.com/types/logger"
@@ -50,6 +51,11 @@ func runNetcheck(ctx context.Context, args []string) error {
if netcheckArgs.verbose {
c.Logf = logger.WithPrefix(log.Printf, "netcheck: ")
c.Verbose = true
if gw, ok := interfaces.LikelyHomeRouterIP(); ok {
c.Logf("likely home router: %v", gw)
} else {
c.Logf("no likely home router IP found")
}
} else {
c.Logf = logger.Discard
}