Skip to content

Commit

Permalink
implemented reboot command
Browse files Browse the repository at this point in the history
  • Loading branch information
furtidev committed Mar 24, 2024
1 parent 0a446b6 commit 0bda8ff
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions wr840n/wr840n.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

0 comments on commit 0bda8ff

Please sign in to comment.