add variable auto_detect_local_dns_server
This commit is contained in:
parent
cfba6f692e
commit
6c4ae75562
|
@ -9,7 +9,7 @@
|
|||
# interval_times = 1
|
||||
|
||||
# #
|
||||
enable = false
|
||||
auto_detect_local_dns_server = false
|
||||
|
||||
## servers to query
|
||||
# servers = ["8.8.8.8"]
|
||||
|
|
|
@ -49,7 +49,7 @@ func (dq *DnsQuery) GetInstances() []inputs.Instance {
|
|||
type Instance struct {
|
||||
config.InstanceConfig
|
||||
|
||||
Enable bool `toml:"enable"`
|
||||
EnableAutoDetectDnsServer bool `toml:"auto_detect_local_dns_server"`
|
||||
// Domains or subdomains to query
|
||||
Domains []string `toml:"domains"`
|
||||
|
||||
|
@ -70,9 +70,7 @@ type Instance struct {
|
|||
}
|
||||
|
||||
func (ins *Instance) Init() error {
|
||||
if ins.Enable == false {
|
||||
return nil
|
||||
}
|
||||
if ins.EnableAutoDetectDnsServer == true {
|
||||
if len(ins.Servers) == 0 {
|
||||
resolvPath := "/etc/resolv.conf"
|
||||
if _, err := os.Stat(resolvPath); os.IsNotExist(err) {
|
||||
|
@ -84,10 +82,11 @@ func (ins *Instance) Init() error {
|
|||
Servers = append(Servers, ipAddress)
|
||||
}
|
||||
ins.Servers = Servers
|
||||
}
|
||||
}
|
||||
if len(ins.Servers) == 0 {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
if ins.Network == "" {
|
||||
ins.Network = "udp"
|
||||
|
|
Loading…
Reference in New Issue