/
options.go
64 lines (52 loc) · 1.59 KB
/
options.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
// SPDX-License-Identifier: GPL-3.0-or-later
package scanner
import (
"time"
"github.com/robgonnella/go-lanscan/pkg/oui"
)
// How long to wait before sending next packet
// the faster you send packets the more packets
// will be missed when reading
const defaultTiming = time.Microsecond * 100
// If no packets are received for this period of time, exit with timeout
const defaultIdleTimeout = time.Second * 5
// Option represents an option that can be passed to any of the
// "New" scanner constructors
type Option = func(s Scanner)
// WithRequestNotifications sets channel for request notifications
func WithRequestNotifications(c chan *Request) Option {
return func(s Scanner) {
s.SetRequestNotifications(c)
}
}
// WithIdleTimeout sets the idle timeout for the scanner
func WithIdleTimeout(duration time.Duration) Option {
return func(s Scanner) {
s.SetIdleTimeout(duration)
}
}
// WithVendorInfo sets whether or not to include vendor info when scanning
func WithVendorInfo(repo oui.VendorRepo) Option {
return func(s Scanner) {
s.IncludeVendorInfo(repo)
}
}
// WithHostnames sets whether or not to perform reverse dns lookup
func WithHostnames(v bool) Option {
return func(s Scanner) {
s.IncludeHostNames(v)
}
}
// WithPacketCapture sets the packet capture implementation for the scanner
func WithPacketCapture(cap PacketCapture) Option {
return func(s Scanner) {
s.SetPacketCapture(cap)
}
}
// WithTiming sets the timing duration for how long to wait in-between each
// packet send
func WithTiming(duration time.Duration) Option {
return func(s Scanner) {
s.SetTiming(duration)
}
}