tplinkrouterc6u 5.10.1__py3-none-any.whl → 5.10.3__py3-none-any.whl

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.
@@ -2,6 +2,7 @@ from tplinkrouterc6u.client.c6u import TplinkRouter
2
2
  from tplinkrouterc6u.client.deco import TPLinkDecoClient
3
3
  from tplinkrouterc6u.client_abstract import AbstractRouter
4
4
  from tplinkrouterc6u.client.mr import TPLinkMRClient
5
+ from tplinkrouterc6u.client.mr200 import TPLinkMR200Client
5
6
  from tplinkrouterc6u.client.ex import TPLinkEXClient
6
7
  from tplinkrouterc6u.client.vr import TPLinkVRClient
7
8
  from tplinkrouterc6u.client.c80 import TplinkC80Router
@@ -0,0 +1,57 @@
1
+ import base64
2
+ from tplinkrouterc6u.common.exception import ClientException, AuthorizeError
3
+ from tplinkrouterc6u.client.mr import TPLinkMRClient
4
+ from Crypto.PublicKey import RSA
5
+ from re import search
6
+ from binascii import hexlify
7
+ from Crypto.Cipher import PKCS1_v1_5
8
+
9
+
10
+ class TPLinkMR200Client(TPLinkMRClient):
11
+
12
+ def authorize(self) -> None:
13
+ params = self.__get_params()
14
+
15
+ # Construct the RSA public key manually using modulus (n) and exponent (e)
16
+ n = int(params["nn"])
17
+ e = int(params["ee"])
18
+ pub_key = RSA.construct((n, e))
19
+
20
+ # Create an RSA cipher with PKCS#1 v1.5 padding (same as rsa.encrypt)
21
+ cipher = PKCS1_v1_5.new(pub_key)
22
+
23
+ # Encrypt username
24
+ rsa_username = cipher.encrypt(self.username.encode("utf-8"))
25
+ rsa_username_hex = hexlify(rsa_username).decode("utf-8")
26
+
27
+ # Encrypt password (after base64 encoding, as in your original code)
28
+ rsa_password = cipher.encrypt(base64.b64encode(self.password.encode("utf-8")))
29
+ rsa_password_hex = hexlify(rsa_password).decode("utf-8")
30
+
31
+ # Send login request
32
+ self.req.post(
33
+ f'{self.host}/cgi/login?UserName={rsa_username_hex}&Passwd={rsa_password_hex}&Action=1&LoginStatus=0'
34
+ )
35
+
36
+ # Try to extract token
37
+ r = self.req.get(self.host)
38
+ try:
39
+ self._token = search(r'var token="(.*)";', r.text).group(1)
40
+ except AttributeError:
41
+ raise AuthorizeError()
42
+
43
+ def __get_params(self, retry=False):
44
+ try:
45
+ r = self.req.get(f"{self.host}/cgi/getParm", timeout=5)
46
+ result = {}
47
+ for line in r.text.splitlines()[0:2]:
48
+ match = search(r"var (.*)=\"(.*)\"", line)
49
+ result[match.group(1)] = int(match.group(2), 16)
50
+ return result
51
+ except Exception:
52
+ if not retry:
53
+ return self.__get_params(True)
54
+ raise ClientException()
55
+
56
+ def _request(self, url, method='POST', data_str=None, encrypt=False, is_login=False):
57
+ return super()._request(url, method, data_str, False, is_login)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tplinkrouterc6u
3
- Version: 5.10.1
3
+ Version: 5.10.3
4
4
  Summary: TP-Link Router API (supports also Mercusys Router)
5
5
  Home-page: https://github.com/AlexandrErohin/TP-Link-Archer-C6U
6
6
  Author: Alex Erohin
