mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-02-03 22:18:39 +00: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:
committed by
Cuong Manh Le
parent
e331a4113a
commit
9e7578fb29
@@ -3,6 +3,8 @@ package main
|
||||
import (
|
||||
"net"
|
||||
"sync"
|
||||
|
||||
"golang.org/x/net/nettest"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -11,8 +13,8 @@ var (
|
||||
)
|
||||
|
||||
func probeStack() {
|
||||
if ln, err := net.Listen("tcp6", "[::]:0"); err == nil {
|
||||
ln.Close()
|
||||
// TODO(cuonglm): use nettest.SupportsIPv6 once https://github.com/golang/go/issues/57386 fixed.
|
||||
if _, err := nettest.RoutedInterface("ip6", net.FlagUp); err == nil {
|
||||
ipv6Enabled = true
|
||||
}
|
||||
}
|
||||
|
||||
2
go.mod
2
go.mod
@@ -13,6 +13,7 @@ require (
|
||||
github.com/spf13/cobra v1.4.0
|
||||
github.com/spf13/viper v1.9.0
|
||||
github.com/stretchr/testify v1.8.0
|
||||
golang.org/x/net v0.1.0
|
||||
golang.org/x/sys v0.1.0
|
||||
tailscale.com v1.34.1
|
||||
)
|
||||
@@ -45,7 +46,6 @@ require (
|
||||
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // 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/net v0.1.0 // indirect
|
||||
golang.org/x/text v0.4.0 // indirect
|
||||
golang.org/x/tools v0.1.12 // indirect
|
||||
gopkg.in/ini.v1 v1.66.2 // indirect
|
||||
|
||||
Reference in New Issue
Block a user