Skip to content

Commit

Permalink
Fix base64 check
Browse files Browse the repository at this point in the history
  • Loading branch information
Mygod committed Feb 20, 2023
1 parent 719c9d8 commit 243cafd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions core/src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro
"cipher ${profile.method} is deprecated."
}
// check the key format for aead-2022-cipher
require(profile.method in arrayOf("2022-blake3-aes-128-gcm", "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305")
&& Base64.decode(profile.password, Base64.DEFAULT).size in arrayOf(16, 32)) {
require(profile.method !in setOf(
"2022-blake3-aes-128-gcm",
"2022-blake3-aes-256-gcm",
"2022-blake3-chacha20-poly1305",
) || Base64.decode(profile.password, Base64.DEFAULT).size in arrayOf(16, 32)) {

This comment has been minimized.

Copy link
@dev4u

dev4u Feb 27, 2023

Contributor

profile.password这个配置,可能存在iPSK:uPSK格式的密码。
如果要在客户端检测,要先以:做分组,然后对分组后的psk做检测。

"The Base64 Key is invalid."
}
}
Expand Down

3 comments on commit 243cafd

@madeye
Copy link
Contributor

@madeye madeye commented on 243cafd Feb 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it cannot work properly with the latest shadowsocks-rust, as it requires strict padding for the input string.

For example, both ul+/ZaHKume+mu7KJ4WCUQ== and ul+/ZaHKume+mu7KJ4WCUQ can be decoded correctly with Base64.DEFAULT mode. However, ss-rust will exit with an error about the padding.

@zonyitoo Maybe you can relax the padding requirement from your side? It should make everyone's life easier. 😃

@Mygod
Copy link
Contributor Author

@Mygod Mygod commented on 243cafd Feb 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zonyitoo Agreed with above. Just imagine your Google return nothing for you because you put an extra space at the end of your query.

@zonyitoo
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.