Chore: contexify ProxyAdapter ListenPacket

This commit is contained in:
Dreamacro
2021-10-15 21:44:53 +08:00
parent 583b2a5ace
commit 68753b4ae1
20 changed files with 96 additions and 66 deletions

8
test/Makefile Normal file
View File

@ -0,0 +1,8 @@
lint:
golangci-lint run --disable-all -E govet -E gofumpt -E megacheck ./...
test:
go test -p 1 -v ./...
benchmark:
go test -benchmem -run=^$ -bench .

View File

@ -45,7 +45,7 @@ Prerequisite
* docker (support Linux and macOS)
```
$ go test -p 1 -v
$ make test
```
benchmark (Linux)
@ -55,5 +55,5 @@ benchmark (Linux)
> (change chunkSize to measure the maximum throughput of clash on your machine)
```
$ go test -benchmem -run=^$ -bench .
$ make benchmark
```

View File

@ -96,6 +96,7 @@ func init() {
images := []string{
ImageShadowsocks,
ImageShadowsocksRust,
ImageVmess,
ImageTrojan,
ImageSnell,
@ -582,7 +583,7 @@ func testSuit(t *testing.T, proxy C.ProxyAdapter) {
return
}
pc, err := proxy.DialUDP(&C.Metadata{
pc, err := proxy.ListenPacketContext(context.Background(), &C.Metadata{
NetWork: C.UDP,
DstIP: localIP,
DstPort: "10001",
@ -595,7 +596,7 @@ func testSuit(t *testing.T, proxy C.ProxyAdapter) {
assert.NoError(t, testPingPongWithPacketConn(t, pc))
pc, err = proxy.DialUDP(&C.Metadata{
pc, err = proxy.ListenPacketContext(context.Background(), &C.Metadata{
NetWork: C.UDP,
DstIP: localIP,
DstPort: "10001",
@ -608,7 +609,7 @@ func testSuit(t *testing.T, proxy C.ProxyAdapter) {
assert.NoError(t, testLargeDataWithPacketConn(t, pc))
pc, err = proxy.DialUDP(&C.Metadata{
pc, err = proxy.ListenPacketContext(context.Background(), &C.Metadata{
NetWork: C.UDP,
DstIP: localIP,
DstPort: "10001",