-
Notifications
You must be signed in to change notification settings - Fork 355
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
269 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
install_gun(){ | ||
cd ${CUR_DIR} | ||
chmod +x ${gun_file} | ||
mv ${gun_file} ${GUN_BIN_PATH} | ||
if [ $? -eq 0 ]; then | ||
[ -f ${GUN_BIN_PATH} ] && ln -fs ${GUN_BIN_PATH} /usr/bin | ||
echo -e "${Info} gun安装成功." | ||
else | ||
echo | ||
echo -e "${Error} gun安装失败." | ||
echo | ||
install_cleanup | ||
exit 1 | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
improt_package "utils" "gen_certificates.sh" | ||
|
||
|
||
# gun Transport mode | ||
GUN_TRANSPORT_MODE=( | ||
grpc-with-tls | ||
grpc-without-tls | ||
) | ||
|
||
|
||
transport_mode_menu(){ | ||
while true | ||
do | ||
echo && echo -e "请为gun选择 Transport mode\n" | ||
for ((i=1;i<=${#GUN_TRANSPORT_MODE[@]};i++ )); do | ||
hint="${GUN_TRANSPORT_MODE[$i-1]}" | ||
echo -e "${Green} ${i}.${suffix} ${hint}" | ||
done | ||
echo | ||
read -e -p "(默认: ${GUN_TRANSPORT_MODE[0]}):" libev_gun | ||
[ -z "$libev_gun" ] && libev_gun=1 | ||
expr ${libev_gun} + 1 &>/dev/null | ||
if [ $? -ne 0 ]; then | ||
echo | ||
echo -e "${Error} 请输入一个数字" | ||
echo | ||
continue | ||
fi | ||
if [[ "$libev_gun" -lt 1 || "$libev_gun" -gt ${#GUN_TRANSPORT_MODE[@]} ]]; then | ||
echo | ||
echo -e "${Error} 请输入一个数字在 [1-${#GUN_TRANSPORT_MODE[@]}] 之间" | ||
echo | ||
continue | ||
fi | ||
|
||
shadowsocklibev_gun=${GUN_TRANSPORT_MODE[$libev_gun-1]} | ||
echo | ||
echo -e "${Red} over = ${shadowsocklibev_gun}${suffix}" | ||
echo | ||
|
||
break | ||
done | ||
} | ||
|
||
print_domain_info(){ | ||
domainType=$1 | ||
|
||
echo | ||
echo -e "${Red} domain = ${domain}${suffix} ${Green}(${domainType})${suffix}" | ||
echo | ||
} | ||
|
||
get_input_domain(){ | ||
while true | ||
do | ||
echo | ||
read -e -p "请输入一个域名(CDN 或 DNS-Only):" domain | ||
|
||
if [ -z "$domain" ]; then | ||
echo | ||
echo -e "${Error} 无默认参数,不能为空,请重新输入." | ||
echo | ||
continue | ||
fi | ||
|
||
if ! get_domain_ip ${domain}; then | ||
echo | ||
echo -e "${Error} 请输入一个正确有效的域名." | ||
echo | ||
continue | ||
fi | ||
|
||
if is_cdn_proxied ${domain_ip}; then | ||
print_domain_info "CDN" | ||
break | ||
elif is_dns_only ${domain_ip}; then | ||
print_domain_info "DNS-Only" | ||
break | ||
else | ||
echo | ||
echo -e "${Error} 请输入一个正确有效的域名." | ||
echo | ||
continue | ||
fi | ||
done | ||
} | ||
|
||
gun_prot_reset(){ | ||
shadowsocksport=$1 | ||
|
||
if check_port_occupy ${shadowsocksport}; then | ||
echo -e "${Error} 检测到${shadowsocksport}端口被占用,请排查后重新运行." | ||
exit 1 | ||
fi | ||
|
||
echo | ||
echo -e "${Tip} Shadowsocks端口已被重置为${Green}${shadowsocksport}${suffix}" | ||
echo | ||
} | ||
|
||
grpc_with_tls_mode_logic(){ | ||
get_input_domain | ||
gun_prot_reset 443 | ||
|
||
if [[ ${domainType} = DNS-Only ]]; then | ||
acme_get_certificate_by_force "${domain}" | ||
elif [[ ${domainType} = CDN ]]; then | ||
acme_get_certificate_by_api_or_manual "${domain}" | ||
fi | ||
} | ||
|
||
install_prepare_libev_gun(){ | ||
transport_mode_menu | ||
|
||
if [[ ${libev_gun} = "1" ]]; then | ||
grpc_with_tls_mode_logic | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# ss + gun config | ||
ss_gun_config(){ | ||
cat > ${SHADOWSOCKS_CONFIG}<<-EOF | ||
{ | ||
"server":${server_value}, | ||
"server_port":${shadowsocksport}, | ||
"password":"${shadowsockspwd}", | ||
"timeout":300, | ||
"user":"nobody", | ||
"method":"${shadowsockscipher}", | ||
"nameserver":"8.8.8.8", | ||
"mode":"tcp_and_udp", | ||
"plugin":"gun-server", | ||
"plugin_opts":"${gunPluginOption}" | ||
} | ||
EOF | ||
} | ||
|
||
config_ss_gun(){ | ||
if [[ ${libev_gun} = "1" ]]; then | ||
gunPluginOption="server:${cerPath}:${keyPath}" | ||
elif [[ ${libev_gun} = "2" ]]; then | ||
gunPluginOption="server:cleartext" | ||
fi | ||
ss_gun_config | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# ss + gun link | ||
ss_gun_link(){ | ||
local link_head="ss:https://" | ||
local cipher_pwd=$(get_str_base64_encode "${shadowsockscipher}:${shadowsockspwd}") | ||
local ip_port_plugin="@${domain}:${shadowsocksport}/?plugin=${plugin_client_name}" | ||
local plugin_opts=$(get_str_replace ";${clientGunPluginOpts}") | ||
ss_link="${link_head}${cipher_pwd}${ip_port_plugin}${plugin_opts}" | ||
} | ||
|
||
gen_ss_gun_link(){ | ||
if [[ ${libev_gun} = "1" ]]; then | ||
clientGunPluginOpts="client" | ||
elif [[ ${libev_gun} = "2" ]]; then | ||
domain="$(get_ip)" | ||
clientGunPluginOpts="client:cleartext" | ||
fi | ||
ss_gun_link | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# ss + gun show | ||
ss_gun_show(){ | ||
echo >> ${HUMAN_CONFIG} | ||
echo -e " Shadowsocks的配置信息:" >> ${HUMAN_CONFIG} | ||
echo >> ${HUMAN_CONFIG} | ||
echo -e " 地址 : ${Red}${domain}${suffix}" >> ${HUMAN_CONFIG} | ||
echo -e " 端口 : ${Red}${shadowsocksport}${suffix}" >> ${HUMAN_CONFIG} | ||
echo -e " 密码 : ${Red}${shadowsockspwd}${suffix}" >> ${HUMAN_CONFIG} | ||
echo -e " 加密 : ${Red}${shadowsockscipher}${suffix}" >> ${HUMAN_CONFIG} | ||
echo -e " 插件程序 : ${Red}${plugin_client_name}${suffix}" >> ${HUMAN_CONFIG} | ||
echo -e " 插件选项 : ${Red}${clientGunPluginOpts}${suffix}" >> ${HUMAN_CONFIG} | ||
echo -e " 插件参数 : " >> ${HUMAN_CONFIG} | ||
echo >> ${HUMAN_CONFIG} | ||
echo -e " SS 链接 : ${Green}${ss_link}${suffix}" >> ${HUMAN_CONFIG} | ||
echo -e " SS二维码 : ./ss-plugins.sh scan < A link at the beginning of ss:https:// >" >> ${HUMAN_CONFIG} | ||
echo >> ${HUMAN_CONFIG} | ||
echo >> ${HUMAN_CONFIG} | ||
echo -e " ${Tip} SS链接${Red}不支持插件参数${suffix}导入,请手动填写。使用${Red}kcptun${suffix}插件时,该链接仅支持${Red}手机${suffix}导入." >> ${HUMAN_CONFIG} | ||
echo -e " 插件程序下载:https://github.com/Qv2ray/gun/releases 下载 sip003-windows-amd64 版本" >> ${HUMAN_CONFIG} | ||
echo -e " 请解压将插件重命名为 ${plugin_client_name}.exe 并移动至 SS-Windows 客户端-安装目录的${Red}根目录${suffix}." >> ${HUMAN_CONFIG} | ||
echo >> ${HUMAN_CONFIG} | ||
} | ||
|
||
ss_gun_visible(){ | ||
ss_gun_show | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.