mirror of
https://github.com/juewuy/ShellCrash.git
synced 2026-03-12 16:31:25 +00:00
已修改 scripts/components/endpoints.sh
已修改 scripts/components/gateway.sh 已修改 scripts/start.sh
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Copyright (C) Juewuy
|
# Copyright (C) Juewuy
|
||||||
|
|
||||||
[ "ts_advertise_routes" = true ] && advertise_routes='"10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"'
|
[ "$ts_service" = ON ] && {
|
||||||
cat >"$TMPDIR"/jsons/tailscale.json <<EOF
|
[ "$ts_subnet" = true ] && advertise_routes='"10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"'
|
||||||
|
[ -z "$ts_exit_node" ] && ts_exit_node=false
|
||||||
|
cat >"$TMPDIR"/jsons/tailscale.json <<EOF
|
||||||
{
|
{
|
||||||
"endpoints": [
|
"endpoints": [
|
||||||
{
|
{
|
||||||
@@ -12,9 +14,56 @@ cat >"$TMPDIR"/jsons/tailscale.json <<EOF
|
|||||||
"auth_key": "$ts_auth_key",
|
"auth_key": "$ts_auth_key",
|
||||||
"hostname": "ShellCrash-ts-ep",
|
"hostname": "ShellCrash-ts-ep",
|
||||||
"advertise_routes": [$advertise_routes],
|
"advertise_routes": [$advertise_routes],
|
||||||
"advertise_exit_node": $ts_advertise_exit_node,
|
"advertise_exit_node": $ts_exit_node,
|
||||||
"udp_timeout": "5m"
|
"udp_timeout": "5m"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
[ "$wg_service" = ON ] && {
|
||||||
|
echo "$crashcore" | grep -q 'singbox' && {
|
||||||
|
[ -n "$wg_ipv6" ] && wg_ipv6_add=", \"$wg_ipv6\""
|
||||||
|
cat >"$TMPDIR"/jsons/wireguard.json <<EOF
|
||||||
|
{
|
||||||
|
"endpoints": [
|
||||||
|
{
|
||||||
|
"type": "wireguard",
|
||||||
|
"tag": "wg-ep",
|
||||||
|
"system": true,
|
||||||
|
"mtu": 1420,
|
||||||
|
"address": [ "$wg_ipv4"$wg_ipv6_add ],
|
||||||
|
"private_key": "$wg_private_key",
|
||||||
|
"peers": [
|
||||||
|
{
|
||||||
|
"address": "$wg_server",
|
||||||
|
"port": $wg_port,
|
||||||
|
"public_key": "$wg_public_key",
|
||||||
|
"pre_shared_key": "$wg_pre_shared_key",
|
||||||
|
"allowed_ips": ["0.0.0.0/0", "::/0"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
#meta内核wg生成
|
||||||
|
echo "$crashcore" | grep -q 'meta' && {
|
||||||
|
cat >"$TMPDIR"/yamls/wireguard.yaml <<EOF
|
||||||
|
- name: "wg"
|
||||||
|
type: wireguard
|
||||||
|
private-key: $wg_private_key
|
||||||
|
server: $wg_server
|
||||||
|
port: $wg_port
|
||||||
|
ip: $wg_ipv4
|
||||||
|
ipv6: $wg_ipv6
|
||||||
|
public-key: $wg_public_key
|
||||||
|
allowed-ips: ['0.0.0.0/0', '::/0']
|
||||||
|
pre-shared-key: $wg_pre_shared_key
|
||||||
|
mtu: 1420
|
||||||
|
udp: true
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ gateway(){
|
|||||||
echo -e " 3 配置DDNS自动域名"
|
echo -e " 3 配置DDNS自动域名"
|
||||||
[ "$disoverride" != "1" ] && {
|
[ "$disoverride" != "1" ] && {
|
||||||
echo -e " 4 自定义公网入站节点"
|
echo -e " 4 自定义公网入站节点"
|
||||||
echo -e " 5 配置\033[32m内网穿透\033[0m(Tailscale,仅限Singbox)"
|
echo -e " 5 配置\033[32mTailscale内网穿透\033[0m(限Singbox)"
|
||||||
|
echo -e " 6 配置\033[32mWireguard客户端\033[0m"
|
||||||
}
|
}
|
||||||
echo -e " 0 返回上级菜单 \033[0m"
|
echo -e " 0 返回上级菜单 \033[0m"
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
@@ -23,29 +24,33 @@ gateway(){
|
|||||||
1)
|
1)
|
||||||
set_pub_fw
|
set_pub_fw
|
||||||
gateway
|
gateway
|
||||||
;;
|
;;
|
||||||
2)
|
2)
|
||||||
set_bot_tg
|
set_bot_tg
|
||||||
gateway
|
gateway
|
||||||
;;
|
;;
|
||||||
3)
|
3)
|
||||||
set_ddns
|
set_ddns
|
||||||
gateway
|
gateway
|
||||||
;;
|
;;
|
||||||
4)
|
4)
|
||||||
set_listeners
|
set_listeners
|
||||||
gateway
|
gateway
|
||||||
;;
|
;;
|
||||||
5)
|
5)
|
||||||
if echo "$crashcore" | grep -q 'sing';then
|
if echo "$crashcore" | grep -q 'sing';then
|
||||||
setendpoints
|
set_tailscale
|
||||||
else
|
else
|
||||||
echo -e "\033[33m$crashcore内核暂不支持此功能,请先更换内核!\033[0m"
|
echo -e "\033[33m$crashcore内核暂不支持此功能,请先更换内核!\033[0m"
|
||||||
sleep 1
|
sleep 1
|
||||||
checkupdate && setcore
|
checkupdate && setcore
|
||||||
fi
|
fi
|
||||||
gateway
|
gateway
|
||||||
;;
|
;;
|
||||||
|
6)
|
||||||
|
set_wireguard
|
||||||
|
gateway
|
||||||
|
;;
|
||||||
*) errornum ;;
|
*) errornum ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
@@ -174,47 +179,122 @@ set_bot_tg(){
|
|||||||
set_ddns(){
|
set_ddns(){
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
setendpoints(){
|
|
||||||
settailscale(){
|
set_tailscale(){
|
||||||
[ -n "$ts_auth_key" ] && ts_auth_key_info='已设置'
|
[ -n "$ts_auth_key" ] && ts_auth_key_info='*********'
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
echo -e "\033[31m注意:\033[0m脚本默认内核为了节约内存没有编译Tailscale模块\n如需使用请先前往自定义内核更新完整版内核文件!"
|
echo -e "\033[31m注意:\033[0m脚本默认内核为了节约内存没有编译Tailscale模块\n如需使用请先前往自定义内核更新完整版内核文件!"
|
||||||
echo -e "创建秘钥:\033[32;4mhttps://login.tailscale.com/admin/settings/keys\033[0m"
|
echo -e "创建秘钥:\033[32;4mhttps://login.tailscale.com/admin/settings/keys\033[0m"
|
||||||
echo -e "访问非本机目标需允许通告:\033[32;4mhttps://login.tailscale.com\033[0m"
|
echo -e "访问非本机目标需允许通告:\033[32;4mhttps://login.tailscale.com\033[0m"
|
||||||
echo -e "访问非本机目标需在终端设置使用Subnet或EXIT-NODE模式"
|
echo -e "访问非本机目标需在终端设置使用Subnet或EXIT-NODE模式"
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
echo -e " 1 启用/关闭Tailscale服务 \033[32m$ts_service\033[0m"
|
echo -e " 1 \033[32m启用/关闭\033[0mTailscale服务 \033[32m$ts_service\033[0m"
|
||||||
echo -e " 2 设置秘钥(Auth Key) \033[32m$ts_auth_key_info\033[0m"
|
echo -e " 2 设置\033[36m秘钥\033[0m(Auth Key) $ts_auth_key_info"
|
||||||
echo -e " 3 通告路由内网地址(Subnet) \033[32m$ts_subnet\033[0m"
|
echo -e " 3 通告路由\033[33m内网地址\033[0m(Subnet) \033[36m$ts_subnet\033[0m"
|
||||||
echo -e " 4 通告路由全部流量(EXIT-NODE) \033[32m$ts_exit_node\033[0m"
|
echo -e " 4 通告路由\033[31m全部流量\033[0m(EXIT-NODE) \033[36m$ts_exit_node\033[0m"
|
||||||
echo -e " 0 返回上级菜单 \033[0m"
|
echo -e " 0 返回上级菜单 \033[0m"
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
read -p "请输入对应数字 > " num
|
read -p "请输入对应数字 > " num
|
||||||
case "$num" in
|
case "$num" in
|
||||||
0) ;;
|
0) ;;
|
||||||
1)
|
1)
|
||||||
|
if [ -n "$ts_auth_key" ];then
|
||||||
[ "$ts_service" = ON ] && ts_service=OFF || ts_service=ON
|
[ "$ts_service" = ON ] && ts_service=OFF || ts_service=ON
|
||||||
setconfig ts_service "$ts_service"
|
setconfig ts_service "$ts_service"
|
||||||
settailscale
|
else
|
||||||
;;
|
echo -e "\033[31m请先设置秘钥!\033[0m"
|
||||||
2)
|
sleep 1
|
||||||
read -p "请输入秘钥(输入0删除) > " text
|
fi
|
||||||
[ "$text" = 0 ] && unset ts_auth_key ts_auth_key_info || ts_auth_key="$text"
|
set_tailscale
|
||||||
[ -n "$ts_auth_key" ] && setconfig ts_auth_key "$ts_auth_key" "$CFG"
|
;;
|
||||||
settailscale
|
2)
|
||||||
;;
|
read -p "请输入秘钥(输入0删除) > " text
|
||||||
3)
|
[ "$text" = 0 ] && unset ts_auth_key ts_auth_key_info || ts_auth_key="$text"
|
||||||
[ "$ts_subnet" = true ] && ts_subnet=false || ts_subnet=true
|
[ -n "$ts_auth_key" ] && setconfig ts_auth_key "$ts_auth_key" "$CFG"
|
||||||
setconfig ts_subnet "$ts_subnet" "$CFG"
|
set_tailscale
|
||||||
settailscale
|
;;
|
||||||
;;
|
3)
|
||||||
4)
|
[ "$ts_subnet" = true ] && ts_subnet=false || ts_subnet=true
|
||||||
[ "$ts_exit_node" = true ] && ts_exit_node=false || ts_exit_node=true
|
setconfig ts_subnet "$ts_subnet" "$CFG"
|
||||||
setconfig ts_exit_node "$ts_exit_node" "$CFG"
|
set_tailscale
|
||||||
settailscale
|
;;
|
||||||
;;
|
4)
|
||||||
*) errornum ;;
|
[ "$ts_exit_node" = true ] && ts_exit_node=false || ts_exit_node=true
|
||||||
esac
|
setconfig ts_exit_node "$ts_exit_node" "$CFG"
|
||||||
}
|
set_tailscale
|
||||||
settailscale
|
;;
|
||||||
|
*) errornum ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
set_wireguard(){
|
||||||
|
[ -n "$wg_public_key" ] && wgp_key_info='*********' || unset wgp_key_info
|
||||||
|
[ -n "$wg_private_key" ] && wgv_key_info='*********' || unset wgv_key_info
|
||||||
|
[ -n "$wg_pre_shared_key" ] && wgpsk_key_info='*********' || unset wgpsk_key_info
|
||||||
|
echo -----------------------------------------------
|
||||||
|
echo -e "\033[31m注意:\033[0m脚本默认内核为了节约内存没有编译WireGuard模块\n如需使用请先前往自定义内核更新完整版内核文件!"
|
||||||
|
echo -----------------------------------------------
|
||||||
|
echo -e " 1 \033[32m启用/关闭\033[0mWireguard服务 \033[32m$wg_service\033[0m"
|
||||||
|
echo -----------------------------------------------
|
||||||
|
echo -e " 2 设置\033[36mEndpoint地址\033[0m: \033[36m$wg_server\033[0m"
|
||||||
|
echo -e " 3 设置\033[36mEndpoint端口\033[0m: \033[36m$wg_port\033[0m"
|
||||||
|
echo -e " 4 设置\033[36m公钥-PublicKey\033[0m: \033[36m$wgp_key_info\033[0m"
|
||||||
|
echo -e " 5 设置\033[36m密钥-PresharedKey\033[0m: \033[36m$wgpsk_key_info\033[0m"
|
||||||
|
echo -----------------------------------------------
|
||||||
|
echo -e " 6 设置\033[33m私钥-PrivateKey\033[0m: \033[33m$wgv_key_info\033[0m"
|
||||||
|
echo -e " 7 设置\033[33m组网IPV4地址\033[0m: \033[33m$wg_ipv4\033[0m"
|
||||||
|
echo -e " 8 可选\033[33m组网IPV6地址\033[0m: \033[33m$wg_ipv6\033[0m"
|
||||||
|
echo -e " 0 返回上级菜单 \033[0m"
|
||||||
|
echo -----------------------------------------------
|
||||||
|
read -p "请输入对应数字 > " num
|
||||||
|
case "$num" in
|
||||||
|
0) ;;
|
||||||
|
1)
|
||||||
|
if [ -n "$wg_server" ] && [ -n "$wg_port" ] && [ -n "$wg_public_key" ] && [ -n "$wg_pre_shared_key" ] && [ -n "$wg_private_key" ] && [ -n "$wg_ipv4" ];then
|
||||||
|
[ "$wg_service" = ON ] && wg_service=OFF || wg_service=ON
|
||||||
|
setconfig wg_service "$wg_service"
|
||||||
|
else
|
||||||
|
echo -e "\033[31m请先完成必选设置!\033[0m"
|
||||||
|
sleep 1
|
||||||
|
fi
|
||||||
|
set_wireguard
|
||||||
|
;;
|
||||||
|
[1-8])
|
||||||
|
read -p "请输入相应内容(回车或0删除) > " text
|
||||||
|
[ "$text" = 0 ] && text=''
|
||||||
|
case "$num" in
|
||||||
|
2)
|
||||||
|
wg_server="$text"
|
||||||
|
setconfig wg_server "$text" "$CFG"
|
||||||
|
;;
|
||||||
|
3)
|
||||||
|
wg_port="$text"
|
||||||
|
setconfig wg_port "$text" "$CFG"
|
||||||
|
;;
|
||||||
|
4)
|
||||||
|
wg_public_key="$text"
|
||||||
|
setconfig wg_public_key "$text" "$CFG"
|
||||||
|
;;
|
||||||
|
5)
|
||||||
|
wg_pre_shared_key="$text"
|
||||||
|
setconfig wg_pre_shared_key "$text" "$CFG"
|
||||||
|
;;
|
||||||
|
6)
|
||||||
|
wg_private_key="$text"
|
||||||
|
setconfig wg_private_key "$text" "$CFG"
|
||||||
|
;;
|
||||||
|
7)
|
||||||
|
wg_ipv4="$text"
|
||||||
|
setconfig wg_ipv4 "$text" "$CFG"
|
||||||
|
;;
|
||||||
|
8)
|
||||||
|
wg_ipv6="$text"
|
||||||
|
setconfig wg_ipv6 "$text" "$CFG"
|
||||||
|
;;
|
||||||
|
|
||||||
|
esac
|
||||||
|
set_wireguard
|
||||||
|
;;
|
||||||
|
*) errornum ;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
@@ -634,7 +634,7 @@ modify_json() { #修饰singbox1.13配置文件
|
|||||||
}
|
}
|
||||||
cat "$TMPDIR"/format.json | sed -n '/"route":/,/^\( "[a-z]\|}\)/p' | sed '$d' >>"$TMPDIR"/jsons/route.json
|
cat "$TMPDIR"/format.json | sed -n '/"route":/,/^\( "[a-z]\|}\)/p' | sed '$d' >>"$TMPDIR"/jsons/route.json
|
||||||
#加载端点配置文件并生成
|
#加载端点配置文件并生成
|
||||||
[ "ts_service" = ON ] || [ "wg_service" = ON ] && {
|
[ "$ts_service" = ON ] || [ "$wg_service" = ON ] && {
|
||||||
. "$CRASHDIR"/configs/gateway.cfg
|
. "$CRASHDIR"/configs/gateway.cfg
|
||||||
. "$CRASHDIR"/components/endpoints.sh
|
. "$CRASHDIR"/components/endpoints.sh
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user