From 5dd358a85128c34193e6462beb24abe49ae3c3d8 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sat, 10 May 2025 10:43:28 +0000 Subject: [PATCH] mmgen-{swaptxcreate,swaptxdo,txsend}: support `--proxy=env` param Allow use of the *_PROXY environment vars when connecting to the THORNode and Etherscan HTTPS servers --- mmgen/data/version | 2 +- mmgen/main_txcreate.py | 4 +++- mmgen/main_txdo.py | 4 +++- mmgen/main_txsend.py | 4 +++- mmgen/swap/proto/thorchain/thornode.py | 4 +++- mmgen/tx/tx_proxy.py | 4 +++- 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/mmgen/data/version b/mmgen/data/version index e5d7edde..b8bb4137 100644 --- a/mmgen/data/version +++ b/mmgen/data/version @@ -1 +1 @@ -15.1.dev35 +15.1.dev36 diff --git a/mmgen/main_txcreate.py b/mmgen/main_txcreate.py index 85d183c1..02a459e6 100755 --- a/mmgen/main_txcreate.py +++ b/mmgen/main_txcreate.py @@ -80,7 +80,9 @@ opts_data = { -s -S, --list-assets List available swap assets -- -v, --verbose Produce more verbose output b- -V, --vsize-adj= f Adjust transaction's estimated vsize by factor 'f' - -s -x, --proxy=P Fetch the swap quote via SOCKS5 proxy ‘P’ (host:port) + -s -x, --proxy=P Fetch the swap quote via SOCKS5 proxy ‘P’ (host:port). + + Use special value ‘env’ to honor *_PROXY environment + + vars instead. -- -y, --yes Answer 'yes' to prompts, suppress non-essential output e- -X, --cached-balances Use cached balances """, diff --git a/mmgen/main_txdo.py b/mmgen/main_txdo.py index 6157270c..4524855d 100755 --- a/mmgen/main_txdo.py +++ b/mmgen/main_txdo.py @@ -106,7 +106,9 @@ opts_data = { -- -v, --verbose Produce more verbose output b- -V, --vsize-adj= f Adjust transaction's estimated vsize by factor 'f' e- -w, --wait Wait for transaction confirmation - -s -x, --proxy=P Fetch the swap quote via SOCKS5 proxy ‘P’ (host:port) + -s -x, --proxy=P Fetch the swap quote via SOCKS5 proxy ‘P’ (host:port). + + Use special value ‘env’ to honor *_PROXY environment + + vars instead. e- -X, --cached-balances Use cached balances -- -y, --yes Answer 'yes' to prompts, suppress non-essential output -- -z, --show-hash-presets Show information on available hash presets diff --git a/mmgen/main_txsend.py b/mmgen/main_txsend.py index bac73c8d..0d8ee8dc 100755 --- a/mmgen/main_txsend.py +++ b/mmgen/main_txsend.py @@ -61,7 +61,9 @@ opts_data = { begins with one. -v, --verbose Be more verbose -w, --wait Wait for transaction confirmation (Ethereum only) --x, --proxy=P Connect to TX proxy via SOCKS5 proxy ‘P’ (host:port) +-x, --proxy=P Connect to TX proxy via SOCKS5h proxy ‘P’ (host:port). + Use special value ‘env’ to honor *_PROXY environment vars + instead. -y, --yes Answer 'yes' to prompts, suppress non-essential output """ }, diff --git a/mmgen/swap/proto/thorchain/thornode.py b/mmgen/swap/proto/thorchain/thornode.py index 36dc0068..210e60bc 100755 --- a/mmgen/swap/proto/thorchain/thornode.py +++ b/mmgen/swap/proto/thorchain/thornode.py @@ -43,7 +43,9 @@ class ThornodeRPCClient: self.session = requests.Session() self.session.trust_env = False # ignore *_PROXY environment vars self.session.headers = self.http_hdrs - if self.cfg.proxy: + if self.cfg.proxy == 'env': + self.session.trust_env = True + elif self.cfg.proxy: self.session.proxies.update({ 'http': f'socks5h://{self.cfg.proxy}', 'https': f'socks5h://{self.cfg.proxy}' diff --git a/mmgen/tx/tx_proxy.py b/mmgen/tx/tx_proxy.py index 60a46d30..05a4181b 100755 --- a/mmgen/tx/tx_proxy.py +++ b/mmgen/tx/tx_proxy.py @@ -30,7 +30,9 @@ class TxProxyClient: self.session = requests.Session() self.session.trust_env = False # ignore *_PROXY environment vars self.session.headers = self.http_hdrs - if self.cfg.proxy: + if self.cfg.proxy == 'env': + self.session.trust_env = True + elif self.cfg.proxy: self.session.proxies.update({ 'http': f'socks5h://{self.cfg.proxy}', 'https': f'socks5h://{self.cfg.proxy}'