Fix UDP and DNS support on Python 2.7 with tproxy method

There was runtime failure on UDP or DNS processing, because "socket" was redefined to PyXAPI's socket_ext in tproxy.py, but still was plain Python's socket in client.py
Fixed https://github.com/sshuttle/sshuttle/issues/134 for me
This commit is contained in:
S-trace 2017-02-20 12:54:26 +03:00 committed by Brian May
parent 9a9015a75e
commit af9ebd0f4b

View File

@ -1,4 +1,3 @@
import socket
import errno
import re
import signal
@ -17,6 +16,20 @@ from sshuttle.helpers import log, debug1, debug2, debug3, Fatal, islocal, \
resolvconf_nameservers
from sshuttle.methods import get_method, Features
try:
# try getting recvmsg from python
import socket as pythonsocket
getattr(pythonsocket.socket, "recvmsg")
socket = pythonsocket
except AttributeError:
# try getting recvmsg from socket_ext library
try:
import socket_ext
getattr(socket_ext.socket, "recvmsg")
socket = socket_ext
except ImportError:
import socket
_extra_fd = os.open('/dev/null', os.O_RDONLY)