Commit graph

1271 commits

Author SHA1 Message Date
Thomas Mangin
4b402e000d plugin/hosts provide more configuration flexibility (#2535)
* plugin/hosts provide more configuration flexibility

This patch adds few features to the host plugin
 * no-reverse (both as first argument on the plugin line and inline)
   disable the automatic generation of reserve entries for hosts
 * ttl <duration> (inline only atm)
   allows to change the default ttl (default 5 minutes)
 * reload <duration> (inline only atm)
   allows to change the reloading interval (default 5s)

* plugin/hosts remove superfluous parameters to parse
2019-02-12 09:09:33 -07:00
Miek Gieben
e47d881461
pkg/replace: make it more efficient. (#2544)
* pkg/replace: make it more efficient.

Remove the map that is allocated on every write and make it more static,
but just defining a function that gets called for a label and returns
its value.

Remove the interface definition and just implement what is needed in our
case. Add benchmark test for replace as well.

Extend metadata test to test multiple values (pretty sure this didn't
work, but there wasn't a test for it, so can't be sure).

Update all callers to use it - concurrent use should be fine as we pass
everything by value.

Benchmarks in replacer:

new: BenchmarkReplacer-4   300000      4717 ns/op     240 B/op       8 allocs/op
old: BenchmarkReplacer-4   300000      4368 ns/op     384 B/op      11 allocs/op

Added benchmark function to the old code to test it.

~~~
func BenchmarkReplacer(b *testing.B) {
	w := dnstest.NewRecorder(&test.ResponseWriter{})
	r := new(dns.Msg)
	r.SetQuestion("example.org.", dns.TypeHINFO)
	r.MsgHdr.AuthenticatedData = true
	b.ResetTimer()
	b.ReportAllocs()
	repl := New(context.TODO(), r, w, "")
	for i := 0; i < b.N; i++ {
		repl.Replace("{type} {name} {size}")
	}
}
~~~

New code contains (of course a different one). The amount of ops is
more, which might be good to look at some more. For all the allocations
is seems it was quite performant.

This looks to be 50% faster, and there is less allocations in log
plugin:

old: BenchmarkLogged-4   	   20000	     70526 ns/op
new: BenchmarkLogged-4   	   30000	     57558 ns/op

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

* Stickler bot

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

* Improve test coverage

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

* typo

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

* Add test for malformed log lines

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-02-12 07:38:49 +00:00
Miek Gieben
29cb00aada
Remove grpc watch functionality (#2549)
This was added, but didn't see any use. For a large, complex chunk of
code we should have some users of it.

Remove all watch functionally from plugins, servers and packages.

Fixes: #2548

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-02-11 14:46:53 +00:00
JoeWrightss
f69819387d Fix t.Error error message (#2551)
Signed-off-by: zhoulin xie <zhoulin.xie@daocloud.io>
2019-02-11 07:23:05 +00:00
JoeWrightss
06d945fc32 Fix some spelling errors in comment (#2533)
Signed-off-by: zhoulin xie <zhoulin.xie@daocloud.io>
2019-02-07 11:27:27 -05:00
Guy Templeton
39cf482348 Set klog's logtostderr flag (#2529)
* Parse as well as  setlogtostderr flag

* Enforce setting of logtostderr for klog

* Clearup comment on klog
2019-02-07 07:33:30 +00:00
Christophe de Carvalho
d878eeebbb support etcd credentials in etcd plugin (#2442)
* support etcd credentials in etcd plugin

fixes #2441

* try to fix cleanup of authentication
2019-02-01 15:30:53 +00:00
JoeWrightss
b455f86824 Fix some typos in comment (#2520)
Signed-off-by: zhoulin xie <zhoulin.xie@daocloud.io>
2019-02-01 19:22:43 +08:00
ckcd
2b651129fb plugin/log: add test and benchmark (#2515) 2019-01-30 11:12:26 +00:00
Chris O'Haver
68e09f00a4 skip pushing watch updates when there are no watches (#2513) 2019-01-29 11:15:49 -08:00
Ye Ben
0eff7f3797 some typo fix (#2512)
Signed-off-by: yeya24 <ben.ye@daocloud.io>
2019-01-29 10:21:19 -05:00
Carl-Magnus Björkell
a84c26d78b plugin/etcd: Filter empty host field by qtype (#2499)
When a query, different from a TXT lookup is performed, all services
with a missing `Host` field should be filtered out, as these otherwize
cause a line in the answer section with a single dot (`.`) as the
result. This behavior manifests for example when a TXT record is present
on a domain, eg. an A or SRV lookup is performed on said domain.

If there are no services containing a `Host` field, a `NODATA` response
should be given. If there are other Services, these alone should be
returned for the query.

Filter any service that has an empty Host field from all lookup types
other than TXT to solve this issue. At the same time the check for empty
`Text` fields in TXT queries are also moved to the same check in the
etcd ServiceBackend.
2019-01-28 16:38:27 +00:00
Thomas Mangin
e343556687 plugin/hosts: fix for ipv4-in-ipv6 (#2506)
* fix for ipv4-in-ipv6

* update comment as requested
2019-01-28 16:36:34 +00:00
Guy Templeton
d571fbe046 Correct formatting of policies list (#2509) 2019-01-28 10:07:13 -05:00
Yong Tang
4a9631cec3 golint fix (#2504)
This PR is a small golint fix:
```
coredns/plugin/test/helpers.go
Line 283: warning: redundant if ...; err != nil check, just return error instead. (golint)
```

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2019-01-27 17:55:07 +00:00
mrasu
eb85af2240 plugin/etcd: Fix REAME's ttl (#2502)
There are string ttls at commands at README.md.
But because `TTL` of `Service` is uint32, commands at README is wrong.

e.g.) `etcdctl put /skydns/local/skydns/x1 '{"host":"1.1.1.1","ttl":"60"}'`.
2019-01-27 17:54:50 +00:00
Carl-Magnus Björkell
48a8d6c75e plugin/etcd: Remove unnecessary struct copy (#2497)
The `b` struct is just copying all the fields into a new one, to
check if it already existed in a set. This isn't needed as all the
fields are identical, and a small rearrangement of the code solves the
same problem without the copy.
2019-01-27 17:54:28 +00:00
Chris O'Haver
92bec854dc
Update README.md (#2490) 2019-01-23 08:49:16 -05:00
Thomas Mangin
3533065ed2 plugin/hosts reload the hosts file every 5 seconds (#2478)
* inform users of the reload feature

* modified as requested
2019-01-21 07:54:41 +00:00
Miek Gieben
725becd134
Stop importing testing in the main binary (#2479)
* Stop importing testing in the main binary

Stop importing "testing" into the main binary:

* test/helpers.go imported it; remote that and change function signature
* update all tests that use this

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

* Drop import testing from metrics plugin

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

* more fiddling

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-01-19 11:23:13 +00:00
Chris O'Haver
278303ca0d set ttl for ns records (#2452) 2019-01-19 10:25:52 +00:00
Rob Maas
b0d37c5443 fix tls_servername in cloudflare example (#2466) 2019-01-15 09:18:20 -08:00
Yong Tang
7bd6855155
Deprecate multiple endpoints for out-of-cluster k8s api (#2454)
This fix deprecates endpoints for out-of-cluster k8s api,
The Corefile still takes multiple endpoints though only
the first one is used. A warning is shown if there are
multiple endpoints.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2019-01-13 10:09:51 -08:00
Miek Gieben
f655d404d4
Fix setup_test in plugin/kubernetes (#2460)
PR race condition, fix the test data for the setup.

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-01-13 17:16:36 +00:00
Miek Gieben
9c16ed1d14
Default to upstream to self (#2436)
* Default to upstream to self

This is a backwards incompatible change.

This is a massive (cleanup) PR where we default to resolving external
names by the coredns process itself, instead of directly forwarding them
to some upstream.

This ignores any arguments `upstream` may have had and makes it depend
on proxy/forward configuration in the Corefile. This allows resolved
upstream names to be cached and we have better healthchecking of the
upstreams. It also means there is only one way to resolve names, by
either using the proxy or forward plugin.

The proxy/forward lookup.go functions have been removed. This also
lessen the dependency on proxy, meaning deprecating proxy will become
easier. Some tests have been removed as well, or moved to the top-level
test directory as they now require a full coredns process instead of
just the plugin.

For the etcd plugin, the entire StubZone resolving is *dropped*! This
was a hacky (but working) solution to say the least. If someone cares
deeply it can be brought back (maybe)?

The pkg/upstream is now very small and almost does nothing. Also the
New() function was changed to return a pointer to upstream.Upstream. It
also returns only one parameter, so any stragglers using it will
encounter a compile error.

All documentation has been adapted. This affected the following plugins:
* etcd
* file
* auto
* secondary
* federation
* template
* route53

A followup PR will make any upstream directives with arguments an error,
right now they are ignored.

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

* Fix etcd build - probably still fails unit test

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

* Slightly smarter lookup check in upstream

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

* Compilez

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-01-13 16:54:49 +00:00
Chris O'Haver
22cacc7cb1 fix soa min ttl in tests cases (#2451) 2019-01-10 15:49:53 +00:00
Chris O'Haver
875c11a0cb set minttl to ttl setting (#2446) 2019-01-10 07:34:22 +00:00
Chris O'Haver
18f25dbef3
plugin/kubernetes: fix case preservation and add test (#2430)
* fix case preservation and add test
* only fix case in k8s
2019-01-08 08:30:03 -05:00
ckcd
418edd2a2f plugin/log: support multi nameScope (#2420) 2019-01-08 07:40:50 +00:00
Yong Tang
53d1afbaf2
Error out when multiple https endpoints are specified. (#2438)
This fix will error out when multiple https endpoints are specified,
as additional work is needed to support beyond http.

This fix fixes 1464.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2019-01-07 09:28:03 -08:00
Miek Gieben
06efc07f46
Generate man-pages (#2439)
Almost 100% mechanical change, except the fact that import/import.md
is moved to import/README.md

No content changes.

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-01-06 09:15:34 +00:00
Miek Gieben
fb32f7a358 Add import plugin to give it docs (#2428)
* wip: add import to make it have docs

Fake the import plugin further to give it proper docs. This should help
make it more discoverable.

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

* Finish writing the documentation

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-01-05 19:41:47 -08:00
Miek Gieben
652b9a69d8
plugin/kubernetes: add memory usage guidelines (#2424)
Add words in object.go on the memory use and put some future ideas in
there to use even less (if we have to at some point).

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-01-05 16:58:27 +00:00
Miek Gieben
35b74eb197
plugin/log: update nodata/NXDOMAIN story a bit (#2416)
* plugin/log: update nodata/NXDOMAIN story a bit

Add more words on nodata and NXDOMAIN which is a confusing DNS
"feature"

Fixes: #2412

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

* typos

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-01-05 16:33:27 +00:00
Miek Gieben
300506ee91
plugin/log: detail {combined} and {common} (#2422)
These can be used (and are handy), document them.

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-01-04 19:39:02 +00:00
Isolus
7642995558 disable ra flag for several plugins (#2408)
* disable ra flag for several plugins

* removed unnecessary assignment

* removed more unnecessary assignments
2018-12-30 17:05:08 +01:00
Miek Gieben
14f8b5d75a
Fuzzing: add more fuzzing targets (#2402)
* Add more fuzzing

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

* More fuzzing targets

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

* Fuzzing: add more fuzzing targets

Also add Corefile fuzzing.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-12-17 07:49:15 +00:00
Miek Gieben
775cf92f03 plugin/loop: show from -> to (#2400)
Show from and to address when detecting a loop they may aid in
debugging.

Hard to create a unit test, but this is a startup run with self induced
loop:

~~~ corefile
.:1053 {
    loop
    log
    forward . 127.0.0.1:1053
}
~~~~

~~~
:1053
2018-12-16T10:11:03.695Z [INFO] CoreDNS-1.3.0
2018-12-16T10:11:03.695Z [INFO] linux/amd64, go1.11,
CoreDNS-1.3.0
linux/amd64, go1.11,
2018-12-16T10:11:03.696Z [FATAL] plugin/loop: Loop (127.0.0.1:51384 -> :1053) detected for zone ".", see https://coredns.io/plugins/loop#troubleshooting. Query: "HINFO 2781022615773629442.4133547885299871809."
~~~

Update the docs and polished that a bit as well.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-12-16 13:48:09 -08:00
Miek Gieben
c1c98924c3
Add new plugin: external - resolve k8s ingress and LB address with external names (#2379)
* Add new plugin: external

This plugin works in conjunction with the kubernetes plugin and exports
ingress and LB addresses as DNS records. It bypasses backend.go and
backend_lookup.go flow because it is not needed.

README, tests are implemented. The tests only exercise the unit tests,
this has not been tested in any ci.

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

* Rename to k8s_external

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

* go gen

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-12-14 09:41:51 +00:00
Miek Gieben
d0adf6f3a6
edns0 compliance: set correct RCODE (#2388)
The miekg/dns API is a bit scruffy (documentation PR in flight soon),
but these both need to be set for the correct RCODE to be reflected in
the returned packet.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-12-11 20:27:29 +00:00
Miek Gieben
9abbf4a4a0 map bool -> map struct{} (#2386)
This clear out the remaining map[x]bool usage and moves the bool to an
empty struct.

Two note worthy other changes:

* EnableChaos in the server is now also exported to make it show up in
  the documentation.
* The auto plugin is left as is, because there the boolean is
  explicitaly set to false to signal 'to-be-deleted' and the key is left
  as-is.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-12-10 02:17:15 -08:00
Yong Tang
c788649a00 Replace bool map with struct{} map in chaos plugin (#2384)
Automatically submitted.
2018-12-08 23:57:57 +00:00
Miek Gieben
95546dfdfe plugin/kubernetes: smaller map (#2383)
* plugin/kubernetes: smaller map

to continue with a theme: the map[string]bool can be reduced
to map[string]struct{} to reduce a tiny amount of memory.

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

* fix tests

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-12-08 15:40:07 -08:00
Yong Tang
0f7d95b1e7
Convert bool map to struct{} map in etcd.go (#2381)
This fix converts bool map to struct{} map in etcd.go
(there might be several other places).

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2018-12-08 06:15:11 -08:00
Miek Gieben
f02da83e9c plugin/kubernetes: make prefix key in msg.Service a const (#2378)
This is a relic from the etcd integration and only used to remove in the
final answer returned to the client. We do need it. Make it a constant
and only one character wide.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-12-08 05:37:00 -08:00
Miek Gieben
65be561722 Make backand.go maps smaller (#2380)
These maps where all map[x]bool. Change this a map[x]struct{} as this
is smaller and we only use these map to signal "this element exists".

This should preserve a (small) amount of memory.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-12-08 05:19:22 -08:00
Miek Gieben
8a5eb58bc0 msg.Service: optimize a bit (#2374)
Make the NewSRV and friends slightly smarter. Optimize the calling of
targetStrip which is almost certainly not used.

Added benchmark show a modest improvement:

benchmark             old ns/op     new ns/op     delta
BenchmarkNewSRV-4     300           283           -5.67%

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-12-07 12:09:09 -08:00
StormXX
16197a1add fix a document error (#2376) 2018-12-07 09:45:13 +00:00
Daniel Garcia
4a3f5cc41e Use Trim(Prefix/Suffix) instead of Trim(Left/Right) in rewrite prefix plugin (#2364) (#2372) 2018-12-06 22:10:46 +00:00
Miek Gieben
fc667b98e0
Fix EDNS0 compliance (#2357)
* Fix EDNS0 compliance

Do SizeAndDo in the server (ScrubWriter) and remove all uses of this
from the plugins. Also *always* do it. This is to get into compliance
for https://dnsflagday.net/.

The pkg/edns0 now exports the EDNS0 options we understand; this is
exported to allow plugins add things there. The *rewrite* plugin used
this to add custom EDNS0 option codes that the server needs to
understand.

This also needs a new release of miekg/dns because it triggered a
race-condition that was basicly there forever.

See:
* https://github.com/miekg/dns/issues/857
* https://github.com/miekg/dns/pull/859

Running a test instance and pointing the https://ednscomp.isc.org/ednscomp
to it shows the tests are now fixed:

~~~
EDNS Compliance Tester
Checking: 'miek.nl' as at 2018-12-01T17:53:15Z

miek.nl. @147.75.204.203 (drone.coredns.io.): dns=ok edns=ok edns1=ok edns@512=ok ednsopt=ok edns1opt=ok do=ok ednsflags=ok docookie=ok edns512tcp=ok optlist=ok
miek.nl. @2604:1380:2002:a000::1 (drone.coredns.io.): dns=ok edns=ok edns1=ok edns@512=ok ednsopt=ok edns1opt=ok do=ok ednsflags=ok docookie=ok edns512tcp=ok optlist=ok

All Ok
Codes
ok - test passed.
~~~

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

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

* typos in comments

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-12-06 21:18:11 +00:00