blob: a660ac774351ac01a4a64b74bedd4ca4324cd88e (
plain)
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
|
// SPDX-License-Identifier: GPL-3.0-or-later
package dnsmasq
import (
"errors"
"fmt"
"github.com/netdata/netdata/go/plugins/plugin/go.d/agent/module"
)
func (d *Dnsmasq) validateConfig() error {
if d.Address == "" {
return errors.New("'address' parameter not set")
}
if !isProtocolValid(d.Protocol) {
return fmt.Errorf("'protocol' (%s) is not valid, expected one of %v", d.Protocol, validProtocols)
}
return nil
}
func (d *Dnsmasq) initDNSClient() (dnsClient, error) {
return d.newDNSClient(d.Protocol, d.Timeout.Duration()), nil
}
func (d *Dnsmasq) initCharts() (*module.Charts, error) {
return cacheCharts.Copy(), nil
}
func isProtocolValid(protocol string) bool {
for _, v := range validProtocols {
if protocol == v {
return true
}
}
return false
}
var validProtocols = []string{
"udp",
"tcp",
"tcp-tls",
}
|