Skip to content

Commit

Permalink
Add AEAD-2022 ciphers for ss-rust #103
Browse files Browse the repository at this point in the history
  • Loading branch information
loyess committed Feb 25, 2023
1 parent 4b78267 commit 0a448bb
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
18 changes: 18 additions & 0 deletions prepare/shadowsocks_prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ none
aes-256-gcm
aes-128-gcm
chacha20-ietf-poly1305
2022-blake3-aes-128-gcm
2022-blake3-aes-256-gcm
2022-blake3-chacha20-poly1305
)

GO_SHADOWSOCKS2_CIPHERS=(
Expand Down Expand Up @@ -79,6 +82,12 @@ install_prepare_password(){
_echo -r " password = ${shadowsockspwd}"
}

gen_random_psk(){
shadowsockspwd=$(openssl rand -base64 "$1")
_echo -i "你选择了AEAD-2022加密方式, SS-Rust密码变更为自动生成的PSK, 如下:"
_echo -r " password = ${shadowsockspwd}"
}

install_prepare_cipher(){
while true
do
Expand All @@ -101,6 +110,15 @@ install_prepare_cipher(){
elif [ "${shadowsockscipher}" == "AEAD_CHACHA20_POLY1305" ]; then
shadowsockscipher="chacha20-ietf-poly1305"
fi
if [ "${shadowsockscipher}" = "2022-blake3-aes-128-gcm" ]; then
gen_random_psk 16
elif [ "${shadowsockscipher}" = "2022-blake3-aes-256-gcm" ]; then
gen_random_psk 32
elif [ "${shadowsockscipher}" = "2022-blake3-chacha20-poly1305" ]; then
gen_random_psk 32
else
CipherMark="Non-AEAD-2022"
fi
break
done
}
15 changes: 15 additions & 0 deletions ss-plugins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1319,6 +1319,20 @@ add_cron_job(){
(crontab -l ; echo "${random_minute} 0 * * * \"${CUR_DIR}\"/ss-plugins.sh renew > /dev/null") | sort - | uniq - | crontab -
}

sync_time(){
if [ "${CipherMark}" = "Non-AEAD-2022" ]; then
return
fi
_echo -i "开始同步时间.."
if [ "$(command -v ntpdate)" ]; then
ntpdate pool.ntp.org
[ $? -eq 0 ] && _echo -i "现在时间: $(date -R) 同步完成..."
elif [ "$(command -v chronyc)" ]; then
chronyc -a makestep
[ $? -eq 0 ] && _echo -i "现在时间: $(date -R) 同步完成..."
fi
}

install_status(){
status_init

Expand Down Expand Up @@ -1347,6 +1361,7 @@ install_step_all(){
config_firewall_logic
install_main
install_webserver
sync_time
add_more_entropy
install_cleanup
improt_package "templates" "config.sh"
Expand Down
9 changes: 9 additions & 0 deletions utils/dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@ install_dependencies_logic(){
local depends=(qrencode jq)
install_dependencies "${depends[*]}"
fi

if [ "${CipherMark}" != "Non-AEAD-2022" ]; then
if check_sys packageManager yum; then
local depends=(chrony)
elif check_sys packageManager apt; then
local depends=(ntpdate)
fi
install_dependencies "${depends[*]}"
fi
}

install_libsodium(){
Expand Down

0 comments on commit 0a448bb

Please sign in to comment.