From 57c8c9a6e8d5412a2f6a62b88583a1150689473d Mon Sep 17 00:00:00 2001 From: Hugo Delaunay Date: Tue, 9 Jan 2024 11:00:17 +0100 Subject: [PATCH] fix(windows): Fixed broadcast hostnames not being used. --- packages/bonsoir_windows/windows/bonsoir_broadcast.cpp | 10 ++-------- packages/bonsoir_windows/windows/utilities.cpp | 5 ----- packages/bonsoir_windows/windows/utilities.h | 2 -- 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/packages/bonsoir_windows/windows/bonsoir_broadcast.cpp b/packages/bonsoir_windows/windows/bonsoir_broadcast.cpp index d958df03..da80dd87 100644 --- a/packages/bonsoir_windows/windows/bonsoir_broadcast.cpp +++ b/packages/bonsoir_windows/windows/bonsoir_broadcast.cpp @@ -35,16 +35,10 @@ namespace bonsoir_windows { propertyKeys.push_back(nullptr); propertyValues.push_back(nullptr); - PIP4_ADDRESS ipAddress = nullptr; - if (servicePtr->host.has_value() && isValidIPv4(servicePtr->host.value())) { - DWORD ip = std::stoul(servicePtr->host.value()); - ipAddress = &ip; - } - - auto computerHost = (getComputerName() + L".local"); + std::wstring host = servicePtr->host.has_value() ? toUtf16(servicePtr->host.value()) : (getComputerName() + L".local"); PDNS_SERVICE_INSTANCE serviceInstance = DnsServiceConstructInstance( toUtf16(servicePtr->name + "." + servicePtr->type + ".local").c_str(), - computerHost.c_str(), + host.c_str(), nullptr, nullptr, static_cast(servicePtr->port), diff --git a/packages/bonsoir_windows/windows/utilities.cpp b/packages/bonsoir_windows/windows/utilities.cpp index a1f4df63..9374b721 100644 --- a/packages/bonsoir_windows/windows/utilities.cpp +++ b/packages/bonsoir_windows/windows/utilities.cpp @@ -73,9 +73,4 @@ namespace bonsoir_windows { } return &computerName[0]; } - - bool isValidIPv4(const std::string &ipAddress) { - const std::regex ipv4Regex(R"(\b(?:\d{1,3}\.){3}\d{1,3}\b)"); - return std::regex_match(ipAddress, ipv4Regex); - } } // namespace bonsoir_windows \ No newline at end of file diff --git a/packages/bonsoir_windows/windows/utilities.h b/packages/bonsoir_windows/windows/utilities.h index 91dccde2..0e2c6e2e 100644 --- a/packages/bonsoir_windows/windows/utilities.h +++ b/packages/bonsoir_windows/windows/utilities.h @@ -9,6 +9,4 @@ namespace bonsoir_windows { std::tuple parseBonjourFqdn(const std::string fqdn); std::wstring getComputerName(); - - bool isValidIPv4(const std::string &ipAddress); } // namespace bonsoir_windows \ No newline at end of file