Skip to content

Commit

Permalink
Fix NoneCliper cannot work
Browse files Browse the repository at this point in the history
  • Loading branch information
AkinoKaede committed Jul 2, 2021
1 parent 4b4722a commit 8f6b274
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion proxy/shadowsocks/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func DecodeUDPPacket(validator *Validator, payload *buf.Buffer) (*protocol.Reque

if user != nil {
account := user.Account.(*MemoryAccount)
if account.Cipher.IsAEAD() {
if _, isAEAD := account.Cipher.(*AEADCipher); isAEAD {
payload.Clear()
payload.Write(d)
} else {
Expand Down
5 changes: 3 additions & 2 deletions proxy/shadowsocks/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (v *Validator) Add(u *protocol.MemoryUser) error {
defer v.Unlock()

account := u.Account.(*MemoryAccount)
if !account.Cipher.IsAEAD() && len(v.users) > 0 {
if _, isAEAD := account.Cipher.(*AEADCipher); !isAEAD && len(v.users) > 0 {
return newError("The cipher is not support Single-port Multi-user")
}
v.users = append(v.users, u)
Expand Down Expand Up @@ -77,7 +77,8 @@ func (v *Validator) Get(bs []byte, command protocol.RequestCommand) (u *protocol
defer v.RUnlock()

for _, user := range v.users {
if account := user.Account.(*MemoryAccount); account.Cipher.IsAEAD() {
account := user.Account.(*MemoryAccount)
if _, isAEAD := account.Cipher.(*AEADCipher); isAEAD {
aeadCipher := account.Cipher.(*AEADCipher)
ivLen = aeadCipher.IVSize()
subkey := make([]byte, 32)
Expand Down

0 comments on commit 8f6b274

Please sign in to comment.