Browse Source

mmgen-{swaptxcreate,swaptxdo,txsend}: support `--proxy=env` param

Allow use of the *_PROXY environment vars when connecting to the THORNode
and Etherscan HTTPS servers
The MMGen Project 6 months ago
parent
commit
5dd358a851

+ 1 - 1
mmgen/data/version

@@ -1 +1 @@
-15.1.dev35
+15.1.dev36

+ 3 - 1
mmgen/main_txcreate.py

@@ -80,7 +80,9 @@ opts_data = {
 			-s -S, --list-assets     List available swap assets
 			-s -S, --list-assets     List available swap assets
 			-- -v, --verbose         Produce more verbose output
 			-- -v, --verbose         Produce more verbose output
 			b- -V, --vsize-adj=   f  Adjust transaction's estimated vsize by factor 'f'
 			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
 			-- -y, --yes             Answer 'yes' to prompts, suppress non-essential output
 			e- -X, --cached-balances Use cached balances
 			e- -X, --cached-balances Use cached balances
 		""",
 		""",

+ 3 - 1
mmgen/main_txdo.py

@@ -106,7 +106,9 @@ opts_data = {
 			-- -v, --verbose          Produce more verbose output
 			-- -v, --verbose          Produce more verbose output
 			b- -V, --vsize-adj=     f Adjust transaction's estimated vsize by factor 'f'
 			b- -V, --vsize-adj=     f Adjust transaction's estimated vsize by factor 'f'
 			e- -w, --wait             Wait for transaction confirmation
 			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
 			e- -X, --cached-balances  Use cached balances
 			-- -y, --yes              Answer 'yes' to prompts, suppress non-essential output
 			-- -y, --yes              Answer 'yes' to prompts, suppress non-essential output
 			-- -z, --show-hash-presets Show information on available hash presets
 			-- -z, --show-hash-presets Show information on available hash presets

+ 3 - 1
mmgen/main_txsend.py

@@ -61,7 +61,9 @@ opts_data = {
                  begins with one.
                  begins with one.
 -v, --verbose    Be more verbose
 -v, --verbose    Be more verbose
 -w, --wait       Wait for transaction confirmation (Ethereum only)
 -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
 -y, --yes        Answer 'yes' to prompts, suppress non-essential output
 """
 """
 	},
 	},

+ 3 - 1
mmgen/swap/proto/thorchain/thornode.py

@@ -43,7 +43,9 @@ class ThornodeRPCClient:
 		self.session = requests.Session()
 		self.session = requests.Session()
 		self.session.trust_env = False # ignore *_PROXY environment vars
 		self.session.trust_env = False # ignore *_PROXY environment vars
 		self.session.headers = self.http_hdrs
 		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({
 			self.session.proxies.update({
 				'http':  f'socks5h://{self.cfg.proxy}',
 				'http':  f'socks5h://{self.cfg.proxy}',
 				'https': f'socks5h://{self.cfg.proxy}'
 				'https': f'socks5h://{self.cfg.proxy}'

+ 3 - 1
mmgen/tx/tx_proxy.py

@@ -30,7 +30,9 @@ class TxProxyClient:
 		self.session = requests.Session()
 		self.session = requests.Session()
 		self.session.trust_env = False # ignore *_PROXY environment vars
 		self.session.trust_env = False # ignore *_PROXY environment vars
 		self.session.headers = self.http_hdrs
 		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({
 			self.session.proxies.update({
 				'http':  f'socks5h://{self.cfg.proxy}',
 				'http':  f'socks5h://{self.cfg.proxy}',
 				'https': f'socks5h://{self.cfg.proxy}'
 				'https': f'socks5h://{self.cfg.proxy}'