default:
if ip.Is4In6() {
// TODO(bradfitz): this could alloc less.
- return "::ffff:" + ip.Unmap().String()
+ if z := ip.Zone(); z != "" {
+ return "::ffff:" + ip.Unmap().String() + "%" + z
+ } else {
+ return "::ffff:" + ip.Unmap().String()
+ }
}
return ip.string6()
}
default:
if ip.Is4In6() {
b = append(b, "::ffff:"...)
- return ip.Unmap().appendTo4(b)
+ b = ip.Unmap().appendTo4(b)
+ if z := ip.Zone(); z != "" {
+ b = append(b, '%')
+ b = append(b, z...)
+ }
+ return b
}
return ip.appendTo6(b)
}
b := make([]byte, 0, max)
if ip.Is4In6() {
b = append(b, "::ffff:"...)
- return ip.Unmap().appendTo4(b), nil
+ b = ip.Unmap().appendTo4(b)
+ if z := ip.Zone(); z != "" {
+ b = append(b, '%')
+ b = append(b, z...)
+ }
+ return b, nil
}
return ip.appendTo6(b), nil
}
+
}
// UnmarshalText implements the encoding.TextUnmarshaler interface.
ip: MkAddr(Mk128(0x0001000200000000, 0x0000ffffc0a88cff), intern.Get("eth1")),
str: "1:2::ffff:c0a8:8cff%eth1",
},
+ // 4-in-6 with zone
+ {
+ in: "::ffff:192.168.140.255%eth1",
+ ip: MkAddr(Mk128(0, 0x0000ffffc0a88cff), intern.Get("eth1")),
+ str: "::ffff:192.168.140.255%eth1",
+ },
// IPv6 with capital letters.
{
in: "FD9E:1A04:F01D::1",