Separate socket creation and connection to be able to cancel it
This commit is contained in:
parent
f4cdc31788
commit
d8453384ab
2 changed files with 2 additions and 3 deletions
|
@ -104,7 +104,8 @@ class Connection(object):
|
||||||
raise Exception("Can't connect to onion addresses, no Tor controller present")
|
raise Exception("Can't connect to onion addresses, no Tor controller present")
|
||||||
self.sock = self.server.tor_manager.createSocket(self.ip, self.port)
|
self.sock = self.server.tor_manager.createSocket(self.ip, self.port)
|
||||||
else:
|
else:
|
||||||
self.sock = socket.create_connection((self.ip, int(self.port)))
|
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
self.sock.connect((self.ip, int(self.port)))
|
||||||
|
|
||||||
# Implicit SSL
|
# Implicit SSL
|
||||||
if self.cert_pin:
|
if self.cert_pin:
|
||||||
|
|
|
@ -304,9 +304,7 @@ class TorManager(object):
|
||||||
self.log.debug("Creating new Tor socket to %s:%s" % (onion, port))
|
self.log.debug("Creating new Tor socket to %s:%s" % (onion, port))
|
||||||
if config.tor == "always": # Every socket is proxied by default, in this mode
|
if config.tor == "always": # Every socket is proxied by default, in this mode
|
||||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
sock.connect((onion, int(port)))
|
|
||||||
else:
|
else:
|
||||||
sock = socks.socksocket()
|
sock = socks.socksocket()
|
||||||
sock.set_proxy(socks.SOCKS5, self.proxy_ip, self.proxy_port)
|
sock.set_proxy(socks.SOCKS5, self.proxy_ip, self.proxy_port)
|
||||||
sock.connect((onion, int(port)))
|
|
||||||
return sock
|
return sock
|
Loading…
Reference in a new issue