Skip to content

Commit

Permalink
kdeconnect: Disable built-in mDNS announce
Browse files Browse the repository at this point in the history
**Summary**

Disable built-in mDNS announce as it conflicts with Avahi or systemd-resolved.
Provide a systemd-resolved service definition so Solus devices can still be discovered.
  • Loading branch information
silkeh committed Oct 24, 2024
1 parent 0c249ab commit 816a529
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
From 1005b8157c2060ef5d97aef39085c6b6be2bdda3 Mon Sep 17 00:00:00 2001
From: Silke Hofstra <[email protected]>
Date: Sun, 8 Sep 2024 21:13:33 +0200
Subject: [PATCH] Allow disabling of mDNS announcer

Add a CMAKE flag to allow for disabling the mDNS announcer.
This allows for KDE connect to run next to existing announcers like Avahi and Systemd Resolved.
---
core/CMakeLists.txt | 4 ++++
core/backends/lan/lanlinkprovider.cpp | 6 +++++-
core/backends/lan/mdnsdiscovery.cpp | 15 +++++++++++----
core/backends/lan/mdnsdiscovery.h | 3 ++-
4 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
index 613c738d..2d788c6d 100644
--- a/core/CMakeLists.txt
+++ b/core/CMakeLists.txt
@@ -8,6 +8,7 @@ set(KDECONNECT_PRIVATE_DBUS_NAME DBusKDEConnectOnly)
configure_file(dbushelper.h.in ${CMAKE_CURRENT_BINARY_DIR}/dbushelper.h)

option(MDNS_ENABLED "Use MDNS for device discovery" ON)
+option(MDNS_ANNOUNCE "Enable the mDNS announcer" ON)

add_subdirectory(backends/lan)
add_subdirectory(backends/loopback)
@@ -83,6 +84,9 @@ endif()

if (MDNS_ENABLED)
target_compile_definitions(kdeconnectcore PRIVATE -DKDECONNECT_MDNS)
+ if (MDNS_ANNOUNCE)
+ target_compile_definitions(kdeconnectcore PRIVATE -DKDECONNECT_MDNS_ANNOUNCE)
+ endif()
endif()

