5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-12-23 12:15:39 +00:00

Fix accidental truncation of addresses ending in 8 on macOS and BSD

This commit is contained in:
Neil Alexander 2018-05-26 21:47:54 +01:00
parent fae00e962f
commit bc899c395a
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944
2 changed files with 2 additions and 2 deletions

View File

@ -137,7 +137,7 @@ func (tun *tunDevice) setupAddress(addr string) error {
copy(ar.ifr_name[:], tun.iface.Name())
ar.ifru_addr.sin6_len = uint8(unsafe.Sizeof(ar.ifru_addr))
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++ {
addr, _ := strconv.ParseUint(parts[i], 16, 16)
b := make([]byte, 16)

View File

@ -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_family = unix.AF_INET6
parts := strings.Split(strings.TrimRight(addr, "/8"), ":")
parts := strings.Split(strings.Split(addr, "/")[0], ":")
for i := 0; i < 8; i++ {
addr, _ := strconv.ParseUint(parts[i], 16, 16)
b := make([]byte, 16)