| | #!/bin/sh |
| | set -e |
| |
|
| | |
| | |
| |
|
| | if [ -n "$STASTIC_PROXY" ]; then |
| | echo "STASTIC_PROXY is set. Configuring proxychains..." |
| |
|
| | |
| | |
| | PROTO=$(echo "$STASTIC_PROXY" | grep :// | sed -e's,^\(.*://\).*,\1,g' | sed -e 's,://,,g') |
| | URL_NO_PROTO=$(echo "$STASTIC_PROXY" | sed -e 's,^.*://,,g') |
| | USER_PASS=$(echo "$URL_NO_PROTO" | grep -o '.*@' | sed 's/@//') |
| | HOST_PORT=$(echo "$URL_NO_PROTO" | sed -e "s,$USER_PASS@,,g") |
| | HOST=$(echo "$HOST_PORT" | cut -d: -f1) |
| | PORT=$(echo "$HOST_PORT" | cut -d: -f2) |
| |
|
| | |
| | if [ "$PROTO" != "http" ] && [ "$PROTO" != "socks4" ] && [ "$PROTO" != "socks5" ]; then |
| | echo "Warning: Unsupported proxy type '$PROTO'. Defaulting to 'http'." |
| | PROTO="http" |
| | fi |
| |
|
| | |
| | CONFIG_DIR="/home/node/.proxychains" |
| | mkdir -p "$CONFIG_DIR" |
| | CONFIG_FILE="$CONFIG_DIR/proxychains.conf" |
| |
|
| | |
| | cat > "$CONFIG_FILE" <<EOF |
| | strict_chain |
| | proxy_dns |
| | |
| | # Exclude local traffic from proxying, so the app can talk to the local ProxyServer. |
| | localnet 127.0.0.0/8 |
| | localnet ::1/128 |
| | |
| | [ProxyList] |
| | EOF |
| |
|
| | |
| | if [ -n "$USER_PASS" ]; then |
| | USER=$(echo "$USER_PASS" | cut -d: -f1) |
| | PASS=$(echo "$USER_PASS" | cut -d: -f2) |
| | echo "$PROTO $HOST $PORT $USER $PASS" >> "$CONFIG_FILE" |
| | echo "Configured proxy: $PROTO://$USER_PASS@$HOST:$PORT" |
| | else |
| | echo "$PROTO $HOST $PORT" >> "$CONFIG_FILE" |
| | echo "Configured proxy: $PROTO://$HOST:$PORT" |
| | fi |
| |
|
| | echo "Starting application with proxychains..." |
| | |
| | exec proxychains4 "$@" |
| | else |
| | echo "STASTIC_PROXY is not set. Starting application without proxy." |
| | |
| | exec "$@" |
| | fi |