mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-06-21 13:00:05 +02:00
dont repeat ipv6availablity for each interface, increase self check timeout but reduce max attempts
This commit is contained in:
committed by
Cuong Manh Le
parent
ef697eb781
commit
414d4e356d
+2
-2
@@ -860,7 +860,7 @@ func selfCheckStatus(ctx context.Context, s service.Service, sockDir string) (bo
|
|||||||
func selfCheckResolveDomain(ctx context.Context, addr, scope string, domain string) error {
|
func selfCheckResolveDomain(ctx context.Context, addr, scope string, domain string) error {
|
||||||
bo := backoff.NewBackoff("self-check", logf, 10*time.Second)
|
bo := backoff.NewBackoff("self-check", logf, 10*time.Second)
|
||||||
bo.LogLongerThan = 500 * time.Millisecond
|
bo.LogLongerThan = 500 * time.Millisecond
|
||||||
maxAttempts := 20
|
maxAttempts := 10
|
||||||
c := new(dns.Client)
|
c := new(dns.Client)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -876,7 +876,7 @@ func selfCheckResolveDomain(ctx context.Context, addr, scope string, domain stri
|
|||||||
m := new(dns.Msg)
|
m := new(dns.Msg)
|
||||||
m.SetQuestion(domain+".", dns.TypeA)
|
m.SetQuestion(domain+".", dns.TypeA)
|
||||||
m.RecursionDesired = true
|
m.RecursionDesired = true
|
||||||
r, _, exErr := exchangeContextWithTimeout(c, time.Second, m, addr)
|
r, _, exErr := exchangeContextWithTimeout(c, 5*time.Second, m, addr)
|
||||||
if r != nil && r.Rcode == dns.RcodeSuccess && len(r.Answer) > 0 {
|
if r != nil && r.Rcode == dns.RcodeSuccess && len(r.Answer) > 0 {
|
||||||
mainLog.Load().Debug().Msgf("%s self-check against %q succeeded", scope, domain)
|
mainLog.Load().Debug().Msgf("%s self-check against %q succeeded", scope, domain)
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -92,6 +92,11 @@ func (m *mdns) init(quitCh chan struct{}) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if IPv6 is available once and use the result for the rest of the function.
|
||||||
|
ctrld.ProxyLogger.Load().Debug().Msgf("checking for IPv6 availability in mdns init")
|
||||||
|
ipv6 := ctrldnet.IPv6Available(context.Background())
|
||||||
|
ctrld.ProxyLogger.Load().Debug().Msgf("IPv6 is %v in mdns init", ipv6)
|
||||||
|
|
||||||
v4ConnList := make([]*net.UDPConn, 0, len(ifaces))
|
v4ConnList := make([]*net.UDPConn, 0, len(ifaces))
|
||||||
v6ConnList := make([]*net.UDPConn, 0, len(ifaces))
|
v6ConnList := make([]*net.UDPConn, 0, len(ifaces))
|
||||||
for _, iface := range ifaces {
|
for _, iface := range ifaces {
|
||||||
@@ -102,14 +107,12 @@ 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 ipv6 {
|
||||||
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")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user