* cidr everywhere: check all middleware
Add tests for cidr in only that middleware that already tests for this.
Check the other ones manually (and put reverse in the tests cases
anyway).
Make etcd setup_test run without +build etcd tag - it is not needed
for this test - move rest of the code to lookup_test.go.
Cleanup proxy test a bit and remove TempDir as there is test.TempFile
that does the same thing.
Fixes#909
* coredns package
* Fix test compile
* Switches out Unhealthy bool for OkUntil timestamp
* Make sure servers are healthy forever if there are no health checks
* Moves health check off into a go routine to avoid blocking conditions
* Improved logging info
* Fixes initial date
* Fixes health checking; alters tests to adapt to async health checking
* Moves future variable into static upstream and populates it in more places
* Restores silencing of stdout during testing
* Restores silencing of stdout during testing
* keeps check url string once built
* Removes debug message
* uses zero value to signal no checking; reduces in-mutex code to a fetch
Singleinflight interferes with the health checking of upstream. If an
upstream would fail, singleinflight would mirror that error to to other
proxy *iff* multple identical queries would be inflight. This would lead
to marking *all* upstreams as bad, essentially collapsing multiple
upstreams into a SPOF. Clearly not what we want.
Singleinflight does have some nice properties, but I've opted to rip it
out entirely. Caching should almost (but not quite) as good.
Added a test case in test that uses 3 CoreDNS instances to reflect the
setup from #715.
Found another bug as well, where (when the policy would be nil), we
would always Spray even though we've found a healthy host.
* Revert "middleware/proxy: Make Unhealthy a pointer (#615)"
This reverts commit acbf522ceb.
* middleware/proxy: add proper locking
This add the proper locking around `Unhealthy`.
Pointer updates are atomic so drop the sync.RWMutex as it is not needed
anymore. This also fixes the race introduced with dfc71df (although I
believe this is the first time we properly tested that code path).
* 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
* 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
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
* 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
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
* 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
* 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
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>
* 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.
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>
* 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.
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.
* 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