Skip to content

Commit 558cec3

Browse files
authored
Use constant for service type enumeration (#461)
1 parent ceb0def commit 558cec3

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

zeroconf/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@
183183
_TCP_PROTOCOL_LOCAL_TRAILER = '._tcp.local.'
184184
_NONTCP_PROTOCOL_LOCAL_TRAILER = '._udp.local.'
185185

186+
# https://datatracker.ietf.org/doc/html/rfc6763#section-9
187+
_SERVICE_TYPE_ENUMERATION_NAME = "_services._dns-sd._udp.local."
188+
186189
try:
187190
_IPPROTO_IPV6 = socket.IPPROTO_IPV6
188191
except AttributeError:
@@ -2191,7 +2194,7 @@ def find(
21912194
"""
21922195
local_zc = zc or Zeroconf(interfaces=interfaces, ip_version=ip_version)
21932196
listener = cls()
2194-
browser = ServiceBrowser(local_zc, '_services._dns-sd._udp.local.', listener=listener)
2197+
browser = ServiceBrowser(local_zc, _SERVICE_TYPE_ENUMERATION_NAME, listener=listener)
21952198

21962199
# wait for responses
21972200
time.sleep(timeout)
@@ -2960,12 +2963,12 @@ def handle_query( # pylint: disable=too-many-branches
29602963

29612964
for question in msg.questions:
29622965
if question.type == _TYPE_PTR:
2963-
if question.name == "_services._dns-sd._udp.local.":
2966+
if question.name == _SERVICE_TYPE_ENUMERATION_NAME:
29642967
for stype in self.registry.get_types():
29652968
out.add_answer(
29662969
msg,
29672970
DNSPointer(
2968-
"_services._dns-sd._udp.local.",
2971+
_SERVICE_TYPE_ENUMERATION_NAME,
29692972
_TYPE_PTR,
29702973
_CLASS_IN,
29712974
_DNS_OTHER_TTL,

0 commit comments

Comments
 (0)