Commit graph

14 commits

Author SHA1 Message Date
Ondřej Benkovský
c2dbb7141a
add golangci-lint linter (#5499) 2022-07-10 11:06:33 -07:00
Frank Riley
eba74389c4
Fix #4395, fix out of order messages and fix forward perspective. (#4396)
Signed-off-by: Frank Riley <fhriley@gmail.com>
2021-01-21 10:00:27 +01:00
Miek Gieben
123da4c844
plugin/dnstap: remove config struct (#4258)
* plugin/dnstap: remove config struct

this struct is an uneeded intermidiate to get a dnstap it can be
removed. Remove the dnstapio subpkg: it's also not needed. Make *many*
functions and structs private now that we can.

Signed-off-by: Miek Gieben <miek@miek.nl>

* correct logging

Signed-off-by: Miek Gieben <miek@miek.nl>
2020-11-05 14:37:16 +01:00
Miek Gieben
b3b8a7e4b7
plugin/dnstap: various cleanups (#4179)
* plugin/dnstap: various cleanups

A recent issue made me look into this plugin, I suspect various other
cleanups (hopefully deletion of code) can be made as well

Remove identical functions ToClientQuery etc, and just use tap.Message
as the base type in plugin. Keep msg/ for a few helper functions that
may proof useful.

This remove the whole test directory as we will just check the things we
are interested in which gives much better feedback and keeps that code
closer together.

tapwr dir is also not needed, writer_test.go was just duplicating the
tests already done. This moves writer.go to the top directory.

Make the only user of dnstap, the forward plugin, use the newer code
also remove the test, a better test there would be a full e2e test to
see the correct thing happens.

Cleanup the Tapper interface and move it to dnstapio where it belongs,
remove higher level interfaces that are not used. This remove
dnstap.Tapper and dnstap.IORoutines.

Use the standard mechanism for getting access to a plugin and remove
shuffling the plugin into the context.

Signed-off-by: Miek Gieben <miek@miek.nl>

* use opts to get the correct proto

Signed-off-by: Miek Gieben <miek@miek.nl>

* Various fixes

Signed-off-by: Miek Gieben <miek@miek.nl>

* Remove bad addr test, as dnstap is only called from within coredns where these fields have been preparsed

Signed-off-by: Miek Gieben <miek@miek.nl>

* dnstap: remove saving the error

all these fields have been preparsed, no need for dnstap to be pedantic
and check (and save!) this error again.

Simplifies it a bit more.

Signed-off-by: Miek Gieben <miek@miek.nl>

* Update plugin/forward/dnstap.go

Co-authored-by: Ruslan Drozhdzh <30860269+rdrozhdzh@users.noreply.github.com>

* Code review

Signed-off-by: Miek Gieben <miek@miek.nl>

* add back in preferUDP

Signed-off-by: Miek Gieben <miek@miek.nl>

* nit

Signed-off-by: Miek Gieben <miek@miek.nl>

Co-authored-by: Ruslan Drozhdzh <30860269+rdrozhdzh@users.noreply.github.com>
2020-10-12 19:10:35 +02:00
Miek Gieben
dbd1c047cb
Run gostaticheck (#3325)
* Run gostaticheck

Run gostaticcheck on the codebase and fix almost all flagged items.

Only keep

* coremain/run.go:192:2: var appVersion is unused (U1000)
* plugin/chaos/setup.go:54:3: the surrounding loop is unconditionally terminated (SA4004)
* plugin/etcd/setup.go:103:3: the surrounding loop is unconditionally terminated (SA4004)
* plugin/pkg/replacer/replacer.go:274:13: argument should be pointer-like to avoid allocations (SA6002)
* plugin/route53/setup.go:124:28: session.New is deprecated: Use NewSession functions to create sessions instead. NewSession has the same functionality as New except an error can be returned when the func is called instead of waiting to receive an error until a request is made.  (SA1019)
* test/grpc_test.go:25:69: grpc.WithTimeout is deprecated: use DialContext and context.WithTimeout instead.  Will be supported throughout 1.x.  (SA1019)

The first one isn't true, as this is set via ldflags. The rest is
minor. The deprecation should be fixed at some point; I'll file some
issues.

Signed-off-by: Miek Gieben <miek@miek.nl>

* Make sure to plug in the plugins

import the plugins, that file that did this was removed, put it in the
reload test as this requires an almost complete coredns server.

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-10-01 07:41:29 +01:00
Stefan Budeanu
f798d18bdd Fix context passing (#2681) 2019-03-13 18:08:33 +00:00
varyoo
9cea32f013 dnstap.TapperFromContext always returns nil (#2018)
Automatically submitted.
2018-08-01 22:58:23 +00:00
Miek Gieben
0930eb8beb
all: fix plugin import ordering (#1717)
Got a bit messed up with stb lib "context" usage.
2018-04-22 08:34:35 +01:00
Miek Gieben
8722336fff
global: move to context (#1699)
* global: move to context

Move from golang.org/x/net/context to std lib's context.

Change done with:

for i in $(grep -l '/context' **/*.go); do sed -e 's|golang.org/x/net/context|context|' -i $i; echo $i; done
for i in **/*.go; do goimports -w $i; done

* drop from dns.pb.go as well
2018-04-20 11:01:06 +01:00
varyoo
6bb08ffee4 Easier way to dnstap? (#1496)
* Easier way to dnstap?

* Remove unnecessary function parameter from Tapper

* golint

* golint 2

* Proxy dnstap tests

* README.md & doc

* net.IP

* Proxy test was incorrect

* Small changes

* Update README.md

* Was not reporting dnstap errors + test

* Wasn't working at all, now it's ok

* Thanks Travis
2018-02-28 18:19:01 -08:00
Miek Gieben
c2d93f7182 plugin/dnstap: some cleanup (#1172)
Some cleanup in proxy and dnstap:
* just use time pkg directly and side step the indirection for Epoch
* Use Set in SetQueryEpoch to be more Go like. (Looked like a reader)
* Don't maintain two sets of time, we already track start, so use that.
* Use time.Time and convert when needed
* dedent the toDnstap function and put in a separate file
2017-10-25 19:46:41 +01:00
Thong Huynh
2f9c42d82e Enable dnstap plugin to insert other plugin's specific data into extra field of tap.Dnstap message (#1101)
* Add custom data into dnstap context

* Fix error and fix UT compile errors

* Add UTs

* Change as per review comments.  Use boolean to indicate which Dnstap message to send out

* Merge with master and fix lint warning

* Remove newline

* Fix review comments
2017-09-29 16:38:01 -04:00
varyoo
daf8ef0da8 Adds the dnstap I/O routines and should fix some issues (#1083)
* adds the dnstap I/O thread and should fix a lot of mistakes

* docs

* -race test

* oops

* docs
2017-09-26 11:45:33 -04:00
Miek Gieben
d8714e64e4 Remove the word middleware (#1067)
* Rename middleware to plugin

first pass; mostly used 'sed', few spots where I manually changed
text.

This still builds a coredns binary.

* fmt error

* Rename AddMiddleware to AddPlugin

* Readd AddMiddleware to remain backwards compat
2017-09-14 09:36:06 +01:00
Renamed from middleware/dnstap/handler.go (Browse further)