From 0bda8ff482833db0a6caaa7edc462540f70ac989 Mon Sep 17 00:00:00 2001 From: furtidev Date: Sun, 24 Mar 2024 22:34:28 +0600 Subject: [PATCH] implemented reboot command --- wr840n/wr840n.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/wr840n/wr840n.go b/wr840n/wr840n.go index 0e7fe69..351956b 100644 --- a/wr840n/wr840n.go +++ b/wr840n/wr840n.go @@ -13,6 +13,9 @@ const ( dhcpClientURL = "http://192.168.0.1/cgi?5" dhcpClientPayload = "[LAN_HOST_ENTRY#0,0,0,0,0,0#0,0,0,0,0,0]0,4\r\nleaseTimeRemaining\r\nMACAddress\r\nhostName\r\nIPAddress\r\n" + + rebootURL = "http://192.168.0.1/cgi?7" + rebootPayload = "[ACT_REBOOT#0,0,0,0,0,0#0,0,0,0,0,0]0,0\r\n" ) var authToken string @@ -50,3 +53,18 @@ func Clients(ctx *cli.Context) error { } return nil } + +func Reboot(ctx *cli.Context) error { + body, err := MakeRequest(rebootURL, rebootPayload, authToken) + if err != nil { + return err + } + + if body == "[error]0" { + fmt.Println("Success!") + } else { + fmt.Println("Could not reboot router. An error occurred.") + } + + return nil +} \ No newline at end of file