mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-07-16 13:17:19 +02:00
cmd/cli: implement auto captive portal detection
ControlD have global list of known captive portals that user can augment with proper setup. However, this requires manual actions, and involving restart ctrld for taking effects. By allowing ctrld "leaks" DNS queries to OS resolver, this process becomes automatically, the captive portal could intercept these queries, and as long as it was passed, ctrld will resume normal operation.
This commit is contained in:
committed by
Cuong Manh Le
parent
617674ce43
commit
082d14a9ba
+6
-2
@@ -105,6 +105,10 @@ type prog struct {
|
||||
loopMu sync.Mutex
|
||||
loop map[string]bool
|
||||
|
||||
captivePortalMu sync.Mutex
|
||||
captivePortalCheckWasRun bool
|
||||
captivePortalDetected atomic.Bool
|
||||
|
||||
started chan struct{}
|
||||
onStartedDone chan struct{}
|
||||
onStarted []func()
|
||||
@@ -240,6 +244,8 @@ func (p *prog) postRun() {
|
||||
ns := ctrld.InitializeOsResolver()
|
||||
mainLog.Load().Debug().Msgf("initialized OS resolver with nameservers: %v", ns)
|
||||
p.setDNS()
|
||||
p.csSetDnsDone <- struct{}{}
|
||||
close(p.csSetDnsDone)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -534,8 +540,6 @@ func (p *prog) setDNS() {
|
||||
setDnsOK := false
|
||||
defer func() {
|
||||
p.csSetDnsOk = setDnsOK
|
||||
p.csSetDnsDone <- struct{}{}
|
||||
close(p.csSetDnsDone)
|
||||
}()
|
||||
|
||||
if cfg.Listener == nil {
|
||||
|
||||
Reference in New Issue
Block a user