Skip to content

Commit

Permalink
don't override nodes if no match in map
Browse files Browse the repository at this point in the history
  • Loading branch information
WGOS committed Feb 5, 2024
1 parent 3be877f commit e3262df
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,9 @@ func answerForNodes(domain string) []dns.RR {

if swarmDomain != normDomain {
var subDomain = replaceLast(normDomain, "."+swarmDomain, "")
nodes = nameToNodeMap[subDomain]
logger.Printf("%v, %v", swarmDomain, normDomain)
if len(nameToNodeMap[subDomain]) > 0 {
nodes = nameToNodeMap[subDomain]
}
}

for _, node := range nodes {
Expand Down Expand Up @@ -211,7 +212,7 @@ func mapNodesToNames(nodes []swarm.SwarmNode) {
for _, name := range node.DnsNames {
newMap[name] = append(newMap[name], node)

logger.Printf("Mapped: [%v] to [%v]\n", name, node.Hostname)
logger.Printf("Mapped: [%v] to [%v]\n", node.Hostname, name)
}
}

Expand Down

0 comments on commit e3262df

Please sign in to comment.