Commit graph

26 commits

Author SHA1 Message Date
Ambrose Chua
ed1f42cf56
Fix mixed indentation within tests (#3855)
Signed-off-by: Ambrose Chua <ambrose@chua.family>
2020-04-25 08:08:36 +02:00
Miek Gieben
9c16ed1d14
Default to upstream to self (#2436)
* Default to upstream to self

This is a backwards incompatible change.

This is a massive (cleanup) PR where we default to resolving external
names by the coredns process itself, instead of directly forwarding them
to some upstream.

This ignores any arguments `upstream` may have had and makes it depend
on proxy/forward configuration in the Corefile. This allows resolved
upstream names to be cached and we have better healthchecking of the
upstreams. It also means there is only one way to resolve names, by
either using the proxy or forward plugin.

The proxy/forward lookup.go functions have been removed. This also
lessen the dependency on proxy, meaning deprecating proxy will become
easier. Some tests have been removed as well, or moved to the top-level
test directory as they now require a full coredns process instead of
just the plugin.

For the etcd plugin, the entire StubZone resolving is *dropped*! This
was a hacky (but working) solution to say the least. If someone cares
deeply it can be brought back (maybe)?

The pkg/upstream is now very small and almost does nothing. Also the
New() function was changed to return a pointer to upstream.Upstream. It
also returns only one parameter, so any stragglers using it will
encounter a compile error.

All documentation has been adapted. This affected the following plugins:
* etcd
* file
* auto
* secondary
* federation
* template
* route53

A followup PR will make any upstream directives with arguments an error,
right now they are ignored.

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

* Fix etcd build - probably still fails unit test

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

* Slightly smarter lookup check in upstream

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

* Compilez

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-01-13 16:54:49 +00:00
Miek Gieben
f3134da45e
Clean up tests logging (#1979)
* Clean up tests logging

This cleans up the travis logs so you can see the failures better.

Older tests in tests/ would call log.SetOutput(ioutil.Discard) in
a haphazard way. This add log.Discard and put an `init` function in each
package's dir (no way to do this globally). The cleanup in tests/ is
clear.

All plugins also got this init function to have some uniformity and kill
any (future) logging there in the tests as well.

There is a one-off in pkg/healthcheck because that does log.

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

* bring back original log_test.go

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

* suppress logging here as well

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-07-19 16:23:06 +01:00
Miek Gieben
4f0b36e57e
Extend presubmit to covert test and request (#1846)
Fix the casing *and* fix use of context as we were still referencing
the non-std lib context - no wondering how this could have worked...
2018-06-01 15:12:49 +01:00
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
f901b0cefa tests: CoreDNSServerAndPorts (#972)
* tests: CoreDNSServerAndPorts

Copy from kubernetes.go and renamed to fit the style, adapted almost
all callers.

This is a mechanicl change, no testdata was changed.

* typos
2017-08-24 11:35:14 +01:00
Miek Gieben
50ab28aa23 mw/file: rename to BenchmarkFileLookup (#741)
In grafana we miss the context of where this is called, make the name
more descriptive.

Also test the GH webhook.
2017-06-18 19:50:38 +01:00
Miek Gieben
5ac6020f45 Pr 586 tweaks (#594)
* 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
2017-03-14 21:32:21 +00:00
Miek Gieben
bfaf9e0aec 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
2017-03-13 20:24:37 +00:00
Miek Gieben
6966bce653 Fix resolving CNAME with no proxy (#564)
This fixes a crash when we resolve (or try to) an external CNAME
when no proxy is set.

Add test as well.
2017-03-02 19:35:44 +00: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
52e01264e8 middleware/proxy: implement Exchanger (#480)
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
2017-01-15 08:12:58 +00:00
Miek Gieben
94c59da577 Run tests in parallel (#478)
Create a small speedup running the tests:

PASS
ok  	github.com/miekg/coredns/test	10.329s

PASS
ok  	github.com/miekg/coredns/test	6.079s

Skip the etcd ones. Doing the middleware/*/*_test ones doesn't yield
any speedup as these are still done on a per directory basis.
2017-01-12 08:13:50 +00:00
Miek Gieben
e43384b501 middleware/file: proper support for wildcard (#323)
Add support for wildcard records, while taking care of wildcard-cnames
and DNSSEC. Add enough tests to check all the corner cases.
2016-10-08 15:22:31 +01:00
Miek Gieben
6cf14746ad small fix 2016-10-08 15:07:07 +01:00
Miek Gieben
a05901f62a middleware/proxy: make it scale (#287)
* middleware/proxy

Use connection pooling for communicating with an upstream, instead of
opening a new socket every time.

This makes the proxy more efficient and allowed for some cleanups.

* Some cleanups

* Some fixes

* more

* Kill pool

* Add nil check

* remove pool
2016-10-08 14:46:22 +01:00
Miek Gieben
4096c4906d Pr 311 2 (#312)
* Add a setup test for middleware/file

This fix adds a setup test for middleware/file so that there is
a basic coverage for the Corefile processing of middleware/file.

This fix is related to 308 (Will look into it).

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

* middleware/file: use helper function for test

Fixup setup_test.go and use the test.TempFile function to make things
somewhat shorter.

Use clean up the use of testing.T in TempFile - it is not used.
2016-10-02 15:58:01 +01:00
Miek Gieben
e54c232c8c middleware/cache: split cache in positive and negative and use lru (#298)
Make the cache memory bounded, by using a LRU cache. Also split the
cache in a positive and negative one - each with its own controls.

Extend the cache stanza to allow for this:

    cache {
       positive limit [ttl]
       negative limit [ttl]
    }

is now possible. This also add a cache_test.go in the toplevel test/
directory that exercises the caching path.

Fixes #260
2016-10-02 08:31:44 +01:00
Miek Gieben
5301c5af5f Run golint and go vet (#276)
Cleanup the errors and removed deadcode along the way. The leaves
some error laying around, mostly about commenting exported identifier.
We should look hard if those really are needed.
2016-09-21 17:01:19 +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
416603383d Cleanup and fixes (#223)
* Set version to 001
* Remove k8stest, test fails is k8s is not there: touch luck
* Remove server directory: not used anymore
* Disable k8s test (for now)
* gometalinter changes
2016-08-20 23:03:36 +01:00
Miek Gieben
9ac3cab1b7 Make CoreDNS a server type plugin for Caddy (#220)
* Make CoreDNS a server type plugin for Caddy

Remove code we don't need and port all middleware over. Fix all tests
and rework the documentation.

Also make `go generate` build a caddy binary which we then copy into
our directory. This means `go build`-builds remain working as-is.

And new etc instances in each etcd test for better isolation.
Fix more tests and rework test.Server with the newer support Caddy offers.

Fix Makefile to support new mode of operation.
2016-08-19 17:14:17 -07:00
Miek Gieben
b738d6e4e7 Fix issue 187: exit test (#188)
When not receiving a reply, exit the test and don't check the contents
of the unreceived packet.

Fixes #187
2016-07-07 20:04:25 +01:00
Miek Gieben
efd5135ee3 Some tiny changes and new benchmark test function (#136) 2016-04-26 20:45:29 +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
9f651a397b All (non etcd) tests are now local (#105)
We don't need to network to do tests, we up enough local servers
to we don't need to forward to,s say 8.8.8.8
2016-04-11 15:56:22 +01:00