Add default tor relay establish timeout constant

Signed-off-by: Loren Eteval <loren.eteval@proton.me>
This commit is contained in:
Loren Eteval
2023-09-07 00:15:55 +08:00
parent 481ba9388b
commit a682662ca1
4 changed files with 27 additions and 11 deletions
+5 -3
View File
@@ -35,6 +35,7 @@ from Furious.Utility.Constants import (
APPLICATION_TUN_GATEWAY_ADDRESS,
DEFAULT_TOR_HTTPS_PORT,
DEFAULT_TOR_SOCKS_PORT,
DEFAULT_TOR_RELAY_ESTABLISH_TIMEOUT,
)
from Furious.Utility.Utility import (
Switch,
@@ -935,13 +936,14 @@ class ConnectAction(Action):
try:
timeout = 1000 * int(
self.torRelayStorageObj.get('relayEstablishTimeout', 15)
self.torRelayStorageObj.get(
'relayEstablishTimeout', DEFAULT_TOR_RELAY_ESTABLISH_TIMEOUT
)
)
except Exception:
# Any non-exit exceptions
# 15s
timeout = 1000 * 15
timeout = 1000 * DEFAULT_TOR_RELAY_ESTABLISH_TIMEOUT
logger.info(f'{TorRelay.name()} bootstrap timeout is {timeout // 1000}s')
+16 -7
View File
@@ -18,6 +18,7 @@
from Furious.Core.Core import Core
from Furious.Utility.Constants import (
APP,
PLATFORM,
DATA_DIR,
DEFAULT_TOR_SOCKS_PORT,
DEFAULT_TOR_HTTPS_PORT,
@@ -54,13 +55,21 @@ class TorRelayStarter(AsyncSubprocessMessage):
return APP().torRelaySettingsWidget.StorageObj
def launch(self, proxyServer):
self.torRelay = subprocess.Popen(
['tor', '-f', '-'],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
creationflags=subprocess.CREATE_NO_WINDOW,
)
if PLATFORM == 'Windows':
self.torRelay = subprocess.Popen(
['tor', '-f', '-'],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
creationflags=subprocess.CREATE_NO_WINDOW,
)
else:
self.torRelay = subprocess.Popen(
['tor', '-f', '-'],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
torConfig = (
f'SocksPort {self.torRelayStorageObj.get("socksTunnelPort", DEFAULT_TOR_SOCKS_PORT)}\n'
+2
View File
@@ -76,6 +76,8 @@ TOR_FAQ_LABEL = f'Tor FAQ: <a href=\"{TOR_FAQ_URL}\">{TOR_FAQ_URL}</a>'
# Avoid standard Tor port in case of running Tor services
DEFAULT_TOR_SOCKS_PORT = 9048
DEFAULT_TOR_HTTPS_PORT = 9047
# 20s
DEFAULT_TOR_RELAY_ESTABLISH_TIMEOUT = 20
ADMINISTRATOR_NAME = 'Administrator' if PLATFORM == 'Windows' else 'root'
+4 -1
View File
@@ -21,6 +21,7 @@ from Furious.Utility.Constants import (
PLATFORM,
DEFAULT_TOR_SOCKS_PORT,
DEFAULT_TOR_HTTPS_PORT,
DEFAULT_TOR_RELAY_ESTABLISH_TIMEOUT,
)
from Furious.Utility.Utility import (
StateContext,
@@ -215,7 +216,9 @@ class TorRelaySettingsWidget(Translatable, SupportConnectedCallback, QDialog):
self.StorageObj.get('logLevel', 'notice')
)
self.torRelayTimeoutSpinBox.setValue(
self.StorageObj.get('relayEstablishTimeout', 15)
self.StorageObj.get(
'relayEstablishTimeout', DEFAULT_TOR_RELAY_ESTABLISH_TIMEOUT
)
)
def closeEvent(self, event):