You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enter the host & credentials used to log in to your router management page. Username is admin by default. But you may pass username as third parameter
fromtplinkrouterc6uimport (
TplinkRouterProvider,
TplinkRouter,
TplinkC1200Router,
TplinkC5400XRouter,
TPLinkMRClient,
TPLinkEXClient,
TPLinkXDRClient,
TPLinkDecoClient,
Connection
)
fromloggingimportLoggerrouter=TplinkRouterProvider.get_client('http://192.168.0.1', 'password')
# You may use client directly like# router = TplinkRouter('http://192.168.0.1', 'password')# You may also pass username if it is different and a logger to log errors as# router = TplinkRouter('http://192.168.0.1','password','admin2', Logger('test'))# If you have the TP-link C5400X or similar, you can use the TplinkC5400XRouter class instead of the TplinkRouter class.# Remember that the password for this router is different, here you need to use the web encrypted password.# To get web encrypted password, read Web Encrypted Password section# router = TplinkC5400XRouter('http://192.168.0.1','WebEncryptedPassword', Logger('test'))try:
router.authorize() # authorizing# Get firmware info - returns Firmwarefirmware=router.get_firmware()
# Get status info - returns Statusstatus=router.get_status()
ifnotstatus.guest_2g_enable: # check if guest 2.4G wifi is disablerouter.set_wifi(Connection.GUEST_2G, True) # turn on guest 2.4G wifi# Get Address reservations, sort by ipaddrreservations=router.get_ipv4_reservations()
reservations.sort(key=lambdaa: a.ipaddr)
forresinreservations:
print(f"{res.macaddr}{res.ipaddr:16s}{res.hostname:36}{'Permanent':12}")
# Get DHCP leases, sort by ipaddrleases=router.get_ipv4_dhcp_leases()
leases.sort(key=lambdaa: a.ipaddr)
forleaseinleases:
print(f"{lease.macaddr}{lease.ipaddr:16s}{lease.hostname:36}{lease.lease_time:12}")
finally:
router.logout() # always logout as TP-Link Web Interface only supports upto 1 user logged
The TP-Link Web Interface only supports upto 1 user logged in at a time (for security reasons, apparently).
So before action you need to authorize and after logout
If you got exception - use web encrypted password instead. Check the documentation!
or you have TP-link C5400X or similar router you need to get web encrypted password by these actions:
Go to the login page of your router. (default: 192.168.0.1).
Type in the password you use to login into the password field.
Click somewhere else on the page so that the password field is not selected anymore.
Open the JavaScript console of your browser (usually by pressing F12 and then clicking on "Console").
Type document.getElementById("login-password").value;
Please let me know if you have tested integration with one of this or other model. Open an issue with info about router's model, hardware and firmware versions.
Make changes to files within the tplinkrouter6u directory.
Exercise the changes following the "Usage" section above.
The sanity check test.py illustrates a few tests and runs through a list of queries in queries.txt creating logs of the results of each query in the logs folder. This can be used to capture the dictionary output of all cgi-bin form submissions.