#!/usr/bin/env bash
set -euo pipefail

SSH_HOST="${WECHAT_EGRESS_SSH_HOST:-ssh105}"
LOCAL_PORT="${WECHAT_EGRESS_LOCAL_PORT:-19090}"
REMOTE_HOST="${WECHAT_EGRESS_REMOTE_HOST:-127.0.0.1}"
REMOTE_PORT="${WECHAT_EGRESS_REMOTE_PORT:-19090}"

exec ssh \
  -N \
  -o ExitOnForwardFailure=yes \
  -o ServerAliveInterval=30 \
  -o ServerAliveCountMax=3 \
  -L "127.0.0.1:${LOCAL_PORT}:${REMOTE_HOST}:${REMOTE_PORT}" \
  "${SSH_HOST}"
