tplinkrouterc6u 5.4.1__py3-none-any.whl → 5.4.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
test/test_client_ex.py CHANGED
@@ -277,6 +277,35 @@ class TestTPLinkEXClient(TestCase):
277
277
  self.assertEqual(result.lan_ipv4_dhcp_enable, True)
278
278
  self.assertEqual(result.remote, None)
279
279
 
280
+ def test_get_ipv4_status_empty(self) -> None:
281
+
282
+ DEV2_ADT_LAN = ('{"data":[],"operation":"gl","oid":"DEV2_ADT_LAN","success":true}')
283
+ DEV2_ADT_WAN = ('{"data":[],"operation":"gl","oid":"DEV2_ADT_WAN","success":true}')
284
+
285
+ class TPLinkEXClientTest(TPLinkEXClient):
286
+ self._token = True
287
+
288
+ def _request(self, url, method='POST', data_str=None, encrypt=False):
289
+ if 'DEV2_ADT_LAN' in data_str:
290
+ return 200, DEV2_ADT_LAN
291
+ elif 'DEV2_ADT_WAN' in data_str:
292
+ return 200, DEV2_ADT_WAN
293
+ raise ClientException()
294
+
295
+ client = TPLinkEXClientTest('', '')
296
+ result = client.get_ipv4_status()
297
+
298
+ self.assertIsInstance(result, IPv4Status)
299
+ self.assertEqual(result.wan_ipv4_ipaddr, None)
300
+ self.assertEqual(result.wan_ipv4_gateway, None)
301
+ self.assertEqual(result.wan_ipv4_netmask, None)
302
+ self.assertEqual(result.wan_ipv4_conntype, '')
303
+ self.assertEqual(result.lan_macaddr, '00-00-00-00-00-00')
304
+ self.assertEqual(result.lan_ipv4_ipaddr, '0.0.0.0')
305
+ self.assertEqual(result.lan_ipv4_netmask, '0.0.0.0')
306
+ self.assertEqual(result.lan_ipv4_dhcp_enable, False)
307
+ self.assertEqual(result.remote, None)
308
+
280
309
  def test_get_ipv4_status_one_wlan(self) -> None:
281
310
 
