Skip to content

Instantly share code, notes, and snippets.

@timrwilliams
Last active December 21, 2015 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save timrwilliams/d48e6a182d083778fd15 to your computer and use it in GitHub Desktop.
Save timrwilliams/d48e6a182d083778fd15 to your computer and use it in GitHub Desktop.
Override QuotaGuard Static Socksify env variable setup with your own socks.conf file
#!/bin/bash
# Script inspired by and derived from Proximo (https://github.com/pirateradio/proximo-stacklet)
# Usage ./qgoverride rails s
if [ "${QUOTAGUARDSTATIC_URL}" == "" ]; then
echo "No QUOTAGUARDSTATIC_URL env variable found. Have you installed QuotaGuard Static?"
echo "If using Heroku:"
echo " heroku addons:add QuotaGuardstatic:test"
echo "If using another platform sign-up at quotaguard.com and follow documentation to manually set variable"
exit 2
fi
SOCKS_DIR="$(dirname $(dirname $(readlink -f ${BASH_SOURCE[0]})))/vendor/dante"
QUOTAGUARDSTATIC_USERNAME=$(awk -F'[/@:]' '{print $4}' <<< ${QUOTAGUARDSTATIC_URL})
QUOTAGUARDSTATIC_PASSWORD=$(awk -F'[/@:]' '{print $5}' <<< ${QUOTAGUARDSTATIC_URL})
export SOCKS_CONF="${SOCKS_DIR}/socks.conf.override"
export SOCKS_LIBDIR="${SOCKS_DIR}/lib"
export SOCKS_USERNAME="${QUOTAGUARDSTATIC_USERNAME}"
export SOCKS_PASSWORD="${QUOTAGUARDSTATIC_PASSWORD}"
export SOCKS_LIBRARY="${SOCKS_DIR}/lib/libdsocks.so"
export SOCKS_USEFULLPATH="true"
chmod +x ${SOCKS_DIR}/bin/socksify
echo "QuotaGuard Static enabled. Using your manually created socks.conf.override"
exec ${SOCKS_DIR}/bin/socksify $*
route {
from: 0.0.0.0/0 to: 0.0.0.0/0 port = 3306 via: us-east-1-static-brooks.quotaguard.com port = 1080
proxyprotocol: socks_v5
method: username
command: connect
}
@timrwilliams
Copy link
Author

Overriding the socks.conf allows you to specify complex client pass rules in your sock configuration file. In this example we are routing only traffic destined for port 3306 to the SOCKS5 proxy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment