tplinkrouterc6u 5.6.2__tar.gz → 5.8.0__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.
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/PKG-INFO +8 -2
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/README.md +7 -1
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/setup.py +1 -1
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/test/test_client_c6u.py +44 -0
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/test/test_client_c80.py +6 -0
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/test/test_client_mr.py +0 -2
- tplinkrouterc6u-5.8.0/test/test_client_wdr.py +292 -0
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/tplinkrouterc6u/__init__.py +1 -0
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/tplinkrouterc6u/client/c6u.py +1 -1
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/tplinkrouterc6u/client/c80.py +6 -2
- tplinkrouterc6u-5.8.0/tplinkrouterc6u/client/wdr.py +672 -0
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/tplinkrouterc6u/common/dataclass.py +1 -0
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/tplinkrouterc6u/provider.py +2 -1
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/tplinkrouterc6u.egg-info/PKG-INFO +8 -2
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/tplinkrouterc6u.egg-info/SOURCES.txt +2 -0
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/LICENSE +0 -0
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/setup.cfg +0 -0
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/test/__init__.py +0 -0
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/test/test_client_c1200.py +0 -0
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/test/test_client_deco.py +0 -0
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/test/test_client_ex.py +0 -0
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/test/test_client_xdr.py +0 -0
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/tplinkrouterc6u/client/__init__.py +0 -0
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/tplinkrouterc6u/client/c1200.py +0 -0
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/tplinkrouterc6u/client/c5400x.py +0 -0
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/tplinkrouterc6u/client/deco.py +0 -0
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/tplinkrouterc6u/client/ex.py +0 -0
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/tplinkrouterc6u/client/mr.py +0 -0
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/tplinkrouterc6u/client/vr.py +0 -0
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/tplinkrouterc6u/client/xdr.py +0 -0
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/tplinkrouterc6u/client_abstract.py +0 -0
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/tplinkrouterc6u/common/__init__.py +0 -0
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/tplinkrouterc6u/common/encryption.py +0 -0
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/tplinkrouterc6u/common/exception.py +0 -0
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/tplinkrouterc6u/common/helper.py +0 -0
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/tplinkrouterc6u/common/package_enum.py +0 -0
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/tplinkrouterc6u.egg-info/dependency_links.txt +0 -0
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/tplinkrouterc6u.egg-info/requires.txt +0 -0
- {tplinkrouterc6u-5.6.2 → tplinkrouterc6u-5.8.0}/tplinkrouterc6u.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tplinkrouterc6u
|
|
3
|
-
Version: 5.
|
|
3
|
+
Version: 5.8.0
|
|
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
|
|
@@ -187,6 +187,7 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
187
187
|
| down_speed | download speed | int, None |
|
|
188
188
|
| up_speed | upload speed | int, None |
|
|
189
189
|
| signal | Signal strength | int, None |
|
|
190
|
+
| active | Is active device | bool |
|
|
190
191
|
|
|
191
192
|
### <a id="IPv4Reservation">IPv4Reservation</a>
|
|
192
193
|
| Field | Description | Type |
|
|
@@ -288,9 +289,11 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
288
289
|
- [TP-LINK routers](#tplink)
|
|
289
290
|
- [MERCUSYS routers](#mercusys)
|
|
290
291
|
### <a id="tplink">TP-LINK routers</a>
|
|
292
|
+
- Archer A6 V2.0
|
|
291
293
|
- Archer A7 V5
|
|
292
|
-
- Archer A8 1.0
|
|
294
|
+
- Archer A8 (1.0, 2.20)
|
|
293
295
|
- Archer A9 V6
|
|
296
|
+
- Archer A20 v1.0
|
|
294
297
|
- Archer AX10 v1.0
|
|
295
298
|
- Archer AX12 v1.0
|
|
296
299
|
- Archer AX20 (v1.0, v3.0)
|
|
@@ -309,6 +312,7 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
309
312
|
- Archer AX3000 V1
|
|
310
313
|
- Archer AX6000 V1
|
|
311
314
|
- Archer AX11000 V1
|
|
315
|
+
- Archer BE550 v1.0
|
|
312
316
|
- Archer BE800 v1.0
|
|
313
317
|
- Archer BE805 v1.0
|
|
314
318
|
- Archer BE3600 1.6
|
|
@@ -338,6 +342,7 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
338
342
|
- Deco P7
|
|
339
343
|
- Deco X20
|
|
340
344
|
- Deco X50 v1.3
|
|
345
|
+
- Deco X55 1.0
|
|
341
346
|
- Deco X60 V3
|
|
342
347
|
- Deco X90
|
|
343
348
|
- Deco XE75 (v1.0, v2.0)
|
|
@@ -353,6 +358,7 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
353
358
|
- TL-WA1201 3.0
|
|
354
359
|
- TL-WA3001 v1.0
|
|
355
360
|
- TL-XDR3010 V2
|
|
361
|
+
- TL-WDR3600 V1
|
|
356
362
|
- XC220-G3v v2.30
|
|
357
363
|
### <a id="mercusys">MERCUSYS routers</a>
|
|
358
364
|
- MR47BE v1.0
|
|
@@ -155,6 +155,7 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
155
155
|
| down_speed | download speed | int, None |
|
|
156
156
|
| up_speed | upload speed | int, None |
|
|
157
157
|
| signal | Signal strength | int, None |
|
|
158
|
+
| active | Is active device | bool |
|
|
158
159
|
|
|
159
160
|
### <a id="IPv4Reservation">IPv4Reservation</a>
|
|
160
161
|
| Field | Description | Type |
|
|
@@ -256,9 +257,11 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
256
257
|
- [TP-LINK routers](#tplink)
|
|
257
258
|
- [MERCUSYS routers](#mercusys)
|
|
258
259
|
### <a id="tplink">TP-LINK routers</a>
|
|
260
|
+
- Archer A6 V2.0
|
|
259
261
|
- Archer A7 V5
|
|
260
|
-
- Archer A8 1.0
|
|
262
|
+
- Archer A8 (1.0, 2.20)
|
|
261
263
|
- Archer A9 V6
|
|
264
|
+
- Archer A20 v1.0
|
|
262
265
|
- Archer AX10 v1.0
|
|
263
266
|
- Archer AX12 v1.0
|
|
264
267
|
- Archer AX20 (v1.0, v3.0)
|
|
@@ -277,6 +280,7 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
277
280
|
- Archer AX3000 V1
|
|
278
281
|
- Archer AX6000 V1
|
|
279
282
|
- Archer AX11000 V1
|
|
283
|
+
- Archer BE550 v1.0
|
|
280
284
|
- Archer BE800 v1.0
|
|
281
285
|
- Archer BE805 v1.0
|
|
282
286
|
- Archer BE3600 1.6
|
|
@@ -306,6 +310,7 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
306
310
|
- Deco P7
|
|
307
311
|
- Deco X20
|
|
308
312
|
- Deco X50 v1.3
|
|
313
|
+
- Deco X55 1.0
|
|
309
314
|
- Deco X60 V3
|
|
310
315
|
- Deco X90
|
|
311
316
|
- Deco XE75 (v1.0, v2.0)
|
|
@@ -321,6 +326,7 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
321
326
|
- TL-WA1201 3.0
|
|
322
327
|
- TL-WA3001 v1.0
|
|
323
328
|
- TL-XDR3010 V2
|
|
329
|
+
- TL-WDR3600 V1
|
|
324
330
|
- XC220-G3v v2.30
|
|
325
331
|
### <a id="mercusys">MERCUSYS routers</a>
|
|
326
332
|
- MR47BE v1.0
|
|
@@ -257,6 +257,7 @@ class TestTPLinkClient(TestCase):
|
|
|
257
257
|
self.assertEqual(status.devices[0].hostname, 'SERVER')
|
|
258
258
|
self.assertEqual(status.devices[0].packets_sent, None)
|
|
259
259
|
self.assertEqual(status.devices[0].packets_received, None)
|
|
260
|
+
self.assertEqual(status.devices[0].active, True)
|
|
260
261
|
self.assertIsInstance(status.devices[0], Device)
|
|
261
262
|
self.assertEqual(status.devices[1].type, Connection.WIRED)
|
|
262
263
|
self.assertEqual(status.devices[1].macaddr, 'AC-04-D6-25-2A-96')
|
|
@@ -266,6 +267,7 @@ class TestTPLinkClient(TestCase):
|
|
|
266
267
|
self.assertEqual(status.devices[1].hostname, 'UNKNOWN')
|
|
267
268
|
self.assertEqual(status.devices[1].packets_sent, None)
|
|
268
269
|
self.assertEqual(status.devices[1].packets_received, None)
|
|
270
|
+
self.assertEqual(status.devices[1].active, True)
|
|
269
271
|
self.assertIsInstance(status.devices[2], Device)
|
|
270
272
|
self.assertEqual(status.devices[2].type, Connection.HOST_2G)
|
|
271
273
|
self.assertEqual(status.devices[2].macaddr, '06-82-9D-2B-8F-C6')
|
|
@@ -273,6 +275,7 @@ class TestTPLinkClient(TestCase):
|
|
|
273
275
|
self.assertEqual(status.devices[2].hostname, 'UNKNOWN')
|
|
274
276
|
self.assertEqual(status.devices[2].packets_sent, 450333)
|
|
275
277
|
self.assertEqual(status.devices[2].packets_received, 4867482)
|
|
278
|
+
self.assertEqual(status.devices[2].active, True)
|
|
276
279
|
self.assertIsInstance(status.devices[3], Device)
|
|
277
280
|
self.assertEqual(status.devices[3].type, Connection.HOST_2G)
|
|
278
281
|
self.assertEqual(status.devices[3].macaddr, '06-55-9D-2B-8F-A7')
|
|
@@ -280,6 +283,7 @@ class TestTPLinkClient(TestCase):
|
|
|
280
283
|
self.assertEqual(status.devices[3].hostname, 'Unknown')
|
|
281
284
|
self.assertEqual(status.devices[3].packets_sent, None)
|
|
282
285
|
self.assertEqual(status.devices[3].packets_received, None)
|
|
286
|
+
self.assertEqual(status.devices[3].active, True)
|
|
283
287
|
self.assertIsInstance(status.devices[4], Device)
|
|
284
288
|
self.assertEqual(status.devices[4].type, Connection.HOST_5G)
|
|
285
289
|
self.assertEqual(status.devices[4].macaddr, '1F-7A-BD-F7-20-0D')
|
|
@@ -287,6 +291,7 @@ class TestTPLinkClient(TestCase):
|
|
|
287
291
|
self.assertEqual(status.devices[4].hostname, '')
|
|
288
292
|
self.assertEqual(status.devices[4].packets_sent, 134815)
|
|
289
293
|
self.assertEqual(status.devices[4].packets_received, 2953078)
|
|
294
|
+
self.assertEqual(status.devices[4].active, True)
|
|
290
295
|
|
|
291
296
|
def test_get_status_ax_55(self) -> None:
|
|
292
297
|
response_status = '''
|
|
@@ -724,6 +729,45 @@ class TestTPLinkClient(TestCase):
|
|
|
724
729
|
self.assertEqual(result.lan_ipv4_dhcp_enable, False)
|
|
725
730
|
self.assertEqual(result.remote, None)
|
|
726
731
|
|
|
732
|
+
def test_get_status_wan_macaddr_empty(self) -> None:
|
|
733
|
+
response_status = '''
|
|
734
|
+
{
|
|
735
|
+
"success": true,
|
|
736
|
+
"data": {
|
|
737
|
+
"lan_macaddr": "06:e6:97:9e:23:f5",
|
|
738
|
+
"wan_macaddr": "",
|
|
739
|
+
"wan_ipv4_ipaddr": "0.0.0.0",
|
|
740
|
+
"wan_ipv4_gateway": "0.0.0.0"
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
'''
|
|
744
|
+
response_stats = '''
|
|
745
|
+
{
|
|
746
|
+
"data": [],
|
|
747
|
+
"timeout": false,
|
|
748
|
+
"success": true,
|
|
749
|
+
"operator": "load"
|
|
750
|
+
}
|
|
751
|
+
'''
|
|
752
|
+
|
|
753
|
+
class TPLinkRouterTest(TplinkRouter):
|
|
754
|
+
def request(self, path: str, data: str,
|
|
755
|
+
ignore_response: bool = False, ignore_errors: bool = False) -> dict | None:
|
|
756
|
+
if path == 'admin/status?form=all&operation=read':
|
|
757
|
+
return loads(response_status)['data']
|
|
758
|
+
elif path == 'admin/wireless?form=statistics':
|
|
759
|
+
return loads(response_stats)['data']
|
|
760
|
+
raise ClientException()
|
|
761
|
+
|
|
762
|
+
client = TPLinkRouterTest('', '')
|
|
763
|
+
result = client.get_status()
|
|
764
|
+
|
|
765
|
+
self.assertIsInstance(result, Status)
|
|
766
|
+
self.assertEqual(result.wan_macaddr, None)
|
|
767
|
+
self.assertEqual(result.wan_ipv4_addr, '0.0.0.0')
|
|
768
|
+
self.assertEqual(result.wan_ipv4_gateway, '0.0.0.0')
|
|
769
|
+
self.assertEqual(result.lan_macaddr, '06-E6-97-9E-23-F5')
|
|
770
|
+
|
|
727
771
|
|
|
728
772
|
if __name__ == '__main__':
|
|
729
773
|
main()
|
|
@@ -474,6 +474,7 @@ class TestTPLinkClient(TestCase):
|
|
|
474
474
|
self.assertEqual(device.hostname, 'Laptop')
|
|
475
475
|
self.assertEqual(device.up_speed, 0)
|
|
476
476
|
self.assertEqual(device.down_speed, 0)
|
|
477
|
+
self.assertEqual(device.active, False)
|
|
477
478
|
|
|
478
479
|
device = status.devices[1]
|
|
479
480
|
self.assertIsInstance(device, Device)
|
|
@@ -485,6 +486,7 @@ class TestTPLinkClient(TestCase):
|
|
|
485
486
|
self.assertEqual(device.hostname, 'iPhone')
|
|
486
487
|
self.assertEqual(device.up_speed, 0)
|
|
487
488
|
self.assertEqual(device.down_speed, 0)
|
|
489
|
+
self.assertEqual(device.active, False)
|
|
488
490
|
|
|
489
491
|
device = status.devices[2]
|
|
490
492
|
self.assertIsInstance(device, Device)
|
|
@@ -496,6 +498,7 @@ class TestTPLinkClient(TestCase):
|
|
|
496
498
|
self.assertEqual(device.hostname, 'Laptop2')
|
|
497
499
|
self.assertEqual(device.up_speed, 30)
|
|
498
500
|
self.assertEqual(device.down_speed, 200)
|
|
501
|
+
self.assertEqual(device.active, True)
|
|
499
502
|
|
|
500
503
|
device = status.devices[3]
|
|
501
504
|
self.assertIsInstance(device, Device)
|
|
@@ -507,6 +510,7 @@ class TestTPLinkClient(TestCase):
|
|
|
507
510
|
self.assertEqual(device.hostname, 'iPhone2')
|
|
508
511
|
self.assertEqual(device.up_speed, 800)
|
|
509
512
|
self.assertEqual(device.down_speed, 400)
|
|
513
|
+
self.assertEqual(device.active, True)
|
|
510
514
|
|
|
511
515
|
device = status.devices[4]
|
|
512
516
|
self.assertIsInstance(device, Device)
|
|
@@ -518,6 +522,7 @@ class TestTPLinkClient(TestCase):
|
|
|
518
522
|
self.assertEqual(device.hostname, 'IoT_thing')
|
|
519
523
|
self.assertEqual(device.up_speed, 1824)
|
|
520
524
|
self.assertEqual(device.down_speed, 800)
|
|
525
|
+
self.assertEqual(device.active, True)
|
|
521
526
|
|
|
522
527
|
device = status.devices[5]
|
|
523
528
|
self.assertIsInstance(device, Device)
|
|
@@ -529,6 +534,7 @@ class TestTPLinkClient(TestCase):
|
|
|
529
534
|
self.assertEqual(device.hostname, 'PC')
|
|
530
535
|
self.assertEqual(device.up_speed, 600)
|
|
531
536
|
self.assertEqual(device.down_speed, 50)
|
|
537
|
+
self.assertEqual(device.active, True)
|
|
532
538
|
|
|
533
539
|
def test_get_status_without_iot(self) -> None:
|
|
534
540
|
client = TplinkC80RouterTest('', '')
|
|
@@ -734,7 +734,6 @@ ussdStatus=1
|
|
|
734
734
|
|
|
735
735
|
class TPLinkMRClientTest(TPLinkMRClient):
|
|
736
736
|
def _request(self, url, method='POST', data_str=None, encrypt=False):
|
|
737
|
-
nonlocal check_url, check_data
|
|
738
737
|
check_url.append(url)
|
|
739
738
|
check_data.append(data_str)
|
|
740
739
|
return 200, responses.pop(0)
|
|
@@ -776,7 +775,6 @@ ussdStatus=2
|
|
|
776
775
|
|
|
777
776
|
class TPLinkMRClientTest(TPLinkMRClient):
|
|
778
777
|
def _request(self, url, method='POST', data_str=None, encrypt=False):
|
|
779
|
-
nonlocal check_url, check_data
|
|
780
778
|
check_url.append(url)
|
|
781
779
|
check_data.append(data_str)
|
|
782
780
|
return 200, responses.pop(0)
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
from unittest import main, TestCase
|
|
2
|
+
from ipaddress import IPv4Address
|
|
3
|
+
from macaddress import EUI48
|
|
4
|
+
from tplinkrouterc6u.common.dataclass import Firmware, Status
|
|
5
|
+
from tplinkrouterc6u.common.dataclass import IPv4Status, IPv4Reservation, IPv4DHCPLease
|
|
6
|
+
from tplinkrouterc6u import ClientError
|
|
7
|
+
from tplinkrouterc6u.client.wdr import TplinkWDRRouter
|
|
8
|
+
|
|
9
|
+
_NETWAN = (
|
|
10
|
+
'<SCRIPT language="javascript" type="text/javascript">\nvar wanTypeDetectInfoArray = '
|
|
11
|
+
+ "new Array(\n1, 0, 4500, \n0,0 );\n</SCRIPT>\n"
|
|
12
|
+
+ '<SCRIPT language="javascript" type="text/javascript">\nvar dhcpInf = new Array(\n1,\n'
|
|
13
|
+
+ '0,\n1,\n0,\n0,\n0,\n0,\n0,\n"",\n"",\n0,\n0,\n"",\n"192.168.0.129",\n"255.255.255.0",\n'
|
|
14
|
+
+ '"192.168.0.1",\n1,\n0,\n1500,\n0,\n"8.8.8.8",\n1,\n"8.8.4.4",\n0,\n0,\n0,\n"TL-WDR3600",\n0,0 );\n</SCRIPT>\n'
|
|
15
|
+
+ '<SCRIPT language="javascript" type="text/javascript">\nvar wantypeinfo = new Array(\n6,\n0,\n'
|
|
16
|
+
+ '"WanDynamicIpCfgRpm.htm",\n1,\n"WanStaticIpCfgRpm.htm",\n'
|
|
17
|
+
+ '2,\n"PPPoECfgRpm.htm",\n5,\n"BPACfgRpm.htm",\n6,\n"L2TPCfgRpm.htm",\n7,\n"PPTPCfgRpm.htm",\n0,0 );\n</SCRIPT>'
|
|
18
|
+
)
|
|
19
|
+
_NETLAN = (
|
|
20
|
+
'<SCRIPT language="javascript" type="text/javascript">\nvar lanPara = new Array(\n"C4-6E-1F-41-67-C0",\n'
|
|
21
|
+
+ '"192.168.1.254",\n2,\n"255.255.255.0",\n1,\n0,0 );\n</SCRIPT>'
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
_W24STA = (
|
|
25
|
+
'<SCRIPT language="javascript" type="text/javascript">\nvar wlanHostPara = new Array(\n1, 1, 8, 5000, 4,\n'
|
|
26
|
+
+ '0,0);\n</SCRIPT>\n<SCRIPT language="javascript" type="text/javascript">\nvar hostList = new Array(\n'
|
|
27
|
+
+ '"D0-BD-53-57-3E-4A", 1, 170893827, 0,\n"08-16-AC-03-E2-FA", 1, 873409583, 0,\n"F8-F1-E8-CD-0A-CF", 1, '
|
|
28
|
+
+ '240958643, 0,\n"ED-49-92-1A-1D-D7", 1, 358743698, 0,\n"0E-50-99-5D-9A-D5", 1, 572346959, 0,\n0,0 );\n</SCRIPT>'
|
|
29
|
+
)
|
|
30
|
+
_W50STA = (
|
|
31
|
+
'<SCRIPT language="javascript" type="text/javascript">\nvar wlanHostPara = new Array(\n1, 1, 8, 5000, 4,\n'
|
|
32
|
+
+ '0,0 );\n</SCRIPT>\n<SCRIPT language="javascript" type="text/javascript">\nvar hostList = new Array(\n'
|
|
33
|
+
+ '"50-A6-FC-6D-EB-D3", 1, 708938274, 0,\n"6A-D0-5F-2A-FA-2D", 1, 287340958, 0,\n"DA-69-2D-59-B3-FA", 1'
|
|
34
|
+
+ ", 540958641, 0,\n0,0 );\n</SCRIPT>"
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
_WLANGUEST = (
|
|
38
|
+
'<SCRIPT language="javascript" type="text/javascript">\nvar guestNetworkBandwidthInf = '
|
|
39
|
+
+ "new Array(\n"
|
|
40
|
+
+ '0,\n1000000,\n1000000,\n1024,\n1024,\n1,\n0,0);\n</SCRIPT>\n<SCRIPT language="javascript" '
|
|
41
|
+
+ 'type="text/javascript">'
|
|
42
|
+
+ '\nvar guestNetAccTime2gInf = new Array(\n1,\n1,\n0,\n0,\n0,\n1,\n0,\n0,\n0,\n0,\n0,\n0,\n0,\n1,\n"",\n"",\n'
|
|
43
|
+
+ "0,0 );"
|
|
44
|
+
+ '\n</SCRIPT>\n<SCRIPT language="javascript" type="text/javascript">\nvar guestNetAccTime5gInf = new Array(\n'
|
|
45
|
+
+ '1,\n0,\n0,\n0,\n0,\n1,\n0,\n0,\n0,\n0,\n0,\n0,\n0,\n1,\n"",\n"",\n0,0 );\n</SCRIPT>\n'
|
|
46
|
+
+ '<SCRIPT language="javascript" type="text/javascript">\nvar guestNetworkInf = '
|
|
47
|
+
+ 'new Array(\n1, 1, 1, 0, "Pegasus", '
|
|
48
|
+
+ '"Pegasus", 1, 1, 3, 3, "333", "333", 0, 0, "p4ssw0rd", "p4ssw0rd", '
|
|
49
|
+
+ "0, 0, 0, 0, 3, 3, 1, 1, 5, 8, 0, \n0,0 );\n"
|
|
50
|
+
+ "</SCRIPT>"
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
_DHCPCFG = (
|
|
54
|
+
'<SCRIPT language="javascript" type="text/javascript">\nvar DHCPPara = new Array(\n1,\n"192.168.1.129",\n'
|
|
55
|
+
+ '"192.168.1.192",\n120,\n"192.168.1.254",\n"internal.lan",\n"8.8.8.8",\n"8.8.4.4",\n0,\n0,0 );\n</SCRIPT>'
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
_DHCPLEASES = (
|
|
59
|
+
'<SCRIPT language="javascript" type="text/javascript">var DHCPDynList = new Array(\n"aliquam",'
|
|
60
|
+
+ '"A9-A8-2B-F7-9F-5D","192.168.1.123","Permanent",\n"pharetra","B3-A5-1E-C3-92-A9","192.168.1.163","Permanent",\n'
|
|
61
|
+
+ '"ligula","71-34-47-FD-DE-84","192.168.1.165","Permanent",\n"vulputate","46-5F-5F-27-23-9F","192.168.1.103",'
|
|
62
|
+
+ '"Permanent",\n"amet","86-9F-53-91-04-2B","192.168.1.72","Permanent",\n"volutpat","FA-5C-6F-87-A3-5A",'
|
|
63
|
+
+ '"192.168.1.43",'
|
|
64
|
+
+ '"Permanent",\n"eget","C4-ED-6C-B6-F6-B9","192.168.1.112","Permanent",\n"ante","FF-C1-A3-93-C8-E6",'
|
|
65
|
+
+ '"192.168.1.38",'
|
|
66
|
+
+ '"Permanent",\n"pellentesque","E3-5E-59-2E-CF-AD","192.168.1.148","Permanent",\n"metus","AE-15-51-37-0E-9E",'
|
|
67
|
+
+ '"192.168.1.178","Permanent",\n0,0 );\n</SCRIPT>\n<SCRIPT language="javascript" type="text/javascript">\n'
|
|
68
|
+
+ "var DHCPDynPara = new Array(\n10,\n4,\n0,0 );\n</SCRIPT>"
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
_DHCPRESERVES = (
|
|
72
|
+
'<SCRIPT language="javascript" type="text/javascript">\nvar dhcpList = new Array(\n"9B-FA-04-D8-AB-8D",'
|
|
73
|
+
+ '"192.168.1.56",1,\n"EE-7C-6B-B6-05-2F","192.168.1.51",1,\n"09-51-B3-0B-92-01","192.168.1.21",1,\n'
|
|
74
|
+
+ '"49-6F-72-CD-68-5D","192.168.1.25",1,\n"DF-24-38-C1-FE-BB","192.168.1.51",1,\n"1A-08-6C-52-31-3D",'
|
|
75
|
+
+ '"192.168.1.22",1,\n"DE-E4-DF-9A-AD-0D","192.168.1.17",1,\n"DF-F2-CB-FE-46-15","192.168.1.26",1,\n'
|
|
76
|
+
+ '0,0 )\n</SCRIPT>\n<SCRIPT language="javascript" type="text/javascript">var DHCPStaticPara = '
|
|
77
|
+
+ "new Array(\n1,\n1,\n8,\n1,\n8,\n0,0 );\n</SCRIPT>"
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
ABSTRACT_STATUS = (
|
|
81
|
+
'<SCRIPT language="javascript" type="text/javascript">\nvar statusPara = new Array(\n1,\n1,\n1,\n'
|
|
82
|
+
+ '22,\n20000,\n1468171,\n"3.13.34 Build 130909 Rel.53148n ",\n"WDR3600 v1 00000000",\n6732336,\n0, 0);\n'
|
|
83
|
+
+ '</SCRIPT>\n'
|
|
84
|
+
+ '<SCRIPT language="javascript" type="text/javascript">\nvar lanPara = new Array(\n"C4-6E-1F-41-67-C0", '
|
|
85
|
+
+ '"192.168.1.254", "255.255.255.0",\n0, 0);\n</SCRIPT>\n<SCRIPT language="javascript" type="text/javascript">\n'
|
|
86
|
+
+ 'var wlanPara = new Array(\n1,\n"testSSID24",\n15,\n5,\n"C4-6E-1F-41-67-BF",\n"192.168.1.254",\n2,\n8,\n71,\n6,\n'
|
|
87
|
+
+ '6,\n0, 0);\n</SCRIPT>\n<SCRIPT language="javascript" type="text/javascript">\nvar wlan5GPara = new Array(\n1,\n'
|
|
88
|
+
+ '"testSSID",\n15,\n8,\n"C4-6E-1F-41-67-C0",\n"192.168.1.254",\n2,\n8,\n83,\n36,\n6,\n0, 0);\n</SCRIPT>\n'
|
|
89
|
+
+ '<SCRIPT language="javascript" type="text/javascript">\nvar statistList = '
|
|
90
|
+
+ "new Array(\n1129349328, 3900411475, 200068023, 165562287,\n0, 0);\n</SCRIPT>\n"
|
|
91
|
+
+ '<SCRIPT language="javascript" type="text/javascript">\nvar wanPara = new Array(\n4, '
|
|
92
|
+
+ '"C4-6E-1F-41-67-C1", "192.168.0.129", 1, "255.255.255.0", 0, 0, "192.168.0.1", 1, 1, 0, '
|
|
93
|
+
+ '"8.8.8.8 , 8.8.4.4", "", 0, 0, "0.0.0.0", "0.0.0.0", "0.0.0.0", "0.0.0.0 , 0.0.0.0", '
|
|
94
|
+
+ "0, 0, 0, 0, 0,\n0, 0);\n</SCRIPT>"
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
ABSTRACT_NETWORK = {
|
|
98
|
+
"netWan": _NETWAN,
|
|
99
|
+
"netLan": _NETLAN,
|
|
100
|
+
"w24stations": _W24STA,
|
|
101
|
+
"w50stations": _W50STA,
|
|
102
|
+
"wgsettings": _WLANGUEST,
|
|
103
|
+
"dhcpconfig": _DHCPCFG,
|
|
104
|
+
"dhcplease": _DHCPLEASES,
|
|
105
|
+
"dhcpreserve": _DHCPRESERVES,
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class ResponseMock:
|
|
110
|
+
def __init__(self, text: str, status_code=0):
|
|
111
|
+
self.content = text.encode("utf8")
|
|
112
|
+
self.status_code = status_code
|
|
113
|
+
self.headers: dict = {}
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
class TplinkWDRRouterTest(TplinkWDRRouter):
|
|
117
|
+
response = ""
|
|
118
|
+
|
|
119
|
+
def request(
|
|
120
|
+
self,
|
|
121
|
+
section: str,
|
|
122
|
+
data: str,
|
|
123
|
+
ignore_response: bool = False,
|
|
124
|
+
ignore_errors: bool = False,
|
|
125
|
+
) -> str | dict | None:
|
|
126
|
+
# only a test, so no extra headers
|
|
127
|
+
# Responses
|
|
128
|
+
sections = "summary,status,"
|
|
129
|
+
sections += "netWan,netLan,dualBand,"
|
|
130
|
+
sections += "w24settings,w24wps,w24sec,w24adv,w24stations,"
|
|
131
|
+
sections += "w50settings,w50wps,w50sec,w50adv,w50stations,"
|
|
132
|
+
sections += "wgsettings,wgshare,dhcpconfig,dhcplease,dhcpreserve,"
|
|
133
|
+
sections += "portFwd,sysroute,upnpFwd"
|
|
134
|
+
|
|
135
|
+
section_list = sections.split(",")
|
|
136
|
+
|
|
137
|
+
if ignore_response:
|
|
138
|
+
return None
|
|
139
|
+
elif section == "check":
|
|
140
|
+
resp = ResponseMock("", 200)
|
|
141
|
+
resp.headers["www-authenticate"] = (
|
|
142
|
+
'Basic realm="TP-LINK Wireless Dual Band Gigabit Router WDR3600"'
|
|
143
|
+
)
|
|
144
|
+
return resp
|
|
145
|
+
elif section in section_list:
|
|
146
|
+
if section in ["summary", "status"]:
|
|
147
|
+
return ResponseMock(ABSTRACT_STATUS).content
|
|
148
|
+
elif section in ["w24stations", "w50stations", "dhcpreserve"]:
|
|
149
|
+
return ResponseMock(ABSTRACT_NETWORK[section]).content
|
|
150
|
+
elif section in [
|
|
151
|
+
"netLan",
|
|
152
|
+
"netWan",
|
|
153
|
+
# 'w24stations',
|
|
154
|
+
# 'w50stations',
|
|
155
|
+
"wgsettings",
|
|
156
|
+
"dhcpconfig",
|
|
157
|
+
"dhcplease",
|
|
158
|
+
# 'dhcpreserve',
|
|
159
|
+
]:
|
|
160
|
+
return ResponseMock(ABSTRACT_NETWORK[section]).content
|
|
161
|
+
else:
|
|
162
|
+
return ""
|
|
163
|
+
# raise ClientError (f'Section {section} not allowed')
|
|
164
|
+
|
|
165
|
+
else:
|
|
166
|
+
error = ""
|
|
167
|
+
error = (
|
|
168
|
+
(
|
|
169
|
+
"WDRRouter - {} - Response with error; Request {} - Response {}".format(
|
|
170
|
+
self.__class__.__name__, section, data
|
|
171
|
+
)
|
|
172
|
+
)
|
|
173
|
+
if not error
|
|
174
|
+
else error
|
|
175
|
+
)
|
|
176
|
+
if self._logger:
|
|
177
|
+
self._logger.debug(error)
|
|
178
|
+
|
|
179
|
+
raise ClientError(error)
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
class TestTPLinkWDRClient(TestCase):
|
|
183
|
+
|
|
184
|
+
def test_supports(self) -> None:
|
|
185
|
+
client = TplinkWDRRouterTest("", "")
|
|
186
|
+
# client.response = ResponseMock(ABSTRACT_STATUS)
|
|
187
|
+
supports = client.supports()
|
|
188
|
+
self.assertTrue(supports)
|
|
189
|
+
|
|
190
|
+
def test_get_firmware(self) -> None:
|
|
191
|
+
|
|
192
|
+
client = TplinkWDRRouterTest("", "")
|
|
193
|
+
client.response = ResponseMock(ABSTRACT_STATUS)
|
|
194
|
+
firmware = client.get_firmware()
|
|
195
|
+
|
|
196
|
+
self.assertIsInstance(firmware, Firmware)
|
|
197
|
+
self.assertEqual(firmware.hardware_version, "WDR3600 v1 00000000")
|
|
198
|
+
self.assertEqual(firmware.model, "WDR3600")
|
|
199
|
+
self.assertEqual(
|
|
200
|
+
firmware.firmware_version.strip(), "3.13.34 Build 130909 Rel.53148n"
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
def test_get_ipv4(self) -> None:
|
|
204
|
+
|
|
205
|
+
client = TplinkWDRRouterTest("", "")
|
|
206
|
+
ipv4status: IPv4Status = IPv4Status()
|
|
207
|
+
ipv4status = client.get_ipv4_status()
|
|
208
|
+
|
|
209
|
+
self.assertIsInstance(ipv4status, IPv4Status)
|
|
210
|
+
self.assertEqual(ipv4status._wan_macaddr, EUI48("C4-6E-1F-41-67-C1"))
|
|
211
|
+
self.assertEqual(
|
|
212
|
+
IPv4Address(ipv4status.wan_ipv4_ipaddr), IPv4Address("192.168.0.129")
|
|
213
|
+
)
|
|
214
|
+
self.assertEqual(
|
|
215
|
+
IPv4Address(ipv4status.wan_ipv4_gateway), IPv4Address("192.168.0.1")
|
|
216
|
+
)
|
|
217
|
+
self.assertEqual(ipv4status.wan_ipv4_conntype, "Dynamic IP")
|
|
218
|
+
self.assertEqual(
|
|
219
|
+
IPv4Address(ipv4status.wan_ipv4_netmask), IPv4Address("255.255.255.0")
|
|
220
|
+
)
|
|
221
|
+
self.assertEqual(
|
|
222
|
+
IPv4Address(ipv4status.wan_ipv4_pridns), IPv4Address("0.0.0.0")
|
|
223
|
+
)
|
|
224
|
+
self.assertEqual(
|
|
225
|
+
IPv4Address(ipv4status.wan_ipv4_snddns), IPv4Address("0.0.0.0")
|
|
226
|
+
)
|
|
227
|
+
self.assertEqual(ipv4status._lan_macaddr, EUI48("C4-6E-1F-41-67-C0"))
|
|
228
|
+
self.assertEqual(
|
|
229
|
+
IPv4Address(ipv4status.lan_ipv4_ipaddr), IPv4Address("192.168.1.254")
|
|
230
|
+
)
|
|
231
|
+
self.assertEqual(ipv4status.lan_ipv4_dhcp_enable, True)
|
|
232
|
+
self.assertEqual(
|
|
233
|
+
IPv4Address(ipv4status.lan_ipv4_netmask), IPv4Address("255.255.255.0")
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
def test_get_ipv4_reservations(self) -> None:
|
|
237
|
+
client = TplinkWDRRouterTest("", "")
|
|
238
|
+
ipv4_reservations: list[IPv4Reservation] = client.get_ipv4_reservations()
|
|
239
|
+
fRes: IPv4Reservation = ipv4_reservations[0]
|
|
240
|
+
|
|
241
|
+
self.assertIsInstance(fRes, IPv4Reservation)
|
|
242
|
+
self.assertEqual(EUI48(fRes.macaddress), EUI48("9B-FA-04-D8-AB-8D"))
|
|
243
|
+
self.assertEqual(IPv4Address(fRes.ipaddress), IPv4Address("192.168.1.56"))
|
|
244
|
+
self.assertEqual(fRes.enabled, True)
|
|
245
|
+
|
|
246
|
+
def test_get_ipv4_dhcp_leases(self) -> None:
|
|
247
|
+
client = TplinkWDRRouterTest("", "")
|
|
248
|
+
dhcp_leases: list[IPv4DHCPLease] = client.get_ipv4_dhcp_leases()
|
|
249
|
+
|
|
250
|
+
self.assertIsInstance(dhcp_leases[0], IPv4DHCPLease)
|
|
251
|
+
self.assertEqual(dhcp_leases[0].macaddress, EUI48("A9-A8-2B-F7-9F-5D"))
|
|
252
|
+
self.assertEqual(dhcp_leases[0].ipaddress, IPv4Address("192.168.1.123"))
|
|
253
|
+
self.assertEqual(dhcp_leases[0].hostname, "aliquam")
|
|
254
|
+
self.assertEqual(dhcp_leases[0].lease_time, "Permanent")
|
|
255
|
+
|
|
256
|
+
self.assertIsInstance(dhcp_leases[1], IPv4DHCPLease)
|
|
257
|
+
self.assertEqual(dhcp_leases[1].macaddress, EUI48("B3-A5-1E-C3-92-A9"))
|
|
258
|
+
self.assertEqual(dhcp_leases[1].ipaddress, IPv4Address("192.168.1.163"))
|
|
259
|
+
self.assertEqual(dhcp_leases[1].hostname, "pharetra")
|
|
260
|
+
self.assertEqual(dhcp_leases[1].lease_time, "Permanent")
|
|
261
|
+
|
|
262
|
+
def test_get_status(self) -> None:
|
|
263
|
+
client = TplinkWDRRouterTest("", "")
|
|
264
|
+
client.response = ResponseMock(ABSTRACT_STATUS)
|
|
265
|
+
|
|
266
|
+
status = client.get_status()
|
|
267
|
+
|
|
268
|
+
self.assertIsInstance(status, Status)
|
|
269
|
+
self.assertEqual(status.wan_macaddr, "C4-6E-1F-41-67-C1")
|
|
270
|
+
self.assertIsInstance(status.wan_macaddress, EUI48)
|
|
271
|
+
self.assertEqual(status.lan_macaddr, "C4-6E-1F-41-67-C0")
|
|
272
|
+
self.assertIsInstance(status.lan_macaddress, EUI48)
|
|
273
|
+
self.assertEqual(status.wan_ipv4_addr, "192.168.0.129")
|
|
274
|
+
self.assertIsInstance(status.lan_ipv4_address, IPv4Address)
|
|
275
|
+
self.assertEqual(status.lan_ipv4_addr, "192.168.1.254")
|
|
276
|
+
self.assertEqual(status.wan_ipv4_gateway, "192.168.0.1")
|
|
277
|
+
self.assertIsInstance(status.wan_ipv4_address, IPv4Address)
|
|
278
|
+
|
|
279
|
+
self.assertEqual(status.wired_total, 10)
|
|
280
|
+
self.assertEqual(status.wifi_clients_total, 8)
|
|
281
|
+
self.assertEqual(status.guest_clients_total, 0)
|
|
282
|
+
self.assertEqual(status.clients_total, 18)
|
|
283
|
+
|
|
284
|
+
self.assertTrue(status.guest_2g_enable)
|
|
285
|
+
self.assertFalse(status.guest_5g_enable)
|
|
286
|
+
self.assertTrue(status.wifi_2g_enable)
|
|
287
|
+
self.assertTrue(status.wifi_5g_enable)
|
|
288
|
+
self.assertEqual(status.wan_ipv4_uptime, 6732336)
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
if __name__ == "__main__":
|
|
292
|
+
main()
|
|
@@ -8,6 +8,7 @@ from tplinkrouterc6u.client.c80 import TplinkC80Router
|
|
|
8
8
|
from tplinkrouterc6u.client.c5400x import TplinkC5400XRouter
|
|
9
9
|
from tplinkrouterc6u.client.c1200 import TplinkC1200Router
|
|
10
10
|
from tplinkrouterc6u.client.xdr import TPLinkXDRClient
|
|
11
|
+
from tplinkrouterc6u.client.wdr import TplinkWDRRouter
|
|
11
12
|
from tplinkrouterc6u.provider import TplinkRouterProvider
|
|
12
13
|
from tplinkrouterc6u.common.package_enum import Connection, VPN
|
|
13
14
|
from tplinkrouterc6u.common.dataclass import (
|
|
@@ -275,7 +275,7 @@ class TplinkBaseRouter(AbstractRouter, TplinkRequest):
|
|
|
275
275
|
data = self.request('admin/status?form=all&operation=read', 'operation=read')
|
|
276
276
|
|
|
277
277
|
status = Status()
|
|
278
|
-
status._wan_macaddr = EUI48(data['wan_macaddr']) if 'wan_macaddr' in data else None
|
|
278
|
+
status._wan_macaddr = EUI48(data['wan_macaddr']) if 'wan_macaddr' in data and data['wan_macaddr'] else None
|
|
279
279
|
status._lan_macaddr = EUI48(data['lan_macaddr'])
|
|
280
280
|
status._wan_ipv4_addr = IPv4Address(data['wan_ipv4_ipaddr']) if 'wan_ipv4_ipaddr' in data else None
|
|
281
281
|
status._lan_ipv4_addr = IPv4Address(data['lan_ipv4_ipaddr']) if 'lan_ipv4_ipaddr' in data else None
|
|
@@ -82,8 +82,11 @@ class TplinkC80Router(AbstractRouter):
|
|
|
82
82
|
self._encryption = EncryptionState()
|
|
83
83
|
|
|
84
84
|
def supports(self) -> bool:
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
try:
|
|
86
|
+
response = self.request(2, 1, data='0|1,0,0')
|
|
87
|
+
return response.status_code == 200 and response.text.startswith('00000')
|
|
88
|
+
except Exception:
|
|
89
|
+
return False
|
|
87
90
|
|
|
88
91
|
def authorize(self) -> None:
|
|
89
92
|
encoded_password = TplinkC80Router._encrypt_password(self.password)
|
|
@@ -328,6 +331,7 @@ class TplinkC80Router(AbstractRouter):
|
|
|
328
331
|
device_to_add = Device(connection_type, EUI48(device['mac']), IPv4Address(device['ip']), device['name'])
|
|
329
332
|
device_to_add.up_speed = int(device['up'])
|
|
330
333
|
device_to_add.down_speed = int(device['down'])
|
|
334
|
+
device_to_add.active = device['online'] == '1'
|
|
331
335
|
mapped_devices.append(device_to_add)
|
|
332
336
|
return mapped_devices
|
|
333
337
|
|