Describe the bug
When a prior invocation of netremote-server exited unexpectedly, the DNS-SD registration may not have been unregistered. In such cases, the next execution of netremote-server will complain that DNS-SD registration failed per below:
Netremote server starting (log level=info)
...
Netremote server started listening on 0.0.0.0:5047
Starting discovery service
Starting systemd-resolved DNS-SD service registration
Failed to register DNS-SD service with systemd-resolved: [org.freedesktop.resolve1.DnssdServiceExists] DNS-SD service 'netremote' exists already
Failed to register new DNS-SD service on dbus
The code ignores this assuming it is fine. In most cases it will be, however, if the new netremote-server execution was bound to a different IP address, then the DNS-SD registration would need to be replaced.
Steps To Reproduce
Steps to reproduce the behavior:
- Start
netremote-server with no arguments.
- Forcibly kill the
netremote server process (eg. kill -9 $(pidof netremote-server)).
- Start
netremote-server with no arguments.
Expected behavior
Any old DNS-SD registration is removed, and replaced with an updated one. No error messages regarding DNS-SD are observed in the log.
Actual behavior
Error messages about failing to register DNS-SD appear, quoting existing registration. DNS-SD registration is not updated.
Screenshots

Proposed Fix
ResolvedDnssd::RegisterService should first check if any registration(s) for the supplied serviceName argument exist. If they do, they should be unregistered by calling the ResolvedDnssd::UnregisterService function with the object path of the existing DNS-SD registration.
Describe the bug
When a prior invocation of netremote-server exited unexpectedly, the DNS-SD registration may not have been unregistered. In such cases, the next execution of
netremote-serverwill complain that DNS-SD registration failed per below:Netremote server starting (log level=info) ... Netremote server started listening on 0.0.0.0:5047 Starting discovery service Starting systemd-resolved DNS-SD service registration Failed to register DNS-SD service with systemd-resolved: [org.freedesktop.resolve1.DnssdServiceExists] DNS-SD service 'netremote' exists already Failed to register new DNS-SD service on dbusThe code ignores this assuming it is fine. In most cases it will be, however, if the new
netremote-serverexecution was bound to a different IP address, then the DNS-SD registration would need to be replaced.Steps To Reproduce
Steps to reproduce the behavior:
netremote-serverwith no arguments.netremote serverprocess (eg.kill -9 $(pidof netremote-server)).netremote-serverwith no arguments.Expected behavior
Any old DNS-SD registration is removed, and replaced with an updated one. No error messages regarding DNS-SD are observed in the log.
Actual behavior
Error messages about failing to register DNS-SD appear, quoting existing registration. DNS-SD registration is not updated.
Screenshots

Proposed Fix
ResolvedDnssd::RegisterServiceshould first check if any registration(s) for the suppliedserviceNameargument exist. If they do, they should be unregistered by calling theResolvedDnssd::UnregisterServicefunction with the object path of the existing DNS-SD registration.