-
Notifications
You must be signed in to change notification settings - Fork 1
/
info.go
50 lines (44 loc) · 1.17 KB
/
info.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
50
package radius
import (
"log"
"os"
"text/template"
"github.com/urfave/cli"
"github.com/garlsecurity/securepassctl/spctl/service"
)
func init() {
Command.Subcommands = append(Command.Subcommands,
cli.Command{
Name: "info",
Usage: "retrieve RADIUS details from SecurePass",
ArgsUsage: "RADIUSIP",
Description: "Retrieve RADIUS details from SecurePass.",
Action: ActionInfo,
})
}
// ActionInfo provides the radius info command
func ActionInfo(c *cli.Context) {
const templ = `FQDN/Name.................: {{.Name}}
Secret....................: {{.Secret}}
Realm.....................: {{.Realm}}
Restrict to group.........: {{.Group}}
Rfid tag..................: {{.Rfid | rfid}}
`
if len(c.Args()) != 1 {
log.Fatal("error: must specify an IP address")
}
radius := c.Args()[0]
resp, err := service.Service.RadiusInfo(radius)
if err != nil {
log.Fatalf("error: %v", err)
}
report := template.Must(template.New("report").Funcs(template.FuncMap{"rfid": func(b bool) string {
if b {
return "enabled"
}
return "disabled"
}}).Parse(templ))
if err := report.Execute(os.Stdout, resp); err != nil {
log.Fatalf("error: %v", err)
}
}