diff --git a/app/src/main/java/io/xpipe/app/beacon/AppBeaconServer.java b/app/src/main/java/io/xpipe/app/beacon/AppBeaconServer.java index 02b42f1e1..be4e4d8cd 100644 --- a/app/src/main/java/io/xpipe/app/beacon/AppBeaconServer.java +++ b/app/src/main/java/io/xpipe/app/beacon/AppBeaconServer.java @@ -1,5 +1,7 @@ package io.xpipe.app.beacon; +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpServer; import io.xpipe.app.core.AppResources; import io.xpipe.app.issue.ErrorEvent; import io.xpipe.app.issue.TrackEvent; @@ -8,13 +10,10 @@ import io.xpipe.beacon.BeaconConfig; import io.xpipe.beacon.BeaconInterface; import io.xpipe.core.process.OsType; import io.xpipe.core.util.XPipeInstallation; - -import com.sun.net.httpserver.HttpExchange; -import com.sun.net.httpserver.HttpServer; import lombok.Getter; import java.io.IOException; -import java.net.InetAddress; +import java.net.Inet4Address; import java.net.InetSocketAddress; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -127,7 +126,7 @@ public class AppBeaconServer { } private void start() throws IOException { - server = HttpServer.create(new InetSocketAddress(InetAddress.getLoopbackAddress(), port), 10); + server = HttpServer.create(new InetSocketAddress(Inet4Address.getByAddress(new byte[]{ 0x7f,0x00,0x00,0x01 }), port), 10); BeaconInterface.getAll().forEach(beaconInterface -> { server.createContext(beaconInterface.getPath(), new BeaconRequestHandler<>(beaconInterface)); }); diff --git a/beacon/src/main/java/io/xpipe/beacon/BeaconClient.java b/beacon/src/main/java/io/xpipe/beacon/BeaconClient.java index 26867ef94..16dbbec7e 100644 --- a/beacon/src/main/java/io/xpipe/beacon/BeaconClient.java +++ b/beacon/src/main/java/io/xpipe/beacon/BeaconClient.java @@ -64,7 +64,8 @@ public class BeaconClient { var client = HttpClient.newHttpClient(); HttpResponse response; try { - var uri = URI.create("http://localhost:" + port + prov.getPath()); + // Use direct IP to prevent DNS lookups and potential blocks (e.g. portmaster) + var uri = URI.create("http://127.0.0.1:" + port + prov.getPath()); var builder = HttpRequest.newBuilder(); if (token != null) { builder.header("Authorization", "Bearer " + token); diff --git a/beacon/src/main/java/io/xpipe/beacon/BeaconServer.java b/beacon/src/main/java/io/xpipe/beacon/BeaconServer.java index 3de5f910b..838058c45 100644 --- a/beacon/src/main/java/io/xpipe/beacon/BeaconServer.java +++ b/beacon/src/main/java/io/xpipe/beacon/BeaconServer.java @@ -8,7 +8,7 @@ import io.xpipe.core.util.XPipeInstallation; import java.io.BufferedReader; import java.io.InputStreamReader; -import java.net.InetAddress; +import java.net.Inet4Address; import java.net.InetSocketAddress; import java.net.Socket; import java.util.List; @@ -20,7 +20,7 @@ public class BeaconServer { public static boolean isReachable(int port) { try (var socket = new Socket()) { - socket.connect(new InetSocketAddress(InetAddress.getLoopbackAddress(), port), 5000); + socket.connect(new InetSocketAddress(Inet4Address.getByAddress(new byte[]{ 0x7f,0x00,0x00,0x01 }), port), 5000); return true; } catch (Exception e) { return false;