python-swidget 1.4.2__tar.gz → 1.4.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_swidget-1.4.2 → python_swidget-1.4.3}/PKG-INFO +1 -1
- {python_swidget-1.4.2 → python_swidget-1.4.3}/pyproject.toml +1 -1
- {python_swidget-1.4.2 → python_swidget-1.4.3}/swidget/__init__.py +1 -0
- {python_swidget-1.4.2 → python_swidget-1.4.3}/swidget/discovery.py +9 -8
- {python_swidget-1.4.2 → python_swidget-1.4.3}/README.md +0 -0
- {python_swidget-1.4.2 → python_swidget-1.4.3}/swidget/cli.py +0 -0
- {python_swidget-1.4.2 → python_swidget-1.4.3}/swidget/exceptions.py +0 -0
- {python_swidget-1.4.2 → python_swidget-1.4.3}/swidget/provision.py +0 -0
- {python_swidget-1.4.2 → python_swidget-1.4.3}/swidget/py.typed +0 -0
- {python_swidget-1.4.2 → python_swidget-1.4.3}/swidget/swidgetdevice.py +0 -0
- {python_swidget-1.4.2 → python_swidget-1.4.3}/swidget/swidgetdimmer.py +0 -0
- {python_swidget-1.4.2 → python_swidget-1.4.3}/swidget/swidgetoutlet.py +0 -0
- {python_swidget-1.4.2 → python_swidget-1.4.3}/swidget/swidgetswitch.py +0 -0
- {python_swidget-1.4.2 → python_swidget-1.4.3}/swidget/swidgettimerswitch.py +0 -0
- {python_swidget-1.4.2 → python_swidget-1.4.3}/swidget/websocket.py +0 -0
|
@@ -43,19 +43,20 @@ async def detect_secure(host: str, timeout: float = DETECT_TIMEOUT_SEC) -> bool:
|
|
|
43
43
|
timeout_obj = ClientTimeout(total=timeout)
|
|
44
44
|
connector = TCPConnector(ssl=False, force_close=True)
|
|
45
45
|
async with ClientSession(connector=connector, timeout=timeout_obj) as session:
|
|
46
|
+
# Try plaintext first: it's the cheap path (no TLS handshake on the
|
|
47
|
+
# MCU) and a 200 response unambiguously means plaintext mode.
|
|
46
48
|
try:
|
|
47
|
-
async with session.get(f"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if resp.status in (200, 403):
|
|
51
|
-
return True
|
|
49
|
+
async with session.get(f"http://{host}/api/v1/summary") as resp:
|
|
50
|
+
if resp.status == 200:
|
|
51
|
+
return False
|
|
52
52
|
except (ClientError, asyncio.TimeoutError):
|
|
53
53
|
pass
|
|
54
54
|
|
|
55
|
+
# Fall back to HTTPS. A 403 means the firmware is enforcing auth.
|
|
55
56
|
try:
|
|
56
|
-
async with session.get(f"
|
|
57
|
-
if resp.status ==
|
|
58
|
-
return
|
|
57
|
+
async with session.get(f"https://{host}/api/v1/summary") as resp:
|
|
58
|
+
if resp.status == 403:
|
|
59
|
+
return True
|
|
59
60
|
except (ClientError, asyncio.TimeoutError):
|
|
60
61
|
pass
|
|
61
62
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|