Browse Source

Add support for reserved TCP addresses (#31)

* Add support for reserved tcp addresses
* Rework to suit pull request comments
Matthew Baggett 5 years ago
parent
commit
6d417fb4de
2 changed files with 10 additions and 0 deletions
  1. 1 0
      README.md
  2. 9 0
      entrypoint.sh

+ 1 - 0
README.md

@@ -42,6 +42,7 @@ Additionally, you can specify one of several environment variable (via `-e`) to
   * `NGROK_AUTH` - Authentication key for your Ngrok account. This is needed for custom subdomains, custom domains, and HTTP authentication.
   * `NGROK_SUBDOMAIN` - Name of the custom subdomain to use for your tunnel. You must also provide the authentication token.
   * `NGROK_HOSTNAME` - Paying Ngrok customers can specify a custom domain. Only one subdomain or domain can be specified, with the domain taking priority.
+  * `NGROK_REMOTE_ADDR` - Name of the reserved TCP address to use for a TCP tunnel. You must also provide the authentication token.
   * `NGROK_USERNAME` - Username to use for HTTP authentication on the tunnel. You must also specify an authentication token.
   * `NGROK_PASSWORD` - Password to use for HTTP authentication on the tunnel. You must also specify an authentication token.
   * `NGROK_PROTOCOL` - Can either be `HTTP` or `TCP`, and it defaults to `HTTP` if not specified. If set to `TCP`, Ngrok will allocate a port instead of a subdomain and proxy TCP requests directly to your application.

+ 9 - 0
entrypoint.sh

@@ -48,6 +48,15 @@ elif [ -n "$NGROK_HOSTNAME" ] || [ -n "$NGROK_SUBDOMAIN" ]; then
   fi
 fi
 
+# Set the remote-addr if specified
+if [ -n "$NGROK_REMOTE_ADDR" ]; then
+  if [ -z "$NGROK_AUTH" ]; then
+    echo "You must specify an authentication token after registering at https://ngrok.com to use reserved ip addresses."
+    exit 1
+  fi
+  ARGS="$ARGS -remote-addr=$NGROK_REMOTE_ADDR "
+fi
+
 # Set a custom region
 if [ -n "$NGROK_REGION" ]; then
   ARGS="$ARGS -region=$NGROK_REGION "