mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Make use of address candidates in Hotspot credentials.
PiperOrigin-RevId: 830572287
This commit is contained in:
committed by
Copybara-Service
parent
35a42d4d31
commit
e49fe76dc5
@@ -29,7 +29,6 @@
|
||||
#include "internal/platform/cancellation_flag_listener.h"
|
||||
#include "internal/platform/exception.h"
|
||||
#include "internal/platform/implementation/wifi_hotspot.h"
|
||||
#include "internal/platform/implementation/wifi_utils.h"
|
||||
#include "internal/platform/logging.h"
|
||||
#include "internal/platform/medium_environment.h"
|
||||
#include "internal/platform/prng.h"
|
||||
@@ -219,9 +218,8 @@ std::unique_ptr<api::WifiHotspotSocket> WifiHotspotMedium::ConnectToService(
|
||||
// First, find an instance of remote medium, that exposed this service.
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
auto* remote_medium = static_cast<WifiHotspotMedium*>(
|
||||
env.GetWifiHotspotMedium({}, WifiUtils::GetHumanReadableIpAddress(
|
||||
{service_address.address.data(),
|
||||
service_address.address.size()})));
|
||||
env.GetWifiHotspotMedium({}, std::string(service_address.address.begin(),
|
||||
service_address.address.end())));
|
||||
if (remote_medium == nullptr) {
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <exception>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -86,8 +87,18 @@ void WifiHotspotServerSocket::PopulateHotspotCredentials(
|
||||
"addresses configured on computer.";
|
||||
return;
|
||||
}
|
||||
hotspot_credentials.SetGateway(hotspot_ipaddr);
|
||||
hotspot_credentials.SetPort(GetPort());
|
||||
std::vector<char> hotspot_ipaddr_bytes;
|
||||
uint32_t address_int = inet_addr(hotspot_ipaddr.c_str());
|
||||
if (address_int != INADDR_NONE) {
|
||||
hotspot_ipaddr_bytes.resize(4);
|
||||
std::memcpy(hotspot_ipaddr_bytes.data(),
|
||||
reinterpret_cast<char*>(&address_int), 4);
|
||||
}
|
||||
ServiceAddress service_address = {
|
||||
.address = hotspot_ipaddr_bytes,
|
||||
.port = static_cast<uint16_t>(GetPort()),
|
||||
};
|
||||
hotspot_credentials.SetAddressCandidates({service_address});
|
||||
}
|
||||
|
||||
bool WifiHotspotServerSocket::Listen(int port, bool dual_stack) {
|
||||
|
||||
Reference in New Issue
Block a user