diff --git a/scripts/components/endpoints.sh b/scripts/components/endpoints.sh new file mode 100644 index 00000000..5c4f913e --- /dev/null +++ b/scripts/components/endpoints.sh @@ -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 <"$CRASHDIR"/yamls/wireguard.yaml < " 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 } \ No newline at end of file diff --git a/scripts/start.sh b/scripts/start.sh index 13ecf977..719a35f7 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -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 <"$TMPDIR"/jsons/add_route.json <