mirror of
https://github.com/sshuttle/sshuttle.git
synced 2025-05-06 00:54:54 +02:00
Fix: Allow --to-ns and --ns-host without --dns.
If the user specifies --to-ns (tells the remote server which DNS server to use for lookups coming from sshuttle), then either --ns-host or --dns need to also be used (route DNS requests through sshuttle). A previous commit incorrectly made it so --to-ns and --ns-host couldn't be successfully used together. Attempts to fix #641.
This commit is contained in:
parent
f376674941
commit
31f059883c
@ -688,19 +688,26 @@ def main(listenip_v6, listenip_v4,
|
|||||||
|
|
||||||
fw = FirewallClient(method_name, sudo_pythonpath, ttl)
|
fw = FirewallClient(method_name, sudo_pythonpath, ttl)
|
||||||
|
|
||||||
# If --dns is used, store the IP addresses that the client
|
# nslist is the list of name severs to intercept. If --dns is
|
||||||
# normally uses for DNS lookups in nslist. The firewall needs to
|
# used, we add all DNS servers in resolv.conf. Otherwise, the list
|
||||||
# redirect packets outgoing to this server to the remote host
|
# can be populated with the --ns-hosts option (which is already
|
||||||
|
# stored in nslist). This list is used to setup the firewall so it
|
||||||
|
# can redirect packets outgoing to this server to the remote host
|
||||||
# instead.
|
# instead.
|
||||||
if dns:
|
if dns:
|
||||||
nslist += resolvconf_nameservers(True)
|
nslist += resolvconf_nameservers(True)
|
||||||
|
|
||||||
|
# If we are intercepting DNS requests, we tell the remote host
|
||||||
|
# where it should send the DNS requests to with the --to-ns
|
||||||
|
# option.
|
||||||
|
if len(nslist) > 0:
|
||||||
if to_nameserver is not None:
|
if to_nameserver is not None:
|
||||||
to_nameserver = "%s@%s" % tuple(to_nameserver[1:])
|
to_nameserver = "%s@%s" % tuple(to_nameserver[1:])
|
||||||
else:
|
else: # if we are not intercepting DNS traffic
|
||||||
# option doesn't make sense if we aren't proxying dns
|
# ...and the user specified a server to send DNS traffic to.
|
||||||
if to_nameserver and len(to_nameserver) > 0:
|
if to_nameserver and len(to_nameserver) > 0:
|
||||||
print("WARNING: --to-ns option is ignored because --dns was not "
|
print("WARNING: --to-ns option is ignored unless "
|
||||||
"used.")
|
"--dns or --ns-hosts is used.")
|
||||||
to_nameserver = None
|
to_nameserver = None
|
||||||
|
|
||||||
# Get family specific subnet lists. Also, the user may not specify
|
# Get family specific subnet lists. Also, the user may not specify
|
||||||
|
Loading…
Reference in New Issue
Block a user