FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

chore: rework the remaining shapes flagged by the sixth independent a… · python-zeroconf/python-zeroconf@bfc1af2 · GitHub

Repository navigation

Commit bfc1af2

Browse files
authored
chore: rework the remaining shapes flagged by the sixth independent audit (#1889)
1 parent ae524a5 commit bfc1af2

3 files changed

Lines changed: 10 additions & 13 deletions

File tree

‎src/zeroconf/_core.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ async def async_update_service(self, info: ServiceInfo) -> Awaitable:
479479
return asyncio.ensure_future(self._async_broadcast_service(info, _REGISTER_TIME, None))
480480

481481
async def async_wait(self, timeout: float) -> None:
482-
"""Suspend the calling task for timeout milliseconds, or less when notified."""
482+
"""Pause until notified or until timeout milliseconds pass."""
483483
loop = self.loop
484484
assert loop is not None
485485
await wait_for_future_set_or_timeout(loop, self._notify_futures, timeout)

‎src/zeroconf/_dns.py‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,14 +243,13 @@ def _repr_with(self, *details: tuple[str, str]) -> str:
243243
return _format_display(type(self).__name__, [*self._display_fields(), *details])
244244

245245
def _set_created_ttl(self, created: _float, ttl: _int) -> None:
246-
"""Set the created and ttl of a record."""
247246
# It would be better if we made a copy instead of mutating the record
248247
# in place, but records currently don't have a copy method.
249248
self.created = created
250249
self.ttl = ttl
251250

252251
def _suppressed_by_answer(self, answer: DNSRecord) -> bool:
253-
"""RFC 6762 section 7.1 known answer test: an equal record whose TTL is at least half of ours."""
252+
"""RFC 6762 section 7.1 known answer test: an equal record with more than half our TTL."""
254253
return self == answer and self.ttl / 2 < answer.ttl
255254

256255

@@ -345,7 +344,6 @@ def __repr__(self) -> str:
345344
return self._repr_with(("cpu", self.cpu), ("os", self.os))
346345

347346
def write(self, out: DNSOutgoing) -> None:
348-
"""Write the rdata to an outgoing packet."""
349347
out.write_character_string(self.cpu.encode("utf-8"))
350348
out.write_character_string(self.os.encode("utf-8"))
351349

@@ -392,7 +390,6 @@ def __repr__(self) -> str:
392390
return self._repr_with(("next_name", self.next_name), ("covers", covered))
393391

394392
def write(self, out: DNSOutgoing) -> None:
395-
"""Write the rdata to an outgoing packet."""
396393
bitmap = bytearray(b"\0" * 32)
397394
total_octets = 0
398395
for rdtype in self.rdtypes:

‎src/zeroconf/_protocol/outgoing.py‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,20 @@ class DNSOutgoing:
8282
)
8383

8484
def __init__(self, flags: int, multicast: bool = True, id_: int = 0) -> None:
85-
self.flags = flags
8685
self.finished = False
86+
self.flags = flags
8787
self.id = id_
8888
self.multicast = multicast
8989
self.packets_data: list[bytes] = []
90+
self.state = STATE_INIT
9091

91-
# these 3 are per-packet -- see also _reset_for_next_packet()
92-
self.names: dict[str, int] = {}
92+
# per-packet state -- see also _reset_for_next_packet()
93+
self.allow_long: bool = True
9394
self.data: list[bytes] = []
95+
self.names: dict[str, int] = {}
9496
self.size: int = _DNS_PACKET_HEADER_LEN
95-
self.allow_long: bool = True
96-
97-
self.state = STATE_INIT
9897

98+
# the four sections in RFC 1035 section 4.1 order
9999
self.questions: list[DNSQuestion] = []
100100
self.answers: list[tuple[DNSRecord, float]] = []
101101
self.authorities: list[DNSPointer] = []
@@ -388,10 +388,10 @@ def _replace_short(self, index: int_, value: int_) -> None:
388388
self.data[index] = self._get_short(value)
389389

390390
def _reset_for_next_packet(self) -> None:
391-
self.names = {}
391+
self.allow_long = True
392392
self.data = []
393+
self.names = {}
393394
self.size = _DNS_PACKET_HEADER_LEN
394-
self.allow_long = True
395395

396396
def _write_answers_from_offset(self, answer_offset: int_) -> int:
397397
answers_written = 0

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL