mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-08-10 13:20:33 +02:00
remove DNS lookups from IPv6 check, close the connection
log ipv6 availability logic more debugging for ipv6 availability checks more debugging for ipv6 availability checks
This commit is contained in:
@@ -160,6 +160,7 @@ func resetDNS(iface *net.Interface) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO(cuonglm): handle DHCPv6 properly.
|
// TODO(cuonglm): handle DHCPv6 properly.
|
||||||
|
mainLog.Load().Debug().Msg("checking for IPv6 availability")
|
||||||
if ctrldnet.IPv6Available(ctx) {
|
if ctrldnet.IPv6Available(ctx) {
|
||||||
c := client6.NewClient()
|
c := client6.NewClient()
|
||||||
conversation, err := c.Exchange(iface.Name)
|
conversation, err := c.Exchange(iface.Name)
|
||||||
@@ -179,6 +180,8 @@ func resetDNS(iface *net.Interface) (err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
mainLog.Load().Debug().Msg("IPv6 is not available")
|
||||||
}
|
}
|
||||||
|
|
||||||
return ignoringEINTR(func() error {
|
return ignoringEINTR(func() error {
|
||||||
|
|||||||
@@ -102,11 +102,14 @@ func (m *mdns) init(quitCh chan struct{}) error {
|
|||||||
v4ConnList = append(v4ConnList, conn)
|
v4ConnList = append(v4ConnList, conn)
|
||||||
go m.readLoop(conn)
|
go m.readLoop(conn)
|
||||||
}
|
}
|
||||||
|
ctrld.ProxyLogger.Load().Debug().Msgf("checking for IPv6 availability in mdns init")
|
||||||
if ctrldnet.IPv6Available(context.Background()) {
|
if ctrldnet.IPv6Available(context.Background()) {
|
||||||
if conn, err := net.ListenMulticastUDP("udp6", &iface, mdnsV6Addr); err == nil {
|
if conn, err := net.ListenMulticastUDP("udp6", &iface, mdnsV6Addr); err == nil {
|
||||||
v6ConnList = append(v6ConnList, conn)
|
v6ConnList = append(v6ConnList, conn)
|
||||||
go m.readLoop(conn)
|
go m.readLoop(conn)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
ctrld.ProxyLogger.Load().Debug().Msgf("IPv6 is not available in mdns init")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-2
@@ -49,8 +49,12 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func supportIPv6(ctx context.Context) bool {
|
func supportIPv6(ctx context.Context) bool {
|
||||||
_, err := probeStackDialer.DialContext(ctx, "tcp6", net.JoinHostPort(controldIPv6Test, "443"))
|
c, err := probeStackDialer.DialContext(ctx, "tcp6", v6BootstrapDNS)
|
||||||
return err == nil
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
c.Close()
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func supportListenIPv6Local() bool {
|
func supportListenIPv6Local() bool {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ const ipv6ProbingInterval = 10 * time.Second
|
|||||||
|
|
||||||
func hasIPv6() bool {
|
func hasIPv6() bool {
|
||||||
hasIPv6Once.Do(func() {
|
hasIPv6Once.Do(func() {
|
||||||
|
Log(context.Background(), ProxyLogger.Load().Debug(), "checking for IPv6 availability once")
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
val := ctrldnet.IPv6Available(ctx)
|
val := ctrldnet.IPv6Available(ctx)
|
||||||
@@ -43,6 +44,7 @@ func probingIPv6(ctx context.Context, old bool) {
|
|||||||
if ipv6Available.CompareAndSwap(old, cur) {
|
if ipv6Available.CompareAndSwap(old, cur) {
|
||||||
old = cur
|
old = cur
|
||||||
}
|
}
|
||||||
|
Log(ctx, ProxyLogger.Load().Debug(), "IPv6 availability: %v", cur)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user