-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathadmin.go
49 lines (40 loc) · 916 Bytes
/
admin.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package hitron
import (
"context"
"fmt"
"net/http"
"net/url"
)
func (c *CableModem) CMReboot(ctx context.Context) (*Error, error) {
csrf, err := c.UsersCSRF(ctx)
if err != nil {
return nil, fmt.Errorf("failed to retrieve CSRF token: %w", err)
}
o := Error{}
err = c.sendRequest(ctx, http.MethodPost, "/CM/Reboot",
url.Values{
"model": []string{`{"reboot":1}`},
"csrf": []string{csrf.CSRF},
}, &o)
if err != nil {
return nil, err
}
return &o, nil
}
func (c *CableModem) CMClearLog(ctx context.Context) (*Error, error) {
csrf, err := c.UsersCSRF(ctx)
if err != nil {
return nil, fmt.Errorf("failed to retrieve CSRF token: %w", err)
}
o := Error{}
err = c.sendRequest(ctx, http.MethodPost, "/CM/Log",
url.Values{
"model": []string{"[]"},
"csrf": []string{csrf.CSRF},
"_method": []string{"PUT"},
}, &o)
if err != nil {
return nil, err
}
return &o, nil
}