tplinkrouterc6u 5.12.0__py3-none-any.whl → 5.12.2__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.
@@ -0,0 +1,43 @@
1
+ from unittest import main, TestCase
2
+ from unittest.mock import patch, MagicMock
3
+ from requests import Session
4
+ from tplinkrouterc6u import TPLinkMR200Client
5
+
6
+
7
+ class TestTPLinkMR200Client(TestCase):
8
+ def setUp(self):
9
+ self.obj = TPLinkMR200Client('', '')
10
+
11
+ def test_supports_false(self):
12
+ responses = [
13
+ 'var param1="0x1A"\nvar param2="0x2B"\nignored line\n',
14
+ '404',
15
+ 'var nn="dfgdfg"\nvar ee="0x2B"\n'
16
+ ]
17
+
18
+ fake_responses = []
19
+ for text in responses:
20
+ r = MagicMock()
21
+ r.text = text
22
+ fake_responses.append(r)
23
+
24
+ with patch.object(Session, "get", side_effect=fake_responses):
25
+ for _ in range(len(fake_responses)):
26
+ result = self.obj.supports()
27
+ self.assertFalse(result)
28
+
29
+ def test_supports_true(self):
30
+ fake_response = MagicMock()
31
+ fake_response.text = (
32
+ 'var nn="0x1A"\n'
33
+ 'var ee="0x2B"\n'
34
+ )
35
+
36
+ with patch.object(Session, "get", return_value=fake_response):
37
+ result = self.obj.supports()
38
+
39
+ self.assertEqual(result, True)
40
+
41
+
42
+ if __name__ == '__main__':
43
+ main()
@@ -240,6 +240,7 @@ class TplinkBaseRouter(AbstractRouter, TplinkRequest):
240
240
  self._url_firmware = 'admin/firmware?form=upgrade&operation=read'
241
241
  self._url_ipv4_reservations = 'admin/dhcps?form=reservation&operation=load'
242
242
  self._url_ipv4_dhcp_leases = 'admin/dhcps?form=client&operation=load'
243
+ self._url_smart_network = 'admin/smart_network?form=game_accelerator&operation=loadDevice'
243
244
  self._url_openvpn = 'admin/openvpn?form=config&operation=read'
244
245
  self._url_pptpd = 'admin/pptpd?form=config&operation=read'
245
246
  self._url_vpnconn_openvpn = 'admin/vpnconn?form=config&operation=list&vpntype=openvpn'
@@ -341,7 +342,7 @@ class TplinkBaseRouter(AbstractRouter, TplinkRequest):
341
342
  smart_network = None
342
343
  if self._smart_network:
343
344
  try:
344
- smart_network = self.request('admin/smart_network?form=game_accelerator', 'operation=loadDevice')
345
+ smart_network = self.request(self._url_smart_network, 'operation=loadDevice')
345
346
  except Exception:
346
347
  self._smart_network = False
347
348
 
@@ -483,6 +484,7 @@ class TplinkRouter(TplinkEncryption, TplinkBaseRouter):
483
484
  self._url_firmware = 'admin/firmware?form=upgrade'
484
485
  self._url_ipv4_reservations = 'admin/dhcps?form=reservation'
485
486
  self._url_ipv4_dhcp_leases = 'admin/dhcps?form=client'
487
+ self._url_smart_network = 'admin/smart_network?form=game_accelerator'
486
488
  self._url_openvpn = 'admin/openvpn?form=config'
487
489
  self._url_pptpd = 'admin/pptpd?form=config'
488
490
  self._url_vpnconn_openvpn = 'admin/vpnconn?form=config'
@@ -22,12 +22,10 @@ class TPLinkMR200Client(TPLinkMRClient):
22
22
  return False
23
23
 
24
24
  def authorize(self) -> None:
25
- params = self.__get_params()
25
+ self.__get_params()
26
26
 
27
27
  # Construct the RSA public key manually using modulus (n) and exponent (e)
28
- n = int(params["nn"])
29
- e = int(params["ee"])
30
- pub_key = RSA.construct((n, e))
28
+ pub_key = RSA.construct((self._nn, self._ee))
31
29
 
32
30
  # Create an RSA cipher with PKCS#1 v1.5 padding (same as rsa.encrypt)
33
31
  cipher = PKCS1_v1_5.new(pub_key)
@@ -116,7 +114,7 @@ class TPLinkMR200Client(TPLinkMRClient):
116
114
 
117
115
  return status
118
116
 
119
- def __get_params(self, retry=False):
117
+ def __get_params(self, retry=False) -> None:
120
118
  self.req.headers = {'referer': f'{self.host}/', 'origin': self.host}
121
119
  try:
122
120
  r = self.req.get(f"{self.host}/cgi/getParm", timeout=5)
