From 6b9b8b89b983f4c25990ce71bacfd0224be7b72b Mon Sep 17 00:00:00 2001 From: bilt Date: Sun, 3 Aug 2025 10:19:50 +0800 Subject: [PATCH] start_frp() --- main.py | 29 ++++++++++++++++++++--------- script.sh | 38 +++++++++++++++++++------------------- template_frpc | 6 +++--- 3 files changed, 42 insertions(+), 31 deletions(-) diff --git a/main.py b/main.py index 06682a7e2..59249913c 100644 --- a/main.py +++ b/main.py @@ -145,25 +145,36 @@ def trigger_vercel_deploy(): print(f"An error occurred: {req_err}") import subprocess +import random def start_frp(): # !cat /kaggle/working/frpc.toml # subprocess.Popen(["sed", "-i", f"s/8188/{port}/g", "/kaggle/working/frpc.toml"],shell=False) + + port = 27666 # 根据 args.frp_remote_port_idx 随机一个端口 + + if args.frp_remote_port_idx is not None: + if args.frp_remote_port_idx == 3: + port = random.randint(27001, 28000) + elif args.frp_remote_port_idx == 4: + port = random.randint(28001, 29000) + elif args.frp_remote_port_idx == 5: + port = random.randint(29001, 30000) + else: + port = random.randint(30001, 31000) + else: + port = random.randint(30001, 31000) + + subprocess.Popen(["sed", "-i", f"s/REMOTE_PORT/{port}/g", "/kaggle/working/frpc.toml"],shell=False) subprocess.run(['chmod', '+x', '/kaggle/working/frpc'], check=True) time.sleep(3) subprocess.Popen(['/kaggle/working/frpc', '-c', '/kaggle/working/frpc.toml']) print(f'frp已经启动') + notion.add_record_to_notion_database(f"http://117.72.185.137:{port}/") + if __name__ == "__main__": - # start_frp() - # frp_remote_port_idx: 3, 4, 5, 6.... - if args.frp_remote_port_idx is not None: - if args.frp_remote_port_idx == -1: - notion.add_record_to_notion_database(f"http://111.170.148.226:21673/") - else: - notion.add_record_to_notion_database(f"http://111.170.148.226:2166{args.frp_remote_port_idx}/") - else: - print("frp_remote_port_idx is None, no records will be added to notion database") + start_frp() print("disable_trigger_vercel_deploy: ", args.disable_trigger_vercel_deploy) if args.disable_trigger_vercel_deploy is None: diff --git a/script.sh b/script.sh index 0e898a230..a06a9b01f 100644 --- a/script.sh +++ b/script.sh @@ -121,23 +121,23 @@ cp -p /kaggle/working/frp_0.54.0_linux_amd64/frpc /kaggle/working/frpc cp -p /kaggle/ComfyUI/template_frpc /kaggle/working/frpc.toml # 1, 2 主要是为了兼容之前的comfyUI notebook(不想一个一个的去修改了) -FRP_CONFIG_FILE="/kaggle/working/frpc.toml" -CHOICE="$1" -if [ "$CHOICE" -eq 3 ]; then - TARGET_REMOTE_PORT="21663" -elif [ "$CHOICE" -eq 4 ]; then - TARGET_REMOTE_PORT="21664" +# FRP_CONFIG_FILE="/kaggle/working/frpc.toml" +# CHOICE="$1" +# if [ "$CHOICE" -eq 3 ]; then +# TARGET_REMOTE_PORT="21663" +# elif [ "$CHOICE" -eq 4 ]; then +# TARGET_REMOTE_PORT="21664" -elif [ "$CHOICE" -eq 5 ]; then - TARGET_REMOTE_PORT="21665" -elif [ "$CHOICE" -eq 6 ]; then - TARGET_REMOTE_PORT="21666" -elif [ "$CHOICE" -eq -1 ]; then - TARGET_REMOTE_PORT="21673" -else - echo "Invalid CHOICE: $CHOICE" - echo "Only 1 or 2 are supported." - exit 1 # 退出并返回错误码 -fi -sed -i "s/REMOTE_PORT/$TARGET_REMOTE_PORT/g" "$FRP_CONFIG_FILE" -sleep 2 +# elif [ "$CHOICE" -eq 5 ]; then +# TARGET_REMOTE_PORT="21665" +# elif [ "$CHOICE" -eq 6 ]; then +# TARGET_REMOTE_PORT="21666" +# elif [ "$CHOICE" -eq -1 ]; then +# TARGET_REMOTE_PORT="21673" +# else +# echo "Invalid CHOICE: $CHOICE" +# echo "Only 1 or 2 are supported." +# exit 1 # 退出并返回错误码 +# fi +# sed -i "s/REMOTE_PORT/$TARGET_REMOTE_PORT/g" "$FRP_CONFIG_FILE" +# sleep 2 diff --git a/template_frpc b/template_frpc index 48618f9f6..fdcafc2bc 100644 --- a/template_frpc +++ b/template_frpc @@ -1,7 +1,7 @@ - serverAddr = '111.170.148.226' - serverPort = 21661 + serverAddr = '117.72.185.137' + serverPort = 27000 auth.method = "token" - auth.token = "072083" + auth.token = "xF5kJa#v" [[proxies]] name = 'web-REMOTE_PORT'