core: add more transports (#574)

* 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
This commit is contained in:
Miek Gieben
2017-03-13 20:24:37 +00:00
committed by GitHub
parent 4985d698e2
commit bfaf9e0aec
24 changed files with 570 additions and 50 deletions

View File

@@ -1,6 +1,8 @@
package dnsserver
import (
"crypto/tls"
"github.com/coredns/coredns/middleware"
"github.com/mholt/caddy"
@@ -21,8 +23,12 @@ type Config struct {
// First consumer is the file middleware to looks for zone files in this place.
Root string
// Server is the server that handles this config
Server *Server
// The transport we implement, normally just "dns" over TCP/UDP, but could be
// DNS-over-TLS or DNS-over-gRPC.
Transport string
// TLSConfig when listening for encrypted connections (gRPC, DNS-over-TLS).
TLSConfig *tls.Config
// Middleware stack.
Middleware []middleware.Middleware
@@ -50,7 +56,6 @@ func GetConfig(c *caddy.Controller) *Config {
// Note that this is order dependent and the order is defined in directives.go, i.e. if your middleware
// comes before the middleware you are checking; it will not be there (yet).
func GetMiddleware(c *caddy.Controller, name string) middleware.Handler {
// TODO(miek): calling the handler h(nil) should be a noop...
conf := GetConfig(c)
for _, h := range conf.Middleware {
x := h(nil)