mirror of
https://github.com/sshuttle/sshuttle.git
synced 2025-05-30 14:48:51 +02:00
Make it clear ports are for IPv4.
This commit is contained in:
parent
4db9b372c2
commit
e7caae8126
@ -415,12 +415,12 @@ def main(listenip, ssh_cmd, remotename, python, latency_control, dns,
|
|||||||
if dns:
|
if dns:
|
||||||
dnsip = dns_listener.v4.getsockname()
|
dnsip = dns_listener.v4.getsockname()
|
||||||
debug1('DNS listening on %r.\n' % (dnsip,))
|
debug1('DNS listening on %r.\n' % (dnsip,))
|
||||||
dnsport = dnsip[1]
|
dnsport_v4 = dnsip[1]
|
||||||
else:
|
else:
|
||||||
dnsport = 0
|
dnsport_v4 = 0
|
||||||
dns_listener = None
|
dns_listener = None
|
||||||
|
|
||||||
fw = FirewallClient(listenip[1], subnets_include, subnets_exclude, dnsport)
|
fw = FirewallClient(listenip[1], subnets_include, subnets_exclude, dnsport_v4)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return _main(tcp_listener, fw, ssh_cmd, remotename,
|
return _main(tcp_listener, fw, ssh_cmd, remotename,
|
||||||
|
22
firewall.py
22
firewall.py
@ -389,11 +389,11 @@ def restore_etc_hosts(port):
|
|||||||
# exit. In case that fails, it's not the end of the world; future runs will
|
# exit. In case that fails, it's not the end of the world; future runs will
|
||||||
# supercede it in the transproxy list, at least, so the leftover rules
|
# supercede it in the transproxy list, at least, so the leftover rules
|
||||||
# are hopefully harmless.
|
# are hopefully harmless.
|
||||||
def main(port, dnsport, syslog):
|
def main(port_v4, dnsport_v4, syslog):
|
||||||
assert(port > 0)
|
assert(port_v4 > 0)
|
||||||
assert(port <= 65535)
|
assert(port_v4 <= 65535)
|
||||||
assert(dnsport >= 0)
|
assert(dnsport_v4 >= 0)
|
||||||
assert(dnsport <= 65535)
|
assert(dnsport_v4 <= 65535)
|
||||||
|
|
||||||
if os.getuid() != 0:
|
if os.getuid() != 0:
|
||||||
raise Fatal('you must be root (or enable su/sudo) to set the firewall')
|
raise Fatal('you must be root (or enable su/sudo) to set the firewall')
|
||||||
@ -449,8 +449,8 @@ def main(port, dnsport, syslog):
|
|||||||
debug1('firewall manager: starting transproxy.\n')
|
debug1('firewall manager: starting transproxy.\n')
|
||||||
|
|
||||||
subnets_v4 = filter(lambda i: i[0]==socket.AF_INET, subnets)
|
subnets_v4 = filter(lambda i: i[0]==socket.AF_INET, subnets)
|
||||||
if port:
|
if port_v4:
|
||||||
do_wait = do_it(port, dnsport, socket.AF_INET, subnets_v4)
|
do_wait = do_it(port_v4, dnsport_v4, socket.AF_INET, subnets_v4)
|
||||||
elif len(subnets_v4) > 0:
|
elif len(subnets_v4) > 0:
|
||||||
debug1('IPv4 subnets defined but IPv4 disabled\n')
|
debug1('IPv4 subnets defined but IPv4 disabled\n')
|
||||||
|
|
||||||
@ -472,7 +472,7 @@ def main(port, dnsport, syslog):
|
|||||||
if line.startswith('HOST '):
|
if line.startswith('HOST '):
|
||||||
(name,ip) = line[5:].strip().split(',', 1)
|
(name,ip) = line[5:].strip().split(',', 1)
|
||||||
hostmap[name] = ip
|
hostmap[name] = ip
|
||||||
rewrite_etc_hosts(port)
|
rewrite_etc_hosts(port_v4)
|
||||||
elif line:
|
elif line:
|
||||||
raise Fatal('expected EOF, got %r' % line)
|
raise Fatal('expected EOF, got %r' % line)
|
||||||
else:
|
else:
|
||||||
@ -482,6 +482,6 @@ def main(port, dnsport, syslog):
|
|||||||
debug1('firewall manager: undoing changes.\n')
|
debug1('firewall manager: undoing changes.\n')
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
if port:
|
if port_v4:
|
||||||
do_it(port, 0, socket.AF_INET, [])
|
do_it(port_v4, 0, socket.AF_INET, [])
|
||||||
restore_etc_hosts(port)
|
restore_etc_hosts(port_v4)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user