/
options.go
65 lines (56 loc) · 1.23 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
65
package fastdialer
import (
"net"
"time"
"golang.org/x/net/proxy"
)
// DefaultResolvers trusted
var DefaultResolvers = []string{
"1.1.1.1:53",
"1.0.0.1:53",
"8.8.8.8:53",
"8.8.4.4:53",
}
type CacheType uint8
const (
Memory CacheType = iota
Disk
Hybrid
)
type DiskDBType uint8
const (
LevelDB DiskDBType = iota
Pogreb
)
type Options struct {
BaseResolvers []string
MaxRetries int
HostsFile bool
ResolversFile bool
EnableFallback bool
Allow []string
Deny []string
CacheType CacheType
CacheMemoryMaxItems int // used by Memory cache type
DiskDbType DiskDBType
WithDialerHistory bool
WithCleanup bool
WithTLSData bool
DialerTimeout time.Duration
DialerKeepAlive time.Duration
Dialer *net.Dialer
ProxyDialer *proxy.Dialer
WithZTLS bool
SNIName string
OnDialCallback func(hostname, IP string)
}
// DefaultOptions of the cache
var DefaultOptions = Options{
BaseResolvers: DefaultResolvers,
MaxRetries: 5,
HostsFile: true,
ResolversFile: true,
CacheType: Disk,
DialerTimeout: 10 * time.Second,
DialerKeepAlive: 10 * time.Second,
}