fix: deadline reader cause panic
This commit is contained in:
parent
36539bb670
commit
41af94ea66
3 changed files with 8 additions and 11 deletions
|
@ -53,9 +53,7 @@ FOR:
|
||||||
if result, ok := result.(*singReadResult); ok {
|
if result, ok := result.(*singReadResult); ok {
|
||||||
destination = result.destination
|
destination = result.destination
|
||||||
err = result.err
|
err = result.err
|
||||||
buffer.Resize(result.buffer.Start(), 0)
|
n, _ := buffer.Write(result.buffer.Bytes())
|
||||||
n := copy(buffer.FreeBytes(), result.buffer.Bytes())
|
|
||||||
buffer.Truncate(n)
|
|
||||||
result.buffer.Advance(n)
|
result.buffer.Advance(n)
|
||||||
if result.buffer.IsEmpty() {
|
if result.buffer.IsEmpty() {
|
||||||
result.buffer.Release()
|
result.buffer.Release()
|
||||||
|
@ -85,14 +83,13 @@ FOR:
|
||||||
}
|
}
|
||||||
|
|
||||||
<-c.netPacketConn.resultCh
|
<-c.netPacketConn.resultCh
|
||||||
go c.pipeReadPacket(buffer.Cap(), buffer.Start())
|
go c.pipeReadPacket(buffer.FreeLen())
|
||||||
|
|
||||||
return c.ReadPacket(buffer)
|
return c.ReadPacket(buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *singPacketConn) pipeReadPacket(bufLen int, bufStart int) {
|
func (c *singPacketConn) pipeReadPacket(pLen int) {
|
||||||
buffer := buf.NewSize(bufLen)
|
buffer := buf.NewSize(pLen)
|
||||||
buffer.Advance(bufStart)
|
|
||||||
destination, err := c.singPacketConn.ReadPacket(buffer)
|
destination, err := c.singPacketConn.ReadPacket(buffer)
|
||||||
result := &singReadResult{}
|
result := &singReadResult{}
|
||||||
result.destination = destination
|
result.destination = destination
|
||||||
|
|
4
go.mod
4
go.mod
|
@ -30,7 +30,7 @@ require (
|
||||||
github.com/openacid/low v0.1.21
|
github.com/openacid/low v0.1.21
|
||||||
github.com/oschwald/geoip2-golang v1.8.0
|
github.com/oschwald/geoip2-golang v1.8.0
|
||||||
github.com/sagernet/netlink v0.0.0-20220905062125-8043b4a9aa97
|
github.com/sagernet/netlink v0.0.0-20220905062125-8043b4a9aa97
|
||||||
github.com/sagernet/sing v0.2.5-0.20230519030052-49166ac42700
|
github.com/sagernet/sing v0.2.5-0.20230530114415-221f066dba7c
|
||||||
github.com/sagernet/sing-mux v0.0.0-20230517134606-1ebe6bb26646
|
github.com/sagernet/sing-mux v0.0.0-20230517134606-1ebe6bb26646
|
||||||
github.com/sagernet/sing-shadowtls v0.1.2-0.20230417103049-4f682e05f19b
|
github.com/sagernet/sing-shadowtls v0.1.2-0.20230417103049-4f682e05f19b
|
||||||
github.com/sagernet/sing-vmess v0.1.5-0.20230417103030-8c3070ae3fb3
|
github.com/sagernet/sing-vmess v0.1.5-0.20230417103030-8c3070ae3fb3
|
||||||
|
@ -105,6 +105,6 @@ require (
|
||||||
golang.org/x/tools v0.6.0 // indirect
|
golang.org/x/tools v0.6.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
replace github.com/sagernet/sing => github.com/metacubex/sing v0.0.0-20230526162852-6afe73474070
|
replace github.com/sagernet/sing => github.com/metacubex/sing v0.0.0-20230530121223-b768faae5c6b
|
||||||
|
|
||||||
replace github.com/sagernet/sing-vmess => github.com/metacubex/sing-vmess v0.1.5-0.20230520082358-78b126617899
|
replace github.com/sagernet/sing-vmess => github.com/metacubex/sing-vmess v0.1.5-0.20230520082358-78b126617899
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -96,8 +96,8 @@ github.com/metacubex/gvisor v0.0.0-20230417114019-3c3ee672d60c h1:D62872jiuzC6b+
|
||||||
github.com/metacubex/gvisor v0.0.0-20230417114019-3c3ee672d60c/go.mod h1:wqEuzdImyqD2MCGE8CYRJXbB77oSEJeoSSXXdwKjnsE=
|
github.com/metacubex/gvisor v0.0.0-20230417114019-3c3ee672d60c/go.mod h1:wqEuzdImyqD2MCGE8CYRJXbB77oSEJeoSSXXdwKjnsE=
|
||||||
github.com/metacubex/quic-go v0.33.3-0.20230510010206-687b537b6a58 h1:E/sNW9tugFjoBjAkth89MHlKHRaMdo43tGQ3MOPVayQ=
|
github.com/metacubex/quic-go v0.33.3-0.20230510010206-687b537b6a58 h1:E/sNW9tugFjoBjAkth89MHlKHRaMdo43tGQ3MOPVayQ=
|
||||||
github.com/metacubex/quic-go v0.33.3-0.20230510010206-687b537b6a58/go.mod h1:9nOiGX6kqV3+ZbkDKdTNzdFD726QQHPH6WDb36jUSpA=
|
github.com/metacubex/quic-go v0.33.3-0.20230510010206-687b537b6a58/go.mod h1:9nOiGX6kqV3+ZbkDKdTNzdFD726QQHPH6WDb36jUSpA=
|
||||||
github.com/metacubex/sing v0.0.0-20230526162852-6afe73474070 h1:AT/Qfe9MvCxyrI9uybcXcVDLDEqR6+9ZK7a7pgis9xQ=
|
github.com/metacubex/sing v0.0.0-20230530121223-b768faae5c6b h1:Bw4j3ktf5vivi5qm/ZQGtyRAgybRKSGJaMV1t3rtC+I=
|
||||||
github.com/metacubex/sing v0.0.0-20230526162852-6afe73474070/go.mod h1:Ta8nHnDLAwqySzKhGoKk4ZIB+vJ3GTKj7UPrWYvM+4w=
|
github.com/metacubex/sing v0.0.0-20230530121223-b768faae5c6b/go.mod h1:Ta8nHnDLAwqySzKhGoKk4ZIB+vJ3GTKj7UPrWYvM+4w=
|
||||||
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 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-shadowsocks v0.2.2-0.20230509230448-a5157cc00a1c/go.mod h1:4uQQReKMTU7KTfOykVBe/oGJ00pl38d+BYJ99+mx26s=
|
||||||
github.com/metacubex/sing-shadowsocks2 v0.0.0-20230529235701-a238874242ca h1:10qc50Q1hHrfGO4NjEJpIAgHX63Y256tHE0dFCTN8J4=
|
github.com/metacubex/sing-shadowsocks2 v0.0.0-20230529235701-a238874242ca h1:10qc50Q1hHrfGO4NjEJpIAgHX63Y256tHE0dFCTN8J4=
|
||||||
|
|
Loading…
Reference in a new issue