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
53c07f7d
Commit
53c07f7d
authored
Dec 05, 2015
by
Brian May
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hostmap shouldn't be global.
parent
7e0c1534
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
6 deletions
+4
-6
firewall.py
sshuttle/firewall.py
+4
-6
No files found.
sshuttle/firewall.py
View file @
53c07f7d
...
@@ -9,11 +9,10 @@ import traceback
...
@@ -9,11 +9,10 @@ import traceback
from
sshuttle.helpers
import
debug1
,
debug2
,
Fatal
from
sshuttle.helpers
import
debug1
,
debug2
,
Fatal
from
sshuttle.methods
import
get_auto_method
,
get_method
from
sshuttle.methods
import
get_auto_method
,
get_method
hostmap
=
{}
HOSTSFILE
=
'/etc/hosts'
HOSTSFILE
=
'/etc/hosts'
def
rewrite_etc_hosts
(
port
):
def
rewrite_etc_hosts
(
hostmap
,
port
):
BAKFILE
=
'
%
s.sbak'
%
HOSTSFILE
BAKFILE
=
'
%
s.sbak'
%
HOSTSFILE
APPEND
=
'# sshuttle-firewall-
%
d AUTOCREATED'
%
port
APPEND
=
'# sshuttle-firewall-
%
d AUTOCREATED'
%
port
old_content
=
''
old_content
=
''
...
@@ -48,9 +47,7 @@ def rewrite_etc_hosts(port):
...
@@ -48,9 +47,7 @@ def rewrite_etc_hosts(port):
def
restore_etc_hosts
(
port
):
def
restore_etc_hosts
(
port
):
global
hostmap
rewrite_etc_hosts
({},
port
)
hostmap
=
{}
rewrite_etc_hosts
(
port
)
# Isolate function that needs to be replaced for tests
# Isolate function that needs to be replaced for tests
...
@@ -87,6 +84,7 @@ def setup_daemon():
...
@@ -87,6 +84,7 @@ def setup_daemon():
# are hopefully harmless.
# are hopefully harmless.
def
main
(
method_name
,
syslog
):
def
main
(
method_name
,
syslog
):
stdin
,
stdout
=
setup_daemon
()
stdin
,
stdout
=
setup_daemon
()
hostmap
=
{}
debug1
(
'firewall manager: Starting firewall with Python version
%
s
\n
'
debug1
(
'firewall manager: Starting firewall with Python version
%
s
\n
'
%
platform
.
python_version
())
%
platform
.
python_version
())
...
@@ -222,7 +220,7 @@ def main(method_name, syslog):
...
@@ -222,7 +220,7 @@ def main(method_name, syslog):
(
name
,
ip
)
=
line
[
5
:]
.
strip
()
.
split
(
','
,
1
)
(
name
,
ip
)
=
line
[
5
:]
.
strip
()
.
split
(
','
,
1
)
hostmap
[
name
]
=
ip
hostmap
[
name
]
=
ip
debug2
(
'firewall manager: setting up /etc/hosts.
\n
'
)
debug2
(
'firewall manager: setting up /etc/hosts.
\n
'
)
rewrite_etc_hosts
(
port_v6
or
port_v4
)
rewrite_etc_hosts
(
hostmap
,
port_v6
or
port_v4
)
elif
line
:
elif
line
:
if
not
method
.
firewall_command
(
line
):
if
not
method
.
firewall_command
(
line
):
raise
Fatal
(
'firewall: expected command, got
%
r'
%
line
)
raise
Fatal
(
'firewall: expected command, got
%
r'
%
line
)
...
...
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