Commit graph

33 commits

Author SHA1 Message Date
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
Miek Gieben
55dafe6f59 core: block CH queries earlier (#973)
block chaos queries, unless the chaos or proxy middleware is loaded. We
respond with REFUSED.

This removes the need for each middleware to do this class != ClassINET
if-then.

Also make config.Registry non-public.
2017-08-25 08:55:53 +01:00
Miek Gieben
46bf7f3106 middleware/file: consider no SOA a fatal error (#734)
Don't load a zone with a SOA record, barf with 'no SOA record' error.
2017-06-13 12:51:52 -07:00
Miek Gieben
990460ee7c middleware/file: don't reload zone when SOA isn't changed (#707)
* middleware/file: don't reload zone when SOA isn't changed

Give Parse an extra argument which is the SOA's serial, if > 0 we check
against the just parsed SOA and then just return.

Most notable use is in reload.go which is both used in the file and auto
middleware.

Fixes #415

* PR comments
2017-06-08 18:43:11 +01:00
Yong Tang
81af74aad0 Fix import path github.com/miekg/coredns -> github.com/coredns/coredns (#547)
This fix fixes import path from
`github.com/miekg/coredns`
->
`github.com/coredns/coredns`
2017-02-22 06:51:47 +00:00
Miek Gieben
c4ab98c6e3 Add middleware.NextOrFailure (#462)
This checks if the next middleware to be called is nil, and if so returns
ServerFailure and an error. This makes the next calling more robust and
saves some lines of code.

Also prefix the error with the name of the middleware to aid in
debugging.
2016-12-20 18:58:05 +00:00
Miek Gieben
d383f279a0 Implement external lookups for CNAMEs 2016-11-10 07:48:47 +00:00
Miek Gieben
3d5be649a2 Issue 388 (#389)
* add extra test

* middleware/auto: fix crash when calling empty handler

Don't call the next middleware, we should be auth. for this zone
getitng into this path we should respond with ServFail.

Fixes #388
2016-11-07 11:12:20 +00:00
Miek Gieben
94dc28646d golint 2016-10-27 11:48:37 +00:00
Miek Gieben
219bfd0493 middleware/metrics: cleanup (#355)
* middleware/metrics: add more metrics

middleware/cache:
Add metrics for number of elements in the cache. Also export the total
size. Update README to detail the new metrics.

middleware/metrics

Move metrics into subpackage called "vars". This breaks the import
cycle and is cleaner. This allows vars.Report to be used in the
the dnsserver to log refused queries.

middleware/metrics: tests

Add tests to the metrics framework. The metrics/test subpackage allows
scraping of the local server. Do a few test scrape of the metrics that
are defined in the metrics middleware.

This also allows metrics integration tests to check if the caching and
dnssec middleware export their metrics correctly.

* update README

* typos

* fix tests
2016-10-26 10:01:52 +01:00
Miek Gieben
d536272201 middleware/auto: add (#333)
Add auto-load middleware that automatically picks up zones.

Every X seconds it will scan for new zones.
Add tests and documentation.

Make 'make test' use -race.
2016-10-17 18:37:56 +01:00
Miek Gieben
de0fa53379 Doc: add package docs (#296)
* Doc: add package docs

Add short package level docs to make godoc looks nicer.
Add some badges to the README.

* correct url
2016-09-25 08:39:20 +01:00
Miek Gieben
090d1872e9 Golint2 (#280)
* Fix linter errors

* More linting fixes

* More docs and making members private that dont need to be public

* Fix linter errors

* More linting fixes

* More docs and making members private that dont need to be public

* More lint fixes

This leaves:

~~~
middleware/kubernetes/nametemplate/nametemplate.go:64:6: exported type NameTemplate should have comment or be unexported
middleware/kubernetes/nametemplate/nametemplate.go:71:1: exported method NameTemplate.SetTemplate should have comment or be unexported
middleware/kubernetes/nametemplate/nametemplate.go:108:1: exported method NameTemplate.GetZoneFromSegmentArray should have comment or be unexported
middleware/kubernetes/nametemplate/nametemplate.go:116:1: exported method NameTemplate.GetNamespaceFromSegmentArray should have comment or be unexported
middleware/kubernetes/nametemplate/nametemplate.go:120:1: exported method NameTemplate.GetServiceFromSegmentArray should have comment or be unexported
middleware/kubernetes/nametemplate/nametemplate.go:124:1: exported method NameTemplate.GetTypeFromSegmentArray should have comment or be unexported
middleware/kubernetes/nametemplate/nametemplate.go:135:1: exported method NameTemplate.GetSymbolFromSegmentArray should have comment or be unexported
middleware/kubernetes/nametemplate/nametemplate.go:167:1: exported method NameTemplate.IsValid should have comment or be unexported
middleware/kubernetes/nametemplate/nametemplate.go:182:6: exported type NameValues should have comment or be unexported
middleware/kubernetes/util/util.go:1:1: package comment should be of the form "Package util ..."
middleware/kubernetes/util/util.go:27:2: exported const WildcardStar should have comment (or a comment on this block) or be unexported
middleware/proxy/lookup.go:66:1: exported method Proxy.Forward should have comment or be unexported
middleware/proxy/proxy.go:24:6: exported type Client should have comment or be unexported
middleware/proxy/proxy.go:107:1: exported function Clients should have comment or be unexported
middleware/proxy/reverseproxy.go:10:6: exported type ReverseProxy should have comment or be unexported
middleware/proxy/reverseproxy.go:16:1: exported method ReverseProxy.ServeDNS should have comment or be unexported
middleware/proxy/upstream.go:42:6: exported type Options should have comment or be unexported
~~~

I plan on reworking the proxy anyway, so I'll leave that be.
2016-09-23 09:14:12 +01:00
Miek Gieben
d1f17fa7e0 Cleanup: put middleware helper functions in pkgs (#245)
Move all (almost all) Go files in middleware into their
own packages. This makes for better naming and discoverability.

Lot of changes elsewhere to make this change.

The middleware.State was renamed to request.Request which is better,
but still does not cover all use-cases. It was also moved out middleware
because it is used by `dnsserver` as well.

A pkg/dnsutil packages was added for shared, handy, dns util functions.

All normalize functions are now put in normalize.go
2016-09-07 11:10:16 +01:00
Miek Gieben
1aa1a92198 Add middleware/dnssec (#133)
This adds an online dnssec middleware. The middleware will sign
responses on the fly. Negative responses are signed with NSEC black
lies.
2016-04-26 17:57:11 +01:00
Miek Gieben
e294c95582 middleware/file: Support delegations (#124)
Return a delegation when seeing one while traversing the tree in
search of an answer.

Put the SOA and NS record in the zone.Apex as these are to be handled
somewhat special.

Lowercase record on insert to make compares easier. This lowercases
all RR that have domain names in their rdata as well.
2016-04-16 16:16:52 +01:00
Miek Gieben
c9d8a57ed6 Reload zone when a write is detected (#122)
Zone reloading
2016-04-15 14:26:27 +01:00
Miek Gieben
eb1f21bfff Drop NSEC3 zone (#120)
Error out when parsing and transferring such a zone. If we would serve
it we would give out the wrong answers, leading to (probably) validation
failures...

Fixes #114
2016-04-14 07:33:03 +01:00
Miek Gieben
ad221f4b2a correct EDNS responses (#96)
Tests updated as well and all the middleware. And Prometheus renamed to
metrics (directive is still prometheus).
2016-04-09 16:17:53 +01:00
Miek Gieben
225cdd1ca3 Add AXFR test
Test shouldTransfer by upping a testserver and sending the SOA query.

Remove state from DefaultErrorHandler and just get it from the request.

Add more logging to show what is going on.



This also adds the infrastructure for future tests.
2016-04-06 22:29:33 +01:00
Miek Gieben
e0c4f94d67 return failure with CH class hits file or etcd, monitoring portis 9135 2016-04-05 16:23:03 +01:00
Miek Gieben
8892a1b490 Middleware chaining fixes
For prometheus use the plain value, not a pointer and change all usages.
Allow AXFR to be requested over udp as well and some other more log
printed when commencing an AXFR.
2016-04-05 15:54:06 +01:00
Miek Gieben
c961acbb6e Add complete secondary support
Respond to notifies and allow a secondary to follow the SOA parameters

to update a zone from a primary. Also sprinkle it with logging.



Also extend monitoring to include qtype in more metrics.
2016-04-05 10:53:23 +01:00
Miek Gieben
6445a3f2f0 Cleanup docs and the chaos middleware
Make the CH middleware actually work. Needs a bit of a hack to route

the fake version.bind and friends zone to the correct handler. Fiddle

with the order in directive.go so that CH queries get logged as well.



Secondly add class rewriting to the rewrite middleware handler and also

log the class by default.
2016-04-04 15:45:17 +01:00
Miek Gieben
f58f1e4285 Add secondary support
Allow specifying a primary server and retrieve the zone's content.

Add tests and an Expired bool to zone struct, to stop server zones

that are expired. The zone is retrieved on Startup, no updates of

changed content are done. We also don't respond to notifies yet.
2016-04-03 09:02:34 +01:00
Miek Gieben
4be4d92ccb Fix positive replies 2016-03-30 13:25:45 +00:00
Miek Gieben
547a4ab2a8 More stuff 2016-03-30 13:25:45 +00:00
Miek Gieben
48f7d55f27 Get positive dnssec stuff going 2016-03-30 13:25:45 +00:00
Miek Gieben
e56d206542 Support outgoing zone transfers
These can be enabled by adding "transfer out" to the Corefile. Without
it no AXFR is allowed.

For now only AXFR and no IXFR. No TSIG and no ACLs.
2016-03-28 18:23:17 +01:00
Miek Gieben
6324bb1fa7 Scrub the returned result 2016-03-28 11:29:50 +01:00
Miek Gieben
5387c162c9 Implement a DNS zone
Full implementation, DNS (and in the future DNSSEC). Returns answer in a
hopefully standards compliant way.
Testing with my miek.nl zone are included as well.
This should correctly handle nodata, nxdomain and cnames.
2016-03-28 10:15:05 +01:00
Miek Gieben
f907311cdf Use context.Context
Rename the old Context to State and use context.Context in the
middleware for intra-middleware communication and more.
2016-03-19 07:32:50 +00:00
Miek Gieben
3ec0d9fe6b First commit 2016-03-18 20:57:35 +00:00