11#! /bin/bash
22set -e
33
4- # Check if the configuration file already exists
5- if [ -f /frpc.toml ]; then
6- echo " /frpc.toml already exists, skipping creation."
7- else
8- # Only create a config file if HP_SHARED_KEY is set.
9- if [ -n " $HP_SHARED_KEY " ]; then
10- echo " HP_SHARED_KEY is set, creating /frpc.toml configuration file..."
11- if [ -d " /certs/frp" ]; then
12- echo " Found /certs/frp directory. Creating configuration with TLS certificates."
13- cat << EOF > /frpc.toml
4+ # Only create a config file if HP_SHARED_KEY is set.
5+ if [ -n " $HP_SHARED_KEY " ]; then
6+ echo " HP_SHARED_KEY is set, creating /frpc.toml configuration file..."
7+ if [ -d " /certs/frp" ]; then
8+ echo " Found /certs/frp directory. Creating configuration with TLS certificates."
9+ cat << EOF > /frpc.toml
1410serverAddr = "$HP_FRP_ADDRESS "
1511serverPort = $HP_FRP_PORT
16- metadatas.token = "$HP_SHARED_KEY "
12+
13+ transport.tls.enable = true
1714transport.tls.certFile = "/certs/frp/client.crt"
1815transport.tls.keyFile = "/certs/frp/client.key"
1916transport.tls.trustedCaFile = "/certs/frp/ca.crt"
17+ transport.tls.serverName = "harp.nc"
18+
19+ metadatas.token = "$HP_SHARED_KEY "
2020
2121[[proxies]]
2222name = "$APP_ID "
@@ -25,11 +25,14 @@ localIP = "127.0.0.1"
2525localPort = $APP_PORT
2626remotePort = $APP_PORT
2727EOF
28- else
29- echo " Directory /certs/frp not found. Creating configuration without TLS certificates."
30- cat << EOF > /frpc.toml
28+ else
29+ echo " Directory /certs/frp not found. Creating configuration without TLS certificates."
30+ cat << EOF > /frpc.toml
3131serverAddr = "$HP_FRP_ADDRESS "
3232serverPort = $HP_FRP_PORT
33+
34+ transport.tls.enable = false
35+
3336metadatas.token = "$HP_SHARED_KEY "
3437
3538[[proxies]]
@@ -39,10 +42,9 @@ localIP = "127.0.0.1"
3942localPort = $APP_PORT
4043remotePort = $APP_PORT
4144EOF
42- fi
43- else
44- echo " HP_SHARED_KEY is not set. Skipping FRP configuration."
4545 fi
46+ else
47+ echo " HP_SHARED_KEY is not set. Skipping FRP configuration."
4648fi
4749
4850# If we have a configuration file and the shared key is present, start the FRP client
0 commit comments