You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now, when users use CheckAddr by passing in a hostname, the address is resolved using net.ResolveTCPAddr("tcp", addr). Unfortunately, this returns an Ipv4 address even in cases when users would rather have preferred to use the Ipv6 address for this host.
Proposed Fix
Option 1: get desired ip address to resolve from users
This option suggest to modify the current CheckAddr to have a parameter for whether users want to check the ipv4 or ipv6 address for this host. Naturally, this means CheckAddrZeroLinger and parseSockAddr need to be changes accordingly. Ex:
In parseSockAddr some logic can be added to parse for ipv6 or ipv4 according to whatever the user provides. (More details below)
Option 2: Add a separate function for checking ipv6 addresses
Option 1 will require users to update their current usage of CheckAddr even if it works just fine for them now. Adding a new function like CheckIpv6Addr would make it easier for users to move to this new function if needed without disrupting current users. Ex:
Regardless of the options above, the way the hostname is resolved would need to be updated to return an ipv4 or v6 address according to user input. Ex:
// parseSockAddr resolves given addr to unix.Sockaddr
func parseSockAddr(addr string) (sAddr unix.Sockaddr, addrType string, family int, err error) {
addrOption := "ip"
if addrType == "ip6" {
addrOption = "ip6"
}
tAddr, err := net.ResolveIPAddr(addrOption, addr)
if err != nil {
return
}
...
...
}
The text was updated successfully, but these errors were encountered:
Issue
Right now, when users use
CheckAddr
by passing in a hostname, the address is resolved usingnet.ResolveTCPAddr("tcp", addr)
. Unfortunately, this returns an Ipv4 address even in cases when users would rather have preferred to use the Ipv6 address for this host.Proposed Fix
Option 1: get desired ip address to resolve from users
This option suggest to modify the current
CheckAddr
to have a parameter for whether users want to check the ipv4 or ipv6 address for this host. Naturally, this meansCheckAddrZeroLinger
andparseSockAddr
need to be changes accordingly. Ex:In
parseSockAddr
some logic can be added to parse for ipv6 or ipv4 according to whatever the user provides. (More details below)Option 2: Add a separate function for checking ipv6 addresses
Option 1 will require users to update their current usage of
CheckAddr
even if it works just fine for them now. Adding a new function likeCheckIpv6Addr
would make it easier for users to move to this new function if needed without disrupting current users. Ex:Changing parseSockAddr
Regardless of the options above, the way the hostname is resolved would need to be updated to return an ipv4 or v6 address according to user input. Ex:
The text was updated successfully, but these errors were encountered: