From 4cb233f48ba572f71aca6a4d6bd2471c90633563 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Tue, 20 May 2014 11:38:15 -0700 Subject: [PATCH] Fixing aliasing issues --- client.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index d449e4d..a352706 100644 --- a/client.go +++ b/client.go @@ -188,8 +188,13 @@ func (c *client) query(params *QueryParam) error { inp = ensureName(inprogress, rr.Ptr) case *dns.SRV: + // Check for a target mismatch + if rr.Target != rr.Hdr.Name { + alias(inprogress, rr.Hdr.Name, rr.Target) + } + // Get the port - inp = ensureName(inprogress, rr.Target) + inp = ensureName(inprogress, rr.Hdr.Name) inp.Port = int(rr.Port) case *dns.TXT: @@ -282,3 +287,9 @@ func ensureName(inprogress map[string]*ServiceEntry, name string) *ServiceEntry inprogress[name] = 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 +}