#!/bin/bash
# One-key script for running frpc for remote support.
# Usage: curl https://dl.helixzz.com/frpc_onekey.sh | bash

remote_port=$(echo $RANDOM/30+7500 | bc)
username=frpc-$(hostname)-ssh

cat > /tmp/frpc.ini << EOF
[common]
server_addr = connect.helixzz.com
server_port = 7000
protocol = tcp
login_fail_exit = false
privilege_token = 2233443322
user = $username

[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = $remote_port
EOF

wget -q -O /tmp/frpc https://dl.helixzz.com/frpc 
chmod a+x /tmp/frpc

echo "Starting FRP Client. Port: $remote_port, Username: $username"
echo "Press Ctrl-C to Stop."

/tmp/frpc -c /tmp/frpc.ini
rm /tmp/frpc.ini
rm /tmp/frpc
