Commit graph

387 commits

Author SHA1 Message Date
Miek Gieben
a6b033a936 We dont support log rotation anymore 2016-10-18 07:03:51 +01:00
Yong Tang
7843a2bd91 Small golint cleanup. ()
A small golint cleanup.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-10-17 16:59:12 -07:00
Miek Gieben
d536272201 middleware/auto: add ()
Add auto-load middleware that automatically picks up zones.

Every X seconds it will scan for new zones.
Add tests and documentation.

Make 'make test' use -race.
2016-10-17 18:37:56 +01:00
Zhipeng JIANG
2eafe3ee94 Fix files reload failure within a single root zone. ()
In the file middleware, if there are multiple zone files under a single root zone, watchers are only invoked on the last element of `zones.Names`. This is caused by loop override on the variable `n`.

This issue can be fixed by passing zone object, which calls reload watcher directly.
2016-10-17 17:04:18 +01:00
Yong Tang
58387afd5d Replace go-cache with golang-lru in dnssec ()
* Replace go-cache with golang-lru

This fix replace go-cache with golang-lru, as is specified in 335.

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

* Move cache initialization to setup

This commit move cache initialization to setup in dnssec middleware.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-10-17 13:04:36 +01:00
Miek Gieben
03bc071774 Check for empty message in typify 2016-10-17 10:26:24 +00:00
Miek Gieben
be3c0195b6 middleware.md: put in the same doc
Move middleware/middleware.md to middleware.md. This should be the
canonical place where to document how middlewares should look and act.
2016-10-17 07:51:44 +01:00
Yong Tang
a69e88db62 Add needed comments for golint cleanup. ()
This fix adds several needed comments in
`middleware/kubernetes/nametemplate/nametemplate.go`
to clean up golint output.

There are still 3 places that needs proper docs:
```
middleware/kubernetes/nametemplate/nametemplate.go:64:1: comment on exported type Template should be of the form "Template ..." (with optional leading article)
middleware/kubernetes/nametemplate/nametemplate.go:72:1: comment on exported method Template.SetTemplate should be of the form "SetTemplate ..."
middleware/kubernetes/nametemplate/nametemplate.go:188:1: comment on exported type NameValues should be of the form "NameValues ..." (with optional leading article)
```

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-10-14 16:28:15 -07:00
Miek Gieben
aa7744dc86 cleanups: go vet/golint ()
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
710c9b111f middleware/root: add it ()
This PR adds the *root* middleware that specifies a path where
all zone file (the *file* middleware is the only consumer now) can
be found. It works the same as in Caddy.

Documentation can be found in the README.md of the middleware.

Fixes 
2016-10-11 20:42:28 +01:00
Yong Tang
baea5eef2f Add a unit test for DuplicateCNAME ()
This fix adds a unit test for DuplicateCNAME to have
a basic coverage for dnsutil.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-10-11 20:25:50 +01:00
Yong Tang
f3066b9463 Add unit tests for ExtractAddressFromReverse ()
This fix adds unit tests for `ExtractAddressFromReverse`. It also
updates the implementation of `ExtractAddressFromReverse` so that
only a valid IPv4 or IPv6 address (in string format) is returned.

If the addresses is not valid and can not be handled by golang's
`net.ParseIP` then an empty string (`""`) will be returned.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-10-11 09:48:15 +01:00
Miek Gieben
faf83b00dd docs: rewrite using manpage style ()
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
c22b7b2252 middleware/log: allows logging based on response classes ()
Add the ability to add a class of responses to be logged; success,
denial or error. The default is to log everything (all).

Fixes 
2016-10-10 12:09:29 +01:00
Miek Gieben
caa3976bfe middlewate/etc: fix test here as well
Make tests compile; failed to catch this due to use of tags for this
part of the (test) code.
2016-10-08 18:19:42 +01:00
Miek Gieben
99cd11c2d4 Add secondary test 2016-10-08 18:06:28 +01:00
Miek Gieben
e8b4412564 tests: clean up output
Some document improvements and add a few more tests.
2016-10-08 16:44:43 +01:00
Miek Gieben
e43384b501 middleware/file: proper support for wildcard ()
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
b44d82839f middleware/cache: rename categories ()
Rename: positive -> success
negative -> denial

There is a third (unused category) which is error. Start using these
new in the caching middleware and later in the logging middleware.
2016-10-08 15:12:28 +01:00
Miek Gieben
6cf14746ad small fix 2016-10-08 15:07:07 +01:00
Miek Gieben
a05901f62a middleware/proxy: make it scale ()
* 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
f29f622ec7 Use dns.port argument as default
Make DefaultPort just be 53. And use the value of Port to make the zone
stanzas complete (instead of defaulting to 53 always). This allows you
to override the port with dns.port.
2016-10-07 10:16:28 +00:00
Miek Gieben
ea98429512 kubernetes: hide contrib ()
This is purely travis (and maybe local testing). Does not warrent (IMHO)
a contrib/ directory. Hide it in a .travis directory.
2016-10-05 16:17:52 +01:00
Miek Gieben
db6c9a3f01 middleware/metrics: fix crash on startup ()
Make the methods that handle Metrics all use pointer receivers to fix
sync.Once not being initialized.

Finish the setup_test to test for failures. And make the check for the
address more strict and return an error when it does not have a port
number.

