From 2fbfeb51b425c025badca85ddfecc4c5be343b8a Mon Sep 17 00:00:00 2001 From: Matt Rohrer Date: Mon, 12 May 2025 14:54:48 +0200 Subject: [PATCH 01/11] Use latest tailscale version https://tailscale.com/changelog#2025-04-17 --- bin/compile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/compile b/bin/compile index 2e98dcb..4bec9d1 100755 --- a/bin/compile +++ b/bin/compile @@ -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" @@ -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 \ No newline at end of file +fi From 24023e8ac95c78c1ad43b0ccdf5e02b8ea84f317 Mon Sep 17 00:00:00 2001 From: Matt Rohrer Date: Thu, 15 May 2025 15:09:19 +0200 Subject: [PATCH 02/11] whitespace/style --- bin/heroku-tailscale-start.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/bin/heroku-tailscale-start.sh b/bin/heroku-tailscale-start.sh index ced4bfc..93aa0c9 100755 --- a/bin/heroku-tailscale-start.sh +++ b/bin/heroku-tailscale-start.sh @@ -8,20 +8,20 @@ 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=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 } if [ -z "$TAILSCALE_HOSTNAME" ]; then @@ -39,7 +39,7 @@ 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" \ --hostname="$TAILSCALE_HOSTNAME" \ From 53dcb5368d95e22ba034a9195c9cdb0751e5a11f Mon Sep 17 00:00:00 2001 From: Matt Rohrer Date: Fri, 16 May 2025 14:24:18 +0200 Subject: [PATCH 03/11] Use integer math for wait calculations The Heroku-24 stack does not include `bc` and bash cannot do non-integer math. Use `awk` to convert the timeout & interval to milliseconds so we can use build-in bash math operators. --- bin/heroku-tailscale-start.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/heroku-tailscale-start.sh b/bin/heroku-tailscale-start.sh index 93aa0c9..a1e878d 100755 --- a/bin/heroku-tailscale-start.sh +++ b/bin/heroku-tailscale-start.sh @@ -10,15 +10,20 @@ fi wait_for_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" ]; do + while [ "$elapsed" -lt "$timeout_ms" ]; do state=$(tailscale status -json | jq -r .BackendState) if [ "$state" = "Running" ]; then return 0 fi sleep "$interval" - elapsed=$(echo "$elapsed + $interval" | bc) + elapsed=$((elapsed + interval_ms)) done return 1 From e67425060d4f04b196186039e811931cb74f215d Mon Sep 17 00:00:00 2001 From: Matt Rohrer Date: Fri, 16 May 2025 14:28:30 +0200 Subject: [PATCH 04/11] Add ability to set TAILSCALE_RUNNING_TIMEOUT --- bin/heroku-tailscale-start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/heroku-tailscale-start.sh b/bin/heroku-tailscale-start.sh index a1e878d..fb38f60 100755 --- a/bin/heroku-tailscale-start.sh +++ b/bin/heroku-tailscale-start.sh @@ -8,7 +8,7 @@ if [ -z "$TAILSCALE_AUTH_KEY" ]; then fi wait_for_tailscale_running() { - timeout=5 # Timeout in seconds + timeout=${TAILSCALE_RUNNING_TIMEOUT:-5} # Timeout in seconds interval=0.5 # Interval between checks # convert to milliseconds so we can use integer math From bec36b6500d41f6b995087de8b9df87a1d3a2c4f Mon Sep 17 00:00:00 2001 From: CoderMiguel <52347827+CoderMiguel@users.noreply.github.com> Date: Fri, 8 Aug 2025 16:08:59 -0400 Subject: [PATCH 05/11] refactor to tailscale up command --- bin/heroku-tailscale-start.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/bin/heroku-tailscale-start.sh b/bin/heroku-tailscale-start.sh index fb38f60..0adc7b3 100755 --- a/bin/heroku-tailscale-start.sh +++ b/bin/heroku-tailscale-start.sh @@ -46,12 +46,10 @@ fi tailscaled -cleanup > /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" \ + --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} export ALL_PROXY=socks5://localhost:1055/ From 35a6989926bb7a0ad1a2767a59f9a48e9da584f7 Mon Sep 17 00:00:00 2001 From: CoderMiguel <52347827+CoderMiguel@users.noreply.github.com> Date: Fri, 8 Aug 2025 17:26:40 -0400 Subject: [PATCH 06/11] dynamically pick the latest version as the default, but still allow configurable versioning --- bin/compile | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/bin/compile b/bin/compile index 4bec9d1..baa6499 100755 --- a/bin/compile +++ b/bin/compile @@ -16,22 +16,46 @@ function indent() { sed -e 's/^/ /' } +function tailscale_latest_release_json() { + local latest_release + curl -s https://api.github.com/repos/tailscale/tailscale/releases/latest +} + +function tailscale_latest_version() { + local version=$(jq -r '.tag_name' <<< "$(tailscale_latest_release_json)") + echo "${version#v}" # remove leading 'v' +} + +#function tailscale_version() { +# local json=$(tailscale version --json $1) +# echo "$(jq -r '.upstream' <<< "$json")" +#} + +# current=$(jq -r '.short' <<< "$json") +# upstream=$(jq -r '.upstream' <<< "$json") +# +## echo "current: $current, upstream: $upstream" +# if [[ "$current" == "$upstream" ]]; then +# echo "Tailscale is up to date" +# else +# echo "Tailscale will be updated: $current => $upstream" + # setup variables BUILD_DIR=$1 CACHE_DIR=$2 ENV_DIR=$3 BUILDPACK_DIR="$(dirname "$(dirname "$0")")" -TAILSCALE_VERSION=1.82.5 -TAILSCALE_BUILD_ARCH=amd64 +TAILSCALE_VERSION=${TAILSCALE_VERSION:-$(tailscale_latest_version)} +TAILSCALE_BUILD_ARCH=${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" -PROXYCHAINS_VERSION=4.17 +PROXYCHAINS_VERSION=${PROXYCHAINS_VERSION:-4.17} PROXYCHAINS_SOURCE_URL="https://github.com/rofl0r/proxychains-ng/archive/refs/tags/v$PROXYCHAINS_VERSION.tar.gz" PROXYCHAINS_INSTALL_DIR="$BUILD_DIR/vendor/proxychains-ng" -log "Installing Tailscale" +log "Installing Tailscale: $TAILSCALE_VERSION ($TAILSCALE_BUILD_ARCH)" mkdir -p $TAILSCALE_INSTALL_DIR export PATH="$TAILSCALE_INSTALL_DIR:$PATH" curl -sL $TAILSCALE_SOURCE_URL \ @@ -47,8 +71,8 @@ echo 'export PATH="/app/vendor/tailscale:$PATH"' >> $BUILD_DIR/.profile.d/heroku log "Installing ProxyChains-ng" PROXYCHAINS_BUILD_DIR="$CACHE_DIR/proxychains-ng-$PROXYCHAINS_VERSION" -if [ ! -f "$PROXYCHAINS_BUILD_DIR/proxychains4" ]; then - rm -rf $PROXYCHAINS_BUILD_DIR +if [ ! -f "$PROXYCHAINS_BUILD_DIR/proxychains4" ]; then + rm -rf $PROXYCHAINS_BUILD_DIR wget $PROXYCHAINS_SOURCE_URL -O $CACHE_DIR/proxychains.tar.gz cd $CACHE_DIR tar -zxvf $CACHE_DIR/proxychains.tar.gz From e9da0fba5f0895572bb30e14401fd3df31ddff43 Mon Sep 17 00:00:00 2001 From: CoderMiguel <52347827+CoderMiguel@users.noreply.github.com> Date: Fri, 8 Aug 2025 17:44:41 -0400 Subject: [PATCH 07/11] clean up --- bin/compile | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/bin/compile b/bin/compile index baa6499..70e26c4 100755 --- a/bin/compile +++ b/bin/compile @@ -17,8 +17,10 @@ function indent() { } function tailscale_latest_release_json() { - local latest_release - curl -s https://api.github.com/repos/tailscale/tailscale/releases/latest + if [ -z "$LATEST_RELEASE_JSON" ]; then + LATEST_RELEASE_JSON=$(curl -s https://api.github.com/repos/tailscale/tailscale/releases/latest) + fi + echo "$LATEST_RELEASE_JSON" } function tailscale_latest_version() { @@ -26,20 +28,6 @@ function tailscale_latest_version() { echo "${version#v}" # remove leading 'v' } -#function tailscale_version() { -# local json=$(tailscale version --json $1) -# echo "$(jq -r '.upstream' <<< "$json")" -#} - -# current=$(jq -r '.short' <<< "$json") -# upstream=$(jq -r '.upstream' <<< "$json") -# -## echo "current: $current, upstream: $upstream" -# if [[ "$current" == "$upstream" ]]; then -# echo "Tailscale is up to date" -# else -# echo "Tailscale will be updated: $current => $upstream" - # setup variables BUILD_DIR=$1 CACHE_DIR=$2 @@ -47,7 +35,7 @@ ENV_DIR=$3 BUILDPACK_DIR="$(dirname "$(dirname "$0")")" TAILSCALE_VERSION=${TAILSCALE_VERSION:-$(tailscale_latest_version)} -TAILSCALE_BUILD_ARCH=${TAILSCALE_BUILD_ARCH:-amd64} +TAILSCALE_BUILD_ARCH=${TAILSCALE_BUILD_ARCH:-arch} TAILSCALE_SOURCE_URL="https://pkgs.tailscale.com/stable/tailscale_${TAILSCALE_VERSION}_${TAILSCALE_BUILD_ARCH}.tgz" TAILSCALE_INSTALL_DIR="$BUILD_DIR/vendor/tailscale" From 46a327f1794b6b30de3f16231fd1af58d01343b0 Mon Sep 17 00:00:00 2001 From: CoderMiguel <52347827+CoderMiguel@users.noreply.github.com> Date: Fri, 8 Aug 2025 17:47:58 -0400 Subject: [PATCH 08/11] add version number to logging --- bin/compile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/compile b/bin/compile index 70e26c4..89ba989 100755 --- a/bin/compile +++ b/bin/compile @@ -43,7 +43,7 @@ PROXYCHAINS_VERSION=${PROXYCHAINS_VERSION:-4.17} PROXYCHAINS_SOURCE_URL="https://github.com/rofl0r/proxychains-ng/archive/refs/tags/v$PROXYCHAINS_VERSION.tar.gz" PROXYCHAINS_INSTALL_DIR="$BUILD_DIR/vendor/proxychains-ng" -log "Installing Tailscale: $TAILSCALE_VERSION ($TAILSCALE_BUILD_ARCH)" +log "Installing Tailscale $TAILSCALE_VERSION ($TAILSCALE_BUILD_ARCH)" mkdir -p $TAILSCALE_INSTALL_DIR export PATH="$TAILSCALE_INSTALL_DIR:$PATH" curl -sL $TAILSCALE_SOURCE_URL \ @@ -57,7 +57,7 @@ chmod +x "$TAILSCALE_INSTALL_DIR/heroku-tailscale-test.sh" mkdir -p $BUILD_DIR/.profile.d echo 'export PATH="/app/vendor/tailscale:$PATH"' >> $BUILD_DIR/.profile.d/heroku-tailscale-buildpack.sh -log "Installing ProxyChains-ng" +log "Installing ProxyChains-ng $PROXYCHAINS_VERSION" PROXYCHAINS_BUILD_DIR="$CACHE_DIR/proxychains-ng-$PROXYCHAINS_VERSION" if [ ! -f "$PROXYCHAINS_BUILD_DIR/proxychains4" ]; then rm -rf $PROXYCHAINS_BUILD_DIR From 34bd078ce01889c9a887604de00a4d972f010b87 Mon Sep 17 00:00:00 2001 From: CoderMiguel <52347827+CoderMiguel@users.noreply.github.com> Date: Fri, 8 Aug 2025 17:55:44 -0400 Subject: [PATCH 09/11] correct typo --- bin/compile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/compile b/bin/compile index 89ba989..1c78453 100755 --- a/bin/compile +++ b/bin/compile @@ -35,7 +35,7 @@ ENV_DIR=$3 BUILDPACK_DIR="$(dirname "$(dirname "$0")")" TAILSCALE_VERSION=${TAILSCALE_VERSION:-$(tailscale_latest_version)} -TAILSCALE_BUILD_ARCH=${TAILSCALE_BUILD_ARCH:-arch} +TAILSCALE_BUILD_ARCH=${TAILSCALE_BUILD_ARCH:-$(arch)} TAILSCALE_SOURCE_URL="https://pkgs.tailscale.com/stable/tailscale_${TAILSCALE_VERSION}_${TAILSCALE_BUILD_ARCH}.tgz" TAILSCALE_INSTALL_DIR="$BUILD_DIR/vendor/tailscale" From bc871c7d84d1cba604119517dcb9d8846f941954 Mon Sep 17 00:00:00 2001 From: CoderMiguel <52347827+CoderMiguel@users.noreply.github.com> Date: Fri, 8 Aug 2025 18:01:51 -0400 Subject: [PATCH 10/11] rollback arch logic --- bin/compile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/compile b/bin/compile index 1c78453..97ee09f 100755 --- a/bin/compile +++ b/bin/compile @@ -35,7 +35,7 @@ ENV_DIR=$3 BUILDPACK_DIR="$(dirname "$(dirname "$0")")" TAILSCALE_VERSION=${TAILSCALE_VERSION:-$(tailscale_latest_version)} -TAILSCALE_BUILD_ARCH=${TAILSCALE_BUILD_ARCH:-$(arch)} +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" @@ -43,7 +43,7 @@ PROXYCHAINS_VERSION=${PROXYCHAINS_VERSION:-4.17} PROXYCHAINS_SOURCE_URL="https://github.com/rofl0r/proxychains-ng/archive/refs/tags/v$PROXYCHAINS_VERSION.tar.gz" PROXYCHAINS_INSTALL_DIR="$BUILD_DIR/vendor/proxychains-ng" -log "Installing Tailscale $TAILSCALE_VERSION ($TAILSCALE_BUILD_ARCH)" +log "Installing Tailscale $TAILSCALE_VERSION" mkdir -p $TAILSCALE_INSTALL_DIR export PATH="$TAILSCALE_INSTALL_DIR:$PATH" curl -sL $TAILSCALE_SOURCE_URL \ From 0346ed2b98da798b7d93ab97c0568522c92739ee Mon Sep 17 00:00:00 2001 From: CoderMiguel <52347827+CoderMiguel@users.noreply.github.com> Date: Fri, 8 Aug 2025 18:07:50 -0400 Subject: [PATCH 11/11] added TODO for new version log if not using the latest version --- bin/compile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/compile b/bin/compile index 97ee09f..701f110 100755 --- a/bin/compile +++ b/bin/compile @@ -43,6 +43,8 @@ PROXYCHAINS_VERSION=${PROXYCHAINS_VERSION:-4.17} PROXYCHAINS_SOURCE_URL="https://github.com/rofl0r/proxychains-ng/archive/refs/tags/v$PROXYCHAINS_VERSION.tar.gz" PROXYCHAINS_INSTALL_DIR="$BUILD_DIR/vendor/proxychains-ng" +# TODO: a new version of Tailscale is available check. + log "Installing Tailscale $TAILSCALE_VERSION" mkdir -p $TAILSCALE_INSTALL_DIR export PATH="$TAILSCALE_INSTALL_DIR:$PATH"