all: disable client discover on desktop platforms

Since requests are mostly originated from the machine itself, so all
necessary metadata is local to it.

Currently, the desktop platforms are Windows desktop and darwin.
This commit is contained in:
Cuong Manh Le
2025-03-12 00:09:19 +07:00
committed by Cuong Manh Le
parent 58c0e4f15a
commit 7a136b8874
5 changed files with 56 additions and 6 deletions
+18 -6
View File
@@ -177,15 +177,27 @@ func (t *Table) SetSelfIP(ip string) {
t.dhcp.addSelf()
}
// initSelfDiscover initializes necessary client metadata for self query.
func (t *Table) initSelfDiscover() {
t.dhcp = &dhcp{selfIP: t.selfIP}
t.dhcp.addSelf()
t.ipResolvers = append(t.ipResolvers, t.dhcp)
t.macResolvers = append(t.macResolvers, t.dhcp)
t.hostnameResolvers = append(t.hostnameResolvers, t.dhcp)
}
func (t *Table) init() {
// Custom client ID presents, use it as the only source.
if _, clientID := controld.ParseRawUID(t.cdUID); clientID != "" {
ctrld.ProxyLogger.Load().Debug().Msg("start self discovery")
t.dhcp = &dhcp{selfIP: t.selfIP}
t.dhcp.addSelf()
t.ipResolvers = append(t.ipResolvers, t.dhcp)
t.macResolvers = append(t.macResolvers, t.dhcp)
t.hostnameResolvers = append(t.hostnameResolvers, t.dhcp)
ctrld.ProxyLogger.Load().Debug().Msg("start self discovery with custom client id")
t.initSelfDiscover()
return
}
// If we are running on platforms that should only do self discover, use it as the only source, too.
if ctrld.SelfDiscover() {
ctrld.ProxyLogger.Load().Debug().Msg("start self discovery on desktop platforms")
t.initSelfDiscover()
return
}