Commit 6ab77f67 authored by Steven Allen's avatar Steven Allen

don't use ipv4 when a zone is set

parent cda29e15
...@@ -115,6 +115,11 @@ func NetAddrToSockaddr(addr net.Addr) Sockaddr { ...@@ -115,6 +115,11 @@ func NetAddrToSockaddr(addr net.Addr) Sockaddr {
// IPAndZoneToSockaddr converts a net.IP (with optional IPv6 Zone) to a Sockaddr // IPAndZoneToSockaddr converts a net.IP (with optional IPv6 Zone) to a Sockaddr
// Returns nil if conversion fails. // Returns nil if conversion fails.
func IPAndZoneToSockaddr(ip net.IP, zone string) Sockaddr { func IPAndZoneToSockaddr(ip net.IP, zone string) Sockaddr {
if zone != "" {
var buf [16]byte
copy(buf[:], ip.To16())
return &SockaddrInet6{Addr: buf, ZoneId: uint32(IP6ZoneToInt(zone))}
}
if ip4 := ip.To4(); ip4 != nil { if ip4 := ip.To4(); ip4 != nil {
var buf [4]byte var buf [4]byte
copy(buf[:], ip4) // last 4 bytes copy(buf[:], ip4) // last 4 bytes
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment