Add socks-proxy option for simplex-chat.

This commit is contained in:
tecnovert
2025-06-01 22:52:18 +02:00
parent f918652b6c
commit 69acf00e0d
3 changed files with 32 additions and 11 deletions

View File

@@ -332,6 +332,17 @@ def runClient(
network_type = network.get("type", "unknown")
if network_type == "simplex":
simplex_dir = os.path.join(data_dir, "simplex")
log_level = "debug" if swap_client.debug else "info"
socks_proxy = None
if "socks_proxy_override" in network:
socks_proxy = network["socks_proxy_override"]
elif swap_client.use_tor_proxy:
socks_proxy = (
f"{swap_client.tor_proxy_host}:{swap_client.tor_proxy_port}"
)
daemons.append(
startSimplexClient(
network["client_path"],
@@ -340,6 +351,8 @@ def runClient(
network["ws_port"],
logger,
swap_client.delay_event,
socks_proxy=socks_proxy,
log_level=log_level,
)
)
pid = daemons[-1].handle.pid

View File

@@ -70,6 +70,8 @@ def startSimplexClient(
websocket_port: int,
logger,
delay_event,
socks_proxy=None,
log_level: str = "debug",
) -> Daemon:
logger.info("Starting Simplex client")
if not os.path.exists(data_path):
@@ -78,13 +80,16 @@ def startSimplexClient(
db_path = os.path.join(data_path, "simplex_client_data")
args = [bin_path, "-d", db_path, "-s", server_address, "-p", str(websocket_port)]
if socks_proxy:
args += ["--socks-proxy", socks_proxy]
if not os.path.exists(db_path + "_chat.db"):
# Need to set initial profile through CLI
# TODO: Must be a better way?
init_args = args + ["-e", "/help"] # Run command ro exit client
init_args = args + ["-e", "/help"] # Run command to exit client
initSimplexClient(init_args, logger, delay_event)
args += ["-l", "debug"]
args += ["-l", log_level]
opened_files = []
stdout_dest = open(