@@ -37,6 +37,9 @@ Python package for API access and management for TP-Link and Mercusys Routers. S
37
37
  [![Downloads](https://static.pepy.tech/personalized-badge/tplinkrouterc6u?period=total&units=international_system&left_color=grey&right_color=orange&left_text=Downloads)](https://pypi.org/project/tplinkrouterc6u/)
38
38
  ![Python versions](https://img.shields.io/pypi/pyversions/tplinkrouterc6u)
39
39
 
40
+ > [!WARNING]
41
+ > A new router firmware update breaks the compatibility. Please try [this fix](https://github.com/AlexandrErohin/home-assistant-tplink-router/issues/220#issuecomment-3396658175)
42
+
40
43
  ## Installation
41
44
  `pip install tplinkrouterc6u`
42
45
 
@@ -301,14 +304,16 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
301
304
  - Archer A20 v1.0
302
305
  - Archer AX10 v1.0
303
306
  - Archer AX12 v1.0
307
+ - Archer AX17 v1.0
304
308
  - Archer AX20 (v1.0, v3.0)
305
309
  - Archer AX21 (v1.20, v3.0)
306
310
  - Archer AX23 (v1.0, v1.2)
307
311
  - Archer AX50 v1.0
308
- - Archer AX53 v2
312
+ - Archer AX53 (v1.0, v2)
309
313
  - Archer AX55 (v1.0, V1.60, v4.0)
314
+ - Archer AX58 v1.0
310
315
  - Archer AX72 V1
311
- - Archer AX73 V1
316
+ - Archer AX73 (V1, V2.0)
312
317
  - Archer AX75 V1
313
318
  - Archer AX90 V1.20
314
319
  - Archer AXE75 V1
@@ -338,6 +343,7 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
338
343
  - Archer MR200 (v5, v5.3, v6.0)
339
344
  - Archer MR550 v1
340
345
  - Archer MR600 (v1, v2, v3)
346
+ - Archer NX200 v2.0
341
347
  - Archer VR400 v3
342
348
  - Archer VR600 v3
343
349
  - Archer VR900v
@@ -374,6 +380,7 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
374
380
  - TL-XDR3010 V2
375
381
  - TL-WDR3600 V1
376
382
  - VX420-G2h v1.1
383
+ - VX800v v1
377
384
  - XC220-G3v v2.30
378
385
  ### <a id="mercusys">MERCUSYS routers</a>
379
386
  - MR47BE v1.0
@@ -7,7 +7,7 @@ test/test_client_ex.py,sha256=Kg6svEKtyGAfyF9yrLh2qZa2tK1mlEBJJwXRsq1MAjo,26591
7
7
  test/test_client_mr.py,sha256=lePxkmjcPzcrSFcaT8bT67L154cVJIOWrFlXMDOa8oY,33423
8
8
  test/test_client_wdr.py,sha256=0ZnRNP57MbuMv2cxFS8iIoVyv8Q6gtY0Q03gtHp9AWY,13492
9
9
  test/test_client_xdr.py,sha256=mgn-xL5mD5sHD8DjTz9vpY7jeh4Ob6Um6Y8v5Qgx2jA,23374
10
- tplinkrouterc6u/__init__.py,sha256=DDy6XVFH8Ne5C9JToRWNzRqevUfNutLUTlDhvIMsebo,1006
10
+ tplinkrouterc6u/__init__.py,sha256=QtZ_rEArMlYRDO0eRHh50hvLuAEiHHw4UOuMyMn63aQ,1065
11
11
  tplinkrouterc6u/client_abstract.py,sha256=3UYzmll774S_Gb5E0FTVO_rI3-XFM7PSklg1-V-2jls,1419
12
12
  tplinkrouterc6u/provider.py,sha256=bzH0WW2peC66f8NqfiI3t_niX6MFO8SAdKP9WZL-IV4,2152
13
13
  tplinkrouterc6u/client/__init__.py,sha256=KBy3fmtA9wgyFrb0Urh2x4CkKtWVnESdp-vxmuOvq0k,27
@@ -18,6 +18,7 @@ tplinkrouterc6u/client/c80.py,sha256=ArVhza_fnXcEO-_fsQOd1l2QvmSfsswtohKxrZxEnoU
18
18
  tplinkrouterc6u/client/deco.py,sha256=cpKRggKD2RvSmMZuD6tzsZmehAUCU9oLiTTHcZBW81Y,8898
19
19
  tplinkrouterc6u/client/ex.py,sha256=gXWsVKAMo4CsX_Qeihb2iCARcsA3E9m2vgIWiJB3sjs,13197
20
20
  tplinkrouterc6u/client/mr.py,sha256=keMii7cetOvY1iq9_gWbWMWjuPShHhLXyrbGwX4Og44,26136
21
+ tplinkrouterc6u/client/mr200.py,sha256=0FJz77ztjXJXJBDjzEU09QdmOr9Py2NA-DboJ8cEwlQ,2116
21
22
  tplinkrouterc6u/client/vr.py,sha256=7Tbu0IrWtr4HHtyrnLFXEJi1QctzhilciL7agtwQ0R8,5025
22
23
  tplinkrouterc6u/client/wdr.py,sha256=i54PEifjhfOScDpgNBXygw9U4bfsVtle846_YjnDoBs,21679
23
24
  tplinkrouterc6u/client/xdr.py,sha256=QaZ_5vCaf8BV_JEs3S2Nz-QDREBYHGh3OUWIVS-fefY,10406
@@ -27,8 +28,8 @@ tplinkrouterc6u/common/encryption.py,sha256=4HelTxzN6esMfDZRBt3m8bwB9Nj_biKijnCn
27
28
  tplinkrouterc6u/common/exception.py,sha256=_0G8ZvW5__CsGifHrsZeULdl8c6EUD071sDCQsQgrHY,140
28
29
  tplinkrouterc6u/common/helper.py,sha256=23b04fk9HuVinrZXMCS5R1rmF8uZ7eM-Cdnp7Br9NR0,572
29
30
  tplinkrouterc6u/common/package_enum.py,sha256=4ykL_2Pw0nDEIH_qR9UJlFF6stTgSfhPz32r8KT-sh8,1624
30
- tplinkrouterc6u-5.10.1.dist-info/licenses/LICENSE,sha256=YF6QR6Vjxcg5b_sYIyqkME7FZYau5TfEUGTG-0JeRK0,35129
31
- tplinkrouterc6u-5.10.1.dist-info/METADATA,sha256=oiaqPd4N9hGpncj_Zm7WWQNi7w3orZbIRuTOqrEYhBE,16373
32
- tplinkrouterc6u-5.10.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
33
- tplinkrouterc6u-5.10.1.dist-info/top_level.txt,sha256=1iSCCIueqgEkrTxtQ-jiHe99jAB10zqrVdBcwvNfe_M,21
34
- tplinkrouterc6u-5.10.1.dist-info/RECORD,,
31
+ tplinkrouterc6u-5.10.3.dist-info/licenses/LICENSE,sha256=YF6QR6Vjxcg5b_sYIyqkME7FZYau5TfEUGTG-0JeRK0,35129
32
+ tplinkrouterc6u-5.10.3.dist-info/METADATA,sha256=iclzoaJy0O9Py7OHa5e4IY3yQX_ubFhKTzJQgkThZKk,16652
33
+ tplinkrouterc6u-5.10.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
34
+ tplinkrouterc6u-5.10.3.dist-info/top_level.txt,sha256=1iSCCIueqgEkrTxtQ-jiHe99jAB10zqrVdBcwvNfe_M,21
35
+ tplinkrouterc6u-5.10.3.dist-info/RECORD,,