fix: UDP packet should not return io.EOF
This commit is contained in:
parent
daab937e48
commit
d70a424a78
4 changed files with 11 additions and 8 deletions
|
@ -3,7 +3,6 @@
|
|||
package packet
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net"
|
||||
"strconv"
|
||||
"syscall"
|
||||
|
@ -34,6 +33,7 @@ func (c *enhanceUDPConn) WaitReadFrom() (data []byte, put func(), addr net.Addr,
|
|||
} else {
|
||||
put()
|
||||
put = nil
|
||||
data = nil
|
||||
}
|
||||
if readErr == syscall.EAGAIN {
|
||||
return false
|
||||
|
@ -48,9 +48,10 @@ func (c *enhanceUDPConn) WaitReadFrom() (data []byte, put func(), addr net.Addr,
|
|||
addr = &net.UDPAddr{IP: ip[:], Port: from.Port, Zone: strconv.FormatInt(int64(from.ZoneId), 10)}
|
||||
}
|
||||
}
|
||||
if readN == 0 {
|
||||
readErr = io.EOF
|
||||
}
|
||||
// udp should not convert readN == 0 to io.EOF
|
||||
//if readN == 0 {
|
||||
// readErr = io.EOF
|
||||
//}
|
||||
return true
|
||||
})
|
||||
if err != nil {
|
||||
|
|
2
go.mod
2
go.mod
|
@ -21,7 +21,7 @@ require (
|
|||
github.com/mdlayher/netlink v1.7.2
|
||||
github.com/metacubex/quic-go v0.33.3-0.20230510010206-687b537b6a58
|
||||
github.com/metacubex/sing-shadowsocks v0.2.2-0.20230509230448-a5157cc00a1c
|
||||
github.com/metacubex/sing-shadowsocks2 v0.0.0-20230511124108-b20f64384bdd
|
||||
github.com/metacubex/sing-shadowsocks2 v0.0.0-20230515071211-0c3604faef69
|
||||
github.com/metacubex/sing-tun v0.1.5-0.20230509224930-30065d4b6376
|
||||
github.com/metacubex/sing-wireguard v0.0.0-20230426030325-41db09ae771a
|
||||
github.com/miekg/dns v1.1.54
|
||||
|
|
4
go.sum
4
go.sum
|
@ -98,8 +98,8 @@ github.com/metacubex/quic-go v0.33.3-0.20230510010206-687b537b6a58 h1:E/sNW9tugF
|
|||
github.com/metacubex/quic-go v0.33.3-0.20230510010206-687b537b6a58/go.mod h1:9nOiGX6kqV3+ZbkDKdTNzdFD726QQHPH6WDb36jUSpA=
|
||||
github.com/metacubex/sing-shadowsocks v0.2.2-0.20230509230448-a5157cc00a1c h1:LpVNvlW/xE+mR8z76xJeYZlYznZXEmU4TeWeuygYdJg=
|
||||
github.com/metacubex/sing-shadowsocks v0.2.2-0.20230509230448-a5157cc00a1c/go.mod h1:4uQQReKMTU7KTfOykVBe/oGJ00pl38d+BYJ99+mx26s=
|
||||
github.com/metacubex/sing-shadowsocks2 v0.0.0-20230511124108-b20f64384bdd h1:RXdD763CbvqaJOyFLAh6xa8xg7BZTkOJ0p8fBc7kB+w=
|
||||
github.com/metacubex/sing-shadowsocks2 v0.0.0-20230511124108-b20f64384bdd/go.mod h1:r+JnKYxqLJIkRhpT9xb3b11icXsvM6yVjCxr2Smp1Og=
|
||||
github.com/metacubex/sing-shadowsocks2 v0.0.0-20230515071211-0c3604faef69 h1:6mwe6TyQUqjpqu8QwRlY5xR5VjENzXtM3LVRhjq00nw=
|
||||
github.com/metacubex/sing-shadowsocks2 v0.0.0-20230515071211-0c3604faef69/go.mod h1:r+JnKYxqLJIkRhpT9xb3b11icXsvM6yVjCxr2Smp1Og=
|
||||
github.com/metacubex/sing-tun v0.1.5-0.20230509224930-30065d4b6376 h1:zKNsbFQyleMFAP7NJYRew9sEMJuniuODH3V0FdWnEtk=
|
||||
github.com/metacubex/sing-tun v0.1.5-0.20230509224930-30065d4b6376/go.mod h1:BMfG00enVf90/CzcdX9PK3Dymgl7BZqHXJfexEyB7Cc=
|
||||
github.com/metacubex/sing-wireguard v0.0.0-20230426030325-41db09ae771a h1:cWKym33Qvl6HA3hj4/YuYD8hHyqQPb47wT5cJRAPgco=
|
||||
|
|
|
@ -55,7 +55,9 @@ func handleUDPToLocal(packet C.UDPPacket, pc N.EnhancePacketConn, key string, oA
|
|||
}
|
||||
|
||||
_, err = packet.WriteBack(data, fromUDPAddr)
|
||||
if put != nil {
|
||||
put()
|
||||
}
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue