mirror of
https://github.com/sshuttle/sshuttle.git
synced 2024-11-29 19:33:17 +01:00
hostmap shouldn't be global.
This commit is contained in:
parent
7e0c1534df
commit
53c07f7d90
@ -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):
|
|||||||
|
|
||||||
|
|
||||||
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():
|
|||||||
# 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):
|
|||||||
(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)
|
||||||
|
Loading…
Reference in New Issue
Block a user