Commit graph

90 commits

Author SHA1 Message Date
John Belamaric
6d9d60081d Add option to parse resolv.conf for proxy upstreams (#353)
* Add option to parse resolv.conf for proxy upstreams

* Add test and README update for resolv.conf proxy

* Run gofmt
2016-10-22 15:52:10 +01:00
Miek Gieben
aa7744dc86 cleanups: go vet/golint (#331)
Go vet and golint the new code once again.

Drop Name from NameTemplate - it's cleaner: nametemplate.Template.
2016-10-12 12:46:35 +01:00
Miek Gieben
faf83b00dd docs: rewrite using manpage style (#327)
This still needs cleanup, but this is a first pass the cleans some
cruft and documents our style (in middleware.md) and makes all the
docs match that style.
2016-10-10 20:13:22 +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
Yong Tang
b9cf32f7a9 Golint middleware/proxy (#290)
While looking into the proxy middleware it appears that there are
several golint messages:
```
ubuntu@ubuntu:~/coredns$ golint middleware/proxy/
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
```

This fix addressed the above golint messages.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-09-23 23:00:50 +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
8555716046 Cleanups and tests (#272)
For some reasons there was a dnsserver/middleware.go that defined
the middleware handlers. This code was a repeat from
middleware/middleware.go. Removed dnsserver/middleware.go and replaced
all uses of dnsserver.Middleware with middleware.Middleware.

Added dnsserver/address_test.go to test the zone normalization (and to
improve the test coverage). The deleted file will also improve the test
coverage :)
2016-09-19 11:26:00 +01:00
Yong Tang
ed907d3327 Fix proxy upstream parser issue and add test cases (#263)
This fix tries to fix 261 where proxy upstream parser is not
able to parse upstream correctly.

Several test cases have also been added to cover the changes
and prevent regression in the future.

This fix fixes 261.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-09-17 07:49:35 +01:00
Miek Gieben
2dd8a687b3 Startup notification (#250)
Stop the caddy message and start our own init notifications.
Log the version of CoreDNS when starting up.
Fix all middleware's setup functions so that return the error prefixed
with *which* middleware was failing; leads to better debuggable errors
when starting up.
2016-09-10 09:16:25 +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
cricketliu
af6ebb7cd9 Update README.md
Grammatical fixes.
2016-08-22 14:33:40 -07: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
34ffb2b314 Fix TestStubLookup and TestLookup (#213)
Changes large parts of proxy lookup mechanism.

The duplicate zone checking erroneous added a nameserver for each
zone we are auth. for, creating to many backend hosts. So even when a
host was determined do be Down() we still got an (identical) new one
from the list.

The Down() and failure checking for upstream hosts had data race in the
uh.Fails check - we now use atomic.LoadInt32 for that.

Use and debug the test/server.go test servers implementation in the
TestStubLookup test to prevent going out to the internet.

Also delete the stub cycle test. That test was wrong and did not test
what it needed to be testing.  Deleted for now.
2016-08-14 12:57:49 -06:00
Miek Gieben
558c34a23e middleware/proxy: healthchecks fixes (#183)
* middleware/proxy: add spray keyword

When spray is used, the proxy will, when all backend are down, spray to
each target. When not used, default to the old defaults: max 1 failure
and no spray. These defaults are also used when forwarding queries to
another CoreDNS instance.

Update the README with the new keyword.

* typos

* Make MaxFail = 1 again

* more reversals
2016-07-04 21:13:28 +01:00
Miek Gieben
2fe42067fa Spray to backend hosts when all are unhealthy (#171)
When all backend hosts are unhealthy, randomly select one and use
that as a target.

This is to preempt the health checking itself failing.
2016-06-14 18:04:29 +01:00
pixelbender
3165084a7b Suppress proxy error for truncated responses (#154)
* suppress proxy error for truncated responses

* Add proxy truncated error suppression for TCP too
2016-06-08 10:22:52 +01:00
Miek Gieben
e635b4e773 middleware/proxy: multiple enhancements (#145)
Add port 53 in the proxy host if not specified.
Check if the host is actually an IP address (v4 or v6)
Remove the http headers and other TODOs
2016-04-30 15:54:41 +01:00
Michael Richmond
e34280e7af Clean up remove caddy refs (#139)
* Changed reference to Caddy over to CoreDNS

* Removing references to caddy

* Fixed misleading error message to reference coredns

* Cleaning up references to caddy

* Adding clean and deps targets

Muscle memory is resulting in "make clean" commands.

* Adding test target to makefile

* More "Caddy" cleanup
2016-04-28 19:07:44 +01:00
Miek Gieben
25cf16af0e Use dns.IsSubDomain (#112)
For the match function use the proper thing from go dns. Fix all
callers and tests to use this.

Fixes: #107
2016-04-12 22:34:44 +01:00
Miek Gieben
27ff83e70f Stub forward/proxy tests (#108)
Test the handling of EDNS0 payloads and forwarding to stubzones
servers.
2016-04-12 21:30:08 +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
Miek Gieben
4829b40efa Rename middleware/testing (#103)
Rename to test and name the toplevel tests dir to test for consitency.
2016-04-11 07:56:38 +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
efcb5cddbc Various cleanups and fixes (#88)
Add port number to health check. Add tests the rewrite

middleware.



Fixes #36
2016-04-07 17:42:35 +01:00
Miek Gieben
84dfdab584 Cache elements of State
Cache the size and the do bit whenever someone asked for it. We can

probably add more:



PASS

BenchmarkStateDo-4  	100000000	        11.9 ns/op

BenchmarkStateSize-4	 5000000	       265 ns/op

ok  	github.com/miekg/coredns/middleware	2.828s



PASS

BenchmarkStateDo-4  	1000000000	         2.86 ns/op

BenchmarkStateSize-4	500000000	         3.10 ns/op

ok  	github.com/miekg/coredns/middleware	5.032s



This PR also includes some testing cleanups as well.
2016-04-04 08:19:06 +01:00
Matt Layher
453a8a1982 middleware: change documentation filenames to README.md 2016-04-01 18:26:18 -04:00
Miek Gieben
5a919198ac Merge pull request #45 from miekg/etcd-stub
Etcd stub
2016-03-28 10:18:08 +01:00
Miek Gieben
ebef64280a Support SkyDNS' stubzones
This implements stubzones in the same way as SkyDNS. This
also works with multiple configured domains and has tests.
Also add more configuration parameters for TLS and path prefix and
enabling stubzones.  Run StubUpdates as a startup command to keep up to
date with the list in etcd.
2016-03-26 16:29:35 +00:00
Miek Gieben
90f73c50cf Add Scrub function
This function will make the message fit for the client's buffer, or
set the TC bit.
2016-03-26 09:26:54 +00:00
Miek Gieben
16e50ec5f8 Add state.SizeAndDo()
This methods returns an OPT record which can be used to create a new
message with the same bufsize and Do bit as the original one.
2016-03-25 17:23:06 +00:00
Miek Gieben
1a7f0deadd More cleanup - needs to think a little about NewSOA() 2016-03-22 10:29:48 +00:00
Miek Gieben
22dade9e12 It compiles; wont work obviously 2016-03-22 08:30:30 +00:00
Miek Gieben
e985af7870 some fixes 2016-03-21 21:22:23 +00:00
Miek Gieben
740178c83f more stuff; insight: use proxy for upstream queries 2016-03-21 21:21:29 +00:00
Miek Gieben
c3e951818f Update docs 2016-03-19 20:59:10 +00:00
Miek Gieben
47fca9a8fc Proxy cleanups
Remove things not supported, fix docs.
2016-03-19 20:53:37 +00:00
Miek Gieben
78432f78a9 Fix upstream tests 2016-03-19 16:11:30 +00:00
Miek Gieben
39dbd447b5 Fix middleware log 2016-03-19 11:16:08 +00: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