Don't use tor proxy for localhost connections (#3500)

This commit is contained in:
benthecarman 2021-08-07 14:36:33 -05:00 committed by GitHub
parent 4f7b6422ea
commit 8979ac2932
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 8 deletions

View File

@ -333,13 +333,17 @@ trait Client
private lazy val httpConnectionPoolSettings: ConnectionPoolSettings =
instance.proxyParams match {
case Some(proxyParams) =>
val socks5ClientTransport = new Socks5ClientTransport(proxyParams)
val host = instance.rpcUri.getHost
if (!host.contains("localhost") && !host.contains("127.0.0.1")) {
val socks5ClientTransport = new Socks5ClientTransport(proxyParams)
val clientConnectionSettings =
ClientConnectionSettings(system).withTransport(socks5ClientTransport)
val clientConnectionSettings =
ClientConnectionSettings(system).withTransport(
socks5ClientTransport)
ConnectionPoolSettings(system).withConnectionSettings(
clientConnectionSettings)
ConnectionPoolSettings(system).withConnectionSettings(
clientConnectionSettings)
} else ConnectionPoolSettings(system)
case None => ConnectionPoolSettings(system)
}

View File

@ -102,9 +102,16 @@ case class P2PClientActor(
val (peerOrProxyAddress, proxyParams) =
peer.socks5ProxyParams match {
case Some(proxyParams) =>
val proxyAddress = proxyParams.address
logger.info(s"connecting to SOCKS5 proxy $proxyAddress")
(proxyAddress, Some(proxyParams))
val host = peer.socket.getHostName
if (!host.contains("localhost") && !host.contains("127.0.0.1")) {
val proxyAddress = proxyParams.address
logger.info(s"connecting to SOCKS5 proxy $proxyAddress")
(proxyAddress, Some(proxyParams))
} else {
val remoteAddress = peer.socket
logger.info(s"connecting to $remoteAddress")
(peer.socket, None)
}
case None =>
val remoteAddress = peer.socket
logger.info(s"connecting to $remoteAddress")