isRunning static method

Future<bool> isRunning()

Checks whether the proxy server is currently reachable.

Returns true if a TCP connection to the proxy succeeds, false otherwise. This can be used to decide whether restart is needed (e.g., after returning from background).

Implementation

static Future<bool> isRunning() async {
  if (!_initialized) return false;
  try {
    final socket = await Socket.connect(
      Config.ip,
      Config.port,
      timeout: Duration(seconds: 1),
    );
    socket.destroy();
    return true;
  } catch (_) {
    return false;
  }
}