Commit graph

27 commits

Author SHA1 Message Date
Ondřej Benkovský
c2dbb7141a
add golangci-lint linter (#5499) 2022-07-10 11:06:33 -07:00
Chris O'Haver
83adb8fa22
plugin/file/cache: Add metadata for wildcard record responses (#5308)
For responses synthesized by known wildcard records, publish metadata containing the wildcard record name

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2022-07-07 17:07:04 -04:00
xuweiwei
c1857f4889
plugin/file: unified NoData result (#5086)
Signed-off-by: xuweiwei <xuweiwei_yewu@cmss.chinamobile.com>
2022-04-25 12:05:24 -04:00
xuweiwei
1d3e901157
plugin/file: optimize cname get rr by type (#5080)
Signed-off-by: xuweiwei <xuweiwei_yewu@cmss.chinamobile.com>
2022-01-21 15:05:11 -08:00
Chris O'Haver
158ad2d738
plugin/file/auto: Write CNAME answer to client even if target lookup is SERVFAIL (#4863)
* write cname answer to client even if target lookup is servfail

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* fix existing unit test expectations

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2021-09-14 10:08:22 +02:00
Kohei Yoshida
5f6baf2973
plugin/file: fix wildcard CNAME answer (#4828)
* plugin/file: fix wildcard CNAME answer

Signed-off-by: Yoshida <ykhr53@yokohei.com>

* plugin/file: fix synthesized CNAME answer

Signed-off-by: Yoshida <ykhr53@yokohei.com>
2021-09-07 12:21:11 -07:00
Miek Gieben
163ac033ae
Revert "plugin/file: Fix in wrong answers returned when wildcard and concrete records exist (#4599)" (#4633)
reverting as I don't want to release 1.8.4 with this enabled.

This reverts commit fbf3f07f46.
2021-05-20 16:25:18 -04:00
Jason Du
fbf3f07f46
plugin/file: Fix in wrong answers returned when wildcard and concrete records exist (#4599)
* plugin/file: Fix in wrong answers returned when wildcard and concrete records exist

Signed-off-by: Jason Du <xdu@infoblox.com>

* Remove superfluous change

Signed-off-by: Jason Du <xdu@infoblox.com>

* Re-implementation and new test case
If the domain's terminal is neither the matching wildcard, nor a domian directly
under the wildcard, return NXDOMAIN

Signed-off-by: Jason Du <xdu@infoblox.com>

* Fix empty non-terminal & add test case

Signed-off-by: Jason Du <xdu@infoblox.com>

* Cleanup

Signed-off-by: Jason Du <xdu@infoblox.com>

* Fix case on domain name with character before * and add more test cases

Signed-off-by: Jason Du <xdu@infoblox.com>

* Use different IPs for records in cornerCasesWildcard zone file

Signed-off-by: Jason Du <xdu@infoblox.com>
2021-05-17 13:21:08 -07:00
Miek Gieben
60e1490ed6
copy rrs (#4416)
* Revert "make copies of RRs before returning them (#4409)"

This reverts commit 8b2ff6c388.

* Document copying responses

See #4409 and the comments. This documents that issue, but doesn't
change the in-tree plugins just yet.

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

* Update plugin.md

Co-authored-by: Chris O'Haver <cohaver@infoblox.com>

Co-authored-by: Chris O'Haver <cohaver@infoblox.com>
2021-01-28 16:50:35 +01:00
Chris O'Haver
8b2ff6c388
make copies of RRs before returning them (#4409)
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2021-01-21 09:59:58 +01:00
Miek Gieben
342eae9b4b
plugin/file: guard against cname loops (#4387)
Automatically submitted.
2021-01-15 18:26:04 +00:00
Chris O'Haver
6bbb48d403
plugin/file: Use NXDOMAIN response if CNAME target is NXDOMAIN (#4303)
* pass through nxdomain results

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* return srvfail and nodata results

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* add test

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* cover more response cases

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2020-12-09 09:44:31 +01:00
Miek Gieben
7aaed71b92
Fix query for SOA record for delegated zone (#3875)
Addresses a bug in the file plugin where SOA queries to zone delegations are
inappropriately returned the SOA for the delegating zone, and not a downward
referral to the delegated zone.

Here is an example of what I believe the expected downward referral in response
to a SOA query for a delegated zone should be (note that no SOA record is
returned):

~~~
; <<>> DiG 9.11.3-1ubuntu1.5-Ubuntu <<>> @k.root-servers.net. miek.nl. SOA
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 58381
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 3, ADDITIONAL: 7
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;miek.nl.                       IN      SOA

;; AUTHORITY SECTION:
nl.                     172800  IN      NS      ns1.dns.nl.
nl.                     172800  IN      NS      ns2.dns.nl.
nl.                     172800  IN      NS      ns3.dns.nl.

;; ADDITIONAL SECTION:
ns1.dns.nl.             172800  IN      A       194.0.28.53
ns2.dns.nl.             172800  IN      A       194.146.106.42
ns3.dns.nl.             172800  IN      A       194.0.25.24
ns1.dns.nl.             172800  IN      AAAA    2001:678:2c:0:194:0:28:53
ns2.dns.nl.             172800  IN      AAAA    2001:67c:1010:10::53
ns3.dns.nl.             172800  IN      AAAA    2001:678:20::24
~~~

See #3852 for the original fix.

Modified clouddns/route53 and removed the faulty tests there.

Signed-off-by: Miek Gieben <miek@miek.nl>
2020-05-11 07:51:02 -07:00
Uladzimir Trehubenka
7b69dfebb5 plugin/file: fix panic in miekg/dns.CompareDomainName() (#3337)
Signed-off-by: utrehubenka <utrehubenka@infoblox.com>
2019-10-01 13:22:42 +01:00
Chris O'Haver
3f47fc8ba4
typo fixes (#3169)
* spelling fixes

* its/it's
2019-08-21 16:08:55 -04:00
Miek Gieben
eba020e6a1
plugin/file: simplify locking (#3024)
* plugin/file: simplify locking

Simplify the locking, remove the reloadMu and just piggyback on the
other lock for accessing content, which assumes things can be move
underneath.

Copy the Apex and Zone to new vars to make sure the pointer isn't
updated from under us.

The releadMu isn't need at all, the time.Ticker firing while we're
reading means we will just miss that tick and get it on the next go.

Add rrutil subpackage and put some more generic functions in there, that
are now used from file and the tree package. This removes some
duplication.

Rename additionalProcessing that didn't actually do that to
externalLookup, because that's what being done at some point.

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

* Update plugin/file/lookup.go

Co-Authored-By: Michael Grosser <development@stp-ip.net>
2019-07-23 18:32:44 +00:00
Miek Gieben
1d5095cf67
plugin/file: Rename do to walk and cleanup and document (#2987)
* plugin/file: Rename do to walk, cleanup and document

* This renames Do to Walk to be more inline with Go standards. Also make
  it return an error instead of a bool.
  Also give give walk access to rrs. Alternatively e.m could be
  exported, but just access the map of rrs should work as well. Another
  alternative would be adding a whole bunch of helper functions, but
  those need grab and return the data. Just having access to the rrs
  should be easiest for most Walks.
* It adds Type and TypeForWildcard to show the different functions
* *Removes* the identical RR check when inserting; this was only done
  for A, AAAA and MX and not finished; removed under the mantra garbage
  in garbage out.
* Reuses Types to return all the types in an *tree.Elem

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

* better comments

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-07-18 17:44:47 +00:00
Miek Gieben
3a0c7c6153 plugin/file: load secondary zones lazily on startup (#2944)
This fixes a long standing bug:
fixes: #1609

Load secondary zones in a go-routine; this required another mutex to
protect some fields; I think those were needded anyway because a
transfer can also happen when we're running; we just didn't have a test
for that situation.

The test had to be changed to wait for the transfer to happen at this is
async now.

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-06-30 05:22:34 +08:00
Miek Gieben
53f3f0b666
Remove context.Context from request.Request (#2726)
* Remove context.Context from request.Request

This removes the context from request.Request and makes all the changes
in the code to make it compile again. It's all mechanical. It did
unearth some weirdness in that the context was kept in handler structs
which may cause havoc with concurrently handling of requests.

Fixes #2721

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

* Make test compile

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-03-26 14:37:30 +00: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
marqc
552aab723c Configurable zone reload interval in file plugin (#2110)
* Configurable zone reload interval in file plugin

* passing reload config from auto plugin to file plugin. removed noReload property from Zone struct. fixed tests based on short file reload hack
2018-09-29 16:50:49 +01:00
Miek Gieben
26c41a0c17
plugin/file: fix local CNAME lookup (#1866)
* plugin/file: fix local CNAME lookup

Issue #1864 explains it will, when we serve the child zone as well we
should just recursive into ourself (upstream self). Thus relax the
IsSubDomain check in file/lookup.go and just query (even if the query
will hit a remote server).

I've looped over all other plugins that do something similar (CNAME
resolving) and they didn't do the IsSubDomain check; therefor I've
removed it from *file* as well.

Added test in file_upstream_test that shows this failed before but now
results in a reply.

Fixes #1864

* self does not need to be exported

* Fix test

We don't know if we had a valid reply. Check this.
2018-06-12 14:54:37 +01:00
Chris O'Haver
ba573c0f40 plugin/auto/file/secondary: Use new upstream resolver (#1534)
* move file, auto, secondary to new upstream

* include context in request
2018-02-16 09:44:50 +01:00
Miek Gieben
5a7e440476
plugin/file: fix crash (#1301)
When z.Tree.Prev returns zero we should break out of this loop, not
use elem as if nothing has happened.

Can be triggered by sending edns0 to unsigned zone.
2017-12-11 14:32:51 +00:00
Miek Gieben
27da0eba04
plugin/file: Fix response for qtype=DS (#1300)
DS is peculiar and needs some special cases to do the right things.
For a direct query return the DS, but if we're hitting below the
delegation return the NS+DS in a delegation response.
2017-12-11 14:17:41 +00:00
Miek Gieben
6cd0050c09
file/plugin: if there is a delegation use that (#1299)
Don't put NS records in the answer section; if we see it is delegated
we should put the records in the AUTHORITY section.

This removes a special case, which is good.
2017-12-11 13:22:19 +00: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
Renamed from middleware/file/lookup.go (Browse further)