From a0b00096b402fdc8bac4b9a7ce16a03fc375139b Mon Sep 17 00:00:00 2001 From: Bohdan Konkevych Date: Tue, 15 Aug 2023 07:22:43 +0000 Subject: [PATCH] Add tcp-proxy.sh --- tcp-proxy.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tcp-proxy.sh diff --git a/tcp-proxy.sh b/tcp-proxy.sh new file mode 100644 index 0000000..2c60a29 --- /dev/null +++ b/tcp-proxy.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +#if [ "$#" -ne 2 ]; then +# echo "usage: $(basename $0) host port" +# exit 1 +#fi + +#HOST="$1" +#PORT="$2" + +DOCKER_HOST_IP=$(route -n | awk '/UG[ \t]/{print $2}'); + +LISTEN_PORT=${LISTEN_PORT:-${PORT}} +HOST=${HOST:-${DOCKER_HOST_IP}} + +echo "relay TCP/IP connections on :${LISTEN_PORT} to ${HOST}:${PORT}" +exec socat TCP-LISTEN:${LISTEN_PORT},fork,reuseaddr TCP:${HOST}:${PORT} \ No newline at end of file