From 7e3081ecd104d797df77a6f0db026309ce9c5908 Mon Sep 17 00:00:00 2001 From: faumaray Date: Thu, 25 Jun 2026 02:13:06 +0300 Subject: [PATCH] RPC info: detect public IP without the proxy getPublicIpAddress() ran the ipify/checkip/icanhazip/ifconfig probes through the shared proxied NetworkClient. That was wrong twice over: it returned the proxy's exit IP instead of the bot's reachable address (so the Desktop could not use it), and every probe died on the proxy CONNECT, hanging the !rpc command ~30s while it retried all four services. Always use a fresh, un-proxied client for public-IP detection. Co-Authored-By: Claude Opus 4.8 --- src/commands/RpcInfoCommand.cpp | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/commands/RpcInfoCommand.cpp b/src/commands/RpcInfoCommand.cpp index c421397..057071e 100644 --- a/src/commands/RpcInfoCommand.cpp +++ b/src/commands/RpcInfoCommand.cpp @@ -9,7 +9,7 @@ namespace Echoion::Core { - std::string getPublicIpAddress(Api::INetworkClient* shared) + std::string getPublicIpAddress() { // Try to get public IP from external services static std::string cachedIp; @@ -28,17 +28,15 @@ namespace Echoion::Core "https://api.ipify.org", "https://checkip.amazonaws.com", "https://icanhazip.com", "https://ifconfig.me/ip"}; - // Prefer the shared, already-initialized network client resolved from - // the service registry; only spin up a throwaway one as a fallback. - std::shared_ptr owned; - Api::INetworkClient* networkClient = shared; - if (!networkClient) { - owned = std::make_shared(); - if (!owned->initialize()) { - return cachedIp.empty() ? "127.0.0.1" : cachedIp; - } - networkClient = owned.get(); + // Public-IP detection must NOT go through the proxy: the Desktop needs + // the bot's own reachable address, not the proxy's exit IP, and routing + // these probes through the proxy is what made them fail (and hang the + // command retrying). Always use a fresh, un-proxied client. + auto owned = std::make_shared(); + if (!owned->initialize()) { + return cachedIp.empty() ? "127.0.0.1" : cachedIp; } + NetworkClient* networkClient = owned.get(); for (const auto& service : ipServices) { try { @@ -84,10 +82,9 @@ namespace Echoion::Core uint16_t rpcPort = networkConfig.rpcPort; std::string rpcBindAddress = networkConfig.rpcBindAddress; - // Determine the public IP to show, reusing the shared network client - // from the registry when available. - auto sharedNet = ctx.service(); - std::string publicIp = getPublicIpAddress(sharedNet.get()); + // Determine the public IP to show. This deliberately bypasses the proxy + // (see getPublicIpAddress) so it reports the bot's reachable address. + std::string publicIp = getPublicIpAddress(); // If bind address is not localhost, use it if (rpcBindAddress != "127.0.0.1" && rpcBindAddress != "localhost") {