Skip to content

Commit

Permalink
zeroconf gives us 'text' records using byte strings
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Jul 11, 2024
1 parent 3eca141 commit 14bd959
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions xpra/client/gtk3/mdns_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from xpra.client.gtk3.sessions_gui import SessionsGUI
from xpra.net.mdns import XPRA_TCP_MDNS_TYPE, XPRA_UDP_MDNS_TYPE, get_listener_class
from xpra.os_util import bytestostr
from xpra.util import envbool
from xpra.log import Logger

Expand Down Expand Up @@ -63,18 +64,21 @@ def mdns_add(self, interface, protocol, name, stype, domain, host, address, port
log("mdns_add%s", (interface, protocol, name, stype, domain, host, address, port, text))
if HIDE_IPV6 and address.find(":")>=0:
return
text = text or {}
# text record may be received as byte strings...
text_rec = {}
if text:
for key, value in text.items():
text_rec[bytestostr(key)] = bytestostr(value)
#strip service from hostname:
#(win32 servers add it? why!?)
if host:
if stype and host.endswith(stype):
host = host[:-len(stype)]
elif stype and domain and host.endswith(stype+"."+domain):
host = host[:-len(stype+"."+domain)]
if text:
mode = text.get("mode")
if mode and host.endswith(mode+"."):
host = host[:-len(mode+".")]
mode = text.get("mode")
if mode and host.endswith(mode+"."):
host = host[:-len(mode+".")]
if host.endswith(".local."):
host = host[:-len(".local.")]
self.records.append((interface, protocol, name, stype, domain, host, address, port, text))
Expand Down

0 comments on commit 14bd959

Please sign in to comment.