From 5a4441c47fdb62f43910699293a249831f6445bf Mon Sep 17 00:00:00 2001 From: Anankke Date: Tue, 12 Apr 2022 22:06:06 -0400 Subject: [PATCH] Chore: add `none` alias to `dummy` on ShadowsocksR (#2056) --- adapter/outbound/shadowsocksr.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/adapter/outbound/shadowsocksr.go b/adapter/outbound/shadowsocksr.go index a5f07ef6..ea1c2838 100644 --- a/adapter/outbound/shadowsocksr.go +++ b/adapter/outbound/shadowsocksr.go @@ -92,6 +92,12 @@ func (ssr *ShadowSocksR) ListenPacketContext(ctx context.Context, metadata *C.Me } func NewShadowSocksR(option ShadowSocksROption) (*ShadowSocksR, error) { + // SSR protocol compatibility + // https://github.com/Dreamacro/clash/pull/2056 + if option.Cipher == "none" { + option.Cipher = "dummy" + } + addr := net.JoinHostPort(option.Server, strconv.Itoa(option.Port)) cipher := option.Cipher password := option.Password @@ -103,13 +109,14 @@ func NewShadowSocksR(option ShadowSocksROption) (*ShadowSocksR, error) { ivSize int key []byte ) + if option.Cipher == "dummy" { ivSize = 0 key = core.Kdf(option.Password, 16) } else { ciph, ok := coreCiph.(*core.StreamCipher) if !ok { - return nil, fmt.Errorf("%s is not dummy or a supported stream cipher in ssr", cipher) + return nil, fmt.Errorf("%s is not none or a supported stream cipher in ssr", cipher) } ivSize = ciph.IVSize() key = ciph.Key