Skip to content

Commit

Permalink
fix ip version enforcement bug
Browse files Browse the repository at this point in the history
  • Loading branch information
pouriyajamshidi committed May 14, 2023
1 parent 2aae69b commit 3b55c07
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 3b55c07

Please sign in to comment.