aboutsummaryrefslogtreecommitdiff
path: root/middleware/proxy (follow)
AgeCommit message (Collapse)AuthorFilesLines
2017-03-01Grpc tracing (#544)Gravatar John Belamaric 4-5/+84
* 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
2017-02-22Golint (#548)Gravatar Miek Gieben 1-1/+1
* linter fixes * Golint and format code * fmt
2017-02-22Fix import path `github.com/miekg/coredns` -> `github.com/coredns/coredns` ↵Gravatar Yong Tang 11-18/+18
(#547) This fix fixes import path from `github.com/miekg/coredns` -> `github.com/coredns/coredns`
2017-02-15readme updates (#525)Gravatar Miek Gieben 1-37/+43
2017-02-14Client-side of gRPC proxy (#511)Gravatar John Belamaric 6-3/+353
* 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
2017-02-11La context (#521)Gravatar Miek Gieben 5-5/+10
* 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
2017-02-07Merge branch 'master' of github.com:miekg/corednsGravatar Miek Gieben 2-23/+27
2017-02-07middleware/proxy: sane(r) metricsGravatar Miek Gieben 3-7/+7
Add proxy_proto and re-instate proto to be the protocol of the incoming query ("tcp" or "udp").
2017-02-07And make it actually work (#508)Gravatar Miek Gieben 2-23/+27
2017-02-07middleware/proxy: fix except keyword (#505)Gravatar Miek Gieben 5-16/+43
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
2017-02-06middleware/proxy: absorb httpproxy (#481)Gravatar Miek Gieben 12-73/+470
* 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
2017-01-29Fix `go fmt`, `go lint`, and `go vet` issues (#494)Gravatar Yong Tang 1-1/+1
This fix fixes several `go fmt`, `go lint`, and `go vet` issues, to make goreportcard happy: https://goreportcard.com/report/github.com/miekg/coredns Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-01-23Add tracing option (#487)Gravatar John Belamaric 1-0/+12
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.
2017-01-23Fix panic caused by missing metric labels in proxy. (#492)Gravatar devnev 1-3/+3
2017-01-18middleware/proxy: drop protcol in metricGravatar Miek Gieben 2-5/+4
This blows up prometheus (panic in CoreDNS) and is not that handy to have.
2017-01-15middleware/proxy: implement Exchanger (#480)Gravatar Miek Gieben 9-34/+114
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-11middleware/proxy: add read/writeDeadline (#477)Gravatar Miek Gieben 2-3/+6
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
2016-12-20Add middleware.NextOrFailure (#462)Gravatar Miek Gieben 1-1/+1
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.
2016-11-26middleware/httpproxy: Add (#439)Gravatar Miek Gieben 1-1/+1
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.
2016-11-24middleware/proxy: config syntax cleanups (#435)Gravatar Miek Gieben 2-35/+9
* 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
2016-11-23Propagate both message and error in proxy exchange.Gravatar Mark Nevill 1-6/+2
2016-10-30ServiceBackend interface (#369)Gravatar Miek Gieben 1-2/+2
* 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
2016-10-28middleware/proxy: add request duration monitoring (#362)Gravatar Miek Gieben 4-0/+52
Add a separate request duration metrics specially for proxying requests upstream. Fixes #259
2016-10-27golintGravatar Miek Gieben 1-0/+1
2016-10-26middleware/metrics: cleanup (#355)Gravatar Miek Gieben 1-0/+2
* 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
2016-10-22Add option to parse resolv.conf for proxy upstreams (#353)Gravatar John Belamaric 3-4/+125
* Add option to parse resolv.conf for proxy upstreams * Add test and README update for resolv.conf proxy * Run gofmt
2016-10-12cleanups: go vet/golint (#331)Gravatar Miek Gieben 4-9/+9
Go vet and golint the new code once again. Drop Name from NameTemplate - it's cleaner: nametemplate.Template.
2016-10-10docs: rewrite using manpage style (#327)Gravatar Miek Gieben 1-18/+18
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-08middleware/proxy: make it scale (#287)Gravatar Miek Gieben 7-388/+120
* 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-09-23Golint middleware/proxy (#290)Gravatar Yong Tang 4-0/+6
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-23Golint2 (#280)Gravatar Miek Gieben 1-0/+1
* 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-19Cleanups and tests (#272)Gravatar Miek Gieben 1-1/+1
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-17Fix proxy upstream parser issue and add test cases (#263)Gravatar Yong Tang 3-3/+80
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-10Startup notification (#250)Gravatar Miek Gieben 1-1/+2
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-07Cleanup: put middleware helper functions in pkgs (#245)Gravatar Miek Gieben 2-10/+12
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-08-22Update README.mdGravatar cricketliu 1-6/+6
Grammatical fixes.
2016-08-19Make CoreDNS a server type plugin for Caddy (#220)Gravatar Miek Gieben 2-4/+31
* 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-14Fix TestStubLookup and TestLookup (#213)Gravatar Miek Gieben 3-7/+9
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-07-04middleware/proxy: healthchecks fixes (#183)Gravatar Miek Gieben 5-24/+33
* 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-06-14Spray to backend hosts when all are unhealthy (#171)Gravatar Miek Gieben 2-2/+24
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-08Suppress proxy error for truncated responses (#154)Gravatar pixelbender 1-0/+6
* suppress proxy error for truncated responses * Add proxy truncated error suppression for TCP too
2016-04-30middleware/proxy: multiple enhancements (#145)Gravatar Miek Gieben 6-57/+79
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-28Clean up remove caddy refs (#139)Gravatar Michael Richmond 1-1/+1
* 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-12Use dns.IsSubDomain (#112)Gravatar Miek Gieben 2-1/+4
For the match function use the proper thing from go dns. Fix all callers and tests to use this. Fixes: #107
2016-04-12Stub forward/proxy tests (#108)Gravatar Miek Gieben 1-1/+3
Test the handling of EDNS0 payloads and forwarding to stubzones servers.
2016-04-11All (non etcd) tests are now local (#105)Gravatar Miek Gieben 1-36/+0
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-11Rename middleware/testing (#103)Gravatar Miek Gieben 1-2/+2
Rename to test and name the toplevel tests dir to test for consitency.
2016-04-09correct EDNS responses (#96)Gravatar Miek Gieben 1-6/+3
Tests updated as well and all the middleware. And Prometheus renamed to metrics (directive is still prometheus).
2016-04-07Various cleanups and fixes (#88)Gravatar Miek Gieben 2-7/+19
Add port number to health check. Add tests the rewrite middleware. Fixes #36
2016-04-04Cache elements of StateGravatar Miek Gieben 1-1/+3
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.