-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement read waiter for ss2022 UDP
- Loading branch information
1 parent
e07da80
commit 6ed02b4
Showing
4 changed files
with
56 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4= | ||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= | ||
github.com/sagernet/sing v0.2.17 h1:vMPKb3MV0Aa5ws4dCJkRI8XEjrsUcDn810czd0FwmzI= | ||
github.com/sagernet/sing v0.2.17/go.mod h1:OL6k2F0vHmEzXz2KW19qQzu172FDgSbUSODylighuVo= | ||
github.com/sagernet/sing v0.2.19-0.20231206123939-86c131fc0547 h1:Mco2TffcdPMlmzbcGmbKd6Vm6dEBJH2VgjO6H1XfZzY= | ||
github.com/sagernet/sing v0.2.19-0.20231206123939-86c131fc0547/go.mod h1:Ce5LNojQOgOiWhiD8pPD6E9H7e2KgtOe3Zxx4Ou5u80= | ||
golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA= | ||
golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= | ||
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= | ||
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= | ||
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= | ||
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= | ||
lukechampine.com/blake3 v1.2.1 h1:YuqqRuaqsGV71BV/nm9xlI0MKUv4QC54jQnBChWbGnI= | ||
lukechampine.com/blake3 v1.2.1/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package shadowaead_2022 | ||
|
||
import ( | ||
"github.com/sagernet/sing/common/buf" | ||
"github.com/sagernet/sing/common/bufio" | ||
M "github.com/sagernet/sing/common/metadata" | ||
N "github.com/sagernet/sing/common/network" | ||
) | ||
|
||
var _ N.PacketReadWaitCreator = (*clientPacketConn)(nil) | ||
|
||
func (c *clientPacketConn) CreateReadWaiter() (N.PacketReadWaiter, bool) { | ||
readWaiter, isReadWaiter := bufio.CreateReadWaiter(c.reader) | ||
if !isReadWaiter { | ||
return nil, false | ||
} | ||
return &clientPacketReadWaiter{c, readWaiter}, true | ||
} | ||
|
||
var _ N.PacketReadWaiter = (*clientPacketReadWaiter)(nil) | ||
|
||
type clientPacketReadWaiter struct { | ||
*clientPacketConn | ||
readWaiter N.ReadWaiter | ||
} | ||
|
||
func (w *clientPacketReadWaiter) InitializeReadWaiter(newBuffer func() *buf.Buffer) { | ||
w.readWaiter.InitializeReadWaiter(newBuffer) | ||
} | ||
|
||
func (w *clientPacketReadWaiter) WaitReadPacket() (buffer *buf.Buffer, destination M.Socksaddr, err error) { | ||
buffer, err = w.readWaiter.WaitReadBuffer() | ||
if err != nil { | ||
return | ||
} | ||
destination, err = w.readPacket(buffer) | ||
if err != nil { | ||
buffer.Release() | ||
return nil, M.Socksaddr{}, err | ||
} | ||
return | ||
} |