zeroconf 0.149.13__tar.gz → 0.149.17__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. {zeroconf-0.149.13 → zeroconf-0.149.17}/CHANGELOG.md +68 -0
  2. {zeroconf-0.149.13 → zeroconf-0.149.17}/PKG-INFO +1 -1
  3. {zeroconf-0.149.13 → zeroconf-0.149.17}/pyproject.toml +6 -5
  4. {zeroconf-0.149.13 → zeroconf-0.149.17}/setup.py +1 -1
  5. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/__init__.py +1 -1
  6. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_core.py +8 -1
  7. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_logger.py +0 -1
  8. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_services/browser.pxd +1 -0
  9. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_services/browser.py +7 -1
  10. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_services/info.pxd +3 -0
  11. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_services/info.py +71 -14
  12. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_utils/ipaddress.py +13 -5
  13. zeroconf-0.149.17/tests/benchmarks/test_cache_mark_expire.py +124 -0
  14. zeroconf-0.149.17/tests/benchmarks/test_ipaddress.py +48 -0
  15. zeroconf-0.149.17/tests/conftest.py +208 -0
  16. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/services/test_browser.py +67 -0
  17. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/services/test_info.py +219 -1
  18. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/test_asyncio.py +31 -15
  19. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/test_handlers.py +54 -28
  20. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/test_services.py +1 -1
  21. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/utils/test_asyncio.py +8 -4
  22. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/utils/test_ipaddress.py +14 -0
  23. zeroconf-0.149.13/tests/conftest.py +0 -116
  24. {zeroconf-0.149.13 → zeroconf-0.149.17}/COPYING +0 -0
  25. {zeroconf-0.149.13 → zeroconf-0.149.17}/README.rst +0 -0
  26. {zeroconf-0.149.13 → zeroconf-0.149.17}/build_ext.py +0 -0
  27. {zeroconf-0.149.13 → zeroconf-0.149.17}/docs/Makefile +0 -0
  28. {zeroconf-0.149.13 → zeroconf-0.149.17}/docs/_ext/zeroconfautodocfix.py +0 -0
  29. {zeroconf-0.149.13 → zeroconf-0.149.17}/docs/api.rst +0 -0
  30. {zeroconf-0.149.13 → zeroconf-0.149.17}/docs/conf.py +0 -0
  31. {zeroconf-0.149.13 → zeroconf-0.149.17}/docs/index.rst +0 -0
  32. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_cache.pxd +0 -0
  33. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_cache.py +0 -0
  34. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_dns.pxd +0 -0
  35. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_dns.py +0 -0
  36. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_engine.py +0 -0
  37. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_exceptions.py +0 -0
  38. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_handlers/__init__.py +0 -0
  39. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_handlers/answers.pxd +0 -0
  40. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_handlers/answers.py +0 -0
  41. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_handlers/multicast_outgoing_queue.pxd +0 -0
  42. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_handlers/multicast_outgoing_queue.py +0 -0
  43. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_handlers/query_handler.pxd +0 -0
  44. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_handlers/query_handler.py +0 -0
  45. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_handlers/record_manager.pxd +0 -0
  46. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_handlers/record_manager.py +0 -0
  47. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_history.pxd +0 -0
  48. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_history.py +0 -0
  49. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_listener.pxd +0 -0
  50. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_listener.py +0 -0
  51. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_protocol/__init__.py +0 -0
  52. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_protocol/incoming.pxd +0 -0
  53. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_protocol/incoming.py +0 -0
  54. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_protocol/outgoing.pxd +0 -0
  55. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_protocol/outgoing.py +0 -0
  56. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_record_update.pxd +0 -0
  57. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_record_update.py +0 -0
  58. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_services/__init__.pxd +0 -0
  59. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_services/__init__.py +0 -0
  60. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_services/registry.pxd +0 -0
  61. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_services/registry.py +0 -0
  62. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_services/types.py +0 -0
  63. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_transport.py +0 -0
  64. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_updates.pxd +0 -0
  65. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_updates.py +0 -0
  66. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_utils/__init__.py +0 -0
  67. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_utils/asyncio.py +0 -0
  68. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_utils/ipaddress.pxd +0 -0
  69. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_utils/name.py +0 -0
  70. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_utils/net.py +0 -0
  71. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_utils/time.pxd +0 -0
  72. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/_utils/time.py +0 -0
  73. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/asyncio.py +0 -0
  74. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/const.py +0 -0
  75. {zeroconf-0.149.13 → zeroconf-0.149.17}/src/zeroconf/py.typed +0 -0
  76. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/__init__.py +0 -0
  77. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/benchmarks/__init__.py +0 -0
  78. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/benchmarks/helpers.py +0 -0
  79. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/benchmarks/test_cache.py +0 -0
  80. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/benchmarks/test_cache_bound.py +0 -0
  81. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/benchmarks/test_incoming.py +0 -0
  82. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/benchmarks/test_listener_dedup.py +0 -0
  83. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/benchmarks/test_mark_seen.py +0 -0
  84. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/benchmarks/test_outgoing.py +0 -0
  85. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/benchmarks/test_send.py +0 -0
  86. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/benchmarks/test_txt_properties.py +0 -0
  87. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/services/__init__.py +0 -0
  88. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/services/test_registry.py +0 -0
  89. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/services/test_types.py +0 -0
  90. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/test_cache.py +0 -0
  91. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/test_circular_imports.py +0 -0
  92. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/test_core.py +0 -0
  93. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/test_dns.py +0 -0
  94. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/test_engine.py +0 -0
  95. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/test_exceptions.py +0 -0
  96. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/test_history.py +0 -0
  97. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/test_init.py +0 -0
  98. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/test_listener.py +0 -0
  99. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/test_logger.py +0 -0
  100. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/test_protocol.py +0 -0
  101. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/test_updates.py +0 -0
  102. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/utils/__init__.py +0 -0
  103. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/utils/test_name.py +0 -0
  104. {zeroconf-0.149.13 → zeroconf-0.149.17}/tests/utils/test_net.py +0 -0
