Add ss aead tests

This commit is contained in:
世界 2022-07-15 11:18:14 +08:00
parent 2c2eb31e18
commit 5a3de62c50
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
6 changed files with 27 additions and 8 deletions

2
go.mod
View file

@ -9,7 +9,7 @@ require (
github.com/oschwald/maxminddb-golang v1.9.0
github.com/sagernet/sing v0.0.0-20220714145306-09b55ce4b6d0
github.com/sagernet/sing-dns v0.0.0-20220711062726-c64e938e4619
github.com/sagernet/sing-shadowsocks v0.0.0-20220714111527-a6fa7ada6e81
github.com/sagernet/sing-shadowsocks v0.0.0-20220715031600-dacfbcd606f4
github.com/sagernet/sing-tun v0.0.0-20220714151007-c0d248af0361
github.com/spf13/cobra v1.5.0
github.com/stretchr/testify v1.8.0

4
go.sum
View file

@ -29,8 +29,8 @@ github.com/sagernet/sing v0.0.0-20220714145306-09b55ce4b6d0 h1:8tnMLN6jdqKkjPXwg
github.com/sagernet/sing v0.0.0-20220714145306-09b55ce4b6d0/go.mod h1:3ZmoGNg/nNJTyHAZFNRSPaXpNIwpDvyIiAUd0KIWV5c=
github.com/sagernet/sing-dns v0.0.0-20220711062726-c64e938e4619 h1:oHbOmq1WS0XaZmXp6WpxzyB2xeyRIA1/L8EJKuNntfY=
github.com/sagernet/sing-dns v0.0.0-20220711062726-c64e938e4619/go.mod h1:y2fpvoxukw3G7eApIZwkcpcG/NE4AB8pCQI0Qd8rMqk=
github.com/sagernet/sing-shadowsocks v0.0.0-20220714111527-a6fa7ada6e81 h1:VuUk/04yCr3dw2uJj0/OFVeVO5O2dwYGlj/RzuEfYDE=
github.com/sagernet/sing-shadowsocks v0.0.0-20220714111527-a6fa7ada6e81/go.mod h1:MuyT+9fEPjvauAv0fSE0a6Q+l0Tv2ZrAafTkYfnxBFw=
github.com/sagernet/sing-shadowsocks v0.0.0-20220715031600-dacfbcd606f4 h1:s3yKbPfiNwFFGfcNUs8NcKYzor78HWmZuDl5B0dsVQI=
github.com/sagernet/sing-shadowsocks v0.0.0-20220715031600-dacfbcd606f4/go.mod h1:MuyT+9fEPjvauAv0fSE0a6Q+l0Tv2ZrAafTkYfnxBFw=
github.com/sagernet/sing-tun v0.0.0-20220714151007-c0d248af0361 h1:M6m9mXG5u151voF0wSDLf5JoDwHU5+4FOMrzb/kaRdc=
github.com/sagernet/sing-tun v0.0.0-20220714151007-c0d248af0361/go.mod h1:p7QbUBs2ejf6UQsiHyy1xGAWOk9JWQjZTHy8pOmkWmo=
github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU=

View file

@ -9,6 +9,7 @@ import (
"github.com/sagernet/sing-box"
"github.com/sagernet/sing-box/option"
"github.com/sagernet/sing/common/control"
F "github.com/sagernet/sing/common/format"
M "github.com/sagernet/sing/common/metadata"
N "github.com/sagernet/sing/common/network"
"github.com/sagernet/sing/protocol/socks"
@ -20,11 +21,11 @@ func mkPort(t *testing.T) uint16 {
var lc net.ListenConfig
lc.Control = control.ReuseAddr()
for {
tcpListener, err := net.ListenTCP("tcp", nil)
tcpListener, err := lc.Listen(context.Background(), "tcp", ":0")
require.NoError(t, err)
listenPort := M.SocksaddrFromNet(tcpListener.Addr()).Port
tcpListener.Close()
udpListener, err := net.ListenUDP("udp", &net.UDPAddr{Port: int(listenPort)})
udpListener, err := lc.Listen(context.Background(), "tcp", F.ToString(":", listenPort))
if err != nil {
continue
}

View file

@ -33,7 +33,7 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/sagernet/sing-dns v0.0.0-20220711062726-c64e938e4619 // indirect
github.com/sagernet/sing-shadowsocks v0.0.0-20220714111527-a6fa7ada6e81 // indirect
github.com/sagernet/sing-shadowsocks v0.0.0-20220715031600-dacfbcd606f4 // indirect
github.com/sagernet/sing-tun v0.0.0-20220714151007-c0d248af0361 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/vishvananda/netlink v1.1.0 // indirect

View file

@ -56,8 +56,8 @@ github.com/sagernet/sing v0.0.0-20220714145306-09b55ce4b6d0 h1:8tnMLN6jdqKkjPXwg
github.com/sagernet/sing v0.0.0-20220714145306-09b55ce4b6d0/go.mod h1:3ZmoGNg/nNJTyHAZFNRSPaXpNIwpDvyIiAUd0KIWV5c=
github.com/sagernet/sing-dns v0.0.0-20220711062726-c64e938e4619 h1:oHbOmq1WS0XaZmXp6WpxzyB2xeyRIA1/L8EJKuNntfY=
github.com/sagernet/sing-dns v0.0.0-20220711062726-c64e938e4619/go.mod h1:y2fpvoxukw3G7eApIZwkcpcG/NE4AB8pCQI0Qd8rMqk=
github.com/sagernet/sing-shadowsocks v0.0.0-20220714111527-a6fa7ada6e81 h1:VuUk/04yCr3dw2uJj0/OFVeVO5O2dwYGlj/RzuEfYDE=
github.com/sagernet/sing-shadowsocks v0.0.0-20220714111527-a6fa7ada6e81/go.mod h1:MuyT+9fEPjvauAv0fSE0a6Q+l0Tv2ZrAafTkYfnxBFw=
github.com/sagernet/sing-shadowsocks v0.0.0-20220715031600-dacfbcd606f4 h1:s3yKbPfiNwFFGfcNUs8NcKYzor78HWmZuDl5B0dsVQI=
github.com/sagernet/sing-shadowsocks v0.0.0-20220715031600-dacfbcd606f4/go.mod h1:MuyT+9fEPjvauAv0fSE0a6Q+l0Tv2ZrAafTkYfnxBFw=
github.com/sagernet/sing-tun v0.0.0-20220714151007-c0d248af0361 h1:M6m9mXG5u151voF0wSDLf5JoDwHU5+4FOMrzb/kaRdc=
github.com/sagernet/sing-tun v0.0.0-20220714151007-c0d248af0361/go.mod h1:p7QbUBs2ejf6UQsiHyy1xGAWOk9JWQjZTHy8pOmkWmo=
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=

View file

@ -14,6 +14,24 @@ import (
)
func TestShadowsocks(t *testing.T) {
for _, method := range []string{
"aes-128-gcm",
"aes-256-gcm",
"chacha20-ietf-poly1305",
} {
t.Run(method+"-inbound", func(t *testing.T) {
testShadowsocksInboundWithShadowsocksRust(t, method, mkBase64(t, 16))
})
t.Run(method+"-outbound", func(t *testing.T) {
testShadowsocksOutboundWithShadowsocksRust(t, method, mkBase64(t, 16))
})
t.Run(method+"-self", func(t *testing.T) {
testShadowsocksSelf(t, method, mkBase64(t, 16))
})
}
}
func TestShadowsocks2022(t *testing.T) {
for _, method16 := range []string{
"2022-blake3-aes-128-gcm",
} {