tplinkrouterc6u 5.1.0__py3-none-any.whl → 5.2.1__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.
- test/{test_client.py → test_client_c6u.py} +2 -1
- test/test_client_mr.py +180 -0
- test/test_client_xdr.py +584 -0
- tplinkrouterc6u/__init__.py +5 -2
- tplinkrouterc6u/client/c5400x.py +1 -1
- tplinkrouterc6u/client/{api_cgi_bin.py → c6u.py} +1 -0
- tplinkrouterc6u/client/deco.py +1 -1
- tplinkrouterc6u/client/mr.py +68 -1
- tplinkrouterc6u/client/xdr.py +263 -0
- tplinkrouterc6u/common/dataclass.py +28 -0
- tplinkrouterc6u/common/package_enum.py +5 -0
- tplinkrouterc6u/provider.py +4 -2
- {tplinkrouterc6u-5.1.0.dist-info → tplinkrouterc6u-5.2.1.dist-info}/METADATA +39 -4
- tplinkrouterc6u-5.2.1.dist-info/RECORD +30 -0
- tplinkrouterc6u-5.1.0.dist-info/RECORD +0 -28
- {tplinkrouterc6u-5.1.0.dist-info → tplinkrouterc6u-5.2.1.dist-info}/LICENSE +0 -0
- {tplinkrouterc6u-5.1.0.dist-info → tplinkrouterc6u-5.2.1.dist-info}/WHEEL +0 -0
- {tplinkrouterc6u-5.1.0.dist-info → tplinkrouterc6u-5.2.1.dist-info}/top_level.txt +0 -0
tplinkrouterc6u/client/mr.py
CHANGED
|
@@ -8,7 +8,7 @@ from macaddress import EUI48
|
|
|
8
8
|
from ipaddress import IPv4Address
|
|
9
9
|
from logging import Logger
|
|
10
10
|
from tplinkrouterc6u.common.encryption import EncryptionWrapperMR
|
|
11
|
-
from tplinkrouterc6u.common.package_enum import Connection
|
|
11
|
+
from tplinkrouterc6u.common.package_enum import Connection, VPN
|
|
12
12
|
from tplinkrouterc6u.common.dataclass import (
|
|
13
13
|
Firmware,
|
|
14
14
|
Status,
|
|
@@ -17,6 +17,8 @@ from tplinkrouterc6u.common.dataclass import (
|
|
|
17
17
|
IPv4DHCPLease,
|
|
18
18
|
IPv4Status,
|
|
19
19
|
SMS,
|
|
20
|
+
LTEStatus,
|
|
21
|
+
VPNStatus,
|
|
20
22
|
)
|
|
21
23
|
from tplinkrouterc6u.common.exception import ClientException, ClientError
|
|
22
24
|
from tplinkrouterc6u.client_abstract import AbstractRouter
|
|
@@ -643,3 +645,68 @@ class TPLinkMRClient(TPLinkMRClientBase):
|
|
|
643
645
|
return values.get('response')
|
|
644
646
|
elif status == '2':
|
|
645
647
|
raise ClientError('Cannot send USSD!')
|
|
648
|
+
|
|
649
|
+
def get_lte_status(self) -> LTEStatus:
|
|
650
|
+
status = LTEStatus()
|
|
651
|
+
acts = [
|
|
652
|
+
self.ActItem(self.ActItem.GET, 'WAN_LTE_LINK_CFG', '2,1,0,0,0,0',
|
|
653
|
+
attrs=['enable', 'connectStatus', 'networkType', 'roamingStatus', 'simStatus']),
|
|
654
|
+
self.ActItem(self.ActItem.GET, 'WAN_LTE_INTF_CFG', '2,0,0,0,0,0',
|
|
655
|
+
attrs=['dataLimit', 'enablePaymentDay', 'curStatistics', 'totalStatistics', 'enableDataLimit',
|
|
656
|
+
'limitation',
|
|
657
|
+
'curRxSpeed', 'curTxSpeed']),
|
|
658
|
+
self.ActItem(self.ActItem.GET, 'LTE_NET_STATUS', '2,1,0,0,0,0',
|
|
659
|
+
attrs=['smsUnreadCount', 'ussdStatus', 'smsSendResult', 'sigLevel', 'rfInfoRsrp',
|
|
660
|
+
'rfInfoRsrq', 'rfInfoSnr']),
|
|
661
|
+
self.ActItem(self.ActItem.GET, 'LTE_PROF_STAT', '2,1,0,0,0,0', attrs=['spn', 'ispName']),
|
|
662
|
+
]
|
|
663
|
+
_, values = self.req_act(acts)
|
|
664
|
+
|
|
665
|
+
status.enable = int(values['0']['enable'])
|
|
666
|
+
status.connect_status = int(values['0']['connectStatus'])
|
|
667
|
+
status.network_type = int(values['0']['networkType'])
|
|
668
|
+
status.sim_status = int(values['0']['simStatus'])
|
|
669
|
+
|
|
670
|
+
status.total_statistics = int(float(values['1']['totalStatistics']))
|
|
671
|
+
status.cur_rx_speed = int(values['1']['curRxSpeed'])
|
|
672
|
+
status.cur_tx_speed = int(values['1']['curTxSpeed'])
|
|
673
|
+
|
|
674
|
+
status.sms_unread_count = int(values['2']['smsUnreadCount'])
|
|
675
|
+
status.sig_level = int(values['2']['sigLevel'])
|
|
676
|
+
status.rsrp = int(values['2']['rfInfoRsrp'])
|
|
677
|
+
status.rsrq = int(values['2']['rfInfoRsrq'])
|
|
678
|
+
status.snr = int(values['2']['rfInfoSnr'])
|
|
679
|
+
|
|
680
|
+
status.isp_name = values['3']['ispName']
|
|
681
|
+
|
|
682
|
+
return status
|
|
683
|
+
|
|
684
|
+
def get_vpn_status(self) -> VPNStatus:
|
|
685
|
+
status = VPNStatus()
|
|
686
|
+
acts = [
|
|
687
|
+
self.ActItem(self.ActItem.GET, 'OPENVPN', attrs=['enable']),
|
|
688
|
+
self.ActItem(self.ActItem.GET, 'PPTPVPN', attrs=['enable']),
|
|
689
|
+
self.ActItem(self.ActItem.GL, 'OVPN_CLIENT', attrs=['connAct']),
|
|
690
|
+
self.ActItem(self.ActItem.GL, 'PVPN_CLIENT', attrs=['connAct']),
|
|
691
|
+
]
|
|
692
|
+
_, values = self.req_act(acts)
|
|
693
|
+
|
|
694
|
+
status.openvpn_enable = True if values['0']['enable'] == '1' else False
|
|
695
|
+
status.pptpvpn_enable = True if values['1']['enable'] == '1' else False
|
|
696
|
+
|
|
697
|
+
for item in values['2']:
|
|
698
|
+
if item['connAct'] == '1':
|
|
699
|
+
status.openvpn_clients_total += 1
|
|
700
|
+
|
|
701
|
+
for item in values['3']:
|
|
702
|
+
if item['connAct'] == '1':
|
|
703
|
+
status.pptpvpn_clients_total += 1
|
|
704
|
+
|
|
705
|
+
return status
|
|
706
|
+
|
|
707
|
+
def set_vpn(self, vpn: VPN, enable: bool) -> None:
|
|
708
|
+
acts = [
|
|
709
|
+
self.ActItem(self.ActItem.SET, vpn.value, attrs=['enable={}'.format(int(enable))])
|
|
710
|
+
]
|
|
711
|
+
|
|
712
|
+
self.req_act(acts)
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
from datetime import timedelta
|
|
2
|
+
from ipaddress import IPv4Address
|
|
3
|
+
from logging import Logger
|
|
4
|
+
from urllib.parse import unquote
|
|
5
|
+
|
|
6
|
+
from macaddress import EUI48
|
|
7
|
+
from requests import Session
|
|
8
|
+
|
|
9
|
+
from tplinkrouterc6u.client_abstract import AbstractRouter
|
|
10
|
+
from tplinkrouterc6u.common.dataclass import (Device, Firmware, IPv4DHCPLease,
|
|
11
|
+
IPv4Reservation, IPv4Status,
|
|
12
|
+
Status)
|
|
13
|
+
from tplinkrouterc6u.common.exception import ClientException
|
|
14
|
+
from tplinkrouterc6u.common.helper import get_ip, get_mac
|
|
15
|
+
from tplinkrouterc6u.common.package_enum import Connection
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class TPLinkXDRClient(AbstractRouter):
|
|
19
|
+
_stok = ''
|
|
20
|
+
|
|
21
|
+
def __init__(self, host: str, password: str, username: str = 'admin', logger: Logger = None,
|
|
22
|
+
verify_ssl: bool = True, timeout: int = 30) -> None:
|
|
23
|
+
super().__init__(host, password, username, logger, verify_ssl, timeout)
|
|
24
|
+
self._session = Session()
|
|
25
|
+
|
|
26
|
+
def supports(self) -> bool:
|
|
27
|
+
response = self._session.get(self.host, timeout=self.timeout, verify=self._verify_ssl)
|
|
28
|
+
return 'TL-XDR' in response.text
|
|
29
|
+
|
|
30
|
+
def authorize(self) -> None:
|
|
31
|
+
response = self._session.post(self.host, json={
|
|
32
|
+
'method': 'do',
|
|
33
|
+
'login': {
|
|
34
|
+
'password': self._encode_password(self.password),
|
|
35
|
+
}
|
|
36
|
+
}, timeout=self.timeout, verify=self._verify_ssl)
|
|
37
|
+
try:
|
|
38
|
+
data = response.json()
|
|
39
|
+
self._stok = data['stok']
|
|
40
|
+
except Exception as e:
|
|
41
|
+
error = ('TplinkRouter - {} - Cannot authorize! Error - {}; Response - {}'.
|
|
42
|
+
format(self.__class__.__name__, e, response))
|
|
43
|
+
raise ClientException(error)
|
|
44
|
+
|
|
45
|
+
def logout(self) -> None:
|
|
46
|
+
data = self._request({
|
|
47
|
+
'method': 'do',
|
|
48
|
+
'system': {
|
|
49
|
+
'logout': None,
|
|
50
|
+
},
|
|
51
|
+
})
|
|
52
|
+
if data['error_code'] != 0:
|
|
53
|
+
raise ClientException('TplinkRouter - {} - logout failed, code - {}'.
|
|
54
|
+
format(self.__class__, data['error_code']))
|
|
55
|
+
self._stok = ''
|
|
56
|
+
|
|
57
|
+
def get_firmware(self) -> Firmware:
|
|
58
|
+
data = self._request({
|
|
59
|
+
'method': 'get',
|
|
60
|
+
'device_info': {
|
|
61
|
+
'name': 'info',
|
|
62
|
+
},
|
|
63
|
+
})
|
|
64
|
+
dev_info = data['device_info']['info']
|
|
65
|
+
return Firmware(dev_info['hw_version'], dev_info['device_model'], dev_info['sw_version'])
|
|
66
|
+
|
|
67
|
+
def get_status(self) -> Status:
|
|
68
|
+
data = self._request({
|
|
69
|
+
'method': 'get',
|
|
70
|
+
'hosts_info': {
|
|
71
|
+
'table': 'host_info',
|
|
72
|
+
},
|
|
73
|
+
'network': {
|
|
74
|
+
'name': [
|
|
75
|
+
'wan_status',
|
|
76
|
+
'lan',
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
'wireless': {
|
|
80
|
+
'name': [
|
|
81
|
+
'wlan_bs',
|
|
82
|
+
'wlan_host_2g',
|
|
83
|
+
'wlan_wds_2g',
|
|
84
|
+
'wlan_host_5g',
|
|
85
|
+
'wlan_wds_5g',
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
'guest_network': {
|
|
89
|
+
'name': [
|
|
90
|
+
'guest_2g',
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
status = Status()
|
|
96
|
+
status._wan_ipv4_addr = get_ip(data['network']['wan_status']['ipaddr'])
|
|
97
|
+
status._lan_ipv4_addr = get_ip(data['network']['lan']['ipaddr'])
|
|
98
|
+
status._lan_macaddr = get_mac(data['network']['lan']['macaddr'])
|
|
99
|
+
status.wifi_2g_enable = data['wireless']['wlan_host_2g']['enable'] == '1'
|
|
100
|
+
status.wifi_5g_enable = (data['wireless']['wlan_host_5g']['enable'] == '1' or
|
|
101
|
+
data['wireless']['wlan_bs']['bs_enable'] == '1')
|
|
102
|
+
status.guest_2g_enable = data['guest_network']['guest_2g']['enable'] == '1'
|
|
103
|
+
|
|
104
|
+
for item_map in data['hosts_info']['host_info']:
|
|
105
|
+
item = item_map[next(iter(item_map))]
|
|
106
|
+
conn_type = Connection.UNKNOWN
|
|
107
|
+
if item['type'] == '0':
|
|
108
|
+
conn_type = Connection.WIRED
|
|
109
|
+
elif item['type'] == '1' and item['wifi_mode'] == '0':
|
|
110
|
+
conn_type = Connection.HOST_2G
|
|
111
|
+
elif item['type'] == '1' and item['wifi_mode'] == '1':
|
|
112
|
+
conn_type = Connection.HOST_5G
|
|
113
|
+
|
|
114
|
+
dev = Device(conn_type, get_mac(item['mac']), get_ip(item['ip']), unquote(item['hostname']))
|
|
115
|
+
dev.up_speed = item['up_speed']
|
|
116
|
+
dev.down_speed = item['down_speed']
|
|
117
|
+
status.devices.append(dev)
|
|
118
|
+
return status
|
|
119
|
+
|
|
120
|
+
def get_ipv4_reservations(self) -> [IPv4Reservation]:
|
|
121
|
+
data = self._request({
|
|
122
|
+
'method': 'get',
|
|
123
|
+
'ip_mac_bind': {
|
|
124
|
+
'table': 'user_bind',
|
|
125
|
+
},
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
ipv4_reservations = []
|
|
129
|
+
for item_map in data['ip_mac_bind']['user_bind']:
|
|
130
|
+
item = item_map[next(iter(item_map))]
|
|
131
|
+
ipv4_reservations.append(IPv4Reservation(
|
|
132
|
+
EUI48(item['mac']),
|
|
133
|
+
IPv4Address(item['ip']),
|
|
134
|
+
item['hostname'],
|
|
135
|
+
True,
|
|
136
|
+
))
|
|
137
|
+
return ipv4_reservations
|
|
138
|
+
|
|
139
|
+
def get_ipv4_dhcp_leases(self) -> [IPv4DHCPLease]:
|
|
140
|
+
data = self._request({
|
|
141
|
+
'method': 'get',
|
|
142
|
+
'dhcpd': {
|
|
143
|
+
'table': 'dhcp_clients',
|
|
144
|
+
},
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
dhcp_leases = []
|
|
148
|
+
for item_map in data['dhcpd']['dhcp_clients']:
|
|
149
|
+
item = item_map[next(iter(item_map))]
|
|
150
|
+
dhcp_leases.append(IPv4DHCPLease(
|
|
151
|
+
get_mac(item['mac']),
|
|
152
|
+
get_ip(item['ip']),
|
|
153
|
+
item['hostname'],
|
|
154
|
+
str(timedelta(seconds=int(item['expires']))) if item['expires'] != '4294967295' else 'Permanent',
|
|
155
|
+
))
|
|
156
|
+
return dhcp_leases
|
|
157
|
+
|
|
158
|
+
def get_ipv4_status(self) -> IPv4Status:
|
|
159
|
+
data = self._request({
|
|
160
|
+
'method': 'get',
|
|
161
|
+
'dhcpd': {
|
|
162
|
+
'name': 'udhcpd',
|
|
163
|
+
},
|
|
164
|
+
'network': {
|
|
165
|
+
'name': [
|
|
166
|
+
'lan',
|
|
167
|
+
'wan_status',
|
|
168
|
+
],
|
|
169
|
+
},
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
ipv4_status = IPv4Status()
|
|
173
|
+
ipv4_status._wan_ipv4_ipaddr = get_ip(data['network']['wan_status']['ipaddr'])
|
|
174
|
+
ipv4_status._wan_ipv4_gateway = get_ip(data['network']['wan_status']['gateway'])
|
|
175
|
+
ipv4_status._wan_ipv4_netmask = get_ip(data['network']['wan_status']['netmask'])
|
|
176
|
+
ipv4_status._wan_ipv4_pridns = get_ip(data['network']['wan_status']['pri_dns'])
|
|
177
|
+
ipv4_status._wan_ipv4_snddns = get_ip(data['network']['wan_status']['snd_dns'])
|
|
178
|
+
ipv4_status._lan_macaddr = get_mac(data['network']['lan']['macaddr'])
|
|
179
|
+
ipv4_status._lan_ipv4_ipaddr = get_ip(data['network']['lan']['ipaddr'])
|
|
180
|
+
ipv4_status.lan_ipv4_dhcp_enable = data['dhcpd']['udhcpd']['enable'] == '1'
|
|
181
|
+
ipv4_status._lan_ipv4_netmask = get_ip(data['network']['lan']['netmask'])
|
|
182
|
+
return ipv4_status
|
|
183
|
+
|
|
184
|
+
def reboot(self) -> None:
|
|
185
|
+
data = self._request({
|
|
186
|
+
'method': 'do',
|
|
187
|
+
'system': {
|
|
188
|
+
'reboot': None,
|
|
189
|
+
},
|
|
190
|
+
})
|
|
191
|
+
self._stok = ''
|
|
192
|
+
if data['error_code'] != 0:
|
|
193
|
+
raise ClientException('TplinkRouter - {} - reboot failed, code - {}'.
|
|
194
|
+
format(self.__class__, data['error_code']))
|
|
195
|
+
|
|
196
|
+
def set_wifi(self, wifi: Connection, enable: bool) -> None:
|
|
197
|
+
payload_map = {
|
|
198
|
+
Connection.HOST_2G: {
|
|
199
|
+
'method': 'set',
|
|
200
|
+
'wireless': {
|
|
201
|
+
'wlan_host_2g': {
|
|
202
|
+
'enable': 1 if enable else 0,
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
Connection.HOST_5G: {
|
|
207
|
+
'method': 'set',
|
|
208
|
+
'wireless': {
|
|
209
|
+
'wlan_host_5g': {
|
|
210
|
+
'enable': 1 if enable else 0,
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
Connection.GUEST_2G: {
|
|
215
|
+
'method': 'set',
|
|
216
|
+
'guest_network': {
|
|
217
|
+
'guest_2g': {
|
|
218
|
+
'enable': '1' if enable else '0',
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
}
|
|
223
|
+
if wifi not in payload_map:
|
|
224
|
+
raise ClientException('Not supported')
|
|
225
|
+
payload = payload_map[wifi]
|
|
226
|
+
data = self._request(payload)
|
|
227
|
+
if data['error_code'] != 0:
|
|
228
|
+
raise ClientException('TplinkRouter - {} - set wifi failed, code - {}'.
|
|
229
|
+
format(self.__class__, data['error_code']))
|
|
230
|
+
|
|
231
|
+
def _request(self, payload: dict) -> dict:
|
|
232
|
+
url = '{}/stok={}/ds'.format(self.host, self._stok)
|
|
233
|
+
response = self._session.post(url, json=payload, timeout=self.timeout, verify=self._verify_ssl)
|
|
234
|
+
return response.json()
|
|
235
|
+
|
|
236
|
+
@staticmethod
|
|
237
|
+
def _encode_password(pwd: str) -> str:
|
|
238
|
+
return TPLinkXDRClient._security_encode(
|
|
239
|
+
pwd,
|
|
240
|
+
'RDpbLfCPsJZ7fiv',
|
|
241
|
+
('yLwVl0zKqws7LgKPRQ84Mdt708T1qQ3Ha7xv3H7NyU84p21BriUWBU43odz3iP4rBL3cD'
|
|
242
|
+
'02KZciXTysVXiV8ngg6vL48rPJyAUw0HurW20xqxv9aYb4M9wK1Ae0wlro510qXeU07kV57fQMc8L6aLg'
|
|
243
|
+
'MLwygtc0F10a0Dg70TOoouyFhdysuRMO51yY5ZlOZZLEal1h0t9YQW0Ko7oBwmCAHoic4HYbUyVeU3sfQ'
|
|
244
|
+
'1xtXcPcf1aT303wAQhv66qzW'),
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
@staticmethod
|
|
248
|
+
def _security_encode(data1: str, data2: str, char_dict: str) -> str:
|
|
249
|
+
data1_len = len(data1)
|
|
250
|
+
data2_len = len(data2)
|
|
251
|
+
dict_len = len(char_dict)
|
|
252
|
+
res = ''
|
|
253
|
+
for c in range(max(data1_len, data2_len)):
|
|
254
|
+
a = b = 187
|
|
255
|
+
if c >= data1_len:
|
|
256
|
+
a = ord(data2[c])
|
|
257
|
+
elif c >= data2_len:
|
|
258
|
+
b = ord(data1[c])
|
|
259
|
+
else:
|
|
260
|
+
b = ord(data1[c])
|
|
261
|
+
a = ord(data2[c])
|
|
262
|
+
res += char_dict[(b ^ a) % dict_len]
|
|
263
|
+
return res
|
|
@@ -24,6 +24,7 @@ class Device:
|
|
|
24
24
|
self.packets_received: int | None = None
|
|
25
25
|
self.down_speed: int | None = None
|
|
26
26
|
self.up_speed: int | None = None
|
|
27
|
+
self.signal: int | None = None
|
|
27
28
|
|
|
28
29
|
@property
|
|
29
30
|
def macaddr(self):
|
|
@@ -257,3 +258,30 @@ class SMS:
|
|
|
257
258
|
self.content = content
|
|
258
259
|
self.received_at = received_at
|
|
259
260
|
self.unread = unread
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
@dataclass
|
|
264
|
+
class LTEStatus:
|
|
265
|
+
def __init__(self) -> None:
|
|
266
|
+
self.enable: int
|
|
267
|
+
self.connect_status: int
|
|
268
|
+
self.network_type: int
|
|
269
|
+
self.sim_status: int
|
|
270
|
+
self.total_statistics: int
|
|
271
|
+
self.cur_rx_speed: int
|
|
272
|
+
self.cur_tx_speed: int
|
|
273
|
+
self.sms_unread_count: int
|
|
274
|
+
self.sig_level: int
|
|
275
|
+
self.rsrp: int
|
|
276
|
+
self.rsrq: int
|
|
277
|
+
self.snr: int
|
|
278
|
+
self.isp_name: str
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
@dataclass
|
|
282
|
+
class VPNStatus:
|
|
283
|
+
def __init__(self) -> None:
|
|
284
|
+
self.openvpn_enable: bool
|
|
285
|
+
self.pptpvpn_enable: bool
|
|
286
|
+
self.openvpn_clients_total: int = 0
|
|
287
|
+
self.pptpvpn_clients_total: int = 0
|
tplinkrouterc6u/provider.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
from logging import Logger
|
|
2
|
+
|
|
3
|
+
from tplinkrouterc6u import TPLinkXDRClient
|
|
2
4
|
from tplinkrouterc6u.common.exception import ClientException, AuthorizeError
|
|
3
|
-
from tplinkrouterc6u.client.
|
|
5
|
+
from tplinkrouterc6u.client.c6u import TplinkRouter
|
|
4
6
|
from tplinkrouterc6u.client.deco import TPLinkDecoClient
|
|
5
7
|
from tplinkrouterc6u.client_abstract import AbstractRouter
|
|
6
8
|
from tplinkrouterc6u.client.mr import TPLinkMRClient
|
|
@@ -15,7 +17,7 @@ class TplinkRouterProvider:
|
|
|
15
17
|
def get_client(host: str, password: str, username: str = 'admin', logger: Logger = None,
|
|
16
18
|
verify_ssl: bool = True, timeout: int = 30) -> AbstractRouter:
|
|
17
19
|
for client in [TplinkC5400XRouter, TPLinkEXClient, TPLinkMRClient, TplinkC6V4Router, TPLinkDecoClient,
|
|
18
|
-
TplinkRouter]:
|
|
20
|
+
TPLinkXDRClient, TplinkRouter]:
|
|
19
21
|
router = client(host, password, username, logger, verify_ssl, timeout)
|
|
20
22
|
if router.supports():
|
|
21
23
|
return router
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: tplinkrouterc6u
|
|
3
|
-
Version: 5.1
|
|
3
|
+
Version: 5.2.1
|
|
4
4
|
Summary: TP-Link Router API
|
|
5
5
|
Home-page: https://github.com/AlexandrErohin/TP-Link-Archer-C6U
|
|
6
6
|
Author: Alex Erohin
|
|
@@ -45,6 +45,7 @@ from tplinkrouterc6u import (
|
|
|
45
45
|
TplinkC5400XRouter,
|
|
46
46
|
TPLinkMRClient,
|
|
47
47
|
TPLinkEXClient,
|
|
48
|
+
TPLinkXDRClient,
|
|
48
49
|
TPLinkDecoClient,
|
|
49
50
|
Connection
|
|
50
51
|
)
|
|
@@ -107,14 +108,17 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
107
108
|
| get_ipv4_reservations | | Gets IPv4 reserved addresses (static) | [[IPv4Reservation]](#IPv4Reservation) |
|
|
108
109
|
| get_ipv4_dhcp_leases | | Gets IPv4 addresses assigned via DHCP | [[IPv4DHCPLease]](#IPv4DHCPLease) |
|
|
109
110
|
| set_wifi | wifi: [Connection](#connection), enable: bool | Allow to turn on/of 4 wifi networks | |
|
|
111
|
+
| reboot | | reboot router |
|
|
112
|
+
| authorize | | authorize for actions |
|
|
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 | |
|
|
110
116
|
| send_sms | phone_number: str, message: str | Send sms for LTE routers | |
|
|
111
117
|
| send_ussd | command: str | Send USSD command for LTE routers | str |
|
|
112
118
|
| get_sms | | Get sms messages from the first page for LTE routers | [[SMS]](#sms) |
|
|
113
119
|
| set_sms_read | sms: [SMS](#sms) | Set sms message read from the first page for LTE routers | |
|
|
114
120
|
| delete_sms | sms: [SMS](#sms) | Delete sms message from the first page for LTE routers | |
|
|
115
|
-
|
|
|
116
|
-
| authorize | | authorize for actions |
|
|
117
|
-
| logout | | logout after all is done |
|
|
121
|
+
| get_lte_status | | Get lte info for LTE routers | [LTEStatus](#lte_status) |
|
|
118
122
|
|
|
119
123
|
## Dataclass
|
|
120
124
|
### <a id="firmware">Firmware</a>
|
|
@@ -169,6 +173,7 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
169
173
|
| packets_received | total packets received | int, None |
|
|
170
174
|
| down_speed | download speed | int, None |
|
|
171
175
|
| up_speed | upload speed | int, None |
|
|
176
|
+
| signal | Signal strength | int, None |
|
|
172
177
|
|
|
173
178
|
### <a id="IPv4Reservation">IPv4Reservation</a>
|
|
174
179
|
| Field | Description | Type |
|
|
@@ -215,6 +220,14 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
215
220
|
| lan_ipv4_netmask_address | router LAN gateway IP netmask | ipaddress |
|
|
216
221
|
| remote | router remote | bool, None |
|
|
217
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
|
+
|
|
218
231
|
### <a id="sms">SMS</a>
|
|
219
232
|
| Field | Description | Type |
|
|
220
233
|
| --- |---|---|
|
|
@@ -224,6 +237,23 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
224
237
|
| received_at| received datetime | datetime |
|
|
225
238
|
| unread| is message unread | bool |
|
|
226
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
|
+
|
|
227
257
|
## Enum
|
|
228
258
|
### <a id="connection">Connection</a>
|
|
229
259
|
- Connection.HOST_2G - host wifi 2.4G
|
|
@@ -237,6 +267,10 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
237
267
|
- Connection.IOT_6G - IoT wifi 6G
|
|
238
268
|
- Connection.WIRED - Wired
|
|
239
269
|
|
|
270
|
+
### <a id="vpn">VPN</a>
|
|
271
|
+
- VPN.OPEN_VPN
|
|
272
|
+
- VPN.PPTP_VPN
|
|
273
|
+
|
|
240
274
|
## <a id="supports">Supported routers</a>
|
|
241
275
|
### Fully tested Hardware Versions
|
|
242
276
|
- Archer A7 V5
|
|
@@ -291,6 +325,7 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
291
325
|
- TL-MR105
|
|
292
326
|
- TL-MR6400 (v5, v5.3)
|
|
293
327
|
- TL-MR6500v
|
|
328
|
+
- TL-XDR3010 V2
|
|
294
329
|
- TL-WA3001 v1.0
|
|
295
330
|
|
|
296
331
|
### Not fully tested Hardware Versions
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
test/__init__.py,sha256=McQmUjeN3AwmwdS6QNfwGXXE77OKoPK852I2BM9XsrU,210
|
|
2
|
+
test/test_client_c1200.py,sha256=O6NK9uXIEb_vks6lI3g7j6q8TYJ9MSDFYzGA_wOBhOA,4620
|
|
3
|
+
test/test_client_c6u.py,sha256=qC0PNE-Hz3d8PYIGej4j_M4cLDqffnPiXu_ff7Ft29M,30709
|
|
4
|
+
test/test_client_deco.py,sha256=ur4u-pWB-6WaYW6PSpK9OvCg3rfo2x06V5Cf_eE2UYU,30447
|
|
5
|
+
test/test_client_ex.py,sha256=cSIMh6yjiAknt0mk7u1dCpXVzZTR_Y95XvXRBRusbpg,17092
|
|
6
|
+
test/test_client_mr.py,sha256=Uomg3T_SA5Y1tb4wlniMKQDi_uJ2Vqm30I-GKgOXBRc,32703
|
|
7
|
+
test/test_client_xdr.py,sha256=Tm3fXAmSxa8F_YNv66eN3zSvy2GKi_q6tuuw8GWqL-c,20698
|
|
8
|
+
tplinkrouterc6u/__init__.py,sha256=bLlCkiL9ycyRVG7VqPOJWPcoPmUfMkdTcUKFYKNP8QI,900
|
|
9
|
+
tplinkrouterc6u/client_abstract.py,sha256=OgftTH6bELzhFWom0MOX4EJe3RNS003ezpHyyRnh2tQ,1328
|
|
10
|
+
tplinkrouterc6u/provider.py,sha256=SsyGu_2SZ-a46ADl9aw_0wx0lgbsJhS6wnwUzb_1qGg,1900
|
|
11
|
+
tplinkrouterc6u/client/__init__.py,sha256=KBy3fmtA9wgyFrb0Urh2x4CkKtWVnESdp-vxmuOvq0k,27
|
|
12
|
+
tplinkrouterc6u/client/c1200.py,sha256=4XEYidEGmVIJk0YQLvmTnd0Gqa7glH2gUWvjreHpWrk,3178
|
|
13
|
+
tplinkrouterc6u/client/c5400x.py,sha256=EhcNcaj2U8OBSv1Bftrg3rH9ylP_73P2VO1JHA9CYO4,4322
|
|
14
|
+
tplinkrouterc6u/client/c6u.py,sha256=8n3nMW20k3SEXamCYzq7-mzBM6wyn5Txl6XxzjHEa6c,17411
|
|
15
|
+
tplinkrouterc6u/client/c6v4.py,sha256=-IF7SqTZx56lRAVmiyxK9VKkrmD7srQSJWFvn2Z0DII,1489
|
|
16
|
+
tplinkrouterc6u/client/deco.py,sha256=0Hwy_kVQshYd-5Oa3mIASaZI_4NUD09NFEdRyPtzjdI,8265
|
|
17
|
+
tplinkrouterc6u/client/ex.py,sha256=jkxCgqbjp-SfjlzgKeNj4WhV3v9gEOzKgrgfVgy9SB4,11604
|
|
18
|
+
tplinkrouterc6u/client/mr.py,sha256=1-aP8xo5JUiFzKmeyOjolzyKR_yIUwTBrRG562tmfAg,25638
|
|
19
|
+
tplinkrouterc6u/client/xdr.py,sha256=lqsBGxi9wZsz1IqQ9KZjAY6gd9-IgK0Cm2oRaswYFSs,9773
|
|
20
|
+
tplinkrouterc6u/common/__init__.py,sha256=pCTvVZ9CAwgb7MxRnLx0y1rI0sTKSwT24FfxWfQXeTM,33
|
|
21
|
+
tplinkrouterc6u/common/dataclass.py,sha256=__u8I8URLk_AdIEN4Jd8Pswh4ujURlJxw8YunuVStwk,7630
|
|
22
|
+
tplinkrouterc6u/common/encryption.py,sha256=4HelTxzN6esMfDZRBt3m8bwB9Nj_biKijnCnrGWPWKg,6228
|
|
23
|
+
tplinkrouterc6u/common/exception.py,sha256=_0G8ZvW5__CsGifHrsZeULdl8c6EUD071sDCQsQgrHY,140
|
|
24
|
+
tplinkrouterc6u/common/helper.py,sha256=phcPUdpY7lJVWF8Ih4KHNdsdem2ed6qFSDXuEAtAgug,334
|
|
25
|
+
tplinkrouterc6u/common/package_enum.py,sha256=py31wF7SntZ0D_o0PS7az29wtsWdp0r0uE7QMmiWigY,1451
|
|
26
|
+
tplinkrouterc6u-5.2.1.dist-info/LICENSE,sha256=YF6QR6Vjxcg5b_sYIyqkME7FZYau5TfEUGTG-0JeRK0,35129
|
|
27
|
+
tplinkrouterc6u-5.2.1.dist-info/METADATA,sha256=KqphtW9gVYMljs9l84CGB6uwutisAIQesbE0ixlSTuA,14917
|
|
28
|
+
tplinkrouterc6u-5.2.1.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
|
29
|
+
tplinkrouterc6u-5.2.1.dist-info/top_level.txt,sha256=1iSCCIueqgEkrTxtQ-jiHe99jAB10zqrVdBcwvNfe_M,21
|
|
30
|
+
tplinkrouterc6u-5.2.1.dist-info/RECORD,,
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
test/__init__.py,sha256=McQmUjeN3AwmwdS6QNfwGXXE77OKoPK852I2BM9XsrU,210
|
|
2
|
-
test/test_client.py,sha256=8cK4qnheszu-zpUJqttKp5Z5WJXrQy1t_fMzMzNnmvw,30638
|
|
3
|
-
test/test_client_c1200.py,sha256=O6NK9uXIEb_vks6lI3g7j6q8TYJ9MSDFYzGA_wOBhOA,4620
|
|
4
|
-
test/test_client_deco.py,sha256=ur4u-pWB-6WaYW6PSpK9OvCg3rfo2x06V5Cf_eE2UYU,30447
|
|
5
|
-
test/test_client_ex.py,sha256=cSIMh6yjiAknt0mk7u1dCpXVzZTR_Y95XvXRBRusbpg,17092
|
|
6
|
-
test/test_client_mr.py,sha256=xdrcOnnhDWp7BBAUrtBf9I7y6H6q5ZnYz3iz0T3hTDw,28666
|
|
7
|
-
tplinkrouterc6u/__init__.py,sha256=HU1JG5MaM_k5J6D2tV_zqhGA2SpGQ2j44K4RE4turfw,818
|
|
8
|
-
tplinkrouterc6u/client_abstract.py,sha256=OgftTH6bELzhFWom0MOX4EJe3RNS003ezpHyyRnh2tQ,1328
|
|
9
|
-
tplinkrouterc6u/provider.py,sha256=TYnpQiLU1IcTd1x9kJenZ5AREgkpWzDJkSai_hfPPEk,1846
|
|
10
|
-
tplinkrouterc6u/client/__init__.py,sha256=KBy3fmtA9wgyFrb0Urh2x4CkKtWVnESdp-vxmuOvq0k,27
|
|
11
|
-
tplinkrouterc6u/client/api_cgi_bin.py,sha256=zzGkdooPopVwcNVpqQ3rbsa7pfjLrgqPQVuV9PFKfY4,17309
|
|
12
|
-
tplinkrouterc6u/client/c1200.py,sha256=4XEYidEGmVIJk0YQLvmTnd0Gqa7glH2gUWvjreHpWrk,3178
|
|
13
|
-
tplinkrouterc6u/client/c5400x.py,sha256=wvqeCnsoM7dYr3q7NHGAeXJHRpEYYXZ0rvrU9j6qLu4,4330
|
|
14
|
-
tplinkrouterc6u/client/c6v4.py,sha256=-IF7SqTZx56lRAVmiyxK9VKkrmD7srQSJWFvn2Z0DII,1489
|
|
15
|
-
tplinkrouterc6u/client/deco.py,sha256=0NW65b39lXKAnVimLHoe0f3Std6i1V21fZMaorKqsW0,8273
|
|
16
|
-
tplinkrouterc6u/client/ex.py,sha256=jkxCgqbjp-SfjlzgKeNj4WhV3v9gEOzKgrgfVgy9SB4,11604
|
|
17
|
-
tplinkrouterc6u/client/mr.py,sha256=nnCYbucl7iFfcePua3fT1YJPDzYlxTTmKddKSC-wUqM,22759
|
|
18
|
-
tplinkrouterc6u/common/__init__.py,sha256=pCTvVZ9CAwgb7MxRnLx0y1rI0sTKSwT24FfxWfQXeTM,33
|
|
19
|
-
tplinkrouterc6u/common/dataclass.py,sha256=DFWANchEhFNHUlduEGPVzcFDaqr3dbFq9Ah8h8pGa_U,6938
|
|
20
|
-
tplinkrouterc6u/common/encryption.py,sha256=4HelTxzN6esMfDZRBt3m8bwB9Nj_biKijnCnrGWPWKg,6228
|
|
21
|
-
tplinkrouterc6u/common/exception.py,sha256=_0G8ZvW5__CsGifHrsZeULdl8c6EUD071sDCQsQgrHY,140
|
|
22
|
-
tplinkrouterc6u/common/helper.py,sha256=phcPUdpY7lJVWF8Ih4KHNdsdem2ed6qFSDXuEAtAgug,334
|
|
23
|
-
tplinkrouterc6u/common/package_enum.py,sha256=bqmnu4gQMEntMCgsya2R7dRcrSJIDPWMj8vNN6JxeME,1382
|
|
24
|
-
tplinkrouterc6u-5.1.0.dist-info/LICENSE,sha256=YF6QR6Vjxcg5b_sYIyqkME7FZYau5TfEUGTG-0JeRK0,35129
|
|
25
|
-
tplinkrouterc6u-5.1.0.dist-info/METADATA,sha256=VHCZsN-I-kBWLIG-IUZmbK7XlO_tTaAjnafRLiqr1Rw,13596
|
|
26
|
-
tplinkrouterc6u-5.1.0.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
|
27
|
-
tplinkrouterc6u-5.1.0.dist-info/top_level.txt,sha256=1iSCCIueqgEkrTxtQ-jiHe99jAB10zqrVdBcwvNfe_M,21
|
|
28
|
-
tplinkrouterc6u-5.1.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|