Skip to content

Commit

Permalink
Merge pull request #2628 from bisq-network/only_whonix_bind_server_to…
Browse files Browse the repository at this point in the history
…_all_interfaces

Only bind servers to all interfaces on Whonix
  • Loading branch information
HenrikJannsen authored Aug 17, 2024
2 parents 7152b66 + 82e15b9 commit ad59985
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions network/tor/tor/src/main/java/bisq/tor/TorService.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

import java.io.File;
import java.io.IOException;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.file.Path;
Expand Down Expand Up @@ -128,11 +130,13 @@ public CompletableFuture<ServerSocket> createOnionService(int port, TorKeyPair t
log.info("Start hidden service with port {}", port);
long ts = System.currentTimeMillis();
try {
var localServerSocket = new ServerSocket(RANDOM_PORT);
int localPort = localServerSocket.getLocalPort();
InetAddress bindAddress = !LinuxDistribution.isWhonix() ? Inet4Address.getLoopbackAddress()
: Inet4Address.getByName("0.0.0.0");
var localServerSocket = new ServerSocket(RANDOM_PORT, 50, bindAddress);

String onionAddress = torKeyPair.getOnionAddress();
if (!publishedOnionServices.contains(onionAddress)) {
int localPort = localServerSocket.getLocalPort();
torController.publish(torKeyPair, port, localPort);
publishedOnionServices.add(onionAddress);
}
Expand Down

0 comments on commit ad59985

Please sign in to comment.