mirror of
https://github.com/SagerNet/sing.git
synced 2025-04-04 20:37:40 +03:00
Improve 4in6 processing (break change)
This commit is contained in:
parent
4ce9815aca
commit
8311d6e970
4 changed files with 20 additions and 36 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue