Skip to content

Only send 20002 discovery request with key included #1207

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

Merged
merged 6 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion kasa/discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ async def do_discover(self) -> None:
if self.target in self.seen_hosts: # Stop sending for discover_single
break
self.transport.sendto(encrypted_req[4:], self.target_1) # type: ignore
self.transport.sendto(Discover.DISCOVERY_QUERY_2, self.target_2) # type: ignore
self.transport.sendto(aes_discovery_query, self.target_2) # type: ignore
await asyncio.sleep(sleep_between_packets)

Expand Down
7 changes: 3 additions & 4 deletions kasa/tests/test_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ async def test_discover_send(mocker):
assert proto.target_1 == ("255.255.255.255", 9999)
transport = mocker.patch.object(proto, "transport")
await proto.do_discover()
assert transport.sendto.call_count == proto.discovery_packets * 3
assert transport.sendto.call_count == proto.discovery_packets * 2


async def test_discover_datagram_received(mocker, discovery_data):
Expand Down Expand Up @@ -501,14 +501,13 @@ async def test_do_discover_drop_packets(mocker, port, do_not_reply_count):
discovery_timeout=discovery_timeout,
discovery_packets=5,
)
expected_send = 1 if port == 9999 else 2
ft = FakeDatagramTransport(dp, port, do_not_reply_count * expected_send)
ft = FakeDatagramTransport(dp, port, do_not_reply_count)
dp.connection_made(ft)

await dp.wait_for_discovery_to_complete()

await asyncio.sleep(0)
assert ft.send_count == do_not_reply_count * expected_send + expected_send
assert ft.send_count == do_not_reply_count + 1
assert dp.discover_task.done()
assert dp.discover_task.cancelled()

Expand Down
Loading