tplinkrouterc6u 5.0.3__tar.gz → 5.2.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.0.3 → tplinkrouterc6u-5.2.0}/PKG-INFO +52 -2
- {tplinkrouterc6u-5.0.3 → tplinkrouterc6u-5.2.0}/README.md +51 -1
- {tplinkrouterc6u-5.0.3 → tplinkrouterc6u-5.2.0}/setup.py +1 -1
- tplinkrouterc6u-5.0.3/test/test_client.py → tplinkrouterc6u-5.2.0/test/test_client_c6u.py +2 -1
- tplinkrouterc6u-5.2.0/test/test_client_ex.py +339 -0
- {tplinkrouterc6u-5.0.3 → tplinkrouterc6u-5.2.0}/test/test_client_mr.py +365 -0
- tplinkrouterc6u-5.2.0/test/test_client_xdr.py +536 -0
- tplinkrouterc6u-5.2.0/tplinkrouterc6u/__init__.py +23 -0
- tplinkrouterc6u-5.2.0/tplinkrouterc6u/client/__init__.py +1 -0
- tplinkrouterc6u-5.2.0/tplinkrouterc6u/client/c1200.py +102 -0
- tplinkrouterc6u-5.2.0/tplinkrouterc6u/client/c5400x.py +109 -0
- tplinkrouterc6u-5.2.0/tplinkrouterc6u/client/c6u.py +436 -0
- tplinkrouterc6u-5.2.0/tplinkrouterc6u/client/c6v4.py +38 -0
- tplinkrouterc6u-5.2.0/tplinkrouterc6u/client/deco.py +177 -0
- tplinkrouterc6u-5.2.0/tplinkrouterc6u/client/ex.py +295 -0
- tplinkrouterc6u-5.2.0/tplinkrouterc6u/client/mr.py +712 -0
- tplinkrouterc6u-5.2.0/tplinkrouterc6u/client/xdr.py +263 -0
- tplinkrouterc6u-5.2.0/tplinkrouterc6u/client_abstract.py +48 -0
- tplinkrouterc6u-5.2.0/tplinkrouterc6u/common/__init__.py +1 -0
- {tplinkrouterc6u-5.0.3/tplinkrouterc6u → tplinkrouterc6u-5.2.0/tplinkrouterc6u/common}/dataclass.py +40 -1
- {tplinkrouterc6u-5.0.3/tplinkrouterc6u → tplinkrouterc6u-5.2.0/tplinkrouterc6u/common}/package_enum.py +5 -0
- tplinkrouterc6u-5.2.0/tplinkrouterc6u/provider.py +39 -0
- {tplinkrouterc6u-5.0.3 → tplinkrouterc6u-5.2.0}/tplinkrouterc6u.egg-info/PKG-INFO +52 -2
- tplinkrouterc6u-5.2.0/tplinkrouterc6u.egg-info/SOURCES.txt +33 -0
- tplinkrouterc6u-5.0.3/tplinkrouterc6u/__init__.py +0 -19
- tplinkrouterc6u-5.0.3/tplinkrouterc6u/client.py +0 -1451
- tplinkrouterc6u-5.0.3/tplinkrouterc6u.egg-info/SOURCES.txt +0 -20
- {tplinkrouterc6u-5.0.3 → tplinkrouterc6u-5.2.0}/LICENSE +0 -0
- {tplinkrouterc6u-5.0.3 → tplinkrouterc6u-5.2.0}/setup.cfg +0 -0
- {tplinkrouterc6u-5.0.3 → tplinkrouterc6u-5.2.0}/test/__init__.py +0 -0
- {tplinkrouterc6u-5.0.3 → tplinkrouterc6u-5.2.0}/test/test_client_c1200.py +0 -0
- {tplinkrouterc6u-5.0.3 → tplinkrouterc6u-5.2.0}/test/test_client_deco.py +0 -0
- {tplinkrouterc6u-5.0.3/tplinkrouterc6u → tplinkrouterc6u-5.2.0/tplinkrouterc6u/common}/encryption.py +0 -0
- {tplinkrouterc6u-5.0.3/tplinkrouterc6u → tplinkrouterc6u-5.2.0/tplinkrouterc6u/common}/exception.py +0 -0
- {tplinkrouterc6u-5.0.3/tplinkrouterc6u → tplinkrouterc6u-5.2.0/tplinkrouterc6u/common}/helper.py +0 -0
- {tplinkrouterc6u-5.0.3 → tplinkrouterc6u-5.2.0}/tplinkrouterc6u.egg-info/dependency_links.txt +0 -0
- {tplinkrouterc6u-5.0.3 → tplinkrouterc6u-5.2.0}/tplinkrouterc6u.egg-info/requires.txt +0 -0
- {tplinkrouterc6u-5.0.3 → tplinkrouterc6u-5.2.0}/tplinkrouterc6u.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: tplinkrouterc6u
|
|
3
|
-
Version: 5.0
|
|
3
|
+
Version: 5.2.0
|
|
4
4
|
Summary: TP-Link Router API
|
|
5
5
|
Home-page: https://github.com/AlexandrErohin/TP-Link-Archer-C6U
|
|
6
6
|
Author: Alex Erohin
|
|
@@ -44,6 +44,8 @@ from tplinkrouterc6u import (
|
|
|
44
44
|
TplinkC1200Router,
|
|
45
45
|
TplinkC5400XRouter,
|
|
46
46
|
TPLinkMRClient,
|
|
47
|
+
TPLinkEXClient,
|
|
48
|
+
TPLinkXDRClient,
|
|
47
49
|
TPLinkDecoClient,
|
|
48
50
|
Connection
|
|
49
51
|
)
|
|
@@ -106,10 +108,17 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
106
108
|
| get_ipv4_reservations | | Gets IPv4 reserved addresses (static) | [[IPv4Reservation]](#IPv4Reservation) |
|
|
107
109
|
| get_ipv4_dhcp_leases | | Gets IPv4 addresses assigned via DHCP | [[IPv4DHCPLease]](#IPv4DHCPLease) |
|
|
108
110
|
| set_wifi | wifi: [Connection](#connection), enable: bool | Allow to turn on/of 4 wifi networks | |
|
|
109
|
-
| send_sms | phone_number: str, message: str | Send sms for LTE routers | |
|
|
110
111
|
| reboot | | reboot router |
|
|
111
112
|
| authorize | | authorize for actions |
|
|
112
113
|
| logout | | logout after all is done |
|
|
114
|
+
| get_vpn_status | | Gets VPN info for OpenVPN and PPTPVPN and connected clients amount | [VPNStatus](#vpn_status) |
|
|
115
|
+
| set_vpn | vpn: [VPNStatus](#vpn_status), enable: bool | Allow to turn on/of VPN | |
|
|
116
|
+
| send_sms | phone_number: str, message: str | Send sms for LTE routers | |
|
|
117
|
+
| send_ussd | command: str | Send USSD command for LTE routers | str |
|
|
118
|
+
| get_sms | | Get sms messages from the first page for LTE routers | [[SMS]](#sms) |
|
|
119
|
+
| set_sms_read | sms: [SMS](#sms) | Set sms message read from the first page for LTE routers | |
|
|
120
|
+
| delete_sms | sms: [SMS](#sms) | Delete sms message from the first page for LTE routers | |
|
|
121
|
+
| get_lte_status | | Get lte info for LTE routers | [LTEStatus](#lte_status) |
|
|
113
122
|
|
|
114
123
|
## Dataclass
|
|
115
124
|
### <a id="firmware">Firmware</a>
|
|
@@ -164,6 +173,7 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
164
173
|
| packets_received | total packets received | int, None |
|
|
165
174
|
| down_speed | download speed | int, None |
|
|
166
175
|
| up_speed | upload speed | int, None |
|
|
176
|
+
| signal | Signal strength | int, None |
|
|
167
177
|
|
|
168
178
|
### <a id="IPv4Reservation">IPv4Reservation</a>
|
|
169
179
|
| Field | Description | Type |
|
|
@@ -210,6 +220,40 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
210
220
|
| lan_ipv4_netmask_address | router LAN gateway IP netmask | ipaddress |
|
|
211
221
|
| remote | router remote | bool, None |
|
|
212
222
|
|
|
223
|
+
### <a id="vpn_status">VPNStatus</a>
|
|
224
|
+
| Field | Description | Type |
|
|
225
|
+
| --- |---|---|
|
|
226
|
+
| openvpn_enable | OpenVPN is enabled | bool |
|
|
227
|
+
| pptpvpn_enable | PPTPVPN is enabled | bool |
|
|
228
|
+
| openvpn_clients_total | OpenVPN clients connected | int |
|
|
229
|
+
| pptpvpn_clients_total | PPTPVPN clients connected | int |
|
|
230
|
+
|
|
231
|
+
### <a id="sms">SMS</a>
|
|
232
|
+
| Field | Description | Type |
|
|
233
|
+
| --- |---|---|
|
|
234
|
+
| id | message index | int |
|
|
235
|
+
| sender| sender | str |
|
|
236
|
+
| content| sms text | str |
|
|
237
|
+
| received_at| received datetime | datetime |
|
|
238
|
+
| unread| is message unread | bool |
|
|
239
|
+
|
|
240
|
+
### <a id="lte_status">LTEStatus</a>
|
|
241
|
+
| Field | Description | Type |
|
|
242
|
+
| --- |---|---|
|
|
243
|
+
| enable | is enabled | int |
|
|
244
|
+
| connect_status | connect status | int |
|
|
245
|
+
| network_type | network type | int |
|
|
246
|
+
| sim_status | sim status | int |
|
|
247
|
+
| total_statistics | total statistics in bytes | int |
|
|
248
|
+
| cur_rx_speed | current download speed in bytes per second | int |
|
|
249
|
+
| cur_tx_speed | current upload speed in bytes per second | int |
|
|
250
|
+
| sms_unread_count | sms unread amount | int |
|
|
251
|
+
| sig_level | signal level | int |
|
|
252
|
+
| rsrp | RSRP | int |
|
|
253
|
+
| rsrq | RSRQ | int |
|
|
254
|
+
| snr | SNR | int |
|
|
255
|
+
| isp_name | ISP name | str |
|
|
256
|
+
|
|
213
257
|
## Enum
|
|
214
258
|
### <a id="connection">Connection</a>
|
|
215
259
|
- Connection.HOST_2G - host wifi 2.4G
|
|
@@ -223,6 +267,10 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
223
267
|
- Connection.IOT_6G - IoT wifi 6G
|
|
224
268
|
- Connection.WIRED - Wired
|
|
225
269
|
|
|
270
|
+
### <a id="vpn">VPN</a>
|
|
271
|
+
- VPN.OPEN_VPN
|
|
272
|
+
- VPN.PPTP_VPN
|
|
273
|
+
|
|
226
274
|
## <a id="supports">Supported routers</a>
|
|
227
275
|
### Fully tested Hardware Versions
|
|
228
276
|
- Archer A7 V5
|
|
@@ -271,11 +319,13 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
271
319
|
- Deco X60 V3
|
|
272
320
|
- Deco X90
|
|
273
321
|
- Deco XE75 (v1.0, v2.0)
|
|
322
|
+
- EX511 v2.0
|
|
274
323
|
- TD-W9960 (v1, V1.20)
|
|
275
324
|
- TL-MR100 v2.0
|
|
276
325
|
- TL-MR105
|
|
277
326
|
- TL-MR6400 (v5, v5.3)
|
|
278
327
|
- TL-MR6500v
|
|
328
|
+
- TL-XDR3010 V2
|
|
279
329
|
- TL-WA3001 v1.0
|
|
280
330
|
|
|
281
331
|
### Not fully tested Hardware Versions
|
|
@@ -22,6 +22,8 @@ from tplinkrouterc6u import (
|
|
|
22
22
|
TplinkC1200Router,
|
|
23
23
|
TplinkC5400XRouter,
|
|
24
24
|
TPLinkMRClient,
|
|
25
|
+
TPLinkEXClient,
|
|
26
|
+
TPLinkXDRClient,
|
|
25
27
|
TPLinkDecoClient,
|
|
26
28
|
Connection
|
|
27
29
|
)
|
|
@@ -84,10 +86,17 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
84
86
|
| get_ipv4_reservations | | Gets IPv4 reserved addresses (static) | [[IPv4Reservation]](#IPv4Reservation) |
|
|
85
87
|
| get_ipv4_dhcp_leases | | Gets IPv4 addresses assigned via DHCP | [[IPv4DHCPLease]](#IPv4DHCPLease) |
|
|
86
88
|
| set_wifi | wifi: [Connection](#connection), enable: bool | Allow to turn on/of 4 wifi networks | |
|
|
87
|
-
| send_sms | phone_number: str, message: str | Send sms for LTE routers | |
|
|
88
89
|
| reboot | | reboot router |
|
|
89
90
|
| authorize | | authorize for actions |
|
|
90
91
|
| logout | | logout after all is done |
|
|
92
|
+
| get_vpn_status | | Gets VPN info for OpenVPN and PPTPVPN and connected clients amount | [VPNStatus](#vpn_status) |
|
|
93
|
+
| set_vpn | vpn: [VPNStatus](#vpn_status), enable: bool | Allow to turn on/of VPN | |
|
|
94
|
+
| send_sms | phone_number: str, message: str | Send sms for LTE routers | |
|
|
95
|
+
| send_ussd | command: str | Send USSD command for LTE routers | str |
|
|
96
|
+
| get_sms | | Get sms messages from the first page for LTE routers | [[SMS]](#sms) |
|
|
97
|
+
| set_sms_read | sms: [SMS](#sms) | Set sms message read from the first page for LTE routers | |
|
|
98
|
+
| delete_sms | sms: [SMS](#sms) | Delete sms message from the first page for LTE routers | |
|
|
99
|
+
| get_lte_status | | Get lte info for LTE routers | [LTEStatus](#lte_status) |
|
|
91
100
|
|
|
92
101
|
## Dataclass
|
|
93
102
|
### <a id="firmware">Firmware</a>
|
|
@@ -142,6 +151,7 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
142
151
|
| packets_received | total packets received | int, None |
|
|
143
152
|
| down_speed | download speed | int, None |
|
|
144
153
|
| up_speed | upload speed | int, None |
|
|
154
|
+
| signal | Signal strength | int, None |
|
|
145
155
|
|
|
146
156
|
### <a id="IPv4Reservation">IPv4Reservation</a>
|
|
147
157
|
| Field | Description | Type |
|
|
@@ -188,6 +198,40 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
188
198
|
| lan_ipv4_netmask_address | router LAN gateway IP netmask | ipaddress |
|
|
189
199
|
| remote | router remote | bool, None |
|
|
190
200
|
|
|
201
|
+
### <a id="vpn_status">VPNStatus</a>
|
|
202
|
+
| Field | Description | Type |
|
|
203
|
+
| --- |---|---|
|
|
204
|
+
| openvpn_enable | OpenVPN is enabled | bool |
|
|
205
|
+
| pptpvpn_enable | PPTPVPN is enabled | bool |
|
|
206
|
+
| openvpn_clients_total | OpenVPN clients connected | int |
|
|
207
|
+
| pptpvpn_clients_total | PPTPVPN clients connected | int |
|
|
208
|
+
|
|
209
|
+
### <a id="sms">SMS</a>
|
|
210
|
+
| Field | Description | Type |
|
|
211
|
+
| --- |---|---|
|
|
212
|
+
| id | message index | int |
|
|
213
|
+
| sender| sender | str |
|
|
214
|
+
| content| sms text | str |
|
|
215
|
+
| received_at| received datetime | datetime |
|
|
216
|
+
| unread| is message unread | bool |
|
|
217
|
+
|
|
218
|
+
### <a id="lte_status">LTEStatus</a>
|
|
219
|
+
| Field | Description | Type |
|
|
220
|
+
| --- |---|---|
|
|
221
|
+
| enable | is enabled | int |
|
|
222
|
+
| connect_status | connect status | int |
|
|
223
|
+
| network_type | network type | int |
|
|
224
|
+
| sim_status | sim status | int |
|
|
225
|
+
| total_statistics | total statistics in bytes | int |
|
|
226
|
+
| cur_rx_speed | current download speed in bytes per second | int |
|
|
227
|
+
| cur_tx_speed | current upload speed in bytes per second | int |
|
|
228
|
+
| sms_unread_count | sms unread amount | int |
|
|
229
|
+
| sig_level | signal level | int |
|
|
230
|
+
| rsrp | RSRP | int |
|
|
231
|
+
| rsrq | RSRQ | int |
|
|
232
|
+
| snr | SNR | int |
|
|
233
|
+
| isp_name | ISP name | str |
|
|
234
|
+
|
|
191
235
|
## Enum
|
|
192
236
|
### <a id="connection">Connection</a>
|
|
193
237
|
- Connection.HOST_2G - host wifi 2.4G
|
|
@@ -201,6 +245,10 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
201
245
|
- Connection.IOT_6G - IoT wifi 6G
|
|
202
246
|
- Connection.WIRED - Wired
|
|
203
247
|
|
|
248
|
+
### <a id="vpn">VPN</a>
|
|
249
|
+
- VPN.OPEN_VPN
|
|
250
|
+
- VPN.PPTP_VPN
|
|
251
|
+
|
|
204
252
|
## <a id="supports">Supported routers</a>
|
|
205
253
|
### Fully tested Hardware Versions
|
|
206
254
|
- Archer A7 V5
|
|
@@ -249,11 +297,13 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
249
297
|
- Deco X60 V3
|
|
250
298
|
- Deco X90
|
|
251
299
|
- Deco XE75 (v1.0, v2.0)
|
|
300
|
+
- EX511 v2.0
|
|
252
301
|
- TD-W9960 (v1, V1.20)
|
|
253
302
|
- TL-MR100 v2.0
|
|
254
303
|
- TL-MR105
|
|
255
304
|
- TL-MR6400 (v5, v5.3)
|
|
256
305
|
- TL-MR6500v
|
|
306
|
+
- TL-XDR3010 V2
|
|
257
307
|
- TL-WA3001 v1.0
|
|
258
308
|
|
|
259
309
|
### Not fully tested Hardware Versions
|
|
@@ -445,7 +445,7 @@ class TestTPLinkClient(TestCase):
|
|
|
445
445
|
{"mac": "54:b3:a2:f7:be:ea", "deviceTag":"iot_5G", "isGuest":false, "ip":"192.168.1.188",
|
|
446
446
|
"deviceName":"name3"},
|
|
447
447
|
{"mac": "3c:ae:e1:83:94:9d", "deviceTag":"iot_6G", "isGuest":false, "ip":"192.168.1.189",
|
|
448
|
-
"deviceName":"name4"}
|
|
448
|
+
"deviceName":"name4", "signal": -52}
|
|
449
449
|
],
|
|
450
450
|
"timeout": false,
|
|
451
451
|
"success": true
|
|
@@ -570,6 +570,7 @@ class TestTPLinkClient(TestCase):
|
|
|
570
570
|
self.assertEqual(status.devices[5].hostname, 'name4')
|
|
571
571
|
self.assertEqual(status.devices[5].packets_sent, None)
|
|
572
572
|
self.assertEqual(status.devices[5].packets_received, None)
|
|
573
|
+
self.assertEqual(status.devices[5].signal, -52)
|
|
573
574
|
self.assertIsInstance(status.devices[6], Device)
|
|
574
575
|
self.assertEqual(status.devices[6].type, Connection.HOST_5G)
|
|
575
576
|
self.assertEqual(status.devices[6].macaddr, '1F-7A-BD-F7-20-0D')
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
from unittest import main, TestCase
|
|
2
|
+
from macaddress import EUI48
|
|
3
|
+
from ipaddress import IPv4Address
|
|
4
|
+
from tplinkrouterc6u import (
|
|
5
|
+
TPLinkEXClient,
|
|
6
|
+
Connection,
|
|
7
|
+
Firmware,
|
|
8
|
+
Status,
|
|
9
|
+
Device,
|
|
10
|
+
IPv4Reservation,
|
|
11
|
+
IPv4DHCPLease,
|
|
12
|
+
IPv4Status,
|
|
13
|
+
ClientException,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class TestTPLinkEXClient(TestCase):
|
|
18
|
+
def test_firmware(self) -> None:
|
|
19
|
+
response = ('{"data":{"hardwareVersion":"EX511 v2.0 00000000","modelName":"EX511",'
|
|
20
|
+
'"softwareVersion":"0.7.0 3.0.0 v607e.0 Build 240930 Rel.11206n","stack":"0,0,0,0,0,0"},'
|
|
21
|
+
'"operation":"go","oid":"DEV2_DEV_INFO","success":true}')
|
|
22
|
+
|
|
23
|
+
class TPLinkEXClientTest(TPLinkEXClient):
|
|
24
|
+
self._token = True
|
|
25
|
+
|
|
26
|
+
def _request(self, url, method='POST', data_str=None, encrypt=False):
|
|
27
|
+
return 200, response
|
|
28
|
+
|
|
29
|
+
client = TPLinkEXClientTest('', '')
|
|
30
|
+
result = client.get_firmware()
|
|
31
|
+
|
|
32
|
+
self.assertIsInstance(result, Firmware)
|
|
33
|
+
self.assertEqual(result.hardware_version, 'EX511 v2.0 00000000')
|
|
34
|
+
self.assertEqual(result.model, 'EX511')
|
|
35
|
+
self.assertEqual(result.firmware_version, '0.7.0 3.0.0 v607e.0 Build 240930 Rel.11206n')
|
|
36
|
+
|
|
37
|
+
def test_get_status_with_5G(self) -> None:
|
|
38
|
+
|
|
39
|
+
DEV2_ADT_LAN = ('{"data":[{"MACAddress":"a0:28:84:de:dd:5c","IPAddress":"192.168.4.1","stack":"1,0,0,0,0,0"}],'
|
|
40
|
+
'"operation":"gl","oid":"DEV2_ADT_LAN","success":true}')
|
|
41
|
+
DEV2_ADT_WAN = ('{"data":[{"enable":"1","MACAddr":"BF-75-44-4C-DC-9E","connIPv4Address":"192.168.30.55",'
|
|
42
|
+
'"connIPv4Gateway":"192.168.30.1","stack":"1,0,0,0,0,0"}],"operation":"gl",'
|
|
43
|
+
'"oid":"DEV2_ADT_WAN","success":true}')
|
|
44
|
+
DEV2_ADT_WIFI_COMMON = ('{"data":[{"primaryEnable":"1","guestEnable":"0","stack":"1,0,0,0,0,0"},'
|
|
45
|
+
'{"primaryEnable":"0","guestEnable":"1","stack":"2,0,0,0,0,0"}],"operation":"gl",'
|
|
46
|
+
'"oid":"DEV2_ADT_WIFI_COMMON","success":true}')
|
|
47
|
+
DEV2_HOST_ENTRY = ('{"data":[{"active":"1","X_TP_LanConnType":"0","physAddress":"66-E2-02-BD-B5-1B",'
|
|
48
|
+
'"IPAddress":"192.168.30.10","hostName":"host1","stack":"1,0,0,0,0,0"},'
|
|
49
|
+
'{"active":"1","X_TP_LanConnType":"1","physAddress":"F4-A3-86-2D-41-B5",'
|
|
50
|
+
'"IPAddress":"192.168.30.11","hostName":"host2","stack":"2,0,0,0,0,0"}],"operation":"gl",'
|
|
51
|
+
'"oid":"DEV2_HOST_ENTRY","success":true}')
|
|
52
|
+
DEV2_MEM_STATUS = ('{"data":{"total":"192780","free":"78400","stack":"0,0,0,0,0,0"},"operation":"go",'
|
|
53
|
+
'"oid":"DEV2_MEM_STATUS","success":true}')
|
|
54
|
+
DEV2_PROC_STATUS = ('{"data":{"CPUUsage":"47","stack":"0,0,0,0,0,0"},"operation":"go",'
|
|
55
|
+
'"oid":"DEV2_PROC_STATUS","success":true}')
|
|
56
|
+
|
|
57
|
+
class TPLinkEXClientTest(TPLinkEXClient):
|
|
58
|
+
self._token = True
|
|
59
|
+
|
|
60
|
+
def _request(self, url, method='POST', data_str=None, encrypt=False):
|
|
61
|
+
if 'DEV2_ADT_LAN' in data_str:
|
|
62
|
+
return 200, DEV2_ADT_LAN
|
|
63
|
+
elif 'DEV2_ADT_WAN' in data_str:
|
|
64
|
+
return 200, DEV2_ADT_WAN
|
|
65
|
+
elif 'DEV2_ADT_WIFI_COMMON' in data_str:
|
|
66
|
+
return 200, DEV2_ADT_WIFI_COMMON
|
|
67
|
+
elif 'DEV2_HOST_ENTRY' in data_str:
|
|
68
|
+
return 200, DEV2_HOST_ENTRY
|
|
69
|
+
elif 'DEV2_MEM_STATUS' in data_str:
|
|
70
|
+
return 200, DEV2_MEM_STATUS
|
|
71
|
+
elif 'DEV2_PROC_STATUS' in data_str:
|
|
72
|
+
return 200, DEV2_PROC_STATUS
|
|
73
|
+
raise ClientException()
|
|
74
|
+
|
|
75
|
+
client = TPLinkEXClientTest('', '')
|
|
76
|
+
status = client.get_status()
|
|
77
|
+
|
|
78
|
+
self.assertIsInstance(status, Status)
|
|
79
|
+
self.assertEqual(status.wan_macaddr, 'BF-75-44-4C-DC-9E')
|
|
80
|
+
self.assertIsInstance(status.wan_macaddress, EUI48)
|
|
81
|
+
self.assertEqual(status.lan_macaddr, 'A0-28-84-DE-DD-5C')
|
|
82
|
+
self.assertIsInstance(status.lan_macaddress, EUI48)
|
|
83
|
+
self.assertEqual(status.wan_ipv4_addr, '192.168.30.55')
|
|
84
|
+
self.assertIsInstance(status.lan_ipv4_address, IPv4Address)
|
|
85
|
+
self.assertEqual(status.lan_ipv4_addr, '192.168.4.1')
|
|
86
|
+
self.assertEqual(status.wan_ipv4_gateway, '192.168.30.1')
|
|
87
|
+
self.assertIsInstance(status.wan_ipv4_address, IPv4Address)
|
|
88
|
+
self.assertEqual(status.wired_total, 1)
|
|
89
|
+
self.assertEqual(status.wifi_clients_total, 1)
|
|
90
|
+
self.assertEqual(status.guest_clients_total, 0)
|
|
91
|
+
self.assertEqual(status.clients_total, 2)
|
|
92
|
+
self.assertEqual(status.guest_2g_enable, False)
|
|
93
|
+
self.assertEqual(status.guest_5g_enable, True)
|
|
94
|
+
self.assertEqual(status.iot_2g_enable, None)
|
|
95
|
+
self.assertEqual(status.iot_5g_enable, None)
|
|
96
|
+
self.assertEqual(status.wifi_2g_enable, True)
|
|
97
|
+
self.assertEqual(status.wifi_5g_enable, False)
|
|
98
|
+
self.assertEqual(status.wan_ipv4_uptime, None)
|
|
99
|
+
self.assertGreaterEqual(status.mem_usage, 0)
|
|
100
|
+
self.assertLessEqual(status.mem_usage, 1)
|
|
101
|
+
self.assertGreaterEqual(status.cpu_usage, 0)
|
|
102
|
+
self.assertLessEqual(status.cpu_usage, 1)
|
|
103
|
+
self.assertEqual(len(status.devices), 2)
|
|
104
|
+
self.assertIsInstance(status.devices[0], Device)
|
|
105
|
+
self.assertEqual(status.devices[0].type, Connection.WIRED)
|
|
106
|
+
self.assertEqual(status.devices[0].macaddr, '66-E2-02-BD-B5-1B')
|
|
107
|
+
self.assertIsInstance(status.devices[0].macaddress, EUI48)
|
|
108
|
+
self.assertEqual(status.devices[0].ipaddr, '192.168.30.10')
|
|
109
|
+
self.assertIsInstance(status.devices[0].ipaddress, IPv4Address)
|
|
110
|
+
self.assertEqual(status.devices[0].hostname, 'host1')
|
|
111
|
+
self.assertEqual(status.devices[0].packets_sent, None)
|
|
112
|
+
self.assertEqual(status.devices[0].packets_received, None)
|
|
113
|
+
self.assertIsInstance(status.devices[1], Device)
|
|
114
|
+
self.assertEqual(status.devices[1].type, Connection.HOST_2G)
|
|
115
|
+
self.assertEqual(status.devices[1].macaddr, 'F4-A3-86-2D-41-B5')
|
|
116
|
+
self.assertIsInstance(status.devices[1].macaddress, EUI48)
|
|
117
|
+
self.assertEqual(status.devices[1].ipaddr, '192.168.30.11')
|
|
118
|
+
self.assertIsInstance(status.devices[1].ipaddress, IPv4Address)
|
|
119
|
+
self.assertEqual(status.devices[1].hostname, 'host2')
|
|
120
|
+
self.assertEqual(status.devices[1].packets_sent, None) # TODO
|
|
121
|
+
self.assertEqual(status.devices[1].packets_received, None) # TODO
|
|
122
|
+
|
|
123
|
+
def test_get_ipv4_reservations(self) -> None:
|
|
124
|
+
|
|
125
|
+
response = ('{"data":[{"enable":"1","chaddr":"bf:75:44:4c:dc:9e","yiaddr":"192.168.8.21",'
|
|
126
|
+
'"stack":"1,1,0,0,0,0"}],"operation":"gl","oid":"DEV2_DHCPV4_POOL_STATICADDR","success":true}')
|
|
127
|
+
|
|
128
|
+
class TPLinkEXClientTest(TPLinkEXClient):
|
|
129
|
+
self._token = True
|
|
130
|
+
|
|
131
|
+
def _request(self, url, method='POST', data_str=None, encrypt=False):
|
|
132
|
+
return 200, response
|
|
133
|
+
|
|
134
|
+
client = TPLinkEXClientTest('', '')
|
|
135
|
+
result = client.get_ipv4_reservations()
|
|
136
|
+
|
|
137
|
+
self.assertEqual(len(result), 1)
|
|
138
|
+
self.assertIsInstance(result[0], IPv4Reservation)
|
|
139
|
+
self.assertEqual(result[0].macaddr, 'BF-75-44-4C-DC-9E')
|
|
140
|
+
self.assertEqual(result[0].ipaddr, '192.168.8.21')
|
|
141
|
+
self.assertEqual(result[0].hostname, '')
|
|
142
|
+
self.assertEqual(result[0].enabled, True)
|
|
143
|
+
|
|
144
|
+
def test_get_ipv4_reservations_no_reservations(self) -> None:
|
|
145
|
+
response = '''
|
|
146
|
+
[error]0
|
|
147
|
+
|
|
148
|
+
'''
|
|
149
|
+
response = '{"data":[],"operation":"gl","oid":"DEV2_DHCPV4_POOL_STATICADDR","success":true}'
|
|
150
|
+
|
|
151
|
+
class TPLinkEXClientTest(TPLinkEXClient):
|
|
152
|
+
self._token = True
|
|
153
|
+
|
|
154
|
+
def _request(self, url, method='POST', data_str=None, encrypt=False):
|
|
155
|
+
return 200, response
|
|
156
|
+
|
|
157
|
+
client = TPLinkEXClientTest('', '')
|
|
158
|
+
result = client.get_ipv4_reservations()
|
|
159
|
+
|
|
160
|
+
self.assertEqual(len(result), 0)
|
|
161
|
+
|
|
162
|
+
def test_get_ipv4_dhcp_leases_no_leases(self) -> None:
|
|
163
|
+
|
|
164
|
+
response = '{"data":[],"operation":"gl","oid":"DEV2_HOST_ENTRY","success":true}'
|
|
165
|
+
|
|
166
|
+
class TPLinkEXClientTest(TPLinkEXClient):
|
|
167
|
+
self._token = True
|
|
168
|
+
|
|
169
|
+
def _request(self, url, method='POST', data_str=None, encrypt=False):
|
|
170
|
+
return 200, response
|
|
171
|
+
|
|
172
|
+
client = TPLinkEXClientTest('', '')
|
|
173
|
+
result = client.get_ipv4_dhcp_leases()
|
|
174
|
+
|
|
175
|
+
self.assertEqual(len(result), 0)
|
|
176
|
+
|
|
177
|
+
def test_get_ipv4_dhcp_leases(self) -> None:
|
|
178
|
+
|
|
179
|
+
response = ('{"data":[{"alias":"","physAddress":"bf:75:44:4c:dc:9e","IPAddress":"192.168.32.175",'
|
|
180
|
+
'"addressSource":"Static","leaseTimeRemaining":"85841","X_TP_IPv6Address":"",'
|
|
181
|
+
'"X_TP_IPv6LinkLocal":"","layer1Interface":"",'
|
|
182
|
+
'"X_TP_Layer2Interface":"Device.WiFi.AccessPoint.1.","vendorClassID":"","clientID":"",'
|
|
183
|
+
'"hostName":"name1","interfaceType":"Wi-Fi","X_TP_LanConnType":"1","X_TP_LanConnDev":"br0",'
|
|
184
|
+
'"active":"1","IPv4AddressNumberOfEntries":"0","X_TP_Vendor":"","X_TP_ClientType":"Other",'
|
|
185
|
+
'"X_TP_DevphyAddress":"","IPv6AddressNumberOfEntries":"0","X_TP_NetworkReadyTime":"0",'
|
|
186
|
+
'"stack":"1,0,0,0,0,0"}],"operation":"gl","oid":"DEV2_HOST_ENTRY","success":true}')
|
|
187
|
+
|
|
188
|
+
class TPLinkEXClientTest(TPLinkEXClient):
|
|
189
|
+
self._token = True
|
|
190
|
+
|
|
191
|
+
def _request(self, url, method='POST', data_str=None, encrypt=False):
|
|
192
|
+
return 200, response
|
|
193
|
+
|
|
194
|
+
client = TPLinkEXClientTest('', '')
|
|
195
|
+
result = client.get_ipv4_dhcp_leases()
|
|
196
|
+
|
|
197
|
+
self.assertEqual(len(result), 1)
|
|
198
|
+
self.assertIsInstance(result[0], IPv4DHCPLease)
|
|
199
|
+
self.assertEqual(result[0].macaddr, 'BF-75-44-4C-DC-9E')
|
|
200
|
+
self.assertEqual(result[0].ipaddr, '192.168.32.175')
|
|
201
|
+
self.assertEqual(result[0].hostname, 'name1')
|
|
202
|
+
self.assertEqual(result[0].lease_time, '23:50:41')
|
|
203
|
+
|
|
204
|
+
def test_get_ipv4_dhcp_leases_permanent(self) -> None:
|
|
205
|
+
|
|
206
|
+
response = ('{"data":[{"alias":"","physAddress":"bf:75:44:4c:dc:9e","IPAddress":"192.168.32.175",'
|
|
207
|
+
'"addressSource":"Static","leaseTimeRemaining":"0","X_TP_IPv6Address":"",'
|
|
208
|
+
'"X_TP_IPv6LinkLocal":"","layer1Interface":"","X_TP_Layer2Interface":"Device.WiFi.AccessPoint.1.",'
|
|
209
|
+
'"vendorClassID":"","clientID":"","hostName":"name1","interfaceType":"Wi-Fi",'
|
|
210
|
+
'"X_TP_LanConnType":"1","X_TP_LanConnDev":"br0","active":"1","IPv4AddressNumberOfEntries":"0",'
|
|
211
|
+
'"X_TP_Vendor":"","X_TP_ClientType":"Other","X_TP_DevphyAddress":"",'
|
|
212
|
+
'"IPv6AddressNumberOfEntries":"0","X_TP_NetworkReadyTime":"0","stack":"1,0,0,0,0,0"},'
|
|
213
|
+
'{"alias":"","physAddress":"a0:28:84:de:dd:5c","IPAddress":"192.168.32.176",'
|
|
214
|
+
'"addressSource":"Static","leaseTimeRemaining":"86372","X_TP_IPv6Address":"",'
|
|
215
|
+
'"X_TP_IPv6LinkLocal":"","layer1Interface":"","X_TP_Layer2Interface":"Device.WiFi.AccessPoint.1.",'
|
|
216
|
+
'"vendorClassID":"","clientID":"","hostName":"name2","interfaceType":"Wi-Fi",'
|
|
217
|
+
'"X_TP_LanConnType":"1","X_TP_LanConnDev":"br0","active":"1","IPv4AddressNumberOfEntries":"0",'
|
|
218
|
+
'"X_TP_Vendor":"","X_TP_ClientType":"Other","X_TP_DevphyAddress":"",'
|
|
219
|
+
'"IPv6AddressNumberOfEntries":"0","X_TP_NetworkReadyTime":"0","stack":"1,0,0,0,0,0"}],'
|
|
220
|
+
'"operation":"gl","oid":"DEV2_HOST_ENTRY","success":true}')
|
|
221
|
+
|
|
222
|
+
class TPLinkEXClientTest(TPLinkEXClient):
|
|
223
|
+
self._token = True
|
|
224
|
+
|
|
225
|
+
def _request(self, url, method='POST', data_str=None, encrypt=False):
|
|
226
|
+
return 200, response
|
|
227
|
+
|
|
228
|
+
client = TPLinkEXClientTest('', '')
|
|
229
|
+
result = client.get_ipv4_dhcp_leases()
|
|
230
|
+
|
|
231
|
+
self.assertEqual(len(result), 2)
|
|
232
|
+
self.assertEqual(result[0].macaddr, 'BF-75-44-4C-DC-9E')
|
|
233
|
+
self.assertEqual(result[0].ipaddr, '192.168.32.175')
|
|
234
|
+
self.assertEqual(result[0].hostname, 'name1')
|
|
235
|
+
self.assertEqual(result[0].lease_time, 'Permanent')
|
|
236
|
+
self.assertEqual(result[1].macaddr, 'A0-28-84-DE-DD-5C')
|
|
237
|
+
self.assertEqual(result[1].ipaddr, '192.168.32.176')
|
|
238
|
+
self.assertEqual(result[1].hostname, 'name2')
|
|
239
|
+
self.assertEqual(result[1].lease_time, '23:59:32')
|
|
240
|
+
|
|
241
|
+
def test_get_ipv4_status(self) -> None:
|
|
242
|
+
|
|
243
|
+
DEV2_ADT_LAN = ('{"data":[{"MACAddress":"bf:75:44:4c:dc:9e","IPAddress":"192.168.5.1",'
|
|
244
|
+
'"IPSubnetMask":"255.255.255.0","DHCPv4Enable":"1","stack":"1,0,0,0,0,0"}],'
|
|
245
|
+
'"operation":"gl","oid":"DEV2_ADT_LAN","success":true}')
|
|
246
|
+
DEV2_ADT_WAN = ('{"data":[{"enable":"1","MACAddr":"a0:28:84:de:dd:5c","connIPv4Address":"10.10.11.5",'
|
|
247
|
+
'"connIPv4Gateway":"11.11.11.11","name":"ipoe_0_0_d","connIPv4SubnetMask":"1.1.1.1",'
|
|
248
|
+
'"connIPv4DnsServer":"8.8.8.8,8.8.4.4","stack":"1,0,0,0,0,0"}],"operation":"gl",'
|
|
249
|
+
'"oid":"DEV2_ADT_WAN","success":true}')
|
|
250
|
+
|
|
251
|
+
class TPLinkEXClientTest(TPLinkEXClient):
|
|
252
|
+
self._token = True
|
|
253
|
+
|
|
254
|
+
def _request(self, url, method='POST', data_str=None, encrypt=False):
|
|
255
|
+
if 'DEV2_ADT_LAN' in data_str:
|
|
256
|
+
return 200, DEV2_ADT_LAN
|
|
257
|
+
elif 'DEV2_ADT_WAN' in data_str:
|
|
258
|
+
return 200, DEV2_ADT_WAN
|
|
259
|
+
raise ClientException()
|
|
260
|
+
|
|
261
|
+
client = TPLinkEXClientTest('', '')
|
|
262
|
+
result = client.get_ipv4_status()
|
|
263
|
+
|
|
264
|
+
self.assertIsInstance(result, IPv4Status)
|
|
265
|
+
self.assertEqual(result.wan_macaddr, 'A0-28-84-DE-DD-5C')
|
|
266
|
+
self.assertEqual(result.wan_ipv4_ipaddr, '10.10.11.5')
|
|
267
|
+
self.assertEqual(result.wan_ipv4_gateway, '11.11.11.11')
|
|
268
|
+
self.assertEqual(result.wan_ipv4_conntype, 'ipoe_0_0_d')
|
|
269
|
+
self.assertEqual(result.wan_ipv4_netmask, '1.1.1.1')
|
|
270
|
+
self.assertEqual(result.wan_ipv4_pridns, '8.8.8.8')
|
|
271
|
+
self.assertEqual(result.wan_ipv4_snddns, '8.8.4.4')
|
|
272
|
+
self.assertEqual(result.lan_macaddr, 'BF-75-44-4C-DC-9E')
|
|
273
|
+
self.assertEqual(result.lan_ipv4_ipaddr, '192.168.5.1')
|
|
274
|
+
self.assertEqual(result.lan_ipv4_netmask, '255.255.255.0')
|
|
275
|
+
self.assertEqual(result.lan_ipv4_dhcp_enable, True)
|
|
276
|
+
self.assertEqual(result.remote, None)
|
|
277
|
+
|
|
278
|
+
def test_get_ipv4_status_one_wlan(self) -> None:
|
|
279
|
+
|
|
280
|
+
DEV2_ADT_LAN = ('{"data":[{"MACAddress":"bf:75:44:4c:dc:9e","IPAddress":"192.168.5.1",'
|
|
281
|
+
'"IPSubnetMask":"255.255.255.0","DHCPv4Enable":"1","stack":"1,0,0,0,0,0"}],'
|
|
282
|
+
'"operation":"gl","oid":"DEV2_ADT_LAN","success":true}')
|
|
283
|
+
DEV2_ADT_WAN = ('{"data":[{"enable":"1","MACAddr":"ba:7a:a4:4a:dc:7e","connIPv4Address":"0.0.0.0",'
|
|
284
|
+
'"connIPv4Gateway":"0.0.0.0","name":"ipoe_0_0_d","connIPv4SubnetMask":"0.0.0.0",'
|
|
285
|
+
'"connIPv4DnsServer":"0.0.0.0,0.0.0.0","stack":"1,0,0,0,0,0"}],"operation":"gl",'
|
|
286
|
+
'"oid":"DEV2_ADT_WAN","success":true}')
|
|
287
|
+
|
|
288
|
+
class TPLinkEXClientTest(TPLinkEXClient):
|
|
289
|
+
self._token = True
|
|
290
|
+
|
|
291
|
+
def _request(self, url, method='POST', data_str=None, encrypt=False):
|
|
292
|
+
if 'DEV2_ADT_LAN' in data_str:
|
|
293
|
+
return 200, DEV2_ADT_LAN
|
|
294
|
+
elif 'DEV2_ADT_WAN' in data_str:
|
|
295
|
+
return 200, DEV2_ADT_WAN
|
|
296
|
+
raise ClientException()
|
|
297
|
+
|
|
298
|
+
client = TPLinkEXClientTest('', '')
|
|
299
|
+
result = client.get_ipv4_status()
|
|
300
|
+
|
|
301
|
+
self.assertIsInstance(result, IPv4Status)
|
|
302
|
+
self.assertEqual(result.wan_macaddr, 'BA-7A-A4-4A-DC-7E')
|
|
303
|
+
self.assertEqual(result.wan_ipv4_ipaddr, '0.0.0.0')
|
|
304
|
+
self.assertEqual(result.wan_ipv4_gateway, '0.0.0.0')
|
|
305
|
+
self.assertEqual(result.wan_ipv4_conntype, 'ipoe_0_0_d')
|
|
306
|
+
self.assertEqual(result.wan_ipv4_netmask, '0.0.0.0')
|
|
307
|
+
self.assertEqual(result.wan_ipv4_pridns, '0.0.0.0')
|
|
308
|
+
self.assertEqual(result.wan_ipv4_snddns, '0.0.0.0')
|
|
309
|
+
self.assertEqual(result.lan_macaddr, 'BF-75-44-4C-DC-9E')
|
|
310
|
+
self.assertEqual(result.lan_ipv4_ipaddr, '192.168.5.1')
|
|
311
|
+
self.assertEqual(result.lan_ipv4_netmask, '255.255.255.0')
|
|
312
|
+
self.assertEqual(result.lan_ipv4_dhcp_enable, True)
|
|
313
|
+
self.assertEqual(result.remote, None)
|
|
314
|
+
|
|
315
|
+
def test_set_wifi(self) -> None:
|
|
316
|
+
response = '{"success":true, "errorcode":0}'
|
|
317
|
+
|
|
318
|
+
check_url = ''
|
|
319
|
+
check_data = ''
|
|
320
|
+
|
|
321
|
+
class TPLinkEXClientTest(TPLinkEXClient):
|
|
322
|
+
self._token = True
|
|
323
|
+
|
|
324
|
+
def _request(self, url, method='POST', data_str=None, encrypt=False):
|
|
325
|
+
nonlocal check_url, check_data
|
|
326
|
+
check_url = url
|
|
327
|
+
check_data = data_str
|
|
328
|
+
return 200, response
|
|
329
|
+
|
|
330
|
+
client = TPLinkEXClientTest('', '')
|
|
331
|
+
client.set_wifi(Connection.HOST_2G, True)
|
|
332
|
+
|
|
333
|
+
self.assertIn('http:///cgi_gdpr?9?_=', check_url)
|
|
334
|
+
self.assertEqual(check_data, '{"data":{"stack":"1,0,0,0,0,0","pstack":"0,0,0,0,0,0",'
|
|
335
|
+
'"primaryEnable":"1"},"operation":"so","oid":"DEV2_ADT_WIFI_COMMON"}')
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
if __name__ == '__main__':
|
|
339
|
+
main()
|