From 005812cd37d646fff901f602df2c920e8ac39276 Mon Sep 17 00:00:00 2001 From: dyhkwong <50692134+dyhkwong@users.noreply.github.com> Date: Sat, 25 Nov 2023 00:09:35 +0800 Subject: [PATCH] fix shadowsocks2022 non-EIH UDP panic --- proxy/shadowsocks2022/method_aes128gcm.go | 3 +++ proxy/shadowsocks2022/method_aes256gcm.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/proxy/shadowsocks2022/method_aes128gcm.go b/proxy/shadowsocks2022/method_aes128gcm.go index 5d2d8c8d070..17b0d9904f0 100644 --- a/proxy/shadowsocks2022/method_aes128gcm.go +++ b/proxy/shadowsocks2022/method_aes128gcm.go @@ -62,6 +62,9 @@ func (a AES128GCMMethod) GetUDPClientProcessor(ipsk [][]byte, psk []byte, deriva } return aead } + if len(ipsk) == 0 { + return NewAESUDPClientPacketProcessor(reqSeparateHeaderCipher, respSeparateHeaderCipher, getPacketAEAD, nil), nil + } eihGenerator := newAESEIHGeneratorContainer(len(ipsk), psk, ipsk) getEIH := func(mask []byte) ExtensibleIdentityHeaders { eih, err := eihGenerator.GenerateEIHUDP(derivation, a, mask) diff --git a/proxy/shadowsocks2022/method_aes256gcm.go b/proxy/shadowsocks2022/method_aes256gcm.go index 064ff3b8ee7..26820dc523e 100644 --- a/proxy/shadowsocks2022/method_aes256gcm.go +++ b/proxy/shadowsocks2022/method_aes256gcm.go @@ -62,6 +62,9 @@ func (a AES256GCMMethod) GetUDPClientProcessor(ipsk [][]byte, psk []byte, deriva } return aead } + if len(ipsk) == 0 { + return NewAESUDPClientPacketProcessor(reqSeparateHeaderCipher, respSeparateHeaderCipher, getPacketAEAD, nil), nil + } eihGenerator := newAESEIHGeneratorContainer(len(ipsk), psk, ipsk) getEIH := func(mask []byte) ExtensibleIdentityHeaders { eih, err := eihGenerator.GenerateEIHUDP(derivation, a, mask)