forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 9
/
config.go
48 lines (35 loc) · 1.02 KB
/
config.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
package tcp
import (
"errors"
"time"
"github.com/elastic/beats/libbeat/outputs"
"github.com/elastic/beats/libbeat/outputs/transport"
"github.com/elastic/beats/heartbeat/monitors"
)
type Config struct {
Name string `config:"name"`
// check all ports if host does not contain port
Hosts []string `config:"hosts" validate:"required"`
Ports []uint16 `config:"ports"`
Mode monitors.IPSettings `config:",inline"`
Socks5 transport.ProxyConfig `config:",inline"`
// configure tls
TLS *outputs.TLSConfig `config:"ssl"`
Timeout time.Duration `config:"timeout"`
// validate connection
SendString string `config:"check.send"`
ReceiveString string `config:"check.receive"`
}
var DefaultConfig = Config{
Name: "tcp",
Timeout: 16 * time.Second,
Mode: monitors.DefaultIPSettings,
}
func (c *Config) Validate() error {
if c.Socks5.URL != "" {
if c.Mode.Mode != monitors.PingAny && !c.Socks5.LocalResolve {
return errors.New("ping all ips only supported if proxy_use_local_resolver is enabled`")
}
}
return nil
}