@@ -124,11 +122,13 @@ class TPLinkMR200Client(TPLinkMRClient):
124
122
  for line in r.text.splitlines()[0:2]:
125
123
  match = search(r"var (.*)=\"(.*)\"", line)
126
124
  result[match.group(1)] = int(match.group(2), 16)
127
- return result
128
- except Exception:
125
+
126
+ self._nn = int(result["nn"])
127
+ self._ee = int(result["ee"])
128
+ except Exception as e:
129
129
  if not retry:
130
- return self.__get_params(True)
131
- raise ClientException()
130
+ self.__get_params(True)
131
+ raise ClientException(str(e))
132
132
 
133
133
  def req_act(self, acts: list):
134
134
  '''
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tplinkrouterc6u
3
- Version: 5.12.0
3
+ Version: 5.12.2
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
@@ -49,7 +49,9 @@ Python package for API access and management for TP-Link and Mercusys Routers. S
49
49
  - [pycryptodome](https://pypi.org/project/pycryptodome/)
50
50
 
51
51
  ## Usage
52
- Enter the host & credentials used to log in to your router management page. Username is `admin` by default. But you may pass username as third parameter. Some routers have default username - `user`
52
+ - Enter the host & credentials used to log in to your router management page. Username is `admin` by default. But you may pass username as third parameter. Some routers have default username - `user`
53
+ - Use Local Password which is for Log In with Local Password. Login with TP-LINK ID doesnt work
54
+ - If you use `https` connection - You need to turn on "Local Management via HTTPS" (advanced->system->administration) in the router web UI
53
55
 
54
56
  ```python
55
57
  from tplinkrouterc6u import (
@@ -304,7 +306,7 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
304
306
  - [TP-LINK routers](#tplink)
305
307
  - [MERCUSYS routers](#mercusys)
306
308
  ### <a id="tplink">TP-LINK routers</a>
307
- - Archer A6 V2.0
309
+ - Archer A6 (2.0, 4.0)
308
310
  - Archer A7 V5
309
311
  - Archer A8 (1.0, 2.20)
310
312
  - Archer A9 V6
@@ -323,6 +325,7 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
323
325
  - Archer AX73 (V1, V2.0)
324
326
  - Archer AX75 V1
325
327
  - Archer AX90 V1.20
328
+ - Archer AX95 v1.0
326
329
  - Archer AXE75 V1
327
330
  - Archer AXE5400 v1.0
328
331
  - Archer AXE16000
@@ -330,6 +333,7 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
330
333
  - Archer AX3000 V1
331
334
  - Archer AX6000 V1
332
335
  - Archer AX11000 V1
336
+ - Archer BE220 v1.0
333
337
  - Archer BE230 v1.0
334
338
  - Archer BE400 v1.0
335
339
  - Archer BE550 v1.0
@@ -391,6 +395,8 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
391
395
  - VX420-G2h v1.1
392
396
  - VX800v v1
393
397
  - XC220-G3v v2.30
398
+ - RE305 4.0
399
+ - RE315 1.0
394
400
  - RE330 v1
395
401
  ### <a id="mercusys">MERCUSYS routers</a>
396
402
  - AC10 1.20
@@ -5,6 +5,7 @@ test/test_client_c80.py,sha256=RY_1SgRVcQQdN9h0_IXA0YW4_0flEB_uel05QvDDfws,42359
5
5
  test/test_client_deco.py,sha256=YPLKRD8GoyDYHfRgdXvCk8iVNw8zdMJW-AHVnNbpdTM,31719
6
6
  test/test_client_ex.py,sha256=Kg6svEKtyGAfyF9yrLh2qZa2tK1mlEBJJwXRsq1MAjo,26591
7
7
  test/test_client_mr.py,sha256=lePxkmjcPzcrSFcaT8bT67L154cVJIOWrFlXMDOa8oY,33423
8
+ test/test_client_mr_200.py,sha256=86yANn5SUhVW6Uc5q5s_aTNL7tDnREeXk378G61v_TM,1186
8
9
  test/test_client_re330.py,sha256=MgefuvOzfZtZOujrcOsjiTDiGEAujfeFXshcq7gn32Q,17044
9
10
  test/test_client_wdr.py,sha256=0ZnRNP57MbuMv2cxFS8iIoVyv8Q6gtY0Q03gtHp9AWY,13492
10
11
  test/test_client_xdr.py,sha256=mgn-xL5mD5sHD8DjTz9vpY7jeh4Ob6Um6Y8v5Qgx2jA,23374
@@ -14,12 +15,12 @@ tplinkrouterc6u/provider.py,sha256=lqxw_pQ4VBYKS3jKrG1zVd4zVnlA6T8MaIRcqq3JAtM,2
14
15
  tplinkrouterc6u/client/__init__.py,sha256=KBy3fmtA9wgyFrb0Urh2x4CkKtWVnESdp-vxmuOvq0k,27
15
16
  tplinkrouterc6u/client/c1200.py,sha256=4XEYidEGmVIJk0YQLvmTnd0Gqa7glH2gUWvjreHpWrk,3178
16
17
  tplinkrouterc6u/client/c5400x.py,sha256=9E0omBSbWY_ljrs5MTCMu5brmrLtzsDB5O62Db8lP8Q,4329
17
- tplinkrouterc6u/client/c6u.py,sha256=n4OMAxg0NXChYaVpWCvx3ZFUxVfynTMy-pyd1CTj9s4,19694
18
+ tplinkrouterc6u/client/c6u.py,sha256=Lh0YktqD4mRdQ_Q6b-fy_s_bgLx3cEdyoD5doOIbOzI,19851
18
19
  tplinkrouterc6u/client/c80.py,sha256=efE0DEjEfzRFr35fjKA_hsv9YaWy_2dgLAaurDM-WQk,17665
19
20
  tplinkrouterc6u/client/deco.py,sha256=cpKRggKD2RvSmMZuD6tzsZmehAUCU9oLiTTHcZBW81Y,8898
20
21
  tplinkrouterc6u/client/ex.py,sha256=tOcMugCViAcISULg8otp3NjdkPyuUXihcoe_0lql3AQ,14886
21
22
  tplinkrouterc6u/client/mr.py,sha256=7MtnKqmtbggWBx6RIiJzlGuSyVDbC8MFynPrc34bSd0,28948
22
- tplinkrouterc6u/client/mr200.py,sha256=-5CjqK8rbCAyiP7XPLlSJO3xqSPnQ8DeQ6S1jo4XKnc,5786
23
+ tplinkrouterc6u/client/mr200.py,sha256=-EkaSpbhyX8QolwIwRdvl5KGTL0fmzA7xCOo_YQGb3c,5800
23
24
  tplinkrouterc6u/client/re330.py,sha256=9Wj4VpYJbVwZJUh9s3magdeL3Jl-B7qyrWfrVBxRk4A,17465
24
25
  tplinkrouterc6u/client/vr.py,sha256=7Tbu0IrWtr4HHtyrnLFXEJi1QctzhilciL7agtwQ0R8,5025
25
26
  tplinkrouterc6u/client/wdr.py,sha256=i54PEifjhfOScDpgNBXygw9U4bfsVtle846_YjnDoBs,21679
@@ -30,8 +31,8 @@ tplinkrouterc6u/common/encryption.py,sha256=EWfgGafOz0YgPilBndVaupnjw6JrzhVBdZkB
30
31
  tplinkrouterc6u/common/exception.py,sha256=_0G8ZvW5__CsGifHrsZeULdl8c6EUD071sDCQsQgrHY,140
31
32
  tplinkrouterc6u/common/helper.py,sha256=23b04fk9HuVinrZXMCS5R1rmF8uZ7eM-Cdnp7Br9NR0,572
32
33
  tplinkrouterc6u/common/package_enum.py,sha256=CMHVSgk4RSZyFoPi3499-sJDYg-nfnyJbz1iArFU9Hw,1644
33
- tplinkrouterc6u-5.12.0.dist-info/licenses/LICENSE,sha256=YF6QR6Vjxcg5b_sYIyqkME7FZYau5TfEUGTG-0JeRK0,35129
34
- tplinkrouterc6u-5.12.0.dist-info/METADATA,sha256=ZyKhYdvdTxEjUCuFKwlbj8E5nssESZZFRmtGs65pKsk,17267
35
- tplinkrouterc6u-5.12.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
36
- tplinkrouterc6u-5.12.0.dist-info/top_level.txt,sha256=1iSCCIueqgEkrTxtQ-jiHe99jAB10zqrVdBcwvNfe_M,21
37
- tplinkrouterc6u-5.12.0.dist-info/RECORD,,
34
+ tplinkrouterc6u-5.12.2.dist-info/licenses/LICENSE,sha256=YF6QR6Vjxcg5b_sYIyqkME7FZYau5TfEUGTG-0JeRK0,35129
35
+ tplinkrouterc6u-5.12.2.dist-info/METADATA,sha256=8g0QXyvFJ1l5gRmUKnKqtubRiClQOVMU7KX8QHpNOvI,17573
36
+ tplinkrouterc6u-5.12.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
37
+ tplinkrouterc6u-5.12.2.dist-info/top_level.txt,sha256=1iSCCIueqgEkrTxtQ-jiHe99jAB10zqrVdBcwvNfe_M,21
38
+ tplinkrouterc6u-5.12.2.dist-info/RECORD,,