Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python-zeroconf 0.75.0 strict=False for _nmos-registration._tcp #829

Merged
merged 2 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions nmostesting/suites/IS0401Test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
from ..IS04Utils import IS04Utils
from ..TestHelper import get_default_ip, is_ip_address, load_resolved_schema, check_content_type

# monkey patch zeroconf to allow us to advertise "_nmos-registration._tcp"
from zeroconf import service_type_name
service_type_name.__kwdefaults__['strict'] = False

NODE_API_KEY = "node"
RECEIVER_CAPS_KEY = "receiver-caps"
CAPS_REGISTER_KEY = "caps-register"
Expand Down Expand Up @@ -94,6 +90,10 @@ def tear_down_tests(self):
if self.dns_server:
self.dns_server.reset()

def _strict_service_name(self, info):
# avoid zeroconf._exceptions.BadTypeInNameException: Service name (nmos-registration) must be <= 15 bytes
return len(info.type[1:info.type.find('.')]) <= 15

def _mdns_info(self, port, service_type, txt={}, api_ver=None, api_proto=None, api_auth=None, ip=None):
"""Get an mDNS ServiceInfo object in order to create an advertisement"""
if api_ver is None:
Expand Down Expand Up @@ -192,9 +192,9 @@ def do_registry_basics_prereqs(self):
if CONFIG.DNS_SD_MODE == "multicast":
# Advertise the primary registry and invalid ones at pri 0, and allow the Node to do a basic registration
if self.is04_utils.compare_api_version(self.apis[NODE_API_KEY]["version"], "v1.0") != 0:
self.zc.register_service(registry_mdns[0])
self.zc.register_service(registry_mdns[1])
self.zc.register_service(registry_mdns[2])
self.zc.register_service(registry_mdns[0], strict=self._strict_service_name(registry_mdns[0]))
self.zc.register_service(registry_mdns[1], strict=self._strict_service_name(registry_mdns[1]))
self.zc.register_service(registry_mdns[2], strict=self._strict_service_name(registry_mdns[2]))

# Wait for n seconds after advertising the service for the first POST from a Node
start_time = time.time()
Expand Down Expand Up @@ -226,7 +226,7 @@ def do_registry_basics_prereqs(self):

if CONFIG.DNS_SD_MODE == "multicast":
for info in registry_mdns[3:]:
self.zc.register_service(info)
self.zc.register_service(info, strict=self._strict_service_name(info))

# Kill registries one by one to collect data around failover
self.invalid_registry.disable()
Expand Down Expand Up @@ -1455,7 +1455,7 @@ def test_21(self, test):

if CONFIG.DNS_SD_MODE == "multicast":
# Advertise a registry at pri 0 and allow the Node to do a basic registration
self.zc.register_service(registry_info)
self.zc.register_service(registry_info, strict=self._strict_service_name(registry_info))

# Wait for n seconds after advertising the service for the first POST and then DELETE from a Node
self.primary_registry.wait_for_registration(CONFIG.DNS_SD_ADVERT_TIMEOUT)
Expand Down Expand Up @@ -2160,7 +2160,7 @@ def collect_mdns_announcements(self):

if CONFIG.DNS_SD_MODE == "multicast":
# Advertise a registry at pri 0 and allow the Node to do a basic registration
self.zc.register_service(registry_info)
self.zc.register_service(registry_info, strict=self._strict_service_name(registry_info))

# Wait for n seconds after advertising the service for the first POST from a Node
self.primary_registry.wait_for_registration(CONFIG.DNS_SD_ADVERT_TIMEOUT)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
flask>=2.0.0
wtforms
jsonschema
zeroconf>=0.32.0
zeroconf>=0.75.0
requests
netifaces
gitpython
Expand Down
Loading