mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-10-12 01:58:46 +02:00
The journal records the network state of the host and each change of that state. The support team reads one file to see the interfaces, the routes, the resolvers, and the recoveries around an incident. The same file shows the health of the query path. A change that touches only AirDrop or virtual interfaces runs no DNS work.
42 lines
1005 B
Go
42 lines
1005 B
Go
package ctrld
|
|
|
|
import (
|
|
"context"
|
|
"sync"
|
|
"sync/atomic"
|
|
"time"
|
|
|
|
ctrldnet "github.com/Control-D-Inc/ctrld/internal/net"
|
|
)
|
|
|
|
var (
|
|
hasIPv6Once sync.Once
|
|
ipv6Available atomic.Bool
|
|
)
|
|
|
|
// HasIPv6 reports whether the current network stack has IPv6 available.
|
|
func HasIPv6() bool {
|
|
hasIPv6Once.Do(func() {
|
|
ProxyLogger.Load().Debug().Msg("checking for IPv6 availability once")
|
|
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
|
defer cancel()
|
|
val := ctrldnet.IPv6Available(ctx)
|
|
ipv6Available.Store(val)
|
|
ProxyLogger.Load().Debug().Msgf("ipv6 availability: %v", val)
|
|
})
|
|
return ipv6Available.Load()
|
|
}
|
|
|
|
// SetIPv6Available stores the IPv6 state that the network monitor reports, so
|
|
// one monitor serves the whole process.
|
|
func SetIPv6Available(v bool) {
|
|
ipv6Available.Store(v)
|
|
}
|
|
|
|
// DisableIPv6 marks IPv6 as unavailable if enabled.
|
|
func DisableIPv6() {
|
|
if ipv6Available.CompareAndSwap(true, false) {
|
|
ProxyLogger.Load().Debug().Msg("turned off IPv6 availability")
|
|
}
|
|
}
|