mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-10 08:40:28 +00:00
Fix accidental truncation of addresses ending in 8 on macOS and BSD
This commit is contained in:
parent
fae00e962f
commit
bc899c395a
@ -137,7 +137,7 @@ func (tun *tunDevice) setupAddress(addr string) error {
|
|||||||
copy(ar.ifr_name[:], tun.iface.Name())
|
copy(ar.ifr_name[:], tun.iface.Name())
|
||||||
ar.ifru_addr.sin6_len = uint8(unsafe.Sizeof(ar.ifru_addr))
|
ar.ifru_addr.sin6_len = uint8(unsafe.Sizeof(ar.ifru_addr))
|
||||||
ar.ifru_addr.sin6_family = unix.AF_INET6
|
ar.ifru_addr.sin6_family = unix.AF_INET6
|
||||||
parts := strings.Split(strings.TrimRight(addr, "/8"), ":")
|
parts := strings.Split(strings.Split(addr, "/")[0], ":")
|
||||||
for i := 0; i < 8; i++ {
|
for i := 0; i < 8; i++ {
|
||||||
addr, _ := strconv.ParseUint(parts[i], 16, 16)
|
addr, _ := strconv.ParseUint(parts[i], 16, 16)
|
||||||
b := make([]byte, 16)
|
b := make([]byte, 16)
|
||||||
|
@ -84,7 +84,7 @@ func (tun *tunDevice) setupAddress(addr string) error {
|
|||||||
|
|
||||||
ar.ifra_addr.sin6_len = uint8(unsafe.Sizeof(ar.ifra_addr))
|
ar.ifra_addr.sin6_len = uint8(unsafe.Sizeof(ar.ifra_addr))
|
||||||
ar.ifra_addr.sin6_family = unix.AF_INET6
|
ar.ifra_addr.sin6_family = unix.AF_INET6
|
||||||
parts := strings.Split(strings.TrimRight(addr, "/8"), ":")
|
parts := strings.Split(strings.Split(addr, "/")[0], ":")
|
||||||
for i := 0; i < 8; i++ {
|
for i := 0; i < 8; i++ {
|
||||||
addr, _ := strconv.ParseUint(parts[i], 16, 16)
|
addr, _ := strconv.ParseUint(parts[i], 16, 16)
|
||||||
b := make([]byte, 16)
|
b := make([]byte, 16)
|
||||||
|
Loading…
Reference in New Issue
Block a user