Browse Source

sanitize server at the interface level (follow up to issue #1330)

283
ThomasV 10 years ago
parent
commit
604d5d432c
  1. 1
      lib/interface.py
  2. 3
      lib/network.py

1
lib/interface.py

@ -72,6 +72,7 @@ class TcpInterface(threading.Thread):
# parse server
self.server = server
self.host, self.port, self.protocol = self.server.split(':')
self.host = str(self.host)
self.port = int(self.port)
self.use_ssl = (self.protocol == 's')

3
lib/network.py

@ -301,12 +301,11 @@ class Network(util.DaemonThread):
def set_proxy(self, proxy):
self.proxy = proxy
if proxy:
self.print_error("setting proxy", proxy)
proxy_mode = proxy_modes.index(proxy["mode"]) + 1
socks.setdefaultproxy(proxy_mode, proxy["host"], int(proxy["port"]))
socket.socket = socks.socksocket
# prevent dns leaks, see http://stackoverflow.com/questions/13184205/dns-over-proxy
socket.getaddrinfo = lambda *args: [(socket.AF_INET, socket.SOCK_STREAM, 6, '', (str(args[0]), args[1]))]
socket.getaddrinfo = lambda *args: [(socket.AF_INET, socket.SOCK_STREAM, 6, '', (args[0], args[1]))]
else:
socket.socket = socket._socketobject
socket.getaddrinfo = socket._socket.getaddrinfo

Loading…
Cancel
Save