Log out of router admin interface after devices are recorded.

This commit is contained in:
Jack Minardi 2017-04-25 00:34:26 -04:00
parent 2d5da3e958
commit 450fd7f2b5

View File

@ -162,6 +162,7 @@ class Tplink3DeviceScanner(TplinkDeviceScanner):
def scan_devices(self):
"""Scan for new devices and return a list with found device IDs."""
self._update_info()
self._log_out()
return self.last_results.keys()
# pylint: disable=no-self-use
@ -251,6 +252,21 @@ class Tplink3DeviceScanner(TplinkDeviceScanner):
return False
def _log_out(self):
with self.lock:
_LOGGER.info("Logging out of router admin interface...")
url = ('http://{}/cgi-bin/luci/;stok={}/admin/system?'
'form=logout').format(self.host, self.stok)
referer = 'http://{}/webpages/index.html'.format(self.host)
response = requests.post(url,
params={'operation': 'write'},
headers={'referer': referer},
cookies={'sysauth': self.sysauth})
self.stok = ''
self.sysauth = ''
class Tplink4DeviceScanner(TplinkDeviceScanner):
"""This class queries an Archer C7 router with TP-Link firmware 150427."""