MatMaul / pynetgear

Python library to control Netgear wireless routers through the SOAP-api.
MIT License
238 stars 75 forks source link

Feature request: Add operation to retrieve firewall logs #95

Open salsaw opened 2 years ago

salsaw commented 2 years ago

This request is to add functionality to retrieve firewall logs as shown under Administration > Logs in the Netgear GUI. I was able to test to a call to API GetSystemLogs (referenced from https://github.com/MatMaul/pynetgear/issues/20#issuecomment-428465492) on an R8000 (V1.0.4.76_10.1.82), but the response returns an incomplete subset of the logs (always returns 22 vs. 200+ lines shown in the GUI). Also, the last line gets truncated and the logs in the response do not seem to get refreshed as frequent as when viewing them in the GUI.

def get_logs(self):
        success, response = self._make_request(
            SERVICE_DEVICE_INFO,
            "GetSystemLogs"
        )

        if not success:
            return None

        success, node = _find_node(
            response.text,
            ".//GetSystemLogsResponse/NewLogDetails")
        if not success:
            return None

        logs = node.text.split('\n')

        return logs

Example response snippet showing the truncated ending line.

[Admin login] from source 192.168.2.66, Thursday, Dec 30,2021 12:11:43
[Site allowed: firetvcaptiveportal.com] from source 192.168.2.52, Thursday, Dec 30,2021 12:11:18
[Site allowed: clientconfig.akamai.steamstatic.com] from source 192
Bristopher commented 10 months ago

I would also be interested in this, interested in deploying fail2ban on my Netgear router's logs.