Add a toplevel test that starts a CoreDNS server with metrics enabled
so we catch these errors in the future.
2016-10-04 11:05:04 +01:00
Yong Tang
d914832904 Fix a typo ()
This fix fixes a typo in middle/cache/README.md:
`1 hours` => `1 hour`

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-10-03 07:21:24 +01:00
Miek Gieben
cc486fb900 middleware/file: transfer from does not make sense ()
Make it return an error when you use `transfer from` when you're
not a secondary.

Add tests as well.

Fixes 
2016-10-02 19:41:00 +01:00
Miek Gieben
560f11d148 EDNS0 unknown flags handling ()
Fix the unknown flags handling when receiving such message. We should
zero out all of the Z bits in the OPT record before returning.

Current behavior:

    dig +norec +noad +ednsflags=0x80 soa miek.nl @deb.atoom.net
    ...
    ; EDNS: version: 0, flags:; MBZ: 0080 , udp: 4096

New:

    dig +norec +noad +ednsflags=0x80 soa miek.nl @localhost -p 2053
    ...
    ; EDNS: version: 0, flags:; udp: 4096

Take care no to overwrite the Do bit.

We still accept *all* EDNS option; I do not consider that a bug in
itself.

Fixes 
2016-10-02 17:23:25 +01:00
Miek Gieben
4096c4906d Pr 311 2 ()
* 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 ()
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 
2016-10-02 08:31:44 +01:00
Yong Tang
9b6b8d2762 Cleanup Makefile and .travis.yml ()
This fix updates .travis.yml and Makefile for several places:
- Remove unneeded `docker pull gcr.io/google_containers/hyperkube-amd64:v1.2.4` (only v1.3.7 was used)
- Use docker to deploy etcd (insteadof downloading etcd binary).
- Merge `make testk8s` and `make testk8s-setup` (no need to have multiple targets for a couple of tests)
- Set version of etcd and kubernetes in .travis.yml (so that it is easy to update new version in the future)

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-09-27 07:57:04 +08:00
Miek Gieben
77947fd51a middleware/etcd: add setup_test.go ()
Add tests for parsing etcd Corefile stanza. Discover a bug in the code,
fix that as well.
2016-09-26 14:43:38 +01:00
Yong Tang
6a7db541fa Move .coverage.sh to make coverage ()
This fix moves the content of `.coverage.sh` to the Makefile
and creates a target of `make coverage`. This cleans up as
there is really no need to have a redundant script for
simple coverage test.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-09-26 07:22:48 +01:00
Yong Tang
ed1a4eed2e Clean up .travis.yml and use go_import_path ()
This fix cleans up `.travis.yml` and use `go_import_path`
to replace the customerized script for go import path
(in case the build is from a forked repo).

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-09-26 07:22:07 +01:00
Miek Gieben
440e92465d Rename port to dns.port ()
Avoid clashing with other server types.
2016-09-25 19:19:15 +01:00
Miek Gieben
9b5c9df321 Don't register quiet flag in register.go ()
This clashes to Caddy, which also has its own quiet flag. Move stuff
around a bit, also to prevent cyclic imports.
2016-09-25 18:42:08 +01:00
Miek Gieben
de0fa53379 Doc: add package docs ()
* Doc: add package docs

Add short package level docs to make godoc looks nicer.
Add some badges to the README.

* correct url
2016-09-25 08:39:20 +01:00
Miek Gieben
edc867fe56 middleware/metrics: fix crash ()
Fix the crash and add `setup_test.go` to catch this in the future.

Fixes 
2016-09-24 22:47:38 +01:00
Miek Gieben
1ad02e8639 Makefile: remove generate ()
Fixes 
2016-09-24 22:47:30 +01:00
Silas Baronda
ec485a74d3 Nil SOA causes panic if we compare it to incoming SOA () 2016-09-24 15:51:20 +01:00
Chris O'Haver
15297c8e63 Add TLS support for k8s middleware ()
* Added TLS to k8s client

Added options for TLS kubernetes client connection.

* Fix k8s TLS config option parsing

Brings config option parsing for kubernetes TLS in line with recent changes.

* Put TLS config on one line

Put kubernetes tls config on one line to match style established in etcd tls config.

* Add tls option to README
2016-09-23 23:07:06 +01:00
Yong Tang
b9cf32f7a9 Golint middleware/proxy ()
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
Manuel Alejandro de Brito Fontes
0959b52e79 Merge pull request from aledbf/remove-k8s-else
Lint k8s middleware
2016-09-23 12:14:56 -03:00
Manuel de Brito Fontes
1810e21b9a Lint k8s middleware 2016-09-23 11:08:23 -03:00
Manuel Alejandro de Brito Fontes
7c105ee037 Merge pull request from aledbf/k8s-util
Refactoring of k8s helpers
2016-09-23 10:52:58 -03:00
Manuel de Brito Fontes
8e6257c51f Lister refactor 2016-09-23 10:23:11 -03:00
Manuel de Brito Fontes
6e0944eb98 Remove unused const block 2016-09-23 10:03:43 -03:00
Manuel de Brito Fontes
2b62384223 Refactoring of k8s helpers 2016-09-23 09:48:11 -03:00
Miek Gieben
090d1872e9 Golint2 ()
* 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
Manuel Alejandro de Brito Fontes
cacbb0e0b1 Merge pull request from aledbf/revert-k8s
Revert k8s changes
2016-09-22 09:27:29 -03:00
Manuel de Brito Fontes
3be9e58ddf Revert k8s changes 2016-09-22 08:29:50 -03:00