* core: hide registerHandler
Remove RegisterHandler and just make it implicit when we look at the
handler compilation step.
* Rename GetHandler to just Handler
Update callers and make auto check Hander in OnStartup.
* Up test coverage in erratic
* up test coverage
* cidr everywhere: check all middleware
Add tests for cidr in only that middleware that already tests for this.
Check the other ones manually (and put reverse in the tests cases
anyway).
Make etcd setup_test run without +build etcd tag - it is not needed
for this test - move rest of the code to lookup_test.go.
Cleanup proxy test a bit and remove TempDir as there is test.TempFile
that does the same thing.
Fixes#909
* coredns package
* Fix test compile
* core: replace GetMiddleware
See the discussion in #881. GetMiddleware would add a `nil` middleware
to the callstack thereby breaking functionality.
This PR drops it in favor of RegisterHandler which is a completely
standalone registry for middleware that want to let it self know to
other middleware.
Currenly *autopath* uses this to call *kubernetes*'s AutoPath method
for dynamic autopathing.
* Drop GetMiddleware
* Register metrics
* drop the panic
* Switches out Unhealthy bool for OkUntil timestamp
* Make sure servers are healthy forever if there are no health checks
* Moves health check off into a go routine to avoid blocking conditions
* Improved logging info
* Fixes initial date
* Fixes health checking; alters tests to adapt to async health checking
* Moves future variable into static upstream and populates it in more places
* Restores silencing of stdout during testing
* Restores silencing of stdout during testing
* keeps check url string once built
* Removes debug message
* uses zero value to signal no checking; reduces in-mutex code to a fetch
* cleanup: go vet and golint run
Various cleanups trickered by go vet and golint.
* Fix tests and lowercase all errors
Lowercase all errors, some tests in kubernetes use errors from
kubernetes which do start with a capital letter.
Singleinflight interferes with the health checking of upstream. If an
upstream would fail, singleinflight would mirror that error to to other
proxy *iff* multple identical queries would be inflight. This would lead
to marking *all* upstreams as bad, essentially collapsing multiple
upstreams into a SPOF. Clearly not what we want.
Singleinflight does have some nice properties, but I've opted to rip it
out entirely. Caching should almost (but not quite) as good.
Added a test case in test that uses 3 CoreDNS instances to reflect the
setup from #715.
Found another bug as well, where (when the policy would be nil), we
would always Spray even though we've found a healthy host.
* Revert "middleware/proxy: Make Unhealthy a pointer (#615)"
This reverts commit acbf522ceb.
* middleware/proxy: add proper locking
This add the proper locking around `Unhealthy`.
* Implements tracing in the native gRPC server
* Undo some unnecessary changes
* Properly revert trace/setup.go this time
* Some very very basic tests
* Remove warning for non-Trace middleware
Pointer updates are atomic so drop the sync.RWMutex as it is not needed
anymore. This also fixes the race introduced with dfc71df (although I
believe this is the first time we properly tested that code path).
* add proxy tcp
* add truncated for tcp to udp response
* move truncation to scrubbing
* add test that executes upstream over tcp
* middleware/proxy: some tweaks
rename force-tcp to force_tcp to be inline with the rest and use
a dnsOptions struct to put the options in to allow it to be extended.
Add some parse tests as well.
* Fix test and rename dnsOptions Options
According to the code, the default health check interval is 30 seconds,
not 10 as stated in the documentation. (The alternative would be to
adjust the interval in the code.)
* core: add listening for other protocols
Allow CoreDNS to listen for TLS request coming over port 853. This can
be enabled with `tls://` in the config file.
Implement listening for grps:// as well.
a Corefile like:
~~~
. tls://.:1853 {
whoami
tls
}
~~~
Means we listen on 1853 for tls requests, the `tls` config item allows
configuration for TLS parameters. We *might* be tempted to use Caddy's
Let's Encrypt implementation here.
* Refactor coredns/grpc into CoreDNS
This makes gRPC a first class citizen in CoreDNS. Add defines as being
just another server.
* some cleanups
* unexport the servers
* Move protobuf dir
* Hook up TLS properly
* Fix test
* listen for TLS as well. README updates
* disable test, fix package
* fix test
* Fix tests
* Fix remaining test
* Some tests
* Make the test work
* Add grpc test from #580
* fix crash
* Fix tests
* Close conn
* README cleanups
* README
* link RFC
* checkpoint
* Pass context through ServeDNS, enable gRPC tracing
* Fix types and make tracer available to proxy. go fmt
* Fix imports
* Use the DoNotStartTrace option
* Change to SpanFilter from DoNotStartTrace
* Use new name (IncludeSpan)
* Final names
* Add tests; fix possible client/conn leaks in grpc
* go fmt
* WIP: Client-side of gRPC proxy
* Add tests
* gofmt
* Implement OnShutdown; add a little logging
* Update for context in Exchange change
* go fmt
* Update README
* Review comments
* Compiling is good
* More README improvements
* middleware/proxy: give Exchange a context
Make context.Context the first paramater in the Exchange method.
This is inline with all other query functions.
* up the version
Fix the except keyword usage - the config would allow it, but it was
not enforced in the code.
Turns out that **FROM** was also not enforced, fix both, by (basically)
copying the code from Caddy.
Update the README and tests.
Locally test as well, shows that this works:
~~~
.:1053 {
proxy miek.nl 8.8.8.8:53 {
except a.miek.nl
}
proxy a.miek.nl 8.8.4.4:53
errors stdout
log stdout
}
~~~
And gives the desired results, not having a proxy line for `a.miek.nl`
results in a SERVFAIL (as expected).
Fixes#502
* middleware/proxy: absorb httpproxy
Move the httproxy into proxy. This adds and Exchanger interface which
is used to exchange the messages with the upstream.
The https_google upstream will re-resolve itself and update the upstream
hosts used every 300s.
* Remove and add TODO
Adds a middleware to enable tracing with OpenTracing/OpenZipkin.
Enabling tracing will have a large impact on performance so it is
not advisable in production.
By defining and using an proxy.Exchanger interface we make the proxy
more generic and we can then fold back httproxy into proxy.
This overrides #463 and #473 and should make futures extensions rather
trivial
* Add docs that talk about `protocol` and how to set it.
* middleware/proxy: rename New to NewLookup
It's used as a Lookup mechanism not as a completely new proxy,
reflect that in the name.
* Set maxfails to 3 by default when looking up names.
Most of the changes have been copied
from https://github.com/johnbelamaric/coredns/pull/1/files
Add deadline to break the connection. We use the default of 5 seconds.
After this the backend is marked unhealthy and not used for some time.
Fixes#467
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.
This PR adds a middleware that talks to dns.google.com over HTTPS,
meaning all your DNS traffic is encrypted when traversing your ISP and
the internet.
The `dns.google.com` address is re-resolved every 30 seconds.
* middleware/proxy: config syntax cleanups
Allow port numbers to be used in the transfer statements and clean
up the proxy stanza parsing. Also allow, when specifying an upstream,
/etc/resolv.conf (or any other file) to be used for getting the upstream
nameserver.
Add tests and fix the documentation to make clear what is allowed.
* Fix the other upstream parse as well
* Add ServiceBackend interface
This adds a ServiceBackend interface that is shared between etcd/etcd3
(later) and kubernetes, leading to a massive reduction in code. When
returning the specific records from their backend.
Fixes#273
* 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