-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
106 lines (91 loc) · 1.74 KB
/
main.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package main
import (
"fmt"
"os"
"time"
"github.com/urfave/cli"
)
func main() {
app := cli.NewApp()
// App meta
app.Name = Name
app.Version = Version
app.Authors = []cli.Author{
cli.Author{
Name: AuthorName,
Email: AuthorEmail,
},
}
app.Usage = Usage
app.UsageText = fmt.Sprintf("%s [options] servername", Name)
// Flags
var (
srvName string
hostName string
port string
delay int
isInsecure bool
isSilent bool
)
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "host, H",
Usage: "target host for scanning",
Destination: &hostName,
},
cli.StringFlag{
Name: "port, p",
Usage: "ssl port",
Value: "443",
Destination: &port,
},
cli.IntFlag{
Name: "delay, d",
Usage: "delay of expire",
Value: 0,
Destination: &delay,
},
cli.BoolFlag{
Name: "insecure, k",
Usage: "permit insecure cert",
Destination: &isInsecure,
},
cli.BoolFlag{
Name: "silent, s",
Usage: "enable silent mode",
Destination: &isSilent,
},
}
// Set HelpTemplate
cli.AppHelpTemplate = HelpTemplate
// Main action
app.Action = func(c *cli.Context) error {
// Args
if c.NArg() != 1 {
cli.ShowAppHelp(c)
return nil
}
srvName = c.Args().Get(0)
if hostName == "" {
hostName = srvName
}
// Dial
expire, err := Dial(srvName, hostName, port, isInsecure)
if err != nil {
if !isSilent {
fmt.Println(err)
}
return cli.NewExitError("", ExitError)
}
if !isSilent {
fmt.Println(expire)
}
// Check expire
limit := time.Now().AddDate(0, 0, delay).UTC()
if !expire.After(limit) {
return cli.NewExitError("", ExitExpire)
}
return nil
}
app.Run(os.Args)
}