Skip to content

Commit ffe6cfd

Browse files
authored
Merge branch 'master' into fix/dedup-per-sender-scope
2 parents bf4f5b4 + bc25ee1 commit ffe6cfd

8 files changed

Lines changed: 48 additions & 18 deletions

File tree

‎.pre-commit-config.yaml‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ repos:
3030
args: ["--tab-width", "2"]
3131
files: ".(css|html|js|json|md|toml|yaml)$"
3232
- repo: https://github.com/asottile/pyupgrade
33-
rev: v3.21.2
33+
rev: v3.22.0
3434
hooks:
3535
- id: pyupgrade
3636
args: [--py310-plus]
3737
- repo: https://github.com/astral-sh/ruff-pre-commit
38-
rev: v0.16.8
38+
rev: v0.17.2
3939
hooks:
4040
- id: ruff
4141
args: [--fix, --exit-non-zero-on-fix]
@@ -45,16 +45,16 @@ repos:
4545
hooks:
4646
- id: codespell
4747
- repo: https://github.com/PyCQA/flake8
48-
rev: 7.3.0
48+
rev: 7.4.1
4949
hooks:
5050
- id: flake8
5151
- repo: https://github.com/pre-commit/mirrors-mypy
52-
rev: v2.3.1
52+
rev: v2.4.0
5353
hooks:
5454
- id: mypy
5555
additional_dependencies: [ifaddr]
5656
- repo: https://github.com/MarcoGorelli/cython-lint
57-
rev: v0.21.1
57+
rev: v0.22.0
5858
hooks:
5959
- id: cython-lint
6060
- id: double-quote-cython-strings

‎CHANGELOG.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
<!-- version list -->
44

5+
## v0.151.6 (2026-10-31)
6+
7+
### Bug Fixes
8+
9+
- Shorten the duplicate packet window to 800 ms
10+
([#1930](https://github.com/python-zeroconf/python-zeroconf/pull/1930),
11+
[`c245c2f`](https://github.com/python-zeroconf/python-zeroconf/commit/c245c2fab48ebedd145895b9fa5ee36f86715159))
12+
13+
514
## v0.151.5 (2026-09-28)
615

716
### Bug Fixes

‎poetry.lock‎

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pyproject.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[project]
66
name = "zeroconf"
7-
version = "0.151.5"
7+
version = "0.151.6"
88
license = "LGPL-2.1-or-later"
99
description = "A pure python implementation of multicast DNS service discovery"
1010
readme = "README.rst"
@@ -88,7 +88,7 @@ pytest = ">=9.1.1,<10.0"
8888
pytest-cov = ">=4,<8"
8989
pytest-asyncio = ">=1.4.0,<1.5.0"
9090
cython = "^3.3.0"
91-
setuptools = ">=84.0.0,<85.0.0"
91+
setuptools = ">=84.2.1,<85.0.0"
9292
pytest-timeout = "^2.1.0"
9393
pytest-codspeed = ">=5.0.3,<6.0"
9494
blockbuster = ">=1.5.29,<2.0.0"

‎src/zeroconf/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373

7474
__author__ = "The python-zeroconf authors" # full history in COPYING and git
7575
__maintainer__ = "J. Nick Koston <[email protected]>"
76-
__version__ = "0.151.5"
76+
__version__ = "0.151.6"
7777
__license__ = "LGPL"
7878

7979

‎src/zeroconf/_listener.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def _process_datagram_at_time(
261261
# _DUPLICATE_PACKET_SUPPRESSION_INTERVAL` so a cache miss never
262262
# triggers the branch even when `now` is small (time.monotonic
263263
# is allowed to start near zero, leaving `now - INTERVAL`
264-
# negative for the first ~1s after boot). Only non-QU payloads
264+
# negative for the first interval after boot). Only non-QU payloads
265265
# are cached, so any hit here is safe to suppress without re-
266266
# checking has_qu_question.
267267
recent = self._recent_packets.get(data, _NOT_SEEN)

‎src/zeroconf/const.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@
1515
_LISTENER_TIME = 200 # ms
1616
_REGISTER_TIME = 225 # ms
1717
_UNREGISTER_TIME = 125 # ms
18-
_DUPLICATE_PACKET_SUPPRESSION_INTERVAL = 1000 # ms
18+
# Below the ~1s spacing of repeated announcements (RFC 6762 §8.3), which some
19+
# responders jitter to a little under a second.
20+
_DUPLICATE_PACKET_SUPPRESSION_INTERVAL = 800 # ms
1921
# Per-listener bounded recency window. 16 is large enough to defeat
2022
# the alternating-payload bypass (RFC 6762 §6.2, issue #1724 — even a
2123
# rotation of a dozen distinct payloads still dedups), and small
2224
# enough that the dict bookkeeping per miss stays cheap under a
2325
# hostile flood.
2426
_RECENT_PACKETS_MAX = 16
25-
_DUPLICATE_QUESTION_INTERVAL = 999 # ms # Must be 1ms less than _DUPLICATE_PACKET_SUPPRESSION_INTERVAL
27+
_DUPLICATE_QUESTION_INTERVAL = 999 # ms
2628
_CACHE_CLEANUP_INTERVAL = 10 # s
2729
_LOADED_SYSTEM_TIMEOUT = 10 # s
2830
_STARTUP_TIMEOUT = 9 # s must be lower than _LOADED_SYSTEM_TIMEOUT

‎tests/test_listener.py‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ def test_recent_packets_miss_with_small_now_is_not_suppressed(zc: Zeroconf) -> N
448448
"""A cache miss must not trigger suppression when `now` is below the suppression interval."""
449449
# time.monotonic() can start near zero on freshly booted systems, so
450450
# `now - _DUPLICATE_PACKET_SUPPRESSION_INTERVAL` is negative for the
451-
# first second of process lifetime. A 0.0 default on the recency
451+
# first interval of process lifetime. A 0.0 default on the recency
452452
# dict would let any negative `now - INTERVAL` satisfy the compare
453453
# and suppress legitimate traffic.
454454
zc.registry.async_add(
@@ -484,3 +484,22 @@ def handle_query_or_defer(
484484
with patch.object(listener, "handle_query_or_defer") as _handle_query_or_defer:
485485
listener._process_datagram_at_time(False, len(packet), 0.0, packet, addrs)
486486
_handle_query_or_defer.assert_called_once()
487+
488+
489+
def test_repeated_announcement_under_one_second_is_processed(zc: Zeroconf) -> None:
490+
"""An announcement repeated a little under a second later is not dropped as a duplicate."""
491+
listener = _listener.AsyncListener(zc)
492+
listener.transport = MagicMock()
493+
response = r.DNSOutgoing(const._FLAGS_QR_RESPONSE | const._FLAGS_AA)
494+
response.add_answer_at_time(
495+
r.DNSAddress("device.local.", const._TYPE_A, const._CLASS_IN, 120, b"\x7f\x00\x00\x01"), 0
496+
)
497+
packet = response.packets()[0]
498+
addrs = ("1.2.3.4", 5353)
499+
500+
now = current_time_millis()
501+
listener._process_datagram_at_time(False, len(packet), now, packet, addrs)
502+
listener._process_datagram_at_time(False, len(packet), now + 5, packet, addrs)
503+
assert listener.last_time == now
504+
listener._process_datagram_at_time(False, len(packet), now + 926, packet, addrs)
505+
assert listener.last_time == now + 926

0 commit comments

Comments
 (0)