|
18 | 18 |
|
19 | 19 | import aiohttp
|
20 | 20 | from aiorpcx import (Event, Notification, RPCError, RPCSession, SOCKSError,
|
21 |
| - SOCKSProxy, TaskGroup, TaskTimeout, connect_rs, |
22 |
| - handler_invocation, ignore_after, sleep) |
| 21 | + SOCKSProxy, TaskGroup, TaskTimeout, UnixAddress, |
| 22 | + connect_rs, handler_invocation, ignore_after, sleep) |
23 | 23 | from aiorpcx.jsonrpc import CodeMessageError
|
24 | 24 |
|
25 | 25 | from electrumx.lib.peer import Peer
|
@@ -185,15 +185,21 @@ async def _detect_proxy(self):
|
185 | 185 |
|
186 | 186 | If found self.proxy is set to a SOCKSProxy instance, otherwise None.
|
187 | 187 | '''
|
188 |
| - host = self.env.tor_proxy_host |
189 |
| - if self.env.tor_proxy_port is None: |
190 |
| - ports = [9050, 9150, 1080] |
191 |
| - else: |
192 |
| - ports = [self.env.tor_proxy_port] |
| 188 | + path = self.env.tor_proxy_path |
| 189 | + if path is None: |
| 190 | + host = self.env.tor_proxy_host |
| 191 | + if self.env.tor_proxy_port is None: |
| 192 | + ports = [9050, 9150, 1080] |
| 193 | + else: |
| 194 | + ports = [self.env.tor_proxy_port] |
193 | 195 | while True:
|
194 |
| - self.logger.info(f'trying to detect proxy on "{host}" ' |
195 |
| - f'ports {ports}') |
196 |
| - proxy = await SOCKSProxy.auto_detect_at_host(host, ports, None) |
| 196 | + if path is None: |
| 197 | + self.logger.info(f'trying to detect proxy on "{host}" ' |
| 198 | + f'ports {ports}') |
| 199 | + proxy = await SOCKSProxy.auto_detect_at_host(host, ports, None) |
| 200 | + else: |
| 201 | + self.logger.info(f'trying to detect proxy on "{path}"') |
| 202 | + proxy = await SOCKSProxy.auto_detect_at_address(UnixAddress(path), None) |
197 | 203 | if proxy:
|
198 | 204 | self.proxy = proxy
|
199 | 205 | self.logger.info(f'detected {proxy}')
|
|
0 commit comments