1
0

Make proxies work

This commit is contained in:
Johann Bauer
2017-02-25 13:36:24 +01:00
committed by ThomasV
parent d4d93b3928
commit 8e54d5c4d4
4 changed files with 12 additions and 9 deletions

View File

@@ -497,12 +497,12 @@ class TorDetector(QThread):
@staticmethod
def is_tor_port(port):
try:
s = socket._socketobject(socket.AF_INET, socket.SOCK_STREAM)
s = (socket._socketobject if hasattr(socket, "_socketobject") else socket.socket)(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(0.1)
s.connect(("127.0.0.1", port))
# Tor responds uniquely to HTTP-like requests
s.send("GET\n")
if "Tor is not an HTTP Proxy" in s.recv(1024):
s.send(b"GET\n")
if b"Tor is not an HTTP Proxy" in s.recv(1024):
return True
except socket.error:
pass