cmd: allow import/running ctrld as library

This commit is contained in:
Ginder Singh
2023-09-18 11:40:03 +00:00
committed by Cuong Manh Le
parent 2765487f10
commit 507c1afd59
8 changed files with 379 additions and 219 deletions
+6
View File
@@ -491,6 +491,12 @@ func runDNSServer(addr, network string, handler dns.Handler) (*dns.Server, <-cha
func (p *prog) getClientInfo(remoteIP string, msg *dns.Msg) *ctrld.ClientInfo {
ci := &ctrld.ClientInfo{}
if p.appCallback != nil {
ci.IP = p.appCallback.LanIp()
ci.Mac = p.appCallback.MacAddress()
ci.Hostname = p.appCallback.HostName()
return ci
}
ci.IP, ci.Mac = ipAndMacFromMsg(msg)
switch {
case ci.IP != "" && ci.Mac != "":