Skip to content

Commit

Permalink
Import resolvconf_nameservers, fix wrong types
Browse files Browse the repository at this point in the history
Add resolvconf_nameservers to the list of functions imported from
helpers.
Fixed an instance where the method client.main was being called with
ns_hosts (string obtained from optional argument --ns-hosts) instead of
nslist (list of tuples that was already being passed to other methods).
Should fix issue apenwarr#24.
  • Loading branch information
vieira committed Nov 8, 2015
1 parent 28be71e commit a82224c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
17 changes: 8 additions & 9 deletions src/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
import ssyslog
import sys
from ssnet import SockWrapper, Handler, Proxy, Mux, MuxWrapper
from helpers import log, debug1, debug2, debug3, Fatal, islocal
from helpers import log, debug1, debug2, debug3, Fatal, islocal, \
resolvconf_nameservers

recvmsg = None
try:
Expand Down Expand Up @@ -277,18 +278,17 @@ def print_listening(self, what):
class FirewallClient:

def __init__(self, port_v6, port_v4, subnets_include, subnets_exclude,
dnsport_v6, dnsport_v4, ns_hosts, method, udp):
dnsport_v6, dnsport_v4, nslist, method, udp):
self.auto_nets = []
self.subnets_include = subnets_include
self.subnets_exclude = subnets_exclude
self.ns_hosts = ns_hosts
argvbase = ([sys.argv[1], sys.argv[0], sys.argv[1]] +
['-v'] * (helpers.verbose or 0) +
['--firewall', str(port_v6), str(port_v4),
str(dnsport_v6), str(dnsport_v4),
method, str(int(udp))])
if dnsport_v4 or dnsport_v6:
argvbase += ['--ns-hosts', ns_hosts]
argvbase += ['--ns-hosts', ' '.join([ip for _, ip in nslist])]
if ssyslog._p:
argvbase += ['--syslog']
argv_tries = [
Expand Down Expand Up @@ -602,7 +602,7 @@ def onhostlist(hostlist):


def main(listenip_v6, listenip_v4,
ssh_cmd, remotename, python, latency_control, dns, ns_hosts,
ssh_cmd, remotename, python, latency_control, dns, nslist,
method, seed_hosts, auto_nets,
subnets_include, subnets_exclude, syslog, daemon, pidfile):

Expand Down Expand Up @@ -698,9 +698,9 @@ def main(listenip_v6, listenip_v4,
udp_listener.print_listening("UDP redirector")

bound = False
if dns or ns_hosts:
if dns or nslist:
if dns:
ns_hosts += resolvconf_nameservers()
nslist += resolvconf_nameservers()
# search for spare port for DNS
debug2('Binding DNS:')
ports = xrange(12300, 9000, -1)
Expand Down Expand Up @@ -740,10 +740,9 @@ def main(listenip_v6, listenip_v4,
dnsport_v6 = 0
dnsport_v4 = 0
dns_listener = None
ns_hosts = []

fw = FirewallClient(redirectport_v6, redirectport_v4, subnets_include,
subnets_exclude, dnsport_v6, dnsport_v4, ns_hosts,
subnets_exclude, dnsport_v6, dnsport_v4, nslist,
method, udp)

if fw.method == "tproxy":
Expand Down
2 changes: 1 addition & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def parse_list(list):
opt.python,
opt.latency_control,
opt.dns,
opt.ns_hosts,
nslist,
method,
sh,
opt.auto_nets,
Expand Down

0 comments on commit a82224c

Please sign in to comment.