Skip to content

Commit

Permalink
fix makefile
Browse files Browse the repository at this point in the history
new test for config
  • Loading branch information
dmachard committed Dec 5, 2023
1 parent 1c967c3 commit 50aee77
Show file tree
Hide file tree
Showing 12 changed files with 429 additions and 310 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ dep:
@go mod tidy

build:
CGO_ENABLED=0 go build -v -ldflags="$(LD_FLAGS)" -o ${BINARY_NAME} dnscollector.go
CGO_ENABLED=0 go build -v -ldflags="$(LD_FLAGS)" -o ${BINARY_NAME} dnscollector.go multiplexer.go

run: build
./${BINARY_NAME}
Expand Down
63 changes: 63 additions & 0 deletions pkgconfig/collectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,66 @@ type ConfigCollectors struct {
ChannelBufferSize int `yaml:"chan-buffer-size"`
} `yaml:"tzsp"`
}

func (c *ConfigCollectors) SetDefault() {
c.Tail.Enable = false
c.Tail.TimeLayout = ""
c.Tail.PatternQuery = ""
c.Tail.PatternReply = ""
c.Tail.FilePath = ""

c.Dnstap.Enable = false
c.Dnstap.ListenIP = AnyIP
c.Dnstap.ListenPort = 6000
c.Dnstap.SockPath = ""
c.Dnstap.TLSSupport = false
c.Dnstap.TLSMinVersion = TLSV12
c.Dnstap.CertFile = ""
c.Dnstap.KeyFile = ""
c.Dnstap.RcvBufSize = 0
c.Dnstap.ResetConn = true
c.Dnstap.ChannelBufferSize = 65535
c.Dnstap.DisableDNSParser = false

c.DnstapProxifier.Enable = false
c.DnstapProxifier.ListenIP = AnyIP
c.DnstapProxifier.ListenPort = 6000
c.DnstapProxifier.SockPath = ""
c.DnstapProxifier.TLSSupport = false
c.DnstapProxifier.TLSMinVersion = TLSV12
c.DnstapProxifier.CertFile = ""
c.DnstapProxifier.KeyFile = ""

c.XdpLiveCapture.Enable = false
c.XdpLiveCapture.Device = ""
c.XdpLiveCapture.ChannelBufferSize = 65535

c.AfpacketLiveCapture.Enable = false
c.AfpacketLiveCapture.Port = 53
c.AfpacketLiveCapture.Device = ""
c.AfpacketLiveCapture.ChannelBufferSize = 65535

c.PowerDNS.Enable = false
c.PowerDNS.ListenIP = AnyIP
c.PowerDNS.ListenPort = 6001
c.PowerDNS.TLSSupport = false
c.PowerDNS.TLSMinVersion = TLSV12
c.PowerDNS.CertFile = ""
c.PowerDNS.KeyFile = ""
c.PowerDNS.AddDNSPayload = false
c.PowerDNS.RcvBufSize = 0
c.PowerDNS.ResetConn = true
c.PowerDNS.ChannelBufferSize = 65535

c.FileIngestor.Enable = false
c.FileIngestor.WatchDir = ""
c.FileIngestor.PcapDNSPort = 53
c.FileIngestor.WatchMode = ModePCAP
c.FileIngestor.DeleteAfter = false
c.FileIngestor.ChannelBufferSize = 65535

c.Tzsp.Enable = false
c.Tzsp.ListenIP = AnyIP
c.Tzsp.ListenPort = 10000
c.Tzsp.ChannelBufferSize = 65535
}
21 changes: 21 additions & 0 deletions pkgconfig/collectors_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package pkgconfig

import "testing"

func TestConfigCollectorsSetDefault(t *testing.T) {
config := ConfigCollectors{}
config.SetDefault()

if config.Dnstap.Enable != false {
t.Errorf("dnstap should be disabled")
}
if config.PowerDNS.Enable != false {
t.Errorf("powerdns should be disabled")
}
if config.Tail.Enable != false {
t.Errorf("tail should be disabled")
}
if config.AfpacketLiveCapture.Enable != false {
t.Errorf("sniffer afpacket should be disabled")
}
}
Loading

0 comments on commit 50aee77

Please sign in to comment.