remove deprecate ciphers in shadowsocks (#710)

* remove deprecate ciphers in shadowsocks

Co-authored-by: Kslr <kslrwang@gmail.com>
This commit is contained in:
yuhan6665 2021-09-16 16:13:07 -04:00 committed by GitHub
parent 1adfc2720a
commit 00bcd40c34
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 77 additions and 543 deletions

View file

@ -18,6 +18,12 @@ func toAccount(a *Account) protocol.Account {
return account
}
func equalRequestHeader(x, y *protocol.RequestHeader) bool {
return cmp.Equal(x, y, cmp.Comparer(func(x, y protocol.RequestHeader) bool {
return x == y
}))
}
func TestUDPEncoding(t *testing.T) {
request := &protocol.RequestHeader{
Version: Version,
@ -27,7 +33,7 @@ func TestUDPEncoding(t *testing.T) {
User: &protocol.MemoryUser{
Email: "love@example.com",
Account: toAccount(&Account{
Password: "shadowsocks-password",
Password: "password",
CipherType: CipherType_AES_128_GCM,
}),
},
@ -47,8 +53,8 @@ func TestUDPEncoding(t *testing.T) {
t.Error("data: ", r)
}
if r := cmp.Diff(decodedRequest, request, cmp.Comparer(func(a1, a2 protocol.Account) bool { return a1.Equals(a2) })); r != "" {
t.Error("request: ", r)
if equalRequestHeader(decodedRequest, request) == false {
t.Error("different request")
}
}
@ -67,7 +73,7 @@ func TestTCPRequest(t *testing.T) {
Email: "love@example.com",
Account: toAccount(&Account{
Password: "tcp-password",
CipherType: CipherType_CHACHA20_POLY1305,
CipherType: CipherType_AES_128_GCM,
}),
},
},
@ -99,7 +105,7 @@ func TestTCPRequest(t *testing.T) {
Email: "love@example.com",
Account: toAccount(&Account{
Password: "password",
CipherType: CipherType_AES_128_GCM,
CipherType: CipherType_CHACHA20_POLY1305,
}),
},
},
@ -123,8 +129,8 @@ func TestTCPRequest(t *testing.T) {
validator.Add(request.User)
decodedRequest, reader, err := ReadTCPSession(validator, cache)
common.Must(err)
if r := cmp.Diff(decodedRequest, request, cmp.Comparer(func(a1, a2 protocol.Account) bool { return a1.Equals(a2) })); r != "" {
t.Error("request: ", r)
if equalRequestHeader(decodedRequest, request) == false {
t.Error("different request")
}
decodedData, err := reader.ReadMultiBuffer()