Improve 4in6 processing (break change)

This commit is contained in:
世界 2022-07-22 16:09:32 +08:00
parent 4ce9815aca
commit 8311d6e970
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
4 changed files with 20 additions and 36 deletions

View file

@ -56,7 +56,7 @@ func (s *Serializer) WriteAddress(writer io.Writer, addr Socksaddr) error {
return err
}
if addr.Addr.IsValid() {
err = rw.WriteBytes(writer, addr.Addr.AsSlice())
err = rw.WriteBytes(writer, addr.Unwrap().Addr.AsSlice())
} else {
err = WriteSocksString(writer, addr.Fqdn)
}
@ -129,11 +129,8 @@ func (s *Serializer) ReadAddress(reader io.Reader) (Socksaddr, error) {
if err != nil {
return Socksaddr{}, E.Cause(err, "read ipv6 address")
}
netAddr := netip.AddrFrom16(addr)
if netAddr.Is4In6() {
netAddr = netip.AddrFrom4(netAddr.As4())
}
return Socksaddr{Addr: netAddr}, nil
return Socksaddr{Addr: netip.AddrFrom16(addr)}.Unwrap(), nil
default:
return Socksaddr{}, E.New("unknown address family: ", af)
}