Skip to content

Commit

Permalink
Ensure connections have unique ips
Browse files Browse the repository at this point in the history
  • Loading branch information
moberghammer committed Apr 26, 2024
1 parent a786eda commit 1b8b5d2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 1b8b5d2

Please sign in to comment.