Commit graph

1208 commits

Author SHA1 Message Date
Miek Gieben
f8551df272
cache: move goroutine closure to separate function to save memory (#3353)
The goroutine closure was causing objects to be heap allocated.  Moving
it to a separate function fixes that.

```benchmark                                old ns/op     new ns/op     delta
BenchmarkCacheResponse/NoPrefetch-12     773           713           -7.76%
BenchmarkCacheResponse/Prefetch-12       878           837           -4.67%
BenchmarkHash-12                         9.17          9.18          +0.11%

benchmark                                old allocs     new allocs     delta
BenchmarkCacheResponse/NoPrefetch-12     9              8              -11.11%
BenchmarkCacheResponse/Prefetch-12       9              8              -11.11%
BenchmarkHash-12                         0              0              +0.00%

benchmark                                old bytes     new bytes     delta
BenchmarkCacheResponse/NoPrefetch-12     471           327           -30.57%
BenchmarkCacheResponse/Prefetch-12       471           327           -30.57%
BenchmarkHash-12                         0             0             +0.00%
```

Signed-off-by: Charlie Vieth <charlie.vieth@gmail.com>
Signed-off-by: Miek Gieben <miek@miek.nl>
2019-10-03 15:05:44 +01:00
Miek Gieben
aa96d6b443
plugin/route53: remove amazon intialization from init (#3348)
Don't perform this code in the init, this allocated 1 megabyte of memory
even if you don't use the plugin. Looks to be only there for testing,
adding a comment to reflect that.

Fixes #3342

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-10-03 07:21:11 +01:00
Miek Gieben
8fde7407d9 plugin/clouddns: remove initialization from init (#3349)
* plugin/clouddns: remove initialization from init

Init should just call the plugin.Register with a setup function.

Fixes: #3343

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

* Fix placement for var f

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-10-02 15:18:36 -07:00
Yong Tang
d48d8516e3 Add clouddns/OWNERS file (#3346)
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2019-10-02 07:42:29 +01:00
Miek Gieben
64f0345e63
plugin/erratic: doc and zone transfer (#3340)
Fix the documentation, remove autopath entry and fix the transfer by
copying some bits from the file plugin.

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-10-02 07:22:26 +01:00
Miek Gieben
575cea4496
Move map to array (#3339)
* Move map to array

The map was not needed move to an array, see #1941 for the original
idea. That of course didn't apply anymore; make a super minimal change
to implements the idea from #1941

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

* Add total count

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-10-01 20:45:52 +01:00
Miek Gieben
2d98d520b5
plugin/forward: make Yield not block (#3336)
* plugin/forward: may Yield not block

Yield may block when we're super busy with creating (and looking) for
connection. Set a small timeout on Yield, to skip putting the connection
back in the queue.

Use persistentConn troughout the socket handling code to be more
consistent.

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

Dont do

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

* Set used in Yield

This gives one central place where we update used in the persistConns

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-10-01 16:39:42 +01:00
Uladzimir Trehubenka
7b69dfebb5 plugin/file: fix panic in miekg/dns.CompareDomainName() (#3337)
Signed-off-by: utrehubenka <utrehubenka@infoblox.com>
2019-10-01 13:22:42 +01:00
Erfan Besharat
4ffbee299a Remove deprecated function calls flagged by staticcheck (#3333)
* Use session.NewSession instead of session.New

Signed-off-by: Erfan Besharat <erbesharat@gmail.com>

* Use grpc.DialContext instead of grpc.WithTimeout

Signed-off-by: Erfan Besharat <erbesharat@gmail.com>

* Pass non-nil context to context.WithTimeout

Signed-off-by: Erfan Besharat <erbesharat@gmail.com>

* Return the error directly in route53 setup

Co-Authored-By: Miek Gieben <miek@miek.nl>
Signed-off-by: Erfan Besharat <erbesharat@gmail.com>
2019-10-01 07:42:10 +01: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
Miek Gieben
03a3695ea9
plugins: calling Dispenser itself is a mistake (#3323)
Remove all these uses and just make them work on caddy.Controller. Also
don't export parsing functions as their should be private to the plugin.

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-09-28 10:41:12 +01:00
Miek Gieben
ba5d4a6372
plugin register (#3321)
These plugins where missed in #3287 because their setup is done in a file
other than setup.go

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-09-28 10:40:43 +01:00
Miek Gieben
7328d3e8c9
plugin/reload: reflow documentation (#3313)
* plugin/reload: reflow documentation

For some reason these we're all bullets points, which made for awkward
reading.

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

* typo

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

* Update plugin/reload/README.md

Co-Authored-By: Michael Grosser <development@stp-ip.net>
2019-09-27 11:10:47 +01:00
Guangming Wang
8af4685587 cleanup code by lint (#3312)
Signed-off-by: Guangming Wang <guangming.wang@daocloud.io>
2019-09-27 11:10:34 +01:00
Miek Gieben
f2df37a1fe
plugin/forward: metrics: make docs reflect reality (#3311)
Remove talk about labels that are not added.

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-09-27 11:09:59 +01:00
xieyanker
9a5e4fa1a0 fix mis-spelling (#3310)
Signed-off-by: xieyanker <xjsisnice@gmail.com>
2019-09-26 13:19:45 +01:00
Guangming Wang
eb59e79207 plugin: cleanup code based on staticcheck warnings (#3302)
TrimPrefix re-assign to former variable

Signed-off-by: Guangming Wang <guangming.wang@daocloud.io>
2019-09-25 13:23:43 +01:00
li mengyang
50bac4d3c3 fix: delete unused var and const (#3294)
Signed-off-by: hwdef <hwdef97@gmail.com>
2019-09-24 07:06:37 +01:00
Guangming Wang
081e45afa3 cleanup: remove redundant return statement (#3297)
Signed-off-by: Guangming Wang <guangming.wang@daocloud.io>
2019-09-23 14:40:14 +01:00
Miek Gieben
004c5fca9d
all: simply registering plugins (#3287)
Abstract the caddy call and make it simpler.

See #3261 for some part of the discussion.

Go from:

~~~ go
func init() {
       caddy.RegisterPlugin("any", caddy.Plugin{
               ServerType: "dns",
               Action:     setup,
       })
}
~~~

To:

~~~ go
func init() { plugin.Register("any", setup) }
~~~

This requires some external documents in coredns.io to be updated as
well; the old way still works, so it's backwards compatible.

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-09-20 08:02:30 +01:00
yeya24
85e65702bd add host metrics (#3277)
* add host metrics

Signed-off-by: yeya24 <yb532204897@gmail.com>

* update hosts readme docs

Signed-off-by: yeya24 <yb532204897@gmail.com>
2019-09-19 16:38:15 +01:00
Miek Gieben
62317c3c14 update doc to not use the root zone for everything (#3288)
Update all documentation in the tree to use example.org as an example
configuration (in so far possible). As to get out of the just use "."
and fallthrough and things would be fine.

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-09-19 06:17:53 -07:00
Guangming Wang
2324439adf ready_test.go: rm t.Fatalf in goroutine (#3284)
Signed-off-by: Guangming Wang <guangming.wang@daocloud.io>
2019-09-19 07:04:19 +01:00
yeya24
88d25cdc20 remove an unused variable (#3278)
Signed-off-by: yeya24 <yb532204897@gmail.com>
2019-09-16 07:28:42 +01:00
Chris O'Haver
70f2bd1dff dont duplicate service recrod for every port (#3240) 2019-09-08 08:28:30 +01:00
Cricket Liu
acabfc5e9e Making README text consistent with other plugins' READMEs (#3254) 2019-09-08 08:26:25 +01:00
Cricket Liu
ab59b28c4f Making cancel's README consistent with other plugins' READMEs (#3253) 2019-09-08 08:26:16 +01:00
Cricket Liu
b156e0440f Making dnssec's README consistent with other plugins' READMEs (#3252) 2019-09-08 08:26:06 +01:00
Cricket Liu
9b192564ac Making README consistent with other plugins' READMEs (#3251) 2019-09-08 08:25:58 +01:00
Cricket Liu
9dc2e3162c Making README consistent with other plugins' READMEs (#3250) 2019-09-08 08:25:35 +01:00
Cricket Liu
5339949596 Making README consistent with other plugins' READMEs (#3249) 2019-09-08 08:25:26 +01:00
Cricket Liu
782994583b Making README consistent with other plugins' READMEs (#3248) 2019-09-08 08:25:17 +01:00
Cricket Liu
ea66273463 Making README consistent with other plugins' READMEs (#3247) 2019-09-08 08:24:43 +01:00
Cricket Liu
47b8ce1fff Fixing the top-level description (#3246) 2019-09-08 08:23:54 +01:00
Cricket Liu
db489056b8 Making README consistent with other plugins' READMEs (#3245) 2019-09-08 08:23:38 +01:00
Cricket Liu
31fd9328cd Making README consistent, fixing "meta data" (#3244) 2019-09-08 08:23:20 +01:00
Cricket Liu
878f906854 Making README consistent with other plugins' READMEs (#3243) 2019-09-08 08:23:07 +01:00
Yong Tang
e4df752b17 Update go mod tidy (and fix for Azure/go-autorest & azure-sdk-for-go) (#3258)
See https://github.com/coredns/coredns/pull/3209#issuecomment-525016357
for the previous issues, also see https://github.com/Azure/go-autorest/issues/414
for some further background.

Basically go mod has some issue when multiple tags exists (as main module and submodule)
within the same repo. That was fixed in go-autorest very recently, though
azure-sdk-for-go has not been fully updated yet.

This fix is a temporarily one with `replace` fix. Once azure-sdk-for-go
is updated then we could drop the `replace fix`

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2019-09-06 12:31:05 -04:00
Cricket Liu
41115fb93d Update README.md (#3242)
Minor textual cleanup.
2019-09-05 19:41:13 +01:00
Chris O'Haver
630d3d60b9
plugin/kubernetes: Handle multiple local IPs and bind (#3208)
* use all local IPs

* mult/bind ips

* gofmt + boundIPs fix

* fix no matching endpoint case

* don't duplicate NS records in answer

* fix answer dedup

* fix comment

* add multi local ip test case
2019-09-05 09:07:55 -04:00
Miek Gieben
d79562842a plugin/acl: whitespace cleanup (#3239)
OWNERS file was padded, remove empty lines. Fix code block in README,
and set codeblock type to 'corefile' without the upper case C.

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-09-04 19:06:10 -07:00
An Xiao
79f37a1460 Add plugin ACL for source ip filtering (#3103)
* Add plugin ACL for source ip filtering

Signed-off-by: An Xiao <hac@zju.edu.cn>

* Allow all arguments to be optional and support multiple qtypes in a single policy

Signed-off-by: An Xiao <hac@zju.edu.cn>

* Add newline before third party imports

Signed-off-by: An Xiao <hac@zju.edu.cn>

* Use camel instead of underscore in method name

Signed-off-by: An Xiao <hac@zju.edu.cn>

* Start with an upper case letter in t.Errorf()

Signed-off-by: An Xiao <hac@zju.edu.cn>

* Use the qtype parse logic in miekg/dns

Signed-off-by: An Xiao <hac@zju.edu.cn>

* Use third party trie implementation as the ip filter

Signed-off-by: An Xiao <hac@zju.edu.cn>

* Update based on rdrozhdzh's comment

Signed-off-by: An Xiao <hac@zju.edu.cn>

* Change the type of action to int

Signed-off-by: An Xiao <hac@zju.edu.cn>

* Add IPv6 support

Signed-off-by: An Xiao <hac@zju.edu.cn>

* Update plugin.cfg

Signed-off-by: An Xiao <hac@zju.edu.cn>

* Remove file functionality

Signed-off-by: An Xiao <hac@zju.edu.cn>

* Update

Signed-off-by: Xiao An <hac@zju.edu.cn>

* Update README

Signed-off-by: Xiao An <hac@zju.edu.cn>

* remove comments

Signed-off-by: Xiao An <hac@zju.edu.cn>

* update

Signed-off-by: Xiao An <hac@zju.edu.cn>

* Update dependency

Signed-off-by: Xiao An <hac@zju.edu.cn>

* Update

Signed-off-by: Xiao An <hac@zju.edu.cn>

* Update test

Signed-off-by: Xiao An <hac@zju.edu.cn>

* Add OWNERS

Signed-off-by: Xiao An <hac@zju.edu.cn>

* Refactor shouldBlock and skip useless check

Signed-off-by: Xiao An <hac@zju.edu.cn>

* Introduce ActionNone

Signed-off-by: Xiao An <hac@zju.edu.cn>

* Update label name

Signed-off-by: Xiao An <hac@zju.edu.cn>

* Avoid capitalizing private types

Signed-off-by: Xiao An <hac@zju.edu.cn>
2019-09-04 08:43:45 -07:00
Miek Gieben
94930d20ea
plugin/file: rework outgoing axfr (#3227)
* plugin/file: rework outgoing axfr

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

* Fix test

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

* Actually properly test xfr

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

* Fix test

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-08-30 13:47:27 +01:00
Miek Gieben
b8a0b52a5e
plugin/sign: a plugin that signs zone (#2993)
* plugin/sign: a plugin that signs zones

Sign is a plugin that signs zone data (on disk). The README.md details
what exactly happens to should be accurate related to the code.

Signs are signed with a CSK, resigning and first time signing is all
handled by *sign* plugin.

Logging with a test zone looks something like this:

~~~ txt
[INFO] plugin/sign: Signing "miek.nl." because open plugin/sign/testdata/db.miek.nl.signed: no such file or directory
[INFO] plugin/sign: Signed "miek.nl." with key tags "59725" in 11.670985ms, saved in "plugin/sign/testdata/db.miek.nl.signed". Next: 2019-07-20T15:49:06.560Z
[INFO] plugin/file: Successfully reloaded zone "miek.nl." in "plugin/sign/testdata/db.miek.nl.signed" with serial 1563636548
[INFO] plugin/sign: Signing "miek.nl." because resign was: 10m0s ago
[INFO] plugin/sign: Signed "miek.nl." with key tags "59725" in 2.055895ms, saved in "plugin/sign/testdata/db.miek.nl.signed". Next: 2019-07-20T16:09:06.560Z
[INFO] plugin/file: Successfully reloaded zone "miek.nl." in "plugin/sign/testdata/db.miek.nl.signed" with serial 1563637748
~~~

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

* Adjust readme and remove timestamps

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

* Comment on the newline

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

* Update plugin/sign/README.md

Co-Authored-By: Michael Grosser <development@stp-ip.net>
2019-08-29 15:41:59 +01:00
Miek Gieben
2cb017928c
plugin/etcd: clarify it's not a generic backend (#3220)
* plugin/etcd: clarify it's not a generic backend

Clarify the docs that this is not a generic backend.

Wrap it on 80 columns as well.

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

* Update plugin/etcd/README.md

Co-Authored-By: Chris O'Haver <cohaver@infoblox.com>

* Update plugin/etcd/README.md

Co-Authored-By: Chris O'Haver <cohaver@infoblox.com>
2019-08-28 14:59:00 +01:00
Miek Gieben
6fdf130b67 pkg/log: remove timestamp (#3218)
journald timestamps, kubernetes timestamps, syslog timestamps. It seems
silly to add our own timestamps to the logging output as these external
ones *also* do it. Only when just running coredns this might be weird.

Remove the timestamping from pkg/log.

Remove test that tested for this.

Fixes: #3211

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-08-28 09:41:11 -04:00
AllenZMC
4fca3b0fb0 fix mis-spelling in pcap.go (#3222) 2019-08-28 09:34:48 -04:00
陈谭军
df6235995b fix the-the mistake (#3216) 2019-08-28 07:18:33 +01:00
Miek Gieben
efcc3758dd
plugin/etcd: fully move to go.etcd.io (#3215)
This is needed as well to make it compile cleanly. Follow up to #3214.

Manually removed github.com/coreos/etcd/ from go.mod

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-08-27 16:58:35 +01:00
Miek Gieben
87bd9dec85
plugin/file: less notify logging spam (#3212)
Say once that we've sent notifies, instead of for every upstream
primary.

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-08-27 13:54:23 +00:00