Fixing aliasing issues

This commit is contained in:
Armon Dadgar 2014-05-20 11:38:15 -07:00
parent 8be7e3ac4e
commit 4cb233f48b

View File

@ -188,8 +188,13 @@ func (c *client) query(params *QueryParam) error {
inp = ensureName(inprogress, rr.Ptr) inp = ensureName(inprogress, rr.Ptr)
case *dns.SRV: case *dns.SRV:
// Check for a target mismatch
if rr.Target != rr.Hdr.Name {
alias(inprogress, rr.Hdr.Name, rr.Target)
}
// Get the port // Get the port
inp = ensureName(inprogress, rr.Target) inp = ensureName(inprogress, rr.Hdr.Name)
inp.Port = int(rr.Port) inp.Port = int(rr.Port)
case *dns.TXT: case *dns.TXT:
@ -282,3 +287,9 @@ func ensureName(inprogress map[string]*ServiceEntry, name string) *ServiceEntry
inprogress[name] = inp inprogress[name] = inp
return inp return inp
} }
// alias is used to setup an alias between two entries
func alias(inprogress map[string]*ServiceEntry, src, dst string) {
srcEntry := ensureName(inprogress, src)
inprogress[dst] = srcEntry
}