mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-07-04 01:07:49 +02:00
internal/clientinfo: improving mdns discovery
- Prevent duplicated log message. - Distinguish in case of create/update hostname. - Stop probing if network is unreachable or invalid.
This commit is contained in:
committed by
Cuong Manh Le
parent
cacd957594
commit
59a895bfe2
@@ -48,10 +48,11 @@ type Table struct {
|
||||
ptr *ptrDiscover
|
||||
mdns *mdns
|
||||
cfg *ctrld.Config
|
||||
quitCh chan struct{}
|
||||
}
|
||||
|
||||
func NewTable(cfg *ctrld.Config) *Table {
|
||||
return &Table{cfg: cfg}
|
||||
return &Table{cfg: cfg, quitCh: make(chan struct{})}
|
||||
}
|
||||
|
||||
func (t *Table) AddLeaseFile(name string, format ctrld.LeaseFileFormat) {
|
||||
@@ -70,6 +71,7 @@ func (t *Table) RefreshLoop(stopCh chan struct{}) {
|
||||
_ = r.refresh()
|
||||
}
|
||||
case <-stopCh:
|
||||
close(t.quitCh)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -122,7 +124,7 @@ func (t *Table) Init() {
|
||||
if t.discoverMDNS() {
|
||||
t.mdns = &mdns{}
|
||||
ctrld.ProxyLog.Debug().Msg("start mdns discovery")
|
||||
if err := t.mdns.init(); err != nil {
|
||||
if err := t.mdns.init(t.quitCh); err != nil {
|
||||
ctrld.ProxyLog.Error().Err(err).Msg("could not init mDNS discover")
|
||||
} else {
|
||||
t.hostnameResolvers = append(t.hostnameResolvers, t.mdns)
|
||||
|
||||
Reference in New Issue
Block a user