Skip to content

Commit f9aae61

Browse files
committed
Add ipv6 support
1 parent f600d76 commit f9aae61

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

client.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -742,9 +742,13 @@ func isPrivateIP(config Config, addr multiaddr.Multiaddr) bool {
742742
return false
743743
}
744744

745-
// Function to extract IP information from a Multiaddr
745+
// Function to extract IP information from a Multiaddr (supports IPv4 and IPv6)
746746
func extractIPFromMultiaddr(addr multiaddr.Multiaddr) (string, error) {
747-
return addr.ValueForProtocol(multiaddr.P_IP4)
747+
ip, err := addr.ValueForProtocol(multiaddr.P_IP4)
748+
if err == nil && ip != "" {
749+
return ip, nil
750+
}
751+
return addr.ValueForProtocol(multiaddr.P_IP6)
748752
}
749753

750754
// GetPublicIP fetches the public IP address from ifconfig.me

0 commit comments

Comments
 (0)