-
Notifications
You must be signed in to change notification settings - Fork 0
/
boost.go
65 lines (53 loc) · 1.05 KB
/
boost.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 boost
import (
"github.com/coredns/coredns/plugin"
clog "github.com/coredns/coredns/plugin/pkg/log"
"github.com/miekg/dns"
"net"
"time"
)
var log = clog.NewWithPlugin("boost")
type Ans struct {
net.IP
dns.RR
}
type MeasureMethod func(b *Boost, in []Ans, out *Ans) (ok bool)
type Method int
const (
MethodPing Method = iota
)
var methods = map[Method]MeasureMethod{
MethodPing: measureByPing,
}
type RankOptions struct {
Method
// Ping related options
PingCount int
PingInterval time.Duration
PingTimeout time.Duration
}
type Boost struct {
Debug bool
Next plugin.Handler
Zones []string
RankOptions
}
const (
defaultMethod = MethodPing
defaultPingCount = 3
defaultPingInterval = 25 * time.Millisecond
defaultPingTimeout = 500 * time.Millisecond
)
func New() *Boost {
return &Boost{
Debug: false,
Next: nil,
Zones: []string{"."},
RankOptions: RankOptions{
Method: defaultMethod,
PingCount: defaultPingCount,
PingInterval: defaultPingInterval,
PingTimeout: defaultPingTimeout,
},
}
}