-
Notifications
You must be signed in to change notification settings - Fork 1
/
security.go
49 lines (44 loc) · 975 Bytes
/
security.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 main
import (
"fmt"
"github.com/codegangsta/cli"
"github.com/modouwifi/md/api"
)
var cmdSecurity = cli.Command{
Name: "security",
Usage: "System security",
Subcommands: []cli.Command{
{
Name: "get",
Usage: "Get system security's status",
Action: runSecurityGet,
},
{
Name: "set",
Usage: "Set system security's status",
Action: runSecuritySet,
},
},
}
func runSecurityGet(c *cli.Context) {
req, err := client.NewRequest("GET", "/security/get_config")
if err != nil {
fmt.Println(err)
}
req.SetCookie(config.Cookie)
var result api.SecurityEnabled
err = req.ToJSON(&result)
fmt.Println(result.Code)
fmt.Println(result.Enabled)
}
func runSecuritySet(c *cli.Context) {
req, err := client.NewRequest("POST", "/security/set_config")
if err != nil {
fmt.Println(err)
}
req.SetCookie(config.Cookie)
var result api.SecurityEnabled
err = req.ToJSON(&result)
fmt.Println(result.Code)
fmt.Println(result.Enabled)
}