luci-app-ssr-plus: improve the generation of shadowsocks configuration file (#3838)

This commit is contained in:
Max Zhao 2020-03-17 01:38:56 +08:00 committed by GitHub
parent 180d9be2de
commit 742415490e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -108,11 +108,15 @@ gen_config_file() {
}
EOF
local plugin=$(uci_get_by_name $1 plugin)
if [ -n "$plugin" ] && [ "$plugin" == "simple-obfs" ]; then
plugin="obfs-local"
fi
if [ -n "$plugin" -a -x "/usr/bin/$plugin" ]; then
sed -i "s@$hostip\",@$hostip\",\n\"plugin\": \"$plugin\",\n\"plugin_opts\": \"$(uci_get_by_name $1 plugin_opts)\",@" $config_file
if [ -n "$plugin" ]; then
if [ "$plugin" == "simple-obfs" ]; then
plugin="obfs-local"
fi
if [ -x "/usr/bin/$plugin" ]; then
sed -i "s@$hostip\",@$hostip\",\n\"plugin\": \"$plugin\",\n\"plugin_opts\": \"$(uci_get_by_name $1 plugin_opts)\",@" $config_file
else
echo "$(date "+%Y-%m-%d %H:%M:%S") Warning!!! SIP003 plugin $plugin not found!!!" >>/tmp/ssrplus.log
fi
fi
elif [ "$stype" == "ssr" ]; then
cat <<-EOF >$config_file