set_target_properties(kdeconnectcore PROPERTIES
diff --git a/core/backends/lan/lanlinkprovider.cpp b/core/backends/lan/lanlinkprovider.cpp
index 292adffd..b034917a 100644
--- a/core/backends/lan/lanlinkprovider.cpp
+++ b/core/backends/lan/lanlinkprovider.cpp
@@ -49,7 +49,11 @@ LanLinkProvider::LanLinkProvider(bool testMode)
, m_testMode(testMode)
, m_combineNetworkChangeTimer(this)
#ifdef KDECONNECT_MDNS
- , m_mdnsDiscovery(this)
+#ifdef MDNS_ANNOUNCE
+ , m_mdnsDiscovery(this, true)
+#else
+ , m_mdnsDiscovery(this, false)
+#endif
#endif
{
m_combineNetworkChangeTimer.setInterval(0); // increase this if waiting a single event-loop iteration is not enough
diff --git a/core/backends/lan/mdnsdiscovery.cpp b/core/backends/lan/mdnsdiscovery.cpp
index 43acb5b4..2a59ed04 100644
--- a/core/backends/lan/mdnsdiscovery.cpp
+++ b/core/backends/lan/mdnsdiscovery.cpp
@@ -14,10 +14,11 @@

const QString kServiceType = QStringLiteral("_kdeconnect._udp.local");

-MdnsDiscovery::MdnsDiscovery(LanLinkProvider *lanLinkProvider)
+MdnsDiscovery::MdnsDiscovery(LanLinkProvider *lanLinkProvider, bool announce)
: mdnsAnnouncer(KdeConnectConfig::instance().deviceId(), kServiceType, LanLinkProvider::UDP_PORT)
{
KdeConnectConfig &config = KdeConnectConfig::instance();
+ m_announce = announce;
mdnsAnnouncer.putTxtRecord(QStringLiteral("id"), config.deviceId());
mdnsAnnouncer.putTxtRecord(QStringLiteral("name"), config.name());
mdnsAnnouncer.putTxtRecord(QStringLiteral("type"), config.deviceType().toString());
@@ -40,19 +41,25 @@ MdnsDiscovery::~MdnsDiscovery()

void MdnsDiscovery::onStart()
{
- mdnsAnnouncer.startAnnouncing();
+ if (m_announce) {
+ mdnsAnnouncer.startAnnouncing();
+ }
mdnsDiscoverer.startDiscovering(kServiceType);
}

void MdnsDiscovery::onStop()
{
- mdnsAnnouncer.stopAnnouncing();
+ if (m_announce) {
+ mdnsAnnouncer.stopAnnouncing();
+ }
mdnsDiscoverer.stopDiscovering();
}

void MdnsDiscovery::onNetworkChange()
{
- mdnsAnnouncer.onNetworkChange();
+ if (m_announce) {
+ mdnsAnnouncer.onNetworkChange();
+ }
mdnsDiscoverer.stopDiscovering();
mdnsDiscoverer.startDiscovering(kServiceType);
}
diff --git a/core/backends/lan/mdnsdiscovery.h b/core/backends/lan/mdnsdiscovery.h
index f48cb00c..4a964676 100644
--- a/core/backends/lan/mdnsdiscovery.h
+++ b/core/backends/lan/mdnsdiscovery.h
@@ -20,7 +20,7 @@ class KDECONNECTCORE_EXPORT MdnsDiscovery : public QObject
Q_OBJECT

public:
- explicit MdnsDiscovery(LanLinkProvider *parent);
+ explicit MdnsDiscovery(LanLinkProvider *parent, bool announce);
~MdnsDiscovery();

void onStart();
@@ -30,6 +30,7 @@ public Q_SLOTS:
void onNetworkChange();

private:
+ bool m_announce;
MdnsWrapper::Discoverer mdnsDiscoverer;
MdnsWrapper::Announcer mdnsAnnouncer;
};
--
2.47.0

3 changes: 3 additions & 0 deletions packages/k/kdeconnect/files/kdeconnect.dnssd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[Service]
Name=%H
Type=_kdeconnect._udp
12 changes: 0 additions & 12 deletions packages/k/kdeconnect/files/openssh-8.2-fix.patch

This file was deleted.

12 changes: 1 addition & 11 deletions packages/k/kdeconnect/files/series
Original file line number Diff line number Diff line change
@@ -1,11 +1 @@
0001-do-not-ignore-ssl-errors.patch
0002-do-not-leak-local-user.patch
0003-fix-use-after-free-in-lanlink.patch
0004-limit-identity-packets.patch
0005-do-not-let-lanlink-connections-stay-open.patch
0006-dont-brute-force-reading-the-socket.patch
0007-limit-number-of-connected-sockets.patch
0008-do-not-remember-more-than-a-few-identity-packets.patch
0009-limit-the-ports.patch
0010-do-not-replace-connections.patch
openssh-8.2-fix.patch
0001-Allow-disabling-of-mDNS-announcer.patch
13 changes: 10 additions & 3 deletions packages/k/kdeconnect/package.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name : kdeconnect

Check notice on line 1 in packages/k/kdeconnect/package.yml

View workflow job for this annotation

GitHub Actions / Checks

This package is included in the ISO. Consider validating the functionality in a newly built ISO.
version : 24.08.2
release : 79
release : 80
source :
- https://download.kde.org/stable/release-service/24.08.2/src/kdeconnect-kde-24.08.2.tar.xz : d7178d96b445ef660923f305a90fc6aecccae4049cc99a39ee6c17ac0bf51c69
homepage : https://kdeconnect.kde.org/
Expand Down Expand Up @@ -44,14 +44,21 @@ optimize :
- speed
- thin-lto
setup : |
# https://bugs.kde.org/show_bug.cgi?id=481870
%cmake_kf6 -DBLUETOOTH_ENABLED=OFF
# Bluetooth: https://bugs.kde.org/show_bug.cgi?id=481870
# mDNS: https://bugs.kde.org/show_bug.cgi?id=487719
# https://invent.kde.org/network/kdeconnect-kde/-/merge_requests/720
%cmake_kf6 \
-DBLUETOOTH_ENABLED=OFF \
-DMDNS_ANNOUNCE=OFF
build : |
%ninja_build
install : |
%ninja_install
%qml6_cache
# Install mDNS service definition for autodiscovery
install -Dm0644 -t $installdir/usr/lib/systemd/dnssd $pkgfiles/*.dnssd
# remove doc
rm -rfv $installdir/usr/share/doc
Expand Down
13 changes: 7 additions & 6 deletions packages/k/kdeconnect/pspec_x86_64.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<Name>kdeconnect</Name>
<Homepage>https://kdeconnect.kde.org/</Homepage>
<Packager>
<Name>Reilly Brogan</Name>
<Email>[email protected]</Email>
<Name>Silke Hofstra</Name>
<Email>[email protected]</Email>
</Packager>
<License>GPL-2.0-or-later</License>
<PartOf>desktop.kde</PartOf>
Expand All @@ -27,6 +27,7 @@
<Path fileType="executable">/usr/bin/kdeconnect-settings</Path>
<Path fileType="executable">/usr/bin/kdeconnect-sms</Path>
<Path fileType="executable">/usr/bin/kdeconnectd</Path>
<Path fileType="library">/usr/lib/systemd/dnssd/kdeconnect.dnssd</Path>
<Path fileType="library">/usr/lib64/libkdeconnectcore.so.24</Path>
<Path fileType="library">/usr/lib64/libkdeconnectcore.so.24.08.2</Path>
<Path fileType="library">/usr/lib64/libkdeconnectpluginkcm.so.24</Path>
Expand Down Expand Up @@ -932,12 +933,12 @@
</Files>
</Package>
<History>
<Update release="79">
<Date>2024-10-19</Date>
<Update release="80">
<Date>2024-10-24</Date>
<Version>24.08.2</Version>
<Comment>Packaging update</Comment>
<Name>Reilly Brogan</Name>
<Email>[email protected]</Email>
<Name>Silke Hofstra</Name>
<Email>[email protected]</Email>
</Update>
</History>
</PISI>

0 comments on commit 816a529

Please sign in to comment.