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

chore: rework the remaining shapes flagged by the sixth independent audit by bdraco · Pull Request #1889 · python-zeroconf/python-zeroconf · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (3) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 1 addition & 1 deletion src/zeroconf/_core.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ async def async_update_service(self, info: ServiceInfo) -> Awaitable:
return asyncio.ensure_future(self._async_broadcast_service(info, _REGISTER_TIME, None))

async def async_wait(self, timeout: float) -> None:
"""Suspend the calling task for timeout milliseconds, or less when notified."""
"""Pause until notified or until timeout milliseconds pass."""
loop = self.loop
assert loop is not None
await wait_for_future_set_or_timeout(loop, self._notify_futures, timeout)
Expand Down
5 changes: 1 addition & 4 deletions src/zeroconf/_dns.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,13 @@ def _repr_with(self, *details: tuple[str, str]) -> str:
return _format_display(type(self).__name__, [*self._display_fields(), *details])

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

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


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

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

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

def write(self, out: DNSOutgoing) -> None:
"""Write the rdata to an outgoing packet."""
bitmap = bytearray(b"\0" * 32)
total_octets = 0
for rdtype in self.rdtypes:
Expand Down
16 changes: 8 additions & 8 deletions src/zeroconf/_protocol/outgoing.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,20 @@ class DNSOutgoing:
)

def __init__(self, flags: int, multicast: bool = True, id_: int = 0) -> None:
self.flags = flags
self.finished = False
self.flags = flags
self.id = id_
self.multicast = multicast
self.packets_data: list[bytes] = []
self.state = STATE_INIT

# these 3 are per-packet -- see also _reset_for_next_packet()
self.names: dict[str, int] = {}
# per-packet state -- see also _reset_for_next_packet()
self.allow_long: bool = True
self.data: list[bytes] = []
self.names: dict[str, int] = {}
self.size: int = _DNS_PACKET_HEADER_LEN
self.allow_long: bool = True

self.state = STATE_INIT

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

def _reset_for_next_packet(self) -> None:
self.names = {}
self.allow_long = True
self.data = []
self.names = {}
self.size = _DNS_PACKET_HEADER_LEN
self.allow_long = True

def _write_answers_from_offset(self, answer_offset: int_) -> int:
answers_written = 0
Expand Down
Loading

Back | FazBrowse Home | New Git URL