Separate out GetExternalIPAddress helper function

De-duplicates the two inline implementations and prepares it for use from Android.
This commit is contained in:
Tom Pratt authored and Tom Pratt committed 2026-05-19 12:03:00 +02:00
1 parent 6655672ee3
commit eb02680cb6
4 files changed
+22 -22

No files matched your search

@@ -30,7 +30,7 @@
#endif
#include "Common/Config/Config.h"
#include "Common/HttpRequest.h"
#include "Core/NetPlayCommon.h"
#include "Common/Logging/Log.h"
#include "Common/TraversalClient.h"
@@ -550,17 +550,8 @@ void NetPlayDialog::show(std::string nickname, bool use_traversal)
void NetPlayDialog::ResetExternalIP()
{
m_external_ip_address = Common::Lazy<std::string>([]() -> std::string {
Common::HttpRequest request;
// ENet does not support IPv6, so IPv4 has to be used
request.UseIPv4();
Common::HttpRequest::Response response =
request.Get("https://ip.dolphin-emu.org/", {{"X-Is-Dolphin", "1"}});
if (response.has_value())
return std::string(response->begin(), response->end());
return "";
});
m_external_ip_address =
Common::Lazy<std::string>([]() -> std::string { return NetPlay::GetExternalIPAddress(); });
}
void NetPlayDialog::UpdateDiscordPresence()