scan wifi adb random port across subnets
This commit is contained in:
1 parent
207cf0eadb
commit
6279b129cb
3 files changed
+68
-2
No files matched your search
@@ -323,6 +323,7 @@ class TestDiscoverAdbDevices:
|
||||
def test_full_flow_one_connected(self):
|
||||
"""子网推导 → 1 个 IP 开 5555 → connect connected → 取 model。"""
|
||||
with patch.object(scan, "get_local_subnet", return_value="192.168.5.0/24"), \
|
||||
patch("gui.gui_core_pkg.config.get_last_wifi_target", return_value={}), \
|
||||
patch.object(
|
||||
scan,
|
||||
"scan_open_ports",
|
||||
@@ -344,6 +345,7 @@ class TestDiscoverAdbDevices:
|
||||
|
||||
def test_unauthorized_still_listed(self):
|
||||
with patch.object(scan, "get_local_subnet", return_value="192.168.5.0/24"), \
|
||||
patch("gui.gui_core_pkg.config.get_last_wifi_target", return_value={}), \
|
||||
patch.object(scan, "scan_open_ports", return_value=[("192.168.5.2", 5555)]), \
|
||||
patch.object(
|
||||
scan,
|
||||
@@ -483,6 +485,31 @@ class TestDiscoverAdbDevices:
|
||||
assert len(captured_ports[0]) <= 8
|
||||
assert captured_ports[1] == [5555]
|
||||
|
||||
def test_changed_subnet_scans_same_host_with_last_random_port(self):
|
||||
calls = []
|
||||
|
||||
def fake_scan_ports(ips, **kwargs):
|
||||
ports = list(kwargs.get("ports") or [])
|
||||
calls.append((list(ips), ports))
|
||||
if "192.168.10.102" in ips and 42047 in ports:
|
||||
return [("192.168.10.102", 42047)]
|
||||
return []
|
||||
|
||||
with patch.object(scan, "get_local_subnets", return_value=["192.168.10.0/24"]), \
|
||||
patch("gui.gui_core_pkg.config.get_last_wifi_target", return_value={"target": "192.168.5.102:42047", "model": "PEPM00"}), \
|
||||
patch.object(scan, "verify_adb_target", return_value=("connected", "ok")), \
|
||||
patch.object(scan, "discover_mdns_targets", return_value=[]), \
|
||||
patch.object(scan, "_list_arp_ipv4_candidates", return_value=[]), \
|
||||
patch.object(scan, "scan_open_ports", side_effect=fake_scan_ports), \
|
||||
patch.object(scan, "query_device_model", return_value="PEPM00"):
|
||||
devs = scan.discover_adb_devices("/adb")
|
||||
|
||||
assert len(devs) == 1
|
||||
assert devs[0].target == "192.168.10.102:42047"
|
||||
assert calls[0][0][0] == "192.168.10.102"
|
||||
assert calls[0][1][0] == 42047
|
||||
assert 5555 in calls[0][1]
|
||||
|
||||
def test_auto_mode_lightweight_port_scan_before_base_5555(self):
|
||||
calls = []
|
||||
|
||||
|
||||
Reference in new issue
Block a user