-
Notifications
You must be signed in to change notification settings - Fork 2
/
option.go
99 lines (88 loc) · 2.04 KB
/
option.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
package radar
import (
"errors"
"time"
"github.com/vela-ssoc/vela-radar/util"
)
type Option struct {
Location string `json:"location"`
Mode string `json:"mode"`
Target string `json:"target"`
ExcludedTarget string `json:"exclude_target"`
Port string `json:"port"`
Rate int `json:"rate"`
Timeout int `json:"timeout"`
Httpx bool `json:"httpx"`
Ping bool `json:"ping"`
FingerDB string `json:"finger_db"`
Screenshot bool `json:"screenshot"`
Pool Pool `json:"pool"`
ExcludeTimeRange util.TimeRange `json:"exclude_time_range"`
MinioCfg util.MinioCfg `json:"-"`
}
func (o *Option) set_rate(n int) {
if n > 20000 {
o.Rate = 20000
} else {
o.Rate = n
}
}
func (o *Option) set_pool_ping(n int) {
if n > 1000 {
o.Pool.Ping = 1000
} else {
o.Pool.Ping = n
}
}
func (o *Option) set_pool_scan(n int) {
if n > 500 {
o.Pool.Scan = 500
} else {
o.Pool.Scan = n
}
}
func (o *Option) set_pool_finger(n int) {
if n > 500 {
o.Pool.Finger = 500
} else {
o.Pool.Finger = n
}
}
func (o *Option) set_timeout(n int) {
if n > 10000 {
o.Timeout = 10000
} else if n < 100 {
o.Timeout = 100
} else {
o.Timeout = n
}
}
func (o *Option) set_ExcludeTimeRange_Daily(s string) error {
switch s {
case "daily":
o.ExcludeTimeRange.Daily = s
case "everyWorKDay":
o.ExcludeTimeRange.Daily = s
case "OpeningtimeBroad":
o.ExcludeTimeRange.Daily = s
default:
return errors.New("invalid time range")
}
return nil
}
func (o *Option) set_ExcludeTimeRange_Begin(s string) error {
_, err := time.Parse("15:04", s)
if err != nil {
return errors.New("invalid time range")
}
o.ExcludeTimeRange.Begin = s
return nil
}
func (o *Option) set_ExcludeTimeRange_End(s string) error {
_, err := time.Parse("15:04", s)
if err != nil {
return errors.New("invalid time range")
}
o.ExcludeTimeRange.End = s
return nil
}