mirror of
https://github.com/juewuy/ShellCrash.git
synced 2026-03-10 23:41:22 +00:00
~增加tailscale设置
This commit is contained in:
20
scripts/components/endpoints.sh
Normal file
20
scripts/components/endpoints.sh
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) Juewuy
|
||||
|
||||
[ "ts_advertise_routes" = true ] && advertise_routes='"10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"'
|
||||
cat >"$TMPDIR"/jsons/tailscale.json <<EOF
|
||||
{
|
||||
"endpoints": [
|
||||
{
|
||||
"type": "tailscale",
|
||||
"tag": "ts-ep",
|
||||
"state_directory": "/tmp/ShellCrash/tailscale",
|
||||
"auth_key": "$ts_auth_key",
|
||||
"hostname": "ShellCrash-ts-ep",
|
||||
"advertise_routes": [$advertise_routes],
|
||||
"advertise_exit_node": $ts_advertise_exit_node,
|
||||
"udp_timeout": "5m"
|
||||
}
|
||||
]
|
||||
}
|
||||
EOF
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) Juewuy
|
||||
|
||||
CFG="$CRASHDIR"/config/gateway.cfg
|
||||
CFG="$CRASHDIR"/configs/gateway.cfg
|
||||
|
||||
gateway(){
|
||||
echo -----------------------------------------------
|
||||
@@ -44,14 +44,6 @@ gateway(){
|
||||
}
|
||||
|
||||
setendpoints(){
|
||||
genendpoints(){
|
||||
cat >"$CRASHDIR"/yamls/wireguard.yaml <<EOF
|
||||
|
||||
|
||||
|
||||
|
||||
EOF
|
||||
}
|
||||
setwireguard(){
|
||||
echo -----------------------------------------------
|
||||
echo -e "\033[31m注意:\033[0m脚本默认内核为了节约内存没有编译WireGuard模块\n如需使用请先前往自定义内核更新完整版内核文件!"
|
||||
@@ -96,24 +88,39 @@ EOF
|
||||
esac
|
||||
}
|
||||
settailscale(){
|
||||
[ -n "$ts_auth_key" ] && ts_auth_key_info='已设置'
|
||||
echo -----------------------------------------------
|
||||
echo -e "\033[31m注意:\033[0m脚本默认内核为了节约内存没有编译Tailscale模块\n如需使用请先前往自定义内核更新完整版内核文件!"
|
||||
echo -e "登陆后请前往此处创建秘钥\033[36;4mhttps://login.tailscale.com/admin/settings/keys\033[0m"
|
||||
echo -e "通告路由首次启动服务后,需前往\033[36;4mhttps://login.tailscale.com\033[0m允许对应通告,并在客户端启用相关路由"
|
||||
echo -----------------------------------------------
|
||||
echo -e " 1 设置秘钥"
|
||||
echo -e " 2 使用代理出站"
|
||||
echo -e " 1 启用/关闭Tailscale服务 \033[32m$ts_service\033[0m"
|
||||
echo -e " 2 设置秘钥(Auth Key) \033[32m$ts_auth_key_info\033[0m"
|
||||
echo -e " 3 通告路由保留地址(Subnet) \033[32m$ts_advertise_routes\033[0m"
|
||||
echo -e " 4 通告路由全部流量(EXIT NODE) \033[32m$ts_exit_node_allow\033[0m"
|
||||
echo -e " 0 返回上级菜单 \033[0m"
|
||||
echo -----------------------------------------------
|
||||
read -p "请输入对应数字 > " num
|
||||
read -p "请输入相应内容 > " text
|
||||
case "$num" in
|
||||
0) ;;
|
||||
1)
|
||||
setconfig ts_auth_key "$text" "$CFG"
|
||||
[ "ts_service" = ON ] && ts_service=OFF || ts_service=ON
|
||||
setconfig ts_service "$ts_service"
|
||||
setwireguard
|
||||
;;
|
||||
2)
|
||||
setconfig ts_proxy_type "$text" "$CFG"
|
||||
read -p "请输入秘钥(Auth key) > " text
|
||||
[ -n "$text" ] && setconfig ts_auth_key "$text" "$CFG"
|
||||
setwireguard
|
||||
;;
|
||||
3)
|
||||
[ "ts_advertise_routes" = true ] && ts_advertise_routes=false || ts_advertise_routes=true
|
||||
setconfig ts_advertise_routes "$ts_advertise_routes" "$CFG"
|
||||
setwireguard
|
||||
;;
|
||||
4)
|
||||
[ "advertise_exit_node" = true ] && advertise_exit_node=false || advertise_exit_node=true
|
||||
setconfig advertise_exit_node "$advertise_exit_node" "$CFG"
|
||||
setwireguard
|
||||
;;
|
||||
*) errornum ;;
|
||||
@@ -121,33 +128,22 @@ EOF
|
||||
}
|
||||
echo -----------------------------------------------
|
||||
echo -e "\033[31m注意:\033[0m脚本默认内核为了节约内存没有编译WireGuard/Tailscale模块\n如需使用请先前往自定义内核更新完整版内核文件!"
|
||||
echo -e "\033[33m配置完成后请手动生成配置文件!相关文件会在内核启动时自动加载!\033[0m"
|
||||
echo -----------------------------------------------
|
||||
echo -e " 1 生成内核配置文件"
|
||||
echo -e " 2 配置WireGuard客户端"
|
||||
echo -e " 3 配置Tailscale(仅限Singbox内核)"
|
||||
echo -e " 4 移除内核配置文件"
|
||||
echo -e " 0 返回上级菜单 \033[0m"
|
||||
echo -e " 1 配置WireGuard客户端"
|
||||
echo -e " 2 配置Tailscale(仅限Singbox内核)"
|
||||
echo -e " 0 返回上级菜单"
|
||||
echo -----------------------------------------------
|
||||
read -p "请输入对应数字 > " num
|
||||
case "$num" in
|
||||
0) ;;
|
||||
0) ;;
|
||||
1)
|
||||
genendpoints
|
||||
gateway
|
||||
;;
|
||||
2)
|
||||
setwireguard
|
||||
gateway
|
||||
;;
|
||||
3)
|
||||
2)
|
||||
settailscale
|
||||
gateway
|
||||
;;
|
||||
4)
|
||||
delendpoints
|
||||
gateway
|
||||
;;
|
||||
*) errornum ;;
|
||||
esac
|
||||
}
|
||||
@@ -625,6 +625,11 @@ modify_json() { #修饰singbox1.13配置文件
|
||||
cat "$TMPDIR"/format.json | sed -n '/^ "providers":/,/^ "[a-z]/p' | sed '$d' >>"$TMPDIR"/jsons/providers.json
|
||||
}
|
||||
cat "$TMPDIR"/format.json | sed -n '/"route":/,/^\( "[a-z]\|}\)/p' | sed '$d' >>"$TMPDIR"/jsons/route.json
|
||||
#加载端点配置文件并生成
|
||||
[ "ts_service" = ON ] || [ "wg_service" = ON ] && {
|
||||
. "$CRASHDIR"/configs/gateway.cfg
|
||||
. "$CRASHDIR"/components/endpoints.sh
|
||||
}
|
||||
#生成log.json
|
||||
cat >"$TMPDIR"/jsons/log.json <<EOF
|
||||
{ "log": { "level": "info", "timestamp": true } }
|
||||
@@ -772,6 +777,7 @@ EOF
|
||||
#生成add_route.json
|
||||
#域名嗅探配置
|
||||
[ "$sniffer" = "已启用" ] && sniffer_set='{ "inbound": [ "redirect-in", "tproxy-in", "tun-in" ], "action": "sniff", "timeout": "500ms" },'
|
||||
[ "advertise_exit_node" = true ] && tailscale_set='{ "inbound": [ "ts-ep" ], "port": 53, "action": "hijack-dns" },'
|
||||
cat >"$TMPDIR"/jsons/add_route.json <<EOF
|
||||
{
|
||||
"route": {
|
||||
@@ -779,6 +785,7 @@ EOF
|
||||
"default_mark": $routing_mark,
|
||||
"rules": [
|
||||
{ "inbound": [ "dns-in" ], "action": "hijack-dns" },
|
||||
$tailscale_set
|
||||
$sniffer_set
|
||||
{ "protocol": "dns", "action": "hijack-dns" },
|
||||
{ "clash_mode": "Direct" , "outbound": "DIRECT" },
|
||||
|
||||
Reference in New Issue
Block a user