forked from folbricht/routedns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlistener.go
54 lines (46 loc) · 1.25 KB
/
listener.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
package rdns
import (
"expvar"
"fmt"
"net"
)
// Listener is an interface for a DNS listener.
type Listener interface {
Start() error
fmt.Stringer
}
// ClientInfo carries information about the client making the request that
// can be used to route requests.
type ClientInfo struct {
SourceIP net.IP
// DoH query path used by the client. Only populated when
// the query was received over DoH.
DoHPath string
// TLS SNI server name
TLSServerName string
// Listener ID of the listener that first received the request. Can be
// used to route queries.
Listener string
}
// Metrics that are available from listeners and clients.
type ListenerMetrics struct {
// DNS query count.
query *expvar.Int
// DNS response type counts.
response *expvar.Map
// Number of queries dropped (denied).
drop *expvar.Int
// RouteDNS failure reason counts.
err *expvar.Map
// Maximum number of queries queued (optional).
maxQueueLen *expvar.Int
}
func NewListenerMetrics(base string, id string) *ListenerMetrics {
return &ListenerMetrics{
query: getVarInt(base, id, "query"),
response: getVarMap(base, id, "response"),
drop: getVarInt(base, id, "drop"),
err: getVarMap(base, id, "error"),
maxQueueLen: getVarInt(base, id, "maxqueue"),
}
}