set loaded properly. when returning dns ensure to get the ip back to pass to the tunneler sdk

This commit is contained in:
dovholuknf
2020-11-02 16:02:36 -05:00
parent 19c615b8f3
commit 5edb033ca0
3 changed files with 12 additions and 7 deletions
+9 -5
View File
@@ -33,7 +33,7 @@ type DnsManager interface {
RegisterService(svcId string, dnsNameToReg string, port uint16, ctx *ZIdentity, svcName string) (net.IP, error)
UnregisterService(host string, port uint16)
ReturnToDns(hostname string)
ReturnToDns(hostname string) net.IP
}
var initOnce = sync.Once{}
@@ -166,12 +166,12 @@ func (dns *dnsImpl) RegisterService(svcId string, dnsNameToReg string, port uint
return ip, nil
}
func (dns *dnsImpl) Resolve(toResolve string) net.IP {
func (dns *dnsImpl) Resolve(toResolve string) *net.IP {
dnsName := normalizeDnsName(toResolve)
found := dns.hostnameMap[dnsName]
if found != nil {
if found.dnsEnabled {
return found.ip
return &found.ip
}
}
return nil
@@ -193,7 +193,10 @@ func (dns *dnsImpl) UnregisterService(host string, port uint16) {
log.Warnf("Unexpected error removing route for %s", icept.host)
}
} else {
dns.hostnameMap[icept.host].dnsEnabled = false
found := dns.hostnameMap[normalizeDnsName(icept.host)]
if found != nil {
found.dnsEnabled = false
}
}
delete(dns.serviceMap, key)
} else {
@@ -222,11 +225,12 @@ func (dns *dnsImpl) GetService(ip net.IP, port uint16) (*ZIdentity, string, erro
*/
}
func (dns *dnsImpl) ReturnToDns(hostname string) {
func (dns *dnsImpl) ReturnToDns(hostname string) *net.IP {
dnsEntry := dns.hostnameMap[normalizeDnsName(hostname)]
if dnsEntry != nil {
dnsEntry.dnsEnabled = true
}
return &dnsEntry.ip
}
func DnsInit(tun api.DesktopEdgeIface, ip string, maskBits int) {
+2 -2
View File
@@ -780,8 +780,8 @@ func connectIdentity(id *Id) {
//string, ZService
log.Warnf("ranging over services. key: %s", key)
val := value.(cziti.ZService)
cziti.DNSMgr.ReturnToDns(val.InterceptHost)
cziti.AddIntercept(val.Id, val.Name, val.InterceptHost, int(val.InterceptPort), id.CId.UnsafePointer())
ip := cziti.DNSMgr.ReturnToDns(val.InterceptHost)
cziti.AddIntercept(val.Id, val.Name, ip.String(), int(val.InterceptPort), id.CId.UnsafePointer())
id.Services = append(id.Services, nil)
return true
})
+1
View File
@@ -204,6 +204,7 @@ func (t *RuntimeState) LoadIdentity(id *Id) {
id.ControllerVersion = id.CId.Version
id.CId.Fingerprint = id.FingerPrint
id.CId.Loaded = true
// hack for now - if the identity name is '<unknown>' don't set it... :(
if id.CId.Name == "<unknown>" {