mirror of
https://github.com/bisq-network/bisq.git
synced 2025-03-03 18:56:59 +01:00
tor: Support socksProxies from remote hosts
This commit is contained in:
parent
49bc7267b3
commit
32a0fc9888
3 changed files with 11 additions and 8 deletions
|
@ -69,7 +69,7 @@ public class NetworkNodeProvider implements Provider<NetworkNode> {
|
||||||
password,
|
password,
|
||||||
cookieFile,
|
cookieFile,
|
||||||
useSafeCookieAuthentication);
|
useSafeCookieAuthentication);
|
||||||
networkNode = new TorNetworkNode(port, networkProtoResolver, streamIsolation, torMode, banFilter, maxConnections);
|
networkNode = new TorNetworkNode(port, networkProtoResolver, streamIsolation, torMode, banFilter, maxConnections, controlHost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,8 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||||
public class TorNetworkNode extends NetworkNode {
|
public class TorNetworkNode extends NetworkNode {
|
||||||
private static final long SHUT_DOWN_TIMEOUT = 2;
|
private static final long SHUT_DOWN_TIMEOUT = 2;
|
||||||
|
|
||||||
|
private final String torControlHost;
|
||||||
|
|
||||||
private HiddenServiceSocket hiddenServiceSocket;
|
private HiddenServiceSocket hiddenServiceSocket;
|
||||||
private Timer shutDownTimeoutTimer;
|
private Timer shutDownTimeoutTimer;
|
||||||
private Tor tor;
|
private Tor tor;
|
||||||
|
@ -70,10 +72,11 @@ public class TorNetworkNode extends NetworkNode {
|
||||||
boolean useStreamIsolation,
|
boolean useStreamIsolation,
|
||||||
TorMode torMode,
|
TorMode torMode,
|
||||||
@Nullable BanFilter banFilter,
|
@Nullable BanFilter banFilter,
|
||||||
int maxConnections) {
|
int maxConnections, String torControlHost) {
|
||||||
super(servicePort, networkProtoResolver, banFilter, maxConnections);
|
super(servicePort, networkProtoResolver, banFilter, maxConnections);
|
||||||
this.torMode = torMode;
|
this.torMode = torMode;
|
||||||
this.streamIsolation = useStreamIsolation;
|
this.streamIsolation = useStreamIsolation;
|
||||||
|
this.torControlHost = torControlHost;
|
||||||
|
|
||||||
executor = SingleThreadExecutorUtils.getSingleThreadExecutor("StartTor");
|
executor = SingleThreadExecutorUtils.getSingleThreadExecutor("StartTor");
|
||||||
}
|
}
|
||||||
|
@ -98,7 +101,7 @@ public class TorNetworkNode extends NetworkNode {
|
||||||
checkArgument(peerNodeAddress.getHostName().endsWith(".onion"), "PeerAddress is not an onion address");
|
checkArgument(peerNodeAddress.getHostName().endsWith(".onion"), "PeerAddress is not an onion address");
|
||||||
// If streamId is null stream isolation gets deactivated.
|
// If streamId is null stream isolation gets deactivated.
|
||||||
// Hidden services use stream isolation by default, so we pass null.
|
// Hidden services use stream isolation by default, so we pass null.
|
||||||
return new TorSocket(peerNodeAddress.getHostName(), peerNodeAddress.getPort(), null);
|
return new TorSocket(peerNodeAddress.getHostName(), peerNodeAddress.getPort(), torControlHost, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Socks5Proxy getSocksProxy() {
|
public Socks5Proxy getSocksProxy() {
|
||||||
|
@ -112,7 +115,7 @@ public class TorNetworkNode extends NetworkNode {
|
||||||
|
|
||||||
if (socksProxy == null || streamIsolation) {
|
if (socksProxy == null || streamIsolation) {
|
||||||
tor = Tor.getDefault();
|
tor = Tor.getDefault();
|
||||||
socksProxy = tor != null ? tor.getProxy(stream) : null;
|
socksProxy = tor != null ? tor.getProxy(torControlHost, stream) : null;
|
||||||
}
|
}
|
||||||
return socksProxy;
|
return socksProxy;
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class TorNetworkNodeTest {
|
||||||
latch = new CountDownLatch(1);
|
latch = new CountDownLatch(1);
|
||||||
int port = 9001;
|
int port = 9001;
|
||||||
TorNetworkNode node1 = new TorNetworkNode(port, TestUtils.getNetworkProtoResolver(), false,
|
TorNetworkNode node1 = new TorNetworkNode(port, TestUtils.getNetworkProtoResolver(), false,
|
||||||
new NewTor(new File("torNode_" + port), null, "", this::getBridgeAddresses), null, 12);
|
new NewTor(new File("torNode_" + port), null, "", this::getBridgeAddresses), null, 12, "127.0.0.1");
|
||||||
node1.start(new SetupListener() {
|
node1.start(new SetupListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onTorNodeReady() {
|
public void onTorNodeReady() {
|
||||||
|
@ -83,7 +83,7 @@ public class TorNetworkNodeTest {
|
||||||
latch = new CountDownLatch(1);
|
latch = new CountDownLatch(1);
|
||||||
int port2 = 9002;
|
int port2 = 9002;
|
||||||
TorNetworkNode node2 = new TorNetworkNode(port2, TestUtils.getNetworkProtoResolver(), false,
|
TorNetworkNode node2 = new TorNetworkNode(port2, TestUtils.getNetworkProtoResolver(), false,
|
||||||
new NewTor(new File("torNode_" + port), null, "", this::getBridgeAddresses), null, 12);
|
new NewTor(new File("torNode_" + port), null, "", this::getBridgeAddresses), null, 12, "127.0.0.1");
|
||||||
node2.start(new SetupListener() {
|
node2.start(new SetupListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onTorNodeReady() {
|
public void onTorNodeReady() {
|
||||||
|
@ -141,7 +141,7 @@ public class TorNetworkNodeTest {
|
||||||
latch = new CountDownLatch(2);
|
latch = new CountDownLatch(2);
|
||||||
int port = 9001;
|
int port = 9001;
|
||||||
TorNetworkNode node1 = new TorNetworkNode(port, TestUtils.getNetworkProtoResolver(), false,
|
TorNetworkNode node1 = new TorNetworkNode(port, TestUtils.getNetworkProtoResolver(), false,
|
||||||
new NewTor(new File("torNode_" + port), null, "", this::getBridgeAddresses), null, 12);
|
new NewTor(new File("torNode_" + port), null, "", this::getBridgeAddresses), null, 12, "127.0.0.1");
|
||||||
node1.start(new SetupListener() {
|
node1.start(new SetupListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onTorNodeReady() {
|
public void onTorNodeReady() {
|
||||||
|
@ -167,7 +167,7 @@ public class TorNetworkNodeTest {
|
||||||
|
|
||||||
int port2 = 9002;
|
int port2 = 9002;
|
||||||
TorNetworkNode node2 = new TorNetworkNode(port2, TestUtils.getNetworkProtoResolver(), false,
|
TorNetworkNode node2 = new TorNetworkNode(port2, TestUtils.getNetworkProtoResolver(), false,
|
||||||
new NewTor(new File("torNode_" + port), null, "", this::getBridgeAddresses), null, 12);
|
new NewTor(new File("torNode_" + port), null, "", this::getBridgeAddresses), null, 12, "127.0.0.1");
|
||||||
node2.start(new SetupListener() {
|
node2.start(new SetupListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onTorNodeReady() {
|
public void onTorNodeReady() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue