Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sshuttle
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pub
sshuttle
Commits
2f11f50b
Commit
2f11f50b
authored
Jan 20, 2013
by
Jim Wyllie
Committed by
Brian May
Sep 15, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding more robust exit codes
parent
a9549176
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
13 deletions
+35
-13
sshuttle.conf
packaging/sshuttle.conf
+26
-11
main.py
src/main.py
+9
-2
No files found.
packaging/sshuttle.conf
View file @
2f11f50b
description
"Create a t
unnel over SSH proxy
"
description
"Create a t
ransparent proxy over SSH
"
author
"Jim Wyllie <jwyllie83@gmail.com>"
author
"Jim Wyllie <jwyllie83@gmail.com>"
manual
manual
...
@@ -8,15 +8,24 @@ nice -5
...
@@ -8,15 +8,24 @@ nice -5
# tunnel.
# tunnel.
env
PREFIX_LOCATION
=/
etc
/
sshuttle
/
prefixes
.
conf
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
# Routing table; defaults to 100
env
ROUTE_TABLE
=
100
env
ROUTE_TABLE
=
100
# fwmark; defaults to 1
# fwmark; defaults to 1
env
FWMARK
=
1
env
FWMARK
=
1
# SSH tunnel configuration file
env
SSHUTTLE_TUNNEL_FILE
=/
etc
/
sshuttle
/
tunnel
.
conf
# File containing the tunnel proxy name / host / whatever
env
TUNNEL_PROXY
=
"/etc/sshuttle/tunnel.conf"
# Any other commands needed to run before or after loading the SSH tunnel.
# This is where you can put any of your hacks to set up tunnels-in-tunnels,
# etc. Scripts in this directory are executed in order.
env
MISC_START_DIR
=/
etc
/
sshuttle
/
pre
-
start
.
d
env
MISC_STOP_DIR
=/
etc
/
sshuttle
/
post
-
stop
.
d
start
on
(
local
-
filesystems
and
net
-
device
-
up
IFACE
!=
lo
)
start
on
(
local
-
filesystems
and
net
-
device
-
up
IFACE
!=
lo
)
stop
on
stopping
network
-
services
stop
on
stopping
network
-
services
...
@@ -30,8 +39,6 @@ pre-start script
...
@@ -30,8 +39,6 @@ pre-start script
if
[ -
f
"${PREFIX_LOCATION}"
];
then
if
[ -
f
"${PREFIX_LOCATION}"
];
then
cat
"${PREFIX_LOCATION}"
|
while
read
ROUTE
;
do
cat
"${PREFIX_LOCATION}"
|
while
read
ROUTE
;
do
logger
"Working on route: ${ROUTE}"
# Skip comments
# Skip comments
if
[ -
n
"$(echo ${ROUTE} | egrep "
^[ ]*
#")" ]; then
if
[ -
n
"$(echo ${ROUTE} | egrep "
^[ ]*
#")" ]; then
continue
continue
...
@@ -42,18 +49,21 @@ pre-start script
...
@@ -42,18 +49,21 @@ pre-start script
continue
continue
fi
fi
logger
"Adding route
command: ip route add local ${ROUTE} dev lo table ${ROUTE_TABL
E}"
logger
"Adding route
: ${ROUT
E}"
ip
route
add
local
${
ROUTE
}
dev
lo
table
${
ROUTE_TABLE
}
ip
route
add
local
${
ROUTE
}
dev
lo
table
${
ROUTE_TABLE
}
done
done
fi
fi
for
RUNFILE
in
${
MISC_START_DIR
}/*;
do
logger
"Executing ${RUNFILE}"
/
bin
/
sh
-
c
"${RUNFILE}"
done
end
script
end
script
post
-
stop
script
post
-
stop
script
if
[ -
f
"${PREFIX_LOCATION}"
];
then
if
[ -
f
"${PREFIX_LOCATION}"
];
then
cat
"${PREFIX_LOCATION}"
|
while
read
ROUTE
;
do
cat
"${PREFIX_LOCATION}"
|
while
read
ROUTE
;
do
logger
"Working on route: ${ROUTE}"
# Skip comments
# Skip comments
if
[ -
n
"$(echo ${ROUTE} | egrep "
^[ ]*
#")" ]; then
if
[ -
n
"$(echo ${ROUTE} | egrep "
^[ ]*
#")" ]; then
continue
continue
...
@@ -64,12 +74,17 @@ post-stop script
...
@@ -64,12 +74,17 @@ post-stop script
continue
continue
fi
fi
logger
"Deleting route
command: ip route del local ${ROUTE} dev lo table ${ROUTE_TABL
E}"
logger
"Deleting route
: ${ROUT
E}"
ip
route
del
local
${
ROUTE
}
dev
lo
table
${
ROUTE_TABLE
}
ip
route
del
local
${
ROUTE
}
dev
lo
table
${
ROUTE_TABLE
}
done
done
fi
fi
ip
rule
del
fwmark
${
FWMARK
}
ip
rule
del
fwmark
${
FWMARK
}
for
RUNFILE
in
"${MISC_STOP_DIR}/*"
;
do
logger
"Executing ${RUNFILE}"
/
bin
/
sh
-
c
"${RUNFILE}"
done
end
script
end
script
exec
sleep
60
exec
/
home
/
jim
/
Projects
/
sshuttle
.
udp
/
src
/
sshuttle
--
method
=
tproxy
--
listen
0
.
0
.
0
.
0
--
remote
sshuttle_tunnel
-
s
/
etc
/
sshuttle
/
prefixes
.
conf
-
e
"ssh -F ${TUNNEL_PROXY}"
src/main.py
View file @
2f11f50b
...
@@ -193,7 +193,7 @@ try:
...
@@ -193,7 +193,7 @@ try:
ipport_v6
=
parse_ipport6
(
ip
)
ipport_v6
=
parse_ipport6
(
ip
)
else
:
else
:
ipport_v4
=
parse_ipport4
(
ip
)
ipport_v4
=
parse_ipport4
(
ip
)
sys
.
exit
(
client
.
main
(
ipport_v6
,
ipport_v4
,
return_code
=
client
.
main
(
ipport_v6
,
ipport_v4
,
opt
.
ssh_cmd
,
opt
.
ssh_cmd
,
remotename
,
remotename
,
opt
.
python
,
opt
.
python
,
...
@@ -204,7 +204,14 @@ try:
...
@@ -204,7 +204,14 @@ try:
opt
.
auto_nets
,
opt
.
auto_nets
,
parse_subnets
(
includes
),
parse_subnets
(
includes
),
parse_subnets
(
excludes
),
parse_subnets
(
excludes
),
opt
.
syslog
,
opt
.
daemon
,
opt
.
pidfile
))
opt
.
syslog
,
opt
.
daemon
,
opt
.
pidfile
)
if
return_code
==
0
:
log
(
'Normal exit code, exiting...'
)
else
:
log
(
'Abnormal exit code detected, failing...'
%
return_code
)
sys
.
exit
(
return_code
)
except
Fatal
,
e
:
except
Fatal
,
e
:
log
(
'fatal:
%
s
\n
'
%
e
)
log
(
'fatal:
%
s
\n
'
%
e
)
sys
.
exit
(
99
)
sys
.
exit
(
99
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment