Only send 20002 discovery request with key included (#1207)

This commit is contained in:
Steven B. 2024-10-29 16:21:24 +00:00 committed by GitHub
parent b82743a5de
commit 6d8dc1cc5f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 5 deletions

View File

@ -276,7 +276,6 @@ class _DiscoverProtocol(asyncio.DatagramProtocol):
if self.target in self.seen_hosts: # Stop sending for discover_single if self.target in self.seen_hosts: # Stop sending for discover_single
break break
self.transport.sendto(encrypted_req[4:], self.target_1) # type: ignore 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 self.transport.sendto(aes_discovery_query, self.target_2) # type: ignore
await asyncio.sleep(sleep_between_packets) await asyncio.sleep(sleep_between_packets)

View File

@ -294,7 +294,7 @@ async def test_discover_send(mocker):
assert proto.target_1 == ("255.255.255.255", 9999) assert proto.target_1 == ("255.255.255.255", 9999)
transport = mocker.patch.object(proto, "transport") transport = mocker.patch.object(proto, "transport")
await proto.do_discover() 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): async def test_discover_datagram_received(mocker, discovery_data):
@ -501,14 +501,13 @@ async def test_do_discover_drop_packets(mocker, port, do_not_reply_count):
discovery_timeout=discovery_timeout, discovery_timeout=discovery_timeout,
discovery_packets=5, discovery_packets=5,
) )
expected_send = 1 if port == 9999 else 2 ft = FakeDatagramTransport(dp, port, do_not_reply_count)
ft = FakeDatagramTransport(dp, port, do_not_reply_count * expected_send)
dp.connection_made(ft) dp.connection_made(ft)
await dp.wait_for_discovery_to_complete() await dp.wait_for_discovery_to_complete()
await asyncio.sleep(0) 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.done()
assert dp.discover_task.cancelled() assert dp.discover_task.cancelled()