mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-09-29 13:51:51 +02:00
cmd/ctrld: use better approach for checking IPv6 available
Some operating systems may throw a confirmation dialog when attempting to listen on any interface other than loopback. A better approach is checking for any interface which is up and can be routed IP traffic.
This commit is contained in:
1 parent
e331a4113a
commit
9e7578fb29
2 files changed
+5
-3
No files matched your search
+4
-2
@@ -3,6 +3,8 @@ package main
|
|||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"golang.org/x/net/nettest"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -11,8 +13,8 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func probeStack() {
|
func probeStack() {
|
||||||
if ln, err := net.Listen("tcp6", "[::]:0"); err == nil {
|
// TODO(cuonglm): use nettest.SupportsIPv6 once https://github.com/golang/go/issues/57386 fixed.
|
||||||
ln.Close()
|
if _, err := nettest.RoutedInterface("ip6", net.FlagUp); err == nil {
|
||||||
ipv6Enabled = true
|
ipv6Enabled = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ require (
|
|||||||
github.com/spf13/cobra v1.4.0
|
github.com/spf13/cobra v1.4.0
|
||||||
github.com/spf13/viper v1.9.0
|
github.com/spf13/viper v1.9.0
|
||||||
github.com/stretchr/testify v1.8.0
|
github.com/stretchr/testify v1.8.0
|
||||||
|
golang.org/x/net v0.1.0
|
||||||
golang.org/x/sys v0.1.0
|
golang.org/x/sys v0.1.0
|
||||||
tailscale.com v1.34.1
|
tailscale.com v1.34.1
|
||||||
)
|
)
|
||||||
@@ -45,7 +46,6 @@ require (
|
|||||||
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect
|
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect
|
||||||
golang.org/x/exp v0.0.0-20220827204233-334a2380cb91 // indirect
|
golang.org/x/exp v0.0.0-20220827204233-334a2380cb91 // indirect
|
||||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
|
||||||
golang.org/x/net v0.1.0 // indirect
|
|
||||||
golang.org/x/text v0.4.0 // indirect
|
golang.org/x/text v0.4.0 // indirect
|
||||||
golang.org/x/tools v0.1.12 // indirect
|
golang.org/x/tools v0.1.12 // indirect
|
||||||
gopkg.in/ini.v1 v1.66.2 // indirect
|
gopkg.in/ini.v1 v1.66.2 // indirect
|
||||||
|
|||||||
Reference in new issue
Block a user