diff options
author | 2017-03-13 20:24:37 +0000 | |
---|---|---|
committer | 2017-03-13 20:24:37 +0000 | |
commit | bfaf9e0aecc74d4e6897cdb9c6ef51b4b21ffd4e (patch) | |
tree | 1eb571726beee206742fa69d6d97ef80d6dcd48f /middleware/normalize.go | |
parent | 4985d698e2d1e7c8335bff3b39c1d593cf1f02e6 (diff) | |
download | coredns-bfaf9e0aecc74d4e6897cdb9c6ef51b4b21ffd4e.tar.gz coredns-bfaf9e0aecc74d4e6897cdb9c6ef51b4b21ffd4e.tar.zst coredns-bfaf9e0aecc74d4e6897cdb9c6ef51b4b21ffd4e.zip |
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
Diffstat (limited to 'middleware/normalize.go')
-rw-r--r-- | middleware/normalize.go | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/middleware/normalize.go b/middleware/normalize.go index 87f3ce703..77ef97993 100644 --- a/middleware/normalize.go +++ b/middleware/normalize.go @@ -7,6 +7,8 @@ import ( "github.com/miekg/dns" ) +// See core/dnsserver/address.go - we should unify these two impls. + // Zones respresents a lists of zone names. type Zones []string @@ -56,12 +58,24 @@ type ( ) // Normalize will return the host portion of host, stripping -// of any port. The host will also be fully qualified and lowercased. +// of any port or transport. The host will also be fully qualified and lowercased. func (h Host) Normalize() string { + + s := string(h) + + switch { + case strings.HasPrefix(s, TransportTLS+"://"): + s = s[len(TransportTLS+"://"):] + case strings.HasPrefix(s, TransportDNS+"://"): + s = s[len(TransportDNS+"://"):] + case strings.HasPrefix(s, TransportGRPC+"://"): + s = s[len(TransportGRPC+"://"):] + } + // separate host and port - host, _, err := net.SplitHostPort(string(h)) + host, _, err := net.SplitHostPort(s) if err != nil { - host, _, _ = net.SplitHostPort(string(h) + ":") + host, _, _ = net.SplitHostPort(s + ":") } return Name(host).Normalize() } @@ -77,3 +91,10 @@ func (a Addr) Normalize() string { // TODO(miek): lowercase it? return net.JoinHostPort(addr, port) } + +// Duplicated from core/dnsserver/address.go ! +const ( + TransportDNS = "dns" + TransportTLS = "tls" + TransportGRPC = "grpc" +) |