From 1b8b5d2cff62d1d1bb35b9aa6cb5d267651fb2f6 Mon Sep 17 00:00:00 2001 From: Carsten Moberg Hammer Date: Fri, 26 Apr 2024 13:36:21 +0200 Subject: [PATCH] Ensure connections have unique ips --- main.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 45b1cc7..5f424ce 100644 --- a/main.go +++ b/main.go @@ -226,10 +226,14 @@ func root(_ *cobra.Command, _ []string) { connections6 = nil } + var connectionsMap map[string]bool connections := append(connections4, connections6...) + for _, ip := range connections { + connectionsMap[ip.String()] = true + } - if len(connections) != 1 { - log.Fatalf("Unable to guess remote IP for %s. %d results returned, ipv4 connections '%v' , ipv6 connections '%v'", hostname, len(connections), connections4, connections6) + if len(connectionsMap) != 1 { + log.Fatalf("Unable to guess remote IP for %s. %d results returned, connectionMap '%v', ipv4 connections '%v' , ipv6 connections '%v'", hostname, len(connectionsMap), connectionsMap, connections4, connections6) } q.Add("remote_ip", connections[0].String())