From 67ec926cf41154beac5be93a4c9f6eb489597b5c Mon Sep 17 00:00:00 2001 From: Lasan Mahaliyana Date: Wed, 11 Mar 2026 23:42:30 +0530 Subject: [PATCH] fixed failing to connect to android wifi hotspot --- .../platform/implementation/linux/wifi_hotspot.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/internal/platform/implementation/linux/wifi_hotspot.h b/internal/platform/implementation/linux/wifi_hotspot.h index 549a3fef..f11c26ad 100644 --- a/internal/platform/implementation/linux/wifi_hotspot.h +++ b/internal/platform/implementation/linux/wifi_hotspot.h @@ -15,6 +15,8 @@ #ifndef PLATFORM_IMPL_LINUX_WIFI_HOTSPOT_H_ #define PLATFORM_IMPL_LINUX_WIFI_HOTSPOT_H_ +#include + #include #include @@ -43,9 +45,17 @@ class NetworkManagerWifiHotspotMedium : public api::WifiHotspotMedium { virtual std::unique_ptr ConnectToService( const ServiceAddress& service_address, CancellationFlag* cancellation_flag) { - return ConnectToService( - std::string(service_address.address.begin(), service_address.address.end()) - , service_address.port, cancellation_flag) ; + if (service_address.address.size() != 4) { + return nullptr; + } + char ip_address_buffer[INET_ADDRSTRLEN] = {}; + if (inet_ntop(AF_INET, service_address.address.data(), + ip_address_buffer, sizeof(ip_address_buffer)) == nullptr) { + return nullptr; + } + + return ConnectToService(ip_address_buffer, service_address.port, + cancellation_flag); }; std::unique_ptr ConnectToService( absl::string_view ip_address, int port,