This repository has been archived by the owner on May 27, 2020. It is now read-only.
forked from apenwarr/sshuttle
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
description "Create a tunnel over SSH proxy" | ||
author "Jim Wyllie <jwyllie83@gmail.com>" | ||
|
||
manual | ||
nice -5 | ||
|
||
# Edit this file with network prefixes that should be loaded through the SSH | ||
# tunnel. | ||
env PREFIX_LOCATION=/etc/sshuttle/prefixes.conf | ||
|
||
# Try all the keys in a given key directory | ||
env KEY_LOCATION=/etc/sshuttle/keys | ||
|
||
# Routing table; defaults to 100 | ||
env ROUTE_TABLE=100 | ||
|
||
# fwmark; defaults to 1 | ||
env FWMARK=1 | ||
|
||
start on (local-filesystems and net-device-up IFACE!=lo) | ||
stop on stopping network-services | ||
|
||
#respawn | ||
|
||
pre-start script | ||
# Make sure we have created the routes | ||
sudo ip rule add fwmark ${FWMARK} lookup ${ROUTE_TABLE} | ||
logger "Starting sshuttle..." | ||
|
||
if [ -f "${PREFIX_LOCATION}" ]; then | ||
cat "${PREFIX_LOCATION}" | while read ROUTE; do | ||
|
||
logger "Working on route: ${ROUTE}" | ||
|
||
# Skip comments | ||
if [ -n "$(echo ${ROUTE} | egrep "^[ ]*#")" ]; then | ||
continue | ||
fi | ||
|
||
# Skip empty lines | ||
if [ -z "${ROUTE}" ]; then | ||
continue | ||
fi | ||
|
||
logger "Adding route command: ip route add local ${ROUTE} dev lo table ${ROUTE_TABLE}" | ||
ip route add local ${ROUTE} dev lo table ${ROUTE_TABLE} | ||
done | ||
fi | ||
end script | ||
|
||
post-stop script | ||
if [ -f "${PREFIX_LOCATION}" ]; then | ||
cat "${PREFIX_LOCATION}" | while read ROUTE; do | ||
|
||
logger "Working on route: ${ROUTE}" | ||
|
||
# Skip comments | ||
if [ -n "$(echo ${ROUTE} | egrep "^[ ]*#")" ]; then | ||
continue | ||
fi | ||
|
||
# Skip empty lines | ||
if [ -z "${ROUTE}" ]; then | ||
continue | ||
fi | ||
|
||
logger "Deleting route command: ip route del local ${ROUTE} dev lo table ${ROUTE_TABLE}" | ||
ip route del local ${ROUTE} dev lo table ${ROUTE_TABLE} | ||
done | ||
fi | ||
|
||
ip rule del fwmark ${FWMARK} | ||
end script | ||
|
||
exec sleep 60 |