From 6d417fb4dea77abfedcf4142bebd399ec954c82b Mon Sep 17 00:00:00 2001 From: Matthew Baggett Date: Fri, 11 Jan 2019 09:02:09 +0000 Subject: [PATCH] Add support for reserved TCP addresses (#31) * Add support for reserved tcp addresses * Rework to suit pull request comments --- README.md | 1 + entrypoint.sh | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/README.md b/README.md index 5047d95..355b0be 100644 --- a/README.md +++ b/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. diff --git a/entrypoint.sh b/entrypoint.sh index 57f37ee..59a51f3 100755 --- a/entrypoint.sh +++ b/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 "