Skip to content

add configurable port and better error handling #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion tunnel.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
#!/bin/sh

if [ "$1" = "--help" ]; then
echo "Usage: $0 [domain]"
echo "Exposes local server on port \$PORT (default 3040) via ngrok."
echo "If domain is provided, uses that domain."
exit 0
fi

domain=$1
port=3040
port=${PORT:-3040}

if ! command -v ngrok >/dev/null 2>&1; then
echo "Please install ngrok: https://ngrok.com/download"
exit 1
fi

if ! nc -z localhost "$port" > /dev/null 2>&1; then
echo "Warning: No server is listening on port $port. Ngrok might not work as expected."
fi

echo "Starting ngrok on port $port..."
if [ -n "$domain" ]; then
ngrok http --domain="$domain" "$port"
else
Expand Down