Fix UDPConn read length
This commit is contained in:
parent
83bfd6b807
commit
66fc78695a
8
udp.go
8
udp.go
@ -20,18 +20,18 @@ type UDPConn struct {
|
||||
}
|
||||
|
||||
func (s *UDPConn) ReadFrom(b []byte) (int, net.Addr, error) {
|
||||
_, _, err := s.PacketConn.ReadFrom(b)
|
||||
nr, _, err := s.PacketConn.ReadFrom(b)
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
|
||||
datagram, err := NewDatagramFrom(bytes.NewReader(b))
|
||||
datagram, err := NewDatagramFrom(bytes.NewReader(b[:nr]))
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
|
||||
n := copy(b, datagram.Data)
|
||||
return n, AddrFromSocks(datagram.ATYP, datagram.DstAddr, datagram.DstPort), nil
|
||||
nc := copy(b, datagram.Data)
|
||||
return nc, AddrFromSocks(datagram.ATYP, datagram.DstAddr, datagram.DstPort), nil
|
||||
}
|
||||
|
||||
func (s *UDPConn) Read(b []byte) (int, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user