start_frp()

This commit is contained in:
bilt 2025-08-03 10:19:50 +08:00
parent a34424a6a8
commit 6b9b8b89b9
3 changed files with 42 additions and 31 deletions

29
main.py
View File

@ -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:

View File

@ -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

View File

@ -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'