@@ -2,6 +2,74 @@
2
2
 
3
3
  <!-- version list -->
4
4
 
5
+ ## v0.149.17 (2026-06-21)
6
+
7
+ ### Performance Improvements
8
+
9
+ - Precompute address hash instead of per-instance lru_cache
10
+ ([#1774](https://github.com/python-zeroconf/python-zeroconf/pull/1774),
11
+ [`868f28f`](https://github.com/python-zeroconf/python-zeroconf/commit/868f28f82eb79a01ee885819afc4309facc9168b))
12
+
13
+ ### Testing
14
+
15
+ - Add benchmarks for cache mark-to-expire path (#1780)
16
+ ([#1785](https://github.com/python-zeroconf/python-zeroconf/pull/1785),
17
+ [`29cc405`](https://github.com/python-zeroconf/python-zeroconf/commit/29cc405045947bf121405cfbc3dbb08805a4c160))
18
+
19
+ - Add benchmarks for ipaddress object creation and hashing
20
+ ([#1773](https://github.com/python-zeroconf/python-zeroconf/pull/1773),
21
+ [`bd20c8e`](https://github.com/python-zeroconf/python-zeroconf/commit/bd20c8efe320230b1dc65b45b7007a2be62e0b24))
22
+
23
+ - Synchronise test_integration on browser first-query
24
+ ([#1771](https://github.com/python-zeroconf/python-zeroconf/pull/1771),
25
+ [`cb81e67`](https://github.com/python-zeroconf/python-zeroconf/commit/cb81e6768ca1d8988d2e9526157a6d731b329b22))
26
+
27
+
28
+ ## v0.149.16 (2026-05-21)
29
+
30
+ ### Bug Fixes
31
+
32
+ - Re-release for GHSA-qc2x-6f54-m6h9
33
+ ([#1770](https://github.com/python-zeroconf/python-zeroconf/pull/1770),
34
+ [`fad8646`](https://github.com/python-zeroconf/python-zeroconf/commit/fad86461630237d1f0c04e3745fef65e4cc3055c))
35
+
36
+
37
+ ## v0.149.15 (2026-05-21)
38
+
39
+ ### Bug Fixes
40
+
41
+ - Preserve scope_id when scoped AAAA arrives alongside unscoped
42
+ ([#1764](https://github.com/python-zeroconf/python-zeroconf/pull/1764),
43
+ [`e2352ea`](https://github.com/python-zeroconf/python-zeroconf/commit/e2352ea84437d6fca81dfbdc41116feaaf45fefc))
44
+
45
+
46
+ ## v0.149.14 (2026-05-20)
47
+
48
+ ### Bug Fixes
49
+
50
+ - Skip NSEC records in ServiceBrowser to suppress spurious updates
51
+ ([#1762](https://github.com/python-zeroconf/python-zeroconf/pull/1762),
52
+ [`137a5d6`](https://github.com/python-zeroconf/python-zeroconf/commit/137a5d6c29389ffcd8abfba0925d8cbe58cb2c1b))
53
+
54
+ ### Testing
55
+
56
+ - Add blockbuster to detect blocking calls in asyncio tests
57
+ ([#1761](https://github.com/python-zeroconf/python-zeroconf/pull/1761),
58
+ [`90a5a39`](https://github.com/python-zeroconf/python-zeroconf/commit/90a5a39df7400926bc5498a86b9fe4c46eaffd44))
59
+
60
+ - Scale aggregation timings 10x to speed up timing-dependent tests
61
+ ([#1759](https://github.com/python-zeroconf/python-zeroconf/pull/1759),
62
+ [`3e5ac4f`](https://github.com/python-zeroconf/python-zeroconf/commit/3e5ac4fbc5cd8d8b5ffed5cc8994782e7157cfad))
63
+
64
+ - Shave loopback timing overhead from remaining slow tests
65
+ ([#1760](https://github.com/python-zeroconf/python-zeroconf/pull/1760),
66
+ [`343dc7a`](https://github.com/python-zeroconf/python-zeroconf/commit/343dc7a305b47a574f58265081f172ed54f461bb))
67
+
68
+ - Widen QM follow-up window in info_asking_default test
69
+ ([#1765](https://github.com/python-zeroconf/python-zeroconf/pull/1765),
70
+ [`4ffba87`](https://github.com/python-zeroconf/python-zeroconf/commit/4ffba87177fcc11a0fd8ccb7d93c6996a1269a26))
71
+
72
+
5
73
  ## v0.149.13 (2026-05-20)
6
74
 
7
75
  ### Bug Fixes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zeroconf
3
- Version: 0.149.13
3
+ Version: 0.149.17
4
4
  Summary: A pure python implementation of multicast DNS service discovery
5
5
  License-Expression: LGPL-2.1-or-later
6
6
  License-File: COPYING
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
4
4
 
5
5
  [project]
6
6
  name = "zeroconf"
7
- version = "0.149.13"
7
+ version = "0.149.17"
8
8
  license = "LGPL-2.1-or-later"
9
9
  description = "A pure python implementation of multicast DNS service discovery"
10
10
  readme = "README.rst"
@@ -84,13 +84,14 @@ python = "^3.10"
84
84
  ifaddr = ">=0.1.7"
85
85
 
86
86
  [tool.poetry.group.dev.dependencies]
87
- pytest = ">=9.0.3,<10.0"
87
+ pytest = ">=9.1.0,<10.0"
88
88
  pytest-cov = ">=4,<8"
89
- pytest-asyncio = ">=1.3.0,<1.4.0"
90
- cython = "^3.2.4"
89
+ pytest-asyncio = ">=1.4.0,<1.5.0"
90
+ cython = "^3.2.5"
91
91
  setuptools = ">=65.6.3,<83.0.0"
92
92
  pytest-timeout = "^2.1.0"
93
- pytest-codspeed = ">=5.0.2,<6.0"
93
+ pytest-codspeed = ">=5.0.3,<6.0"
94
+ blockbuster = ">=1.5.5,<2.0.0"
94
95
 
95
96
  [tool.poetry.group.docs.dependencies]
96
97
  sphinx = "^7.4.7 || ^8.1.3"
@@ -19,7 +19,7 @@ install_requires = \
19
19
 
20
20
  setup_kwargs = {
21
21
  'name': 'zeroconf',
22
- 'version': '0.149.13',
22
+ 'version': '0.149.17',
23
23
  'description': 'A pure python implementation of multicast DNS service discovery',
24
24
  'long_description': 'python-zeroconf\n===============\n\n.. image:: https://github.com/python-zeroconf/python-zeroconf/workflows/CI/badge.svg\n :target: https://github.com/python-zeroconf/python-zeroconf?query=workflow%3ACI+branch%3Amaster\n\n.. image:: https://img.shields.io/pypi/v/zeroconf.svg\n :target: https://pypi.python.org/pypi/zeroconf\n\n.. image:: https://codecov.io/gh/python-zeroconf/python-zeroconf/branch/master/graph/badge.svg\n :target: https://codecov.io/gh/python-zeroconf/python-zeroconf\n\n.. image:: https://img.shields.io/endpoint?url=https://codspeed.io/badge.json\n :target: https://codspeed.io/python-zeroconf/python-zeroconf\n :alt: Codspeed.io status for python-zeroconf\n\n.. image:: https://readthedocs.org/projects/python-zeroconf/badge/?version=latest\n :target: https://python-zeroconf.readthedocs.io/en/latest/?badge=latest\n :alt: Documentation Status\n\n`Documentation <https://python-zeroconf.readthedocs.io/en/latest/>`_.\n\nThis is fork of pyzeroconf, Multicast DNS Service Discovery for Python,\noriginally by Paul Scott-Murphy (https://github.com/paulsm/pyzeroconf),\nmodified by William McBrine (https://github.com/wmcbrine/pyzeroconf).\n\nThe original William McBrine\'s fork note::\n\n This fork is used in all of my TiVo-related projects: HME for Python\n (and therefore HME/VLC), Network Remote, Remote Proxy, and pyTivo.\n Before this, I was tracking the changes for zeroconf.py in three\n separate repos. I figured I should have an authoritative source.\n\n Although I make changes based on my experience with TiVos, I expect that\n they\'re generally applicable. This version also includes patches found\n on the now-defunct (?) Launchpad repo of pyzeroconf, and elsewhere\n around the net -- not always well-documented, sorry.\n\nCompatible with:\n\n* Bonjour\n* Avahi\n\nCompared to some other Zeroconf/Bonjour/Avahi Python packages, python-zeroconf:\n\n* isn\'t tied to Bonjour or Avahi\n* doesn\'t use D-Bus\n* doesn\'t force you to use particular event loop or Twisted (asyncio is used under the hood but not required)\n* is pip-installable\n* has PyPI distribution\n* has an optional cython extension for performance (pure python is supported as well)\n\nPython compatibility\n--------------------\n\n* CPython 3.10+\n* PyPy 3.10+\n\nVersioning\n----------\n\nThis project uses semantic versioning.\n\nStatus\n------\n\nThis project is actively maintained.\n\nTraffic Reduction\n-----------------\n\nBefore version 0.32, most traffic reduction techniques described in https://datatracker.ietf.org/doc/html/rfc6762#section-7\nwhere not implemented which could lead to excessive network traffic. It is highly recommended that version 0.32 or later\nis used if this is a concern.\n\nIPv6 support\n------------\n\nIPv6 support is relatively new and currently limited, specifically:\n\n* `InterfaceChoice.All` is an alias for `InterfaceChoice.Default` on non-POSIX\n systems.\n* Dual-stack IPv6 sockets are used, which may not be supported everywhere (some\n BSD variants do not have them).\n* Listening on localhost (`::1`) does not work. Help with understanding why is\n appreciated.\n\nHow to get python-zeroconf?\n===========================\n\n* PyPI page https://pypi.org/project/zeroconf/\n* GitHub project https://github.com/python-zeroconf/python-zeroconf\n\nThe easiest way to install python-zeroconf is using pip::\n\n pip install zeroconf\n\n\n\nHow do I use it?\n================\n\nHere\'s an example of browsing for a service:\n\n.. code-block:: python\n\n from zeroconf import ServiceBrowser, ServiceListener, Zeroconf\n\n\n class MyListener(ServiceListener):\n\n def update_service(self, zc: Zeroconf, type_: str, name: str) -> None:\n print(f"Service {name} updated")\n\n def remove_service(self, zc: Zeroconf, type_: str, name: str) -> None:\n print(f"Service {name} removed")\n\n def add_service(self, zc: Zeroconf, type_: str, name: str) -> None:\n info = zc.get_service_info(type_, name)\n print(f"Service {name} added, service info: {info}")\n\n\n zeroconf = Zeroconf()\n listener = MyListener()\n browser = ServiceBrowser(zeroconf, "_http._tcp.local.", listener)\n try:\n input("Press enter to exit...\\n\\n")\n finally:\n zeroconf.close()\n\n.. note::\n\n Discovery and service registration use *all* available network interfaces by default.\n If you want to customize that you need to specify ``interfaces`` argument when\n constructing ``Zeroconf`` object (see the code for details).\n\nIf you don\'t know the name of the service you need to browse for, try:\n\n.. code-block:: python\n\n from zeroconf import ZeroconfServiceTypes\n print(\'\\n\'.join(ZeroconfServiceTypes.find()))\n\nSee examples directory for more.\n\nChangelog\n=========\n\n`Changelog <CHANGELOG.md>`_\n\nLicense\n=======\n\nGNU Lesser General Public License v2.1 or later (LGPL-2.1-or-later).\n\nThe full text of LGPL 2.1 is included in the `COPYING <COPYING>`_ file.\nYou may, at your option, use this library under the terms of any later\nversion of the LGPL published by the Free Software Foundation. The\ncanonical SPDX identifier for this project is ``LGPL-2.1-or-later``, as\ndeclared in ``pyproject.toml``.\n',
25
25
  'author': 'Paul Scott-Murphy',
@@ -88,7 +88,7 @@ from ._utils.time import ( # noqa # import needed for backwards compat
88
88
 
89
89
  __author__ = "Paul Scott-Murphy, William McBrine"
90
90
  __maintainer__ = "Jakub Stasiak <jakub@stasiak.at>"
91
- __version__ = "0.149.13"
91
+ __version__ = "0.149.17"
92
92
  __license__ = "LGPL"
93
93
 
94
94
 
@@ -104,6 +104,13 @@ _PROTECTED_AGGREGATION_DELAY = 200 # ms
104
104
 
105
105
  _REGISTER_BROADCASTS = 3
106
106
 
107
+ # RFC 6762 §8.1 thundering-herd avoidance: wait a random
108
+ # 0-250ms before the first probe so simultaneously-started
109
+ # responders don't collide. We default to 150-250ms to
110
+ # preserve existing timing assumptions; tests on loopback
111
+ # may patch this lower via the `quick_timing` fixture.
112
+ _PROBE_RANDOM_DELAY_INTERVAL = (150, 250) # ms
113
+
107
114
 
108
115
  def async_send_with_transport(
109
116
  log_debug: bool,
@@ -561,7 +568,7 @@ class Zeroconf(QuietLogger):
561
568
 
562
569
  # Wait a random amount of time up avoid collisions and avoid
563
570
  # a thundering herd when multiple services are started on the network
564
- await self.async_wait(random.randint(150, 250)) # noqa: S311
571
+ await self.async_wait(random.randint(*_PROBE_RANDOM_DELAY_INTERVAL)) # noqa: S311
565
572
 
566
573
  next_instance_number = 2
567
574
  next_time = now = current_time_millis()
@@ -1,5 +1,4 @@
1
1
  """Multicast DNS Service Discovery for Python, v0.14-wmcbrine
2
- )
3
2
  Copyright 2003 Paul Scott-Murphy, 2014 William McBrine
4
3
 
5
4
  This module provides a framework for the use of DNS Service Discovery
@@ -14,6 +14,7 @@ cdef bint TYPE_CHECKING
14
14
  cdef object cached_possible_types
15
15
  cdef cython.uint _EXPIRE_REFRESH_TIME_PERCENT, _MAX_MSG_TYPICAL, _DNS_PACKET_HEADER_LEN
16
16
  cdef cython.uint _TYPE_PTR
17
+ cdef cython.uint _TYPE_NSEC
17
18
  cdef object _CLASS_IN
18
19
  cdef object SERVICE_STATE_CHANGE_ADDED, SERVICE_STATE_CHANGE_REMOVED, SERVICE_STATE_CHANGE_UPDATED
19
20
  cdef cython.set _ADDRESS_RECORD_TYPES
@@ -63,6 +63,7 @@ from ..const import (
63
63
  _MDNS_ADDR,
64
64
  _MDNS_ADDR6,
65
65
  _MDNS_PORT,
66
+ _TYPE_NSEC,
66
67
  _TYPE_PTR,
67
68
  )
68
69
 
@@ -678,7 +679,12 @@ class _ServiceBrowserBase(RecordUpdateListener):
678
679
  old_record = record_update.old
679
680
  record_type = record.type
680
681
 
681
- if record_type is _TYPE_PTR:
682
+ # NSEC records assert non-existence of a record type
683
+ # (RFC 6762 §6.1); skip so we do not fire spurious updates.
684
+ if record_type == _TYPE_NSEC:
685
+ continue
686
+
687
+ if record_type == _TYPE_PTR:
682
688
  if TYPE_CHECKING:
683
689
  record = cast(DNSPointer, record)
684
690
  pointer = record
@@ -107,6 +107,9 @@ cdef class ServiceInfo(RecordUpdateListener):
107
107
  )
108
108
  cdef bint _process_record_threadsafe(self, object zc, DNSRecord record, double now)
109
109
 
110
+ @cython.locals(existing_idx=int, existing=object)
111
+ cdef bint _upsert_ipv6_address(self, object ip_addr)
112
+
110
113
  @cython.locals(cache=DNSCache)
111
114
  cdef cython.list _get_address_records_from_cache_by_type(self, object zc, object _type)
112
115
 
@@ -24,6 +24,7 @@ from __future__ import annotations
24
24
 
25
25
  import asyncio
26
26
  import random
27
+ from collections.abc import Sequence
27
28
  from typing import TYPE_CHECKING, cast
28
29
 
29
30
  from .._cache import DNSCache
@@ -108,6 +109,36 @@ if TYPE_CHECKING:
108
109
  from .._core import Zeroconf
109
110
 
110
111
 
112
+ def _index_of_same_address(
113
+ addresses: Sequence[ZeroconfIPv4Address | ZeroconfIPv6Address],
114
+ ip_addr: ZeroconfIPv4Address | ZeroconfIPv6Address,
115
+ ) -> int:
116
+ """Return the index of an existing entry with the same packed bytes, or -1.
117
+
118
+ Match by ``zc_integer`` so IPv6 addresses that differ only in
119
+ scope_id (one observed without scope on an IPv4 socket, another
120
+ observed with scope on an IPv6 socket) collapse to a single entry.
121
+ """
122
+ target = ip_addr.zc_integer
123
+ for idx, existing in enumerate(addresses):
124
+ if existing.zc_integer == target:
125
+ return idx
126
+ return -1
127
+
128
+
129
+ def _has_more_scope_info(
130
+ new_addr: ZeroconfIPv4Address | ZeroconfIPv6Address,
131
+ existing: ZeroconfIPv4Address | ZeroconfIPv6Address,
132
+ ) -> bool:
133
+ """True if ``new_addr`` carries a scope_id the ``existing`` entry lacks."""
134
+ if new_addr.version != 6:
135
+ return False
136
+ if TYPE_CHECKING:
137
+ assert isinstance(new_addr, ZeroconfIPv6Address)
138
+ assert isinstance(existing, ZeroconfIPv6Address)
139
+ return new_addr.scope_id is not None and existing.scope_id is None
140
+
141
+
111
142
  def instance_name_from_service_info(info: ServiceInfo, strict: bool = True) -> str:
112
143
  """Calculate the instance name from the ServiceInfo."""
113
144
  # This is kind of funky because of the subtype based tests
@@ -453,11 +484,49 @@ class ServiceInfo(RecordUpdateListener):
453
484
  if record.is_expired(now):
454
485
  continue
455
486
  ip_addr = get_ip_address_object_from_record(record)
456
- if ip_addr is not None and ip_addr not in address_list:
487
+ if ip_addr is None:
488
+ continue
489
+ # The cache keeps scoped and unscoped link-local AAAA
490
+ # records as separate entries because DNSAddress equality
491
+ # includes scope_id. Collapse them here so each address
492
+ # appears once; the scoped variant wins so callers of
493
+ # parsed_scoped_addresses() get a %<interface_index>-
494
+ # qualified link-local address when one was observed.
495
+ existing_idx = _index_of_same_address(address_list, ip_addr)
496
+ if existing_idx == -1:
457
497
  address_list.append(ip_addr)
498
+ continue
499
+ # Move the re-seen address to the end so the later observation
500
+ # wins both in value (scope) and in LIFO position after reverse.
501
+ existing = address_list.pop(existing_idx)
502
+ address_list.append(ip_addr if _has_more_scope_info(ip_addr, existing) else existing)
458
503
  address_list.reverse() # Reverse to get LIFO order
459
504
  return address_list
460
505
 
506
+ def _upsert_ipv6_address(self, ip_addr: ZeroconfIPv6Address) -> bool:
507
+ """Insert or update an IPv6 address in LIFO order.
508
+
509
+ Compares by integer (not IPv6Address equality, which respects
510
+ scope_id) so the same link-local address received first without
511
+ scope (IPv4 socket) and then with scope (IPv6 socket) collapses
512
+ to one entry. The scoped variant wins so parsed_scoped_addresses()
513
+ can return a qualified address.
514
+ """
515
+ ipv6_addresses = self._ipv6_addresses
516
+ existing_idx = _index_of_same_address(ipv6_addresses, ip_addr)
517
+ if existing_idx == -1:
518
+ ipv6_addresses.insert(0, ip_addr)
519
+ return True
520
+ existing = ipv6_addresses[existing_idx]
521
+ if _has_more_scope_info(ip_addr, existing):
522
+ ipv6_addresses.pop(existing_idx)
523
+ ipv6_addresses.insert(0, ip_addr)
524
+ return True
525
+ if existing_idx != 0:
526
+ ipv6_addresses.pop(existing_idx)
527
+ ipv6_addresses.insert(0, existing)
528
+ return False
529
+
461
530
  def _set_ipv6_addresses_from_cache(self, zc: Zeroconf, now: float_) -> None:
462
531
  """Set IPv6 addresses from the cache."""
463
532
  if TYPE_CHECKING:
@@ -532,19 +601,7 @@ class ServiceInfo(RecordUpdateListener):
532
601
 
533
602
  if TYPE_CHECKING:
534
603
  assert isinstance(ip_addr, ZeroconfIPv6Address)
535
- ipv6_addresses = self._ipv6_addresses
536
- if ip_addr not in self._ipv6_addresses:
537
- ipv6_addresses.insert(0, ip_addr)
538
- return True
539
- # Use int() to compare the addresses as integers
540
- # since by default IPv6Address.__eq__ compares the
541
- # the addresses on version and int which more than
542
- # we need here since we know the version is 6.
543
- if ip_addr.zc_integer != self._ipv6_addresses[0].zc_integer:
544
- ipv6_addresses.remove(ip_addr)
545
- ipv6_addresses.insert(0, ip_addr)
546
-
547
- return False
604
+ return self._upsert_ipv6_address(ip_addr)
548
605
 
549
606
  if record_key != self.key:
550
607
  return False
@@ -22,7 +22,7 @@ USA
22
22
 
23
23
  from __future__ import annotations
24
24
 
25
- from functools import cache, lru_cache
25
+ from functools import lru_cache
26
26
  from ipaddress import AddressValueError, IPv4Address, IPv6Address, NetmaskValueError
27
27
  from typing import Any
28
28
 
@@ -34,7 +34,7 @@ int_ = int
34
34
 
35
35
 
36
36
  class ZeroconfIPv4Address(IPv4Address):
37
- __slots__ = ("__hash__", "_is_link_local", "_is_loopback", "_is_unspecified", "_str", "zc_integer")
37
+ __slots__ = ("_hash", "_is_link_local", "_is_loopback", "_is_unspecified", "_str", "zc_integer")
38
38
 
39
39
  def __init__(self, *args: Any, **kwargs: Any) -> None:
40
40
  """Initialize a new IPv4 address."""
@@ -43,13 +43,17 @@ class ZeroconfIPv4Address(IPv4Address):
43
43
  self._is_link_local = super().is_link_local
44
44
  self._is_unspecified = super().is_unspecified
45
45
  self._is_loopback = super().is_loopback
46
- self.__hash__ = cache(lambda: IPv4Address.__hash__(self)) # type: ignore[method-assign]
46
+ self._hash = IPv4Address.__hash__(self)
47
47
  self.zc_integer = int(self)
48
48
 
49
49
  def __str__(self) -> str:
50
50
  """Return the string representation of the IPv4 address."""
51
51
  return self._str
52
52
 
53
+ def __hash__(self) -> int:
54
+ """Return the precomputed hash of the IPv4 address."""
55
+ return self._hash
56
+
53
57
  @property
54
58
  def is_link_local(self) -> bool:
55
59
  """Return True if this is a link-local address."""
@@ -67,7 +71,7 @@ class ZeroconfIPv4Address(IPv4Address):
67
71
 
68
72
 
69
73
  class ZeroconfIPv6Address(IPv6Address):
70
- __slots__ = ("__hash__", "_is_link_local", "_is_loopback", "_is_unspecified", "_str", "zc_integer")
74
+ __slots__ = ("_hash", "_is_link_local", "_is_loopback", "_is_unspecified", "_str", "zc_integer")
71
75
 
72
76
  def __init__(self, *args: Any, **kwargs: Any) -> None:
73
77
  """Initialize a new IPv6 address."""
@@ -76,13 +80,17 @@ class ZeroconfIPv6Address(IPv6Address):
76
80
  self._is_link_local = super().is_link_local
77
81
  self._is_unspecified = super().is_unspecified
78
82
  self._is_loopback = super().is_loopback
79
- self.__hash__ = cache(lambda: IPv6Address.__hash__(self)) # type: ignore[method-assign]
83
+ self._hash = IPv6Address.__hash__(self)
80
84
  self.zc_integer = int(self)
81
85
 
82
86
  def __str__(self) -> str:
83
87
  """Return the string representation of the IPv6 address."""
84
88
  return self._str
85
89
 
90
+ def __hash__(self) -> int:
91
+ """Return the precomputed hash of the IPv6 address."""
92
+ return self._hash
93
+
86
94
  @property
87
95
  def is_link_local(self) -> bool:
88
96
  """Return True if this is a link-local address."""
@@ -0,0 +1,124 @@
1
+ """Benchmarks for DNSCache.async_mark_unique_records_older_than_1s_to_expire.
2
+
3
+ Covers the RFC 6762 §10.2 paragraph 2 path. ``_async_set_created_ttl``
4
+ mutates cached records in place, so a repeated-iteration benchmark
5
+ would only measure work on the first call. Each test uses
6
+ ``benchmark.pedantic`` with a per-round ``setup`` that rebuilds the
7
+ stale cache; the ``async_add_records`` cost stays outside the timed
8
+ window.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ from typing import Any
14
+
15
+ from pytest_codspeed import BenchmarkFixture
16
+
17
+ from zeroconf import DNSAddress, DNSCache, DNSPointer, current_time_millis
18
+ from zeroconf.const import _CLASS_IN, _CLASS_UNIQUE, _TYPE_A, _TYPE_PTR
19
+
20
+ _UNIQUE_CLASS = _CLASS_IN | _CLASS_UNIQUE
21
+
22
+
23
+ def _ipv4_bytes(i: int) -> bytes:
24
+ return bytes(((i >> 24) & 0xFF, (i >> 16) & 0xFF, (i >> 8) & 0xFF, i & 0xFF))
25
+
26
+
27
+ def test_mark_to_expire_1000_records_all_stale(benchmark: BenchmarkFixture) -> None:
28
+ """Worst-case mark-to-expire: 1000 stale unique A records, all mutated."""
29
+ now = current_time_millis()
30
+ name = "stale.local."
31
+ unique_types = {(name, _TYPE_A, _UNIQUE_CLASS)}
32
+ # Unrelated answer keeps every cached record in the "must expire"
33
+ # branch (no membership hit short-circuits the mutation).
34
+ answers = [DNSAddress(name, _TYPE_A, _UNIQUE_CLASS, 120, _ipv4_bytes(0xDEAD_BEEF))]
35
+
36
+ def _setup() -> tuple[tuple[Any, ...], dict[str, Any]]:
37
+ cache = DNSCache()
38
+ cache.async_add_records(
39
+ DNSAddress(
40
+ name,
41
+ _TYPE_A,
42
+ _UNIQUE_CLASS,
43
+ 120,
44
+ _ipv4_bytes(i),
45
+ created=now - 5_000,
46
+ )
47
+ for i in range(1000)
48
+ )
49
+ return (cache,), {}
50
+
51
+ def _mark(cache: DNSCache) -> None:
52
+ cache.async_mark_unique_records_older_than_1s_to_expire(unique_types, answers, now)
53
+
54
+ benchmark.pedantic(_mark, setup=_setup)
55
+
56
+
57
+ def test_mark_to_expire_1000_records_none_stale(benchmark: BenchmarkFixture) -> None:
58
+ """Scan-only path: 1000 fresh records, no mutation."""
59
+ now = current_time_millis()
60
+ name = "fresh.local."
61
+ unique_types = {(name, _TYPE_A, _UNIQUE_CLASS)}
62
+ answers = [DNSAddress(name, _TYPE_A, _UNIQUE_CLASS, 120, _ipv4_bytes(0xDEAD_BEEF))]
63
+
64
+ def _setup() -> tuple[tuple[Any, ...], dict[str, Any]]:
65
+ cache = DNSCache()
66
+ cache.async_add_records(
67
+ DNSAddress(
68
+ name,
69
+ _TYPE_A,
70
+ _UNIQUE_CLASS,
71
+ 120,
72
+ _ipv4_bytes(i),
73
+ created=now,
74
+ )
75
+ for i in range(1000)
76
+ )
77
+ return (cache,), {}
78
+
79
+ def _mark(cache: DNSCache) -> None:
80
+ cache.async_mark_unique_records_older_than_1s_to_expire(unique_types, answers, now)
81
+
82
+ benchmark.pedantic(_mark, setup=_setup)
83
+
84
+
85
+ def test_mark_to_expire_many_unique_types(benchmark: BenchmarkFixture) -> None:
86
+ """100 distinct (name, type, class) triplets, one stale record each."""
87
+ now = current_time_millis()
88
+ unique_types: set[tuple[str, int, int]] = {
89
+ (f"svc{i}.local.", _TYPE_PTR, _UNIQUE_CLASS) for i in range(100)
90
+ }
91
+ # New answers reference a different alias, so the cached entries are
92
+ # not equal to anything in ``answers_rrset`` and must be expired.
93
+ answers = [
94
+ DNSPointer(
95
+ f"svc{i}.local.",
96
+ _TYPE_PTR,
97
+ _UNIQUE_CLASS,
98
+ 120,
99
+ f"new-target{i}.local.",
100
+ )
101
+ for i in range(100)
102
+ ]
103
+
104
+ def _setup() -> tuple[tuple[Any, ...], dict[str, Any]]:
105
+ cache = DNSCache()
106
+ for i in range(100):
107
+ cache.async_add_records(
108
+ [
109
+ DNSPointer(
110
+ f"svc{i}.local.",
111
+ _TYPE_PTR,
112
+ _UNIQUE_CLASS,
113
+ 120,
114
+ f"target{i}.local.",
115
+ created=now - 5_000,
116
+ )
117
+ ]
118
+ )
119
+ return (cache,), {}
120
+
121
+ def _mark(cache: DNSCache) -> None:
122
+ cache.async_mark_unique_records_older_than_1s_to_expire(unique_types, answers, now)
123
+
124
+ benchmark.pedantic(_mark, setup=_setup)
@@ -0,0 +1,48 @@
1
+ """Benchmarks for zeroconf._utils.ipaddress address objects."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pytest_codspeed import BenchmarkFixture
6
+
7
+ from zeroconf._utils.ipaddress import ZeroconfIPv4Address, ZeroconfIPv6Address
8
+
9
+ _IPV4_STRS = [f"10.{(i >> 8) & 0xFF}.{i & 0xFF}.1" for i in range(1000)]
10
+ _IPV6_BYTES = [(0x20010DB8 << 96 | i).to_bytes(16, "big") for i in range(1000)]
11
+
12
+
13
+ def test_create_ipv4_addresses(benchmark: BenchmarkFixture) -> None:
14
+ """Benchmark constructing 1000 distinct IPv4 address objects."""
15
+
16
+ @benchmark
17
+ def _create() -> None:
18
+ for addr in _IPV4_STRS:
19
+ ZeroconfIPv4Address(addr)
20
+
21
+
22
+ def test_create_ipv6_addresses(benchmark: BenchmarkFixture) -> None:
23
+ """Benchmark constructing 1000 distinct IPv6 address objects."""
24
+
25
+ @benchmark
26
+ def _create() -> None:
27
+ for addr in _IPV6_BYTES:
28
+ ZeroconfIPv6Address(addr)
29
+
30
+
31
+ def test_hash_ipv4_address(benchmark: BenchmarkFixture) -> None:
32
+ """Benchmark hashing the same IPv4 address object 1000 times."""
33
+ addr = ZeroconfIPv4Address("10.0.0.1")
34
+
35
+ @benchmark
36
+ def _hash() -> None:
37
+ for _ in range(1000):
38
+ hash(addr)
39
+
40
+
41
+ def test_hash_ipv6_address(benchmark: BenchmarkFixture) -> None:
42
+ """Benchmark hashing the same IPv6 address object 1000 times."""
43
+ addr = ZeroconfIPv6Address(b"\x20\x01\x0d\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01")
44
+
45
+ @benchmark
46
+ def _hash() -> None:
47
+ for _ in range(1000):
48
+ hash(addr)