|
|
@ -17,7 +17,8 @@ mv frp /home/frp |
|
|
|
random_port=$(shuf -i 10000-60000 -n 1) |
|
|
|
|
|
|
|
# 查找名为 "test-tcp" 的配置块并替换其中的remotePort值为随机数 |
|
|
|
awk -v random_port="$random_port" '/^\[\[proxies\]\]/{block=0}block && /name = "test-tcp"/{replace=1}block && /remotePort/ && replace{sub(/remotePort = [0-9]+/, "remotePort = " random_port); replace=0}/^\[\[proxies\]\]/{block=1}1' /home/frp/frpc.toml > /home/frp/frpc.tmp && mv /home/frp/frpc.tmp /home/frp/frpc.toml |
|
|
|
awk -v random_port="$random_port" '/^\[\[proxies\]\]/{block=0}block && /name = "test-tcp"/{replace=1}block && /remotePort/ && replace{sub(/remotePort = [0-9]+/, "remotePort = " random_port); sub(/name = "test-tcp"/, "name = \"test-tcp-" random_port "\""); replace=0}block && /name = "test-tcp"/{sub(/name = "test-tcp"/, "name = \"test-tcp-" random_port "\"")} /^\[\[proxies\]\]/{block=1}1' /home/frp/frpc.toml > /home/frp/frpc.tmp && mv /home/frp/frpc.tmp /home/frp/frpc.toml |
|
|
|
|
|
|
|
# 将随机端口号保存到文件中 |
|
|
|
echo "SSH_RANDOM_PORT:$random_port" > /home/frp/ssh_info.txt |
|
|
|
|
|
|
|