282
311
  DEV2_ADT_LAN = ('{"data":[{"MACAddress":"bf:75:44:4c:dc:9e","IPAddress":"192.168.5.1",'
test/test_client_mr.py CHANGED
@@ -618,6 +618,7 @@ DNSServers=7.7.7.7,2.2.2.2
618
618
 
619
619
  self.assertIsInstance(result, IPv4Status)
620
620
  self.assertEqual(result.lan_macaddr, '00-00-00-00-00-00')
621
+ self.assertEqual(result.wan_ipv4_conntype, '')
621
622
  self.assertEqual(result.lan_ipv4_ipaddr, '0.0.0.0')
622
623
  self.assertEqual(result.lan_ipv4_netmask, '0.0.0.0')
623
624
  self.assertEqual(result.lan_ipv4_dhcp_enable, False)
@@ -366,7 +366,7 @@ class TplinkBaseRouter(AbstractRouter, TplinkRequest):
366
366
  ipv4_status._wan_macaddr = get_mac(data.get('wan_macaddr', '00:00:00:00:00:00'))
367
367
  ipv4_status._wan_ipv4_ipaddr = get_ip(data.get('wan_ipv4_ipaddr', '0.0.0.0'))
368
368
  ipv4_status._wan_ipv4_gateway = get_ip(data.get('wan_ipv4_gateway', '0.0.0.0'))
369
- ipv4_status.wan_ipv4_conntype = data.get('wan_ipv4_conntype', '')
369
+ ipv4_status._wan_ipv4_conntype = data.get('wan_ipv4_conntype', '')
370
370
  ipv4_status._wan_ipv4_netmask = get_ip(data.get('wan_ipv4_netmask', '0.0.0.0'))
371
371
  ipv4_status._wan_ipv4_pridns = get_ip(data.get('wan_ipv4_pridns', '0.0.0.0'))
372
372
  ipv4_status._wan_ipv4_snddns = get_ip(data.get('wan_ipv4_snddns', '0.0.0.0'))
@@ -1,6 +1,6 @@
1
1
  from requests import post
2
2
  from tplinkrouterc6u.common.package_enum import Connection
3
- from tplinkrouterc6u.common.dataclass import Firmware, Status
3
+ from tplinkrouterc6u.common.dataclass import Firmware, Status, IPv4Status
4
4
  from tplinkrouterc6u.common.exception import ClientException
5
5
  from tplinkrouterc6u.client_abstract import AbstractRouter
6
6
 
@@ -31,6 +31,9 @@ class TplinkC6V4Router(AbstractRouter):
31
31
  def get_status(self) -> Status:
32
32
  raise ClientException('Not Implemented')
33
33
 
34
+ def get_ipv4_status(self) -> IPv4Status:
35
+ raise ClientException('Not Implemented')
36
+
34
37
  def reboot(self) -> None:
35
38
  raise ClientException('Not Implemented')
36
39
 
@@ -132,7 +132,7 @@ class TPLinkDecoClient(TplinkEncryption, AbstractRouter):
132
132
  element = get_value(data, ['wan', 'ip_info', 'gateway'])
133
133
  ipv4_status._wan_ipv4_gateway = IPv4Address(element) if element else None
134
134
  element = get_value(data, ['wan', 'dial_type'])
135
- ipv4_status.wan_ipv4_conntype = element if element else ''
135
+ ipv4_status._wan_ipv4_conntype = element if element else ''
136
136
  element = get_value(data, ['wan', 'ip_info', 'mask'])
137
137
  ipv4_status._wan_ipv4_netmask = IPv4Address(element) if element else None
138
138
  element = get_value(data, ['wan', 'ip_info', 'dns1'])
@@ -5,6 +5,7 @@ from macaddress import EUI48
5
5
  from ipaddress import IPv4Address
6
6
  from logging import Logger
7
7
  from tplinkrouterc6u.common.package_enum import Connection, VPN
8
+ from tplinkrouterc6u.common.helper import get_ip, get_mac, get_value
8
9
  from tplinkrouterc6u.common.dataclass import (
9
10
  Firmware,
10
11
  Status,
@@ -203,26 +204,26 @@ class TPLinkEXClient(TPLinkMRClientBase):
203
204
  ]
204
205
  _, values = self.req_act(acts)
205
206
 
206
- if values[0].__class__ == list:
207
+ if values[0].__class__ == list and len(values[0]) > 0:
207
208
  values[0] = values[0][0]
208
209
 
209
210
  ipv4_status = IPv4Status()
210
- ipv4_status._lan_macaddr = EUI48(values[0]['MACAddress'])
211
- ipv4_status._lan_ipv4_ipaddr = IPv4Address(values[0]['IPAddress'])
212
- ipv4_status._lan_ipv4_netmask = IPv4Address(values[0]['IPSubnetMask'])
213
- ipv4_status.lan_ipv4_dhcp_enable = bool(int(values[0]['DHCPv4Enable']))
211
+ ipv4_status._lan_macaddr = get_mac(get_value(values, [0, 'MACAddress'], '00:00:00:00:00:00'))
212
+ ipv4_status._lan_ipv4_ipaddr = get_ip(get_value(values, [0, 'IPAddress'], '0.0.0.0'))
213
+ ipv4_status._lan_ipv4_netmask = get_ip(get_value(values, [0, 'IPSubnetMask'], '0.0.0.0'))
214
+ ipv4_status.lan_ipv4_dhcp_enable = bool(int(get_value(values, [0, 'DHCPv4Enable'], '0')))
214
215
 
215
216
  for item in values[1]:
216
217
  if int(item['enable']) == 0 and values[1].__class__ == list:
217
218
  continue
218
- ipv4_status._wan_macaddr = EUI48(item['MACAddr'])
219
- ipv4_status._wan_ipv4_ipaddr = IPv4Address(item['connIPv4Address'])
220
- ipv4_status._wan_ipv4_gateway = IPv4Address(item['connIPv4Gateway'])
221
- ipv4_status.wan_ipv4_conntype = item['name']
222
- ipv4_status._wan_ipv4_netmask = IPv4Address(item['connIPv4SubnetMask'])
223
- dns = item['connIPv4DnsServer'].split(',')
224
- ipv4_status._wan_ipv4_pridns = IPv4Address(dns[0])
225
- ipv4_status._wan_ipv4_snddns = IPv4Address(dns[1])
219
+ ipv4_status._wan_macaddr = get_mac(get_value(item, ['MACAddr'], '00:00:00:00:00:00'))
220
+ ipv4_status._wan_ipv4_ipaddr = get_ip(get_value(item, ['connIPv4Address'], '0.0.0.0'))
221
+ ipv4_status._wan_ipv4_gateway = get_ip(get_value(item, ['connIPv4Gateway'], '0.0.0.0'))
222
+ ipv4_status._wan_ipv4_conntype = get_value(item, ['name'], '')
223
+ ipv4_status._wan_ipv4_netmask = get_ip(get_value(item, ['connIPv4SubnetMask'], '0.0.0.0'))
224
+ dns = get_value(item, ['connIPv4DnsServer'], '').split(',')
225
+ ipv4_status._wan_ipv4_pridns = get_ip(dns[0] if len(dns) > 0 else '0.0.0.0')
226
+ ipv4_status._wan_ipv4_snddns = get_ip(dns[1] if len(dns) > 1 else '0.0.0.0')
226
227
 
227
228
  return ipv4_status
228
229
 
@@ -7,7 +7,7 @@ from datetime import timedelta, datetime
7
7
  from macaddress import EUI48
8
8
  from ipaddress import IPv4Address
9
9
  from logging import Logger
10
- from tplinkrouterc6u.common.helper import get_ip, get_mac
10
+ from tplinkrouterc6u.common.helper import get_ip, get_mac, get_value
11
11
  from tplinkrouterc6u.common.encryption import EncryptionWrapperMR
12
12
  from tplinkrouterc6u.common.package_enum import Connection, VPN
13
13
  from tplinkrouterc6u.common.dataclass import (
@@ -543,10 +543,10 @@ class TPLinkMRClient(TPLinkMRClientBase):
543
543
  _, values = self.req_act(acts)
544
544
 
545
545
  ipv4_status = IPv4Status()
546
- ipv4_status._lan_macaddr = get_mac(values.get('0', {}).get('X_TP_MACAddress', '00:00:00:00:00:00'))
547
- ipv4_status._lan_ipv4_ipaddr = get_ip(values.get('0', {}).get('IPInterfaceIPAddress', '0.0.0.0'))
548
- ipv4_status._lan_ipv4_netmask = get_ip(values.get('0', {}).get('IPInterfaceSubnetMask', '0.0.0.0'))
549
- ipv4_status.lan_ipv4_dhcp_enable = bool(int(values.get('1', {}).get('DHCPServerEnable', '0')))
546
+ ipv4_status._lan_macaddr = get_mac(get_value(values, ['0', 'X_TP_MACAddress'], '00:00:00:00:00:00'))
547
+ ipv4_status._lan_ipv4_ipaddr = get_ip(get_value(values, ['0', 'IPInterfaceIPAddress'], '0.0.0.0'))
548
+ ipv4_status._lan_ipv4_netmask = get_ip(get_value(values, ['0', 'IPInterfaceSubnetMask'], '0.0.0.0'))
549
+ ipv4_status.lan_ipv4_dhcp_enable = bool(int(get_value(values, ['1', 'DHCPServerEnable'], '0')))
550
550
 
551
551
  for item in self._to_list(values.get('2')):
552
552
  if int(item.get('enable', '0')) == 0 and values.get('2').__class__ == list:
@@ -554,11 +554,11 @@ class TPLinkMRClient(TPLinkMRClientBase):
554
554
  ipv4_status._wan_macaddr = get_mac(item.get('MACAddress', '00:00:00:00:00:00'))
555
555
  ipv4_status._wan_ipv4_ipaddr = get_ip(item.get('externalIPAddress', '0.0.0.0'))
556
556
  ipv4_status._wan_ipv4_gateway = get_ip(item.get('defaultGateway', '0.0.0.0'))
557
- ipv4_status.wan_ipv4_conntype = item.get('name', '')
557
+ ipv4_status._wan_ipv4_conntype = item.get('name', '')
558
558
  ipv4_status._wan_ipv4_netmask = get_ip(item.get('subnetMask', '0.0.0.0'))
559
559
  dns = item.get('DNSServers', '').split(',')
560
- ipv4_status._wan_ipv4_pridns = get_ip(dns[0] if len(dns) == 2 else '0.0.0.0')
561
- ipv4_status._wan_ipv4_snddns = get_ip(dns[1] if len(dns) == 2 else '0.0.0.0')
560
+ ipv4_status._wan_ipv4_pridns = get_ip(dns[0] if len(dns) > 0 else '0.0.0.0')
561
+ ipv4_status._wan_ipv4_snddns = get_ip(dns[1] if len(dns) > 1 else '0.0.0.0')
562
562
 
563
563
  return ipv4_status
564
564
 
@@ -1,7 +1,7 @@
1
1
  from requests.packages import urllib3
2
2
  from logging import Logger
3
3
  from tplinkrouterc6u.common.package_enum import Connection
4
- from tplinkrouterc6u.common.dataclass import Firmware, Status
4
+ from tplinkrouterc6u.common.dataclass import Firmware, Status, IPv4Status
5
5
  from abc import ABC, abstractmethod
6
6
 
7
7
 
@@ -39,6 +39,10 @@ class AbstractRouter(ABC):
39
39
  def get_status(self) -> Status:
40
40
  pass
41
41
 
42
+ @abstractmethod
43
+ def get_ipv4_status(self) -> IPv4Status:
44
+ pass
45
+
42
46
  @abstractmethod
43
47
  def reboot(self) -> None:
44
48
  pass
@@ -167,7 +167,7 @@ class IPv4Status:
167
167
  self._wan_macaddr: EUI48
168
168
  self._wan_ipv4_ipaddr: IPv4Address | None = None
169
169
  self._wan_ipv4_gateway: IPv4Address | None = None
170
- self.wan_ipv4_conntype: str
170
+ self._wan_ipv4_conntype: str
171
171
  self._wan_ipv4_netmask: IPv4Address | None = None
172
172
  self._wan_ipv4_pridns: IPv4Address
173
173
  self._wan_ipv4_snddns: IPv4Address
@@ -189,6 +189,10 @@ class IPv4Status:
189
189
  def wan_ipv4_ipaddr(self):
190
190
  return str(self._wan_ipv4_ipaddr) if self._wan_ipv4_ipaddr else None
191
191
 
192
+ @property
193
+ def wan_ipv4_conntype(self):
194
+ return self._wan_ipv4_conntype if hasattr(self, '_wan_ipv4_conntype') else ''
195
+
192
196
  @property
193
197
  def wan_ipv4_ipaddress(self):
194
198
  return self._wan_ipv4_ipaddr
@@ -16,12 +16,12 @@ def get_mac(mac: str) -> EUI48:
16
16
  return EUI48('00:00:00:00:00:00')
17
17
 
18
18
 
19
- def get_value(dictionary: dict, keys: list):
19
+ def get_value(dictionary, keys: list, default=None):
20
20
  nested_dict = dictionary
21
21
 
22
22
  for key in keys:
23
23
  try:
24
24
  nested_dict = nested_dict[key]
25
25
  except Exception:
26
- return None
26
+ return default
27
27
  return nested_dict
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: tplinkrouterc6u
3
- Version: 5.4.1
3
+ Version: 5.4.2
4
4
  Summary: TP-Link Router API
5
5
  Home-page: https://github.com/AlexandrErohin/TP-Link-Archer-C6U
6
6
  Author: Alex Erohin
@@ -319,6 +319,7 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
319
319
  - Archer VR600 v3
320
320
  - Archer VR900v
321
321
  - Archer VR2100v v1
322
+ - Archer VX1800v v1.0
322
323
  - Deco M4 2.0
323
324
  - Deco M4R 2.0
324
325
  - Deco M5 v3
@@ -2,29 +2,29 @@ test/__init__.py,sha256=McQmUjeN3AwmwdS6QNfwGXXE77OKoPK852I2BM9XsrU,210
2
2
  test/test_client_c1200.py,sha256=4RdwMEwTGWLOxOVTuPikifXDcUJFQ13DuyWGm2Aevrk,8811
3
3
  test/test_client_c6u.py,sha256=rJKJWwUBcmMehvdyyRtWm420X6KIXdrJu75VH6JPvng,32066
4
4
  test/test_client_deco.py,sha256=YPLKRD8GoyDYHfRgdXvCk8iVNw8zdMJW-AHVnNbpdTM,31719
5
- test/test_client_ex.py,sha256=YGY3auCiZTM91640LHmsL6r2-xcK5n5cB_CpvD83GeI,20429
6
- test/test_client_mr.py,sha256=2ZFNwJGHqFbnePRvmmg5r_4YzqsHo3bjkmBXVzht7YQ,33407
5
+ test/test_client_ex.py,sha256=0dVvOJqxpR2xNca99vadfdpxmzW-4sk9X_4tAK8x9-c,21710
6
+ test/test_client_mr.py,sha256=pKlQwGZNZRek9oFQPm2HkeeU3cI9EPySxtdZ8H2mqWY,33462
7
7
  test/test_client_xdr.py,sha256=mgn-xL5mD5sHD8DjTz9vpY7jeh4Ob6Um6Y8v5Qgx2jA,23374
8
8
  tplinkrouterc6u/__init__.py,sha256=bLlCkiL9ycyRVG7VqPOJWPcoPmUfMkdTcUKFYKNP8QI,900
9
- tplinkrouterc6u/client_abstract.py,sha256=OgftTH6bELzhFWom0MOX4EJe3RNS003ezpHyyRnh2tQ,1328
9
+ tplinkrouterc6u/client_abstract.py,sha256=3UYzmll774S_Gb5E0FTVO_rI3-XFM7PSklg1-V-2jls,1419
10
10
  tplinkrouterc6u/provider.py,sha256=SsyGu_2SZ-a46ADl9aw_0wx0lgbsJhS6wnwUzb_1qGg,1900
11
11
  tplinkrouterc6u/client/__init__.py,sha256=KBy3fmtA9wgyFrb0Urh2x4CkKtWVnESdp-vxmuOvq0k,27
12
12
  tplinkrouterc6u/client/c1200.py,sha256=_nY_pJ-wPWODAaes9kHPdVcM6YM54f1E54CfdoFHqbE,4771
13
13
  tplinkrouterc6u/client/c5400x.py,sha256=9E0omBSbWY_ljrs5MTCMu5brmrLtzsDB5O62Db8lP8Q,4329
14
- tplinkrouterc6u/client/c6u.py,sha256=sDlwtccncuVrBRAzbLxgT5hU7VYNM0LCVtyEs-9bk-Q,17587
15
- tplinkrouterc6u/client/c6v4.py,sha256=-IF7SqTZx56lRAVmiyxK9VKkrmD7srQSJWFvn2Z0DII,1489
16
- tplinkrouterc6u/client/deco.py,sha256=yL1fmDo7j67_iD4qi9gl402C0IGauAtgrA0EGAOR1jg,8228
17
- tplinkrouterc6u/client/ex.py,sha256=PxMKq7Yj-2iJBtSKzgxaJ1D0SrblFwhPWJYyrac0c9Q,12706
18
- tplinkrouterc6u/client/mr.py,sha256=rS9aqAxrzIh0Pl8ZqGQQ9uWA3TzEHijkvY-WESRbVHs,25863
14
+ tplinkrouterc6u/client/c6u.py,sha256=fRNqT8vifpqQoLLNUwEYX1A6jEzat5XGbhCVGmL7ihk,17588
15
+ tplinkrouterc6u/client/c6v4.py,sha256=bvquZ0FHgU_LJfZxQkfyKQz0C52mFytC4mzFSOqp99Y,1596
16
+ tplinkrouterc6u/client/deco.py,sha256=7uVd9wt3aJGShft7L520AzFpQ85xbgRWM-8uyrpxE8Y,8229
17
+ tplinkrouterc6u/client/ex.py,sha256=RVB04rWTFEqYlKr_4TSqzVC3niNWZOcrkxfI2ub9PY0,13070
18
+ tplinkrouterc6u/client/mr.py,sha256=clqCU8q5WM5xKSgJrcgKmDvrvE_INEf5gwja0iHhkPc,25877
19
19
  tplinkrouterc6u/client/xdr.py,sha256=9YuVfrmsrDeqnhJXp1Fc4OfcJEz9SkjdmpOoTIDi6Js,10327
20
20
  tplinkrouterc6u/common/__init__.py,sha256=pCTvVZ9CAwgb7MxRnLx0y1rI0sTKSwT24FfxWfQXeTM,33
21
- tplinkrouterc6u/common/dataclass.py,sha256=__u8I8URLk_AdIEN4Jd8Pswh4ujURlJxw8YunuVStwk,7630
21
+ tplinkrouterc6u/common/dataclass.py,sha256=iozL4PzEiFX3Ry4yJA9VU83sr-yPv8AmU1cquusj-Ks,7765
22
22
  tplinkrouterc6u/common/encryption.py,sha256=4HelTxzN6esMfDZRBt3m8bwB9Nj_biKijnCnrGWPWKg,6228
23
23
  tplinkrouterc6u/common/exception.py,sha256=_0G8ZvW5__CsGifHrsZeULdl8c6EUD071sDCQsQgrHY,140
24
- tplinkrouterc6u/common/helper.py,sha256=x9Y0zkCnELpzNzuQtq2yMrWmp7nCyJylTBKu4a8RfKc,561
24
+ tplinkrouterc6u/common/helper.py,sha256=23b04fk9HuVinrZXMCS5R1rmF8uZ7eM-Cdnp7Br9NR0,572
25
25
  tplinkrouterc6u/common/package_enum.py,sha256=4ykL_2Pw0nDEIH_qR9UJlFF6stTgSfhPz32r8KT-sh8,1624
26
- tplinkrouterc6u-5.4.1.dist-info/LICENSE,sha256=YF6QR6Vjxcg5b_sYIyqkME7FZYau5TfEUGTG-0JeRK0,35129
27
- tplinkrouterc6u-5.4.1.dist-info/METADATA,sha256=Z1zydhvJZQU6Ffx_8vpUQgyNjUw4tABTmeTLx1xaabs,15189
28
- tplinkrouterc6u-5.4.1.dist-info/WHEEL,sha256=nn6H5-ilmfVryoAQl3ZQ2l8SH5imPWFpm1A5FgEuFV4,91
29
- tplinkrouterc6u-5.4.1.dist-info/top_level.txt,sha256=1iSCCIueqgEkrTxtQ-jiHe99jAB10zqrVdBcwvNfe_M,21
30
- tplinkrouterc6u-5.4.1.dist-info/RECORD,,
26
+ tplinkrouterc6u-5.4.2.dist-info/LICENSE,sha256=YF6QR6Vjxcg5b_sYIyqkME7FZYau5TfEUGTG-0JeRK0,35129
27
+ tplinkrouterc6u-5.4.2.dist-info/METADATA,sha256=FWZupEQ4AcBd0PaHlJHj_hE6UE_zGXr8lqX9lx2SRpc,15211
28
+ tplinkrouterc6u-5.4.2.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
29
+ tplinkrouterc6u-5.4.2.dist-info/top_level.txt,sha256=1iSCCIueqgEkrTxtQ-jiHe99jAB10zqrVdBcwvNfe_M,21
30
+ tplinkrouterc6u-5.4.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.1)
2
+ Generator: setuptools (75.8.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5