Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ CACHE_DIR=$2
ENV_DIR=$3
BUILDPACK_DIR="$(dirname "$(dirname "$0")")"

TAILSCALE_VERSION=1.74.0
TAILSCALE_VERSION=1.82.5
TAILSCALE_BUILD_ARCH=amd64
TAILSCALE_SOURCE_URL="https://pkgs.tailscale.com/stable/tailscale_${TAILSCALE_VERSION}_${TAILSCALE_BUILD_ARCH}.tgz"
TAILSCALE_INSTALL_DIR="$BUILD_DIR/vendor/tailscale"
Expand Down Expand Up @@ -81,4 +81,4 @@ if [ -f "$BUILD_DIR/bin/rails" ]; then
mv $BUILD_DIR/bin/rake $BUILD_DIR/bin/rake_original
cp "$BUILDPACK_DIR/bin/rails/rake" $BUILD_DIR/bin/
chmod +x $BUILD_DIR/bin/rake
fi
fi
41 changes: 22 additions & 19 deletions bin/heroku-tailscale-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,25 @@ if [ -z "$TAILSCALE_AUTH_KEY" ]; then
fi

wait_for_tailscale_running() {
timeout=5 # Timeout in seconds
interval=0.5 # Interval between checks
elapsed=0

while [ "$elapsed" -lt "$timeout" ]; do
state=$(tailscale status -json | jq -r .BackendState)
if [ "$state" = "Running" ]; then
return 0
fi
sleep "$interval"
elapsed=$(echo "$elapsed + $interval" | bc)
done

return 1
timeout=${TAILSCALE_RUNNING_TIMEOUT:-5} # Timeout in seconds
interval=0.5 # Interval between checks

# convert to milliseconds so we can use integer math
timeout_ms=$(awk "BEGIN {print $timeout * 1000}")
interval_ms=$(awk "BEGIN {print $interval * 1000}")

elapsed=0

while [ "$elapsed" -lt "$timeout_ms" ]; do
state=$(tailscale status -json | jq -r .BackendState)
if [ "$state" = "Running" ]; then
return 0
fi
sleep "$interval"
elapsed=$((elapsed + interval_ms))
done

return 1
}

if [ -z "$TAILSCALE_HOSTNAME" ]; then
Expand All @@ -39,14 +44,12 @@ else
TAILSCALE_HOSTNAME="$TAILSCALE_HOSTNAME"
fi
tailscaled -cleanup > /dev/null 2>&1
(tailscaled -verbose ${TAILSCALED_VERBOSE:--1} --tun=userspace-networking --socks5-server=localhost:1055 > /dev/null 2>&1 &)
(tailscaled -verbose ${TAILSCALED_VERBOSE:--1} --tun=userspace-networking --socks5-server=localhost:1055 > /dev/null 2>&1 &)
tailscale up \
--authkey="${TAILSCALE_AUTH_KEY}?preauthorized=true&ephemeral=true" \
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the query params here are causing a:

backend error: invalid key: unable to validate API key

I believe that these attributes are handled in the API Key that is generated in the Tailscale admin UI

--authkey="${TAILSCALE_AUTH_KEY}" \
--hostname="$TAILSCALE_HOSTNAME" \
--advertise-tags=${TAILSCALE_ADVERTISE_TAGS:-} \
--accept-routes \
--timeout=15s \
${TAILSCALE_ADDITIONAL_ARGS:---timeout=15s}
${TAILSCALE_ADDITIONAL_ARGS:---accept-routes --timeout=15s}
Comment on lines -48 to +52
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a refactor to make sure that the --timeout flag value that may be in $TAILSCALE_ADDITIONAL_ARGS is not overridden by the preexisting --timeout=15s \ and leaves --accept-routes as a default but an option that could be removed as well without making a new $ENV_VAR


export ALL_PROXY=socks5://localhost:1055/

Expand Down