MatMaul / pynetgear

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

No Longer Able To Authenticate After Updating Router #104

Closed gist901 closed 2 years ago

gist901 commented 2 years ago

I have a script that I could run that would return to me the traffic meter results from my router. However after updating my router's firmware I can no longer authenticate. I have tried the numerous different authentication methods that I have read in your code, but I am still getting a return of False.

My router, while not listed on supported devices, is a R6700v3 and it is currently on Firmware version V1.0.4.122_10.0.95. Any help or assistance would be greatly appreciated.

# -*- coding: utf-8 -*-
import re
import os
import urllib3
from bitmath import MiB
from pynetgear import Netgear

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
os.system('mode con: cols=56 lines=35')

def print_header(head_length):
        print('\t'+'-'*head_length)
        print('\t'+'-'+(' '*(head_length-2))+'-')
        print('\t'+'-'*head_length)

def netgear_traffic():

    netgear = Netgear(password='mysecurepassword', host='192.168.48.1')
    netgear.login()

    traffic = netgear.get_traffic_meter()
    filtered_traffic = {k: v for k, v in traffic.items() if v is not None}

    header_length = 40

    count = 0
    print('\n')
    for key, value in filtered_traffic.items():
        if count == 0:
            print_header(header_length)
        name =  re.findall('[A-Z][^A-Z]*', key)
        if 'Today' in name or 'Yesterday' in name:
            final_desc = f'Total {name[2]} {name[1]}'
        elif 'Last' in name:
            final_desc = f'Total {name[3]} {name[1]} {name[2]}'
        else:
            final_desc = f'Total {name[2]} This {name[1]}'

        if type(value) is float:
            raw_value = value
        else:
            raw_value = value[0]

        result = MiB(raw_value).to_GiB().format("{value:.2f} {unit}")
        spaces = ' ' * int((header_length - len(final_desc)) - len(result))
        print(f'\t{final_desc}{spaces}{result}')

        count += 1
        if count == 2:
            count = 0

    print_header(header_length)          
    input("\n\n\tPress enter to exit")

if __name__ == "__main__":

    netgear_traffic()
starkillerOG commented 2 years ago

@gist901 make sure you use pynetgear version 0.9.0. Then replace netgear.login() with netgear.login_try_port()

also check what response you get from the login like this: print(netgear.login_try_port())

That schould do the trick.

If that suceeds simply use netgear.port and netgear.ssl to figure out what the correct port ssl combination is that you need for the next time.

gist901 commented 2 years ago

Awesome - netgear.login_try_port() solves the issue. Looks like port 5555 and ssl true is the solution.

Many thanks for the quick response and great work on this library.