Cast 4in6 from reading socksaddr

This commit is contained in:
世界 2022-05-27 07:24:02 +08:00
parent 5b49366f6e
commit 01ea424838
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
2 changed files with 6 additions and 2 deletions

View file

@ -122,7 +122,11 @@ func (s *Serializer) ReadAddress(reader io.Reader) (Socksaddr, error) {
if err != nil {
return Socksaddr{}, E.Cause(err, "read ipv6 address")
}
return Socksaddr{Addr: netip.AddrFrom16(addr)}, nil
netAddr := netip.AddrFrom16(addr)
if netAddr.Is4In6() {
netAddr = netip.AddrFrom4(netAddr.As4())
}
return Socksaddr{Addr: netAddr}, nil
default:
return Socksaddr{}, E.New("unknown address family: ", af)
}