Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavide Beatrici <git@davidebeatrici.dev>2020-09-22 08:36:43 +0300
committerDavide Beatrici <git@davidebeatrici.dev>2020-09-22 08:36:43 +0300
commitee731f8405caf42d22a92c8784809f0bc4bb1ad3 (patch)
treef0271a452c931201e7204c69e1b020aff771b3ff /src/murmur/Zeroconf.h
parent6a59ae2443b25942e8460980290e7cdfaf13c87e (diff)
FEAT(client, server): use native mDNS/DNS-SD API on Windows, if available
This allows: - The client to find servers advertized via zeroconf without the need for Bonjour to be installed. - The server to advertize itself via zeroconf without the need for Bonjour to be installed. The Win32 API was introduced in the version 10.0.18362.0 (1903/19H1) of Windows SDK. Before that, only the UWP interface was available (introduced in Windows 10 1507). This commit was successfully tested on Windows 10 1809, which probably means that the API can be used on previous versions as well. Even if that isn't the case, it's not a problem: if the code fails to load the required symbols, it falls back to Bonjour. "Q_OS_WIN64" is used instead of "Q_OS_WIN" because of an issue that appears when certain DNS functions are used in an x86 (32 bit) build: https://developercommunity.visualstudio.com/content/problem/1191345/some-dns-api-functions-cause-lnk2019-errors-in-32.html This means that until the issue is fixed we can safely use the native mDNS-DNS-SD API only on x86_64 (64 bit).
Diffstat (limited to 'src/murmur/Zeroconf.h')
-rw-r--r--src/murmur/Zeroconf.h28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/murmur/Zeroconf.h b/src/murmur/Zeroconf.h
index cc92f1443..598897735 100644
--- a/src/murmur/Zeroconf.h
+++ b/src/murmur/Zeroconf.h
@@ -6,19 +6,39 @@
#ifndef MUMBLE_MURMUR_ZEROCONF_H_
#define MUMBLE_MURMUR_ZEROCONF_H_
-#include <QtCore/QObject>
+#include "BonjourServiceRegister.h"
-class BonjourServiceRegister;
+#include <memory>
+
+#ifdef Q_OS_WIN64
+# include <windns.h>
+#endif
class Zeroconf : public QObject {
private:
Q_OBJECT
Q_DISABLE_COPY(Zeroconf)
+protected:
+ bool m_ok;
+ std::unique_ptr< BonjourServiceRegister > m_helper;
+#ifdef Q_OS_WIN64
+ std::unique_ptr< DNS_SERVICE_CANCEL > m_cancel;
+ std::unique_ptr< DNS_SERVICE_REGISTER_REQUEST > m_request;
+
+ static void WINAPI callbackRegisterComplete(const DWORD status, void *context, DNS_SERVICE_INSTANCE *instance);
+#endif
+ void helperError(const DNSServiceErrorType error);
+
public:
+ inline bool isOk() const { return m_ok; }
+
+ void resetHelper();
+
+ bool registerService(const BonjourRecord &record, const uint16_t port);
+ bool unregisterService();
+
Zeroconf();
~Zeroconf();
-
- BonjourServiceRegister *bsrRegister;
};
#endif