Skip to content

Commit

Permalink
Merge pull request #79 from pouriyajamshidi/fix/ip_version_selection_bug
Browse files Browse the repository at this point in the history
fix IP version enforcement bug
  • Loading branch information
pouriyajamshidi authored May 14, 2023
2 parents 2aae69b + 3b55c07 commit e3fd75c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tcping.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,12 @@ func resolveHostname(tcpStats *stats) ipAddress {
colorRed("Failed to find IPv4 address for %s\n", tcpStats.hostname)
os.Exit(1)
}
if len(ipAddrs) > 1 {
if len(ipList) > 1 {
index = rand.Intn(len(ipAddrs))
} else {
index = 0
}
ip, _ = netip.ParseAddr(ipAddrs[index].String())
ip, _ = netip.ParseAddr(ipList[index].String())

case tcpStats.useIPv6:
for _, ip := range ipAddrs {
Expand All @@ -331,12 +331,12 @@ func resolveHostname(tcpStats *stats) ipAddress {
colorRed("Failed to find IPv6 address for %s\n", tcpStats.hostname)
os.Exit(1)
}
if len(ipAddrs) > 1 {
if len(ipList) > 1 {
index = rand.Intn(len(ipAddrs))
} else {
index = 0
}
ip, _ = netip.ParseAddr(ipAddrs[index].String())
ip, _ = netip.ParseAddr(ipList[index].String())

default:
if len(ipAddrs) > 1 {
Expand Down

0 comments on commit e3fd75c

Please sign in to comment.