mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-05-19 13:58:37 -04:00
Fix app running check [stage]
This commit is contained in:
@@ -5,11 +5,13 @@ import io.xpipe.core.FilePath;
|
||||
import io.xpipe.core.OsType;
|
||||
import io.xpipe.core.XPipeDaemonMode;
|
||||
import io.xpipe.core.XPipeInstallation;
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.Inet4Address;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.util.List;
|
||||
|
||||
@@ -18,14 +20,25 @@ import java.util.List;
|
||||
*/
|
||||
public class BeaconServer {
|
||||
|
||||
@SneakyThrows
|
||||
public static boolean isReachable(int port) {
|
||||
var local = Inet4Address.getByAddress(new byte[]{0x7f, 0x00, 0x00, 0x01});
|
||||
|
||||
try (var socket = new Socket()) {
|
||||
socket.connect(
|
||||
new InetSocketAddress(Inet4Address.getByAddress(new byte[] {0x7f, 0x00, 0x00, 0x01}), port), 5000);
|
||||
return true;
|
||||
InetSocketAddress adress = new InetSocketAddress(local, port);
|
||||
socket.connect(adress, 5000);
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If there's some kind of networking tool interfering with sockets by for example proxying socket connections
|
||||
// The previous connect might succeed even though nothing is running.
|
||||
// To be sure, check that the socket is indeed occupied
|
||||
try (var ignored = new ServerSocket(port, 0, local)) {
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static List<String> toProcessCommand(String toExec) {
|
||||
|
||||
1
dist/changelogs/17.0.md
vendored
1
dist/changelogs/17.0.md
vendored
@@ -145,3 +145,4 @@ The HTTP API has been improved in various areas. The action system is integrated
|
||||
- Fix text color on hover having low contrast in some themes
|
||||
- Fix connection search freezing on Ubuntu systems with LXD snap stub installed
|
||||
- Fix freeze after waking up the local system from a long hibernation
|
||||
- Fix application not starting up if some antivirus interfered with local socket connections
|
||||
|
||||
Reference in New Issue
Block a user