Skip to content
This repository has been archived by the owner on Jul 13, 2022. It is now read-only.

Commit

Permalink
🔙 Shadowsocks: Disable IV check by default
Browse files Browse the repository at this point in the history
This reverts commit 32a1406 and partially reverts 19ce248. For discussions see shadowsocks/shadowsocks-rust#556.
  • Loading branch information
database64128 committed Oct 23, 2021
1 parent fba26be commit cb88d14
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 68 deletions.
34 changes: 17 additions & 17 deletions infra/conf/shadowsocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ func cipherFromString(c string) shadowsocks.CipherType {
}

type ShadowsocksServerConfig struct {
Cipher string `json:"method"`
Password string `json:"password"`
Level byte `json:"level"`
Email string `json:"email"`
NetworkList *cfgcommon.NetworkList `json:"network"`
DisableIvCheck bool `json:"ivCheck"`
Cipher string `json:"method"`
Password string `json:"password"`
Level byte `json:"level"`
Email string `json:"email"`
NetworkList *cfgcommon.NetworkList `json:"network"`
IvCheck bool `json:"ivCheck"`
}

func (v *ShadowsocksServerConfig) Build() (proto.Message, error) {
Expand All @@ -43,8 +43,8 @@ func (v *ShadowsocksServerConfig) Build() (proto.Message, error) {
return nil, newError("Shadowsocks password is not specified.")
}
account := &shadowsocks.Account{
Password: v.Password,
DisableIvCheck: v.DisableIvCheck,
Password: v.Password,
IvCheck: v.IvCheck,
}
account.CipherType = cipherFromString(v.Cipher)
if account.CipherType == shadowsocks.CipherType_UNKNOWN {
Expand All @@ -61,14 +61,14 @@ func (v *ShadowsocksServerConfig) Build() (proto.Message, error) {
}

type ShadowsocksServerTarget struct {
Address *cfgcommon.Address `json:"address"`
Port uint16 `json:"port"`
Cipher string `json:"method"`
Password string `json:"password"`
Email string `json:"email"`
Ota bool `json:"ota"`
Level byte `json:"level"`
DisableIvCheck bool `json:"ivCheck"`
Address *cfgcommon.Address `json:"address"`
Port uint16 `json:"port"`
Cipher string `json:"method"`
Password string `json:"password"`
Email string `json:"email"`
Ota bool `json:"ota"`
Level byte `json:"level"`
IvCheck bool `json:"ivCheck"`
}

type ShadowsocksClientConfig struct {
Expand Down Expand Up @@ -101,7 +101,7 @@ func (v *ShadowsocksClientConfig) Build() (proto.Message, error) {
return nil, newError("unknown cipher method: ", server.Cipher)
}

account.DisableIvCheck = server.DisableIvCheck
account.IvCheck = server.IvCheck

ss := &protocol.ServerEndpoint{
Address: server.Address.Build(),
Expand Down
2 changes: 1 addition & 1 deletion proxy/shadowsocks/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (a *Account) AsAccount() (protocol.Account, error) {
Cipher: Cipher,
Key: passwordToCipherKey([]byte(a.Password), Cipher.KeySize()),
replayFilter: func() antireplay.GeneralizedReplayFilter {
if !a.DisableIvCheck {
if a.IvCheck {
return antireplay.NewBloomRing()
}
return nil
Expand Down
73 changes: 36 additions & 37 deletions proxy/shadowsocks/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion proxy/shadowsocks/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ message Account {
string password = 1;
CipherType cipher_type = 2;

bool disable_iv_check = 3;
bool iv_check = 3;
}

enum CipherType {
Expand Down
15 changes: 6 additions & 9 deletions proxy/shadowsocks/protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ func TestTCPRequest(t *testing.T) {
User: &protocol.MemoryUser{
Email: "[email protected]",
Account: toAccount(&Account{
Password: "tcp-password",
CipherType: CipherType_AES_128_GCM,
DisableIvCheck: true,
Password: "tcp-password",
CipherType: CipherType_AES_128_GCM,
}),
},
},
Expand All @@ -87,9 +86,8 @@ func TestTCPRequest(t *testing.T) {
User: &protocol.MemoryUser{
Email: "[email protected]",
Account: toAccount(&Account{
Password: "password",
CipherType: CipherType_AES_256_GCM,
DisableIvCheck: true,
Password: "password",
CipherType: CipherType_AES_256_GCM,
}),
},
},
Expand All @@ -104,9 +102,8 @@ func TestTCPRequest(t *testing.T) {
User: &protocol.MemoryUser{
Email: "[email protected]",
Account: toAccount(&Account{
Password: "password",
CipherType: CipherType_CHACHA20_POLY1305,
DisableIvCheck: true,
Password: "password",
CipherType: CipherType_CHACHA20_POLY1305,
}),
},
},
Expand Down
5 changes: 2 additions & 3 deletions testing/scenarios/shadowsocks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,8 @@ func TestShadowsocksNone(t *testing.T) {
defer tcpServer.Close()

account := serial.ToTypedMessage(&shadowsocks.Account{
Password: "shadowsocks-password",
CipherType: shadowsocks.CipherType_NONE,
DisableIvCheck: true,
Password: "shadowsocks-password",
CipherType: shadowsocks.CipherType_NONE,
})

serverPort := tcp.PickPort()
Expand Down

0 comments on commit cb88d14

Please sign in to comment.