mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-10 04:29:51 +00:00
qt TorDetector: close socket
ResourceWarning below is shown when running python3 with "-X dev": ...\electrum\electrum\gui\qt\network_dialog.py:457: ResourceWarning: unclosed <socket.socket fd=3276, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('0.0.0.0', 55693), raddr=('127.0.0.1', 9050)> if TorDetector.is_tor_port(net_addr): ResourceWarning: Enable tracemalloc to get the object allocation traceback
This commit is contained in:
parent
e60aede77e
commit
52f4189176
1 changed files with 7 additions and 7 deletions
|
@ -464,13 +464,13 @@ class TorDetector(QThread):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def is_tor_port(net_addr: Tuple[str, int]) -> bool:
|
def is_tor_port(net_addr: Tuple[str, int]) -> bool:
|
||||||
try:
|
try:
|
||||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||||
s.settimeout(0.1)
|
s.settimeout(0.1)
|
||||||
s.connect(net_addr)
|
s.connect(net_addr)
|
||||||
# Tor responds uniquely to HTTP-like requests
|
# Tor responds uniquely to HTTP-like requests
|
||||||
s.send(b"GET\n")
|
s.send(b"GET\n")
|
||||||
if b"Tor is not an HTTP Proxy" in s.recv(1024):
|
if b"Tor is not an HTTP Proxy" in s.recv(1024):
|
||||||
return True
|
return True
|
||||||
except socket.error:
|
except socket.error:
|
||||||
pass
|
pass
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Add table
Reference in a new issue