mirror of
https://github.com/SagerNet/sing.git
synced 2025-04-06 05:17:38 +03:00
Cast 4in6 from reading socksaddr
This commit is contained in:
parent
5b49366f6e
commit
01ea424838
2 changed files with 6 additions and 2 deletions
|
@ -94,7 +94,7 @@ func (b *Buffer) Write(data []byte) (n int, err error) {
|
||||||
return 0, io.ErrShortBuffer
|
return 0, io.ErrShortBuffer
|
||||||
}
|
}
|
||||||
if b.end+len(data) > b.Cap() {
|
if b.end+len(data) > b.Cap() {
|
||||||
panic("buffer overflow")
|
panic("buffer overflow: cap " + strconv.Itoa(len(b.data)) + ",end " + strconv.Itoa(b.end) + ", need " + strconv.Itoa(len(data)))
|
||||||
}
|
}
|
||||||
n = copy(b.data[b.end:], data)
|
n = copy(b.data[b.end:], data)
|
||||||
b.end += n
|
b.end += n
|
||||||
|
|
|
@ -122,7 +122,11 @@ func (s *Serializer) ReadAddress(reader io.Reader) (Socksaddr, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Socksaddr{}, E.Cause(err, "read ipv6 address")
|
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:
|
default:
|
||||||
return Socksaddr{}, E.New("unknown address family: ", af)
|
return Socksaddr{}, E.New("unknown address family: ", af)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue