From 6107abf10f1a942e12611f45121912c818ccbc0d Mon Sep 17 00:00:00 2001 From: Jim Wyllie Date: Mon, 22 Oct 2012 21:24:00 -0400 Subject: [PATCH] Fixed a bug where lack of IPv6 destination = fatal There was a problem where trying to bind .v4 and .v6 listeners would set them to None if there was nothing to bind (if, say, you weren't binding an IPv6 listener). Later, the code then would try to call a member function of the listener. The member function would not do anything if there was no listener, but trying to dereference None yielded the broken behavior. --- client.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/client.py b/client.py index bd8e82b..ef4920a 100644 --- a/client.py +++ b/client.py @@ -681,12 +681,16 @@ def main(listenip_v6, listenip_v4, tcp_listener.setsockopt(socket.SOL_IP, IP_TRANSPARENT, 1) if udp_listener: udp_listener.setsockopt(socket.SOL_IP, IP_TRANSPARENT, 1) - udp_listener.v4.setsockopt(socket.SOL_IP, IP_RECVORIGDSTADDR, 1) - udp_listener.v6.setsockopt(SOL_IPV6, IPV6_RECVORIGDSTADDR, 1) + if udp_listener.v4 is not None: + udp_listener.v4.setsockopt(socket.SOL_IP, IP_RECVORIGDSTADDR, 1) + if udp_listener.v6 is not None: + udp_listener.v6.setsockopt(SOL_IPV6, IPV6_RECVORIGDSTADDR, 1) if dns_listener: dns_listener.setsockopt(socket.SOL_IP, IP_TRANSPARENT, 1) - dns_listener.v4.setsockopt(socket.SOL_IP, IP_RECVORIGDSTADDR, 1) - dns_listener.v6.setsockopt(SOL_IPV6, IPV6_RECVORIGDSTADDR, 1) + if dns_listener.v4 is not None: + dns_listener.v4.setsockopt(socket.SOL_IP, IP_RECVORIGDSTADDR, 1) + if dns_listener.v6 is not None: + dns_listener.v6.setsockopt(SOL_IPV6, IPV6_RECVORIGDSTADDR, 1) try: return _main(tcp_listener, udp_listener, fw, ssh_cmd, remotename,