Commit Graph

35 Commits

Author SHA1 Message Date
Yong Tang
3342b414e3 plugin/cache: allow cache TTLs above default 3600s (#8134)
* plugin/cache: allow cache TTLs above default 3600s

This change allows the cache plugin to honor configured maximum TTL values above the default 3600s limit. Default behavior remains unchanged
This PR fixes 7846

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

* Keep MinimalTTL

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

---------

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2026-06-06 07:48:26 +03:00
Cedric Wang
3718f0cc81 dnsserver: use http.LocalAddrContextKey for DoH local address (#8149)
The DoH server resolved the per-connection local address in a custom
http.Server.ConnContext callback. ConnContext runs synchronously in the
http.Server accept loop, so calling c.LocalAddr() there is a problem when
the listener is proxyproto-wrapped: LocalAddr() triggers the PROXY-header
read, which blocks the accept loop until the header arrives and
head-of-line-blocks acceptance of every other connection.

net/http and http2 already populate http.LocalAddrContextKey from the
connection in the per-connection serving goroutine (net/http server.go,
http2 server_common.go / h2_bundle.go), resolved through the same
tls.Conn -> proxyproto.Conn chain. For a proxyproto connection that value
is the PROXY header's destination address -- byte-identical to what the
custom callback produced -- and it is set off the accept loop on both the
HTTP/1.1 and HTTP/2 paths.

Drop the custom ConnContext callback and the connKey type, and read
http.LocalAddrContextKey in localAddr() instead. The client address is
unaffected: it arrives via r.RemoteAddr, which the framework populates
natively.

Signed-off-by: zongqi-wang <wangzongqi@msn.com>
2026-06-05 18:31:53 -07:00
Yong Tang
c0e6e7cef3 core: Add full TSIG verification in DoH transport (#8013)
* core: Add full TSIG verification in DoH transport

This PR add full TSIG verification in DoH using dns.TsigVerify()
7943

---------

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2026-04-09 15:24:00 +03:00
Cedric Wang
03d0863a45 fix(doh): use per-connection local address for PROXY protocol (#8005) 2026-04-04 11:32:10 -07:00
Ville Vesilehto
6720959b8b lint(revive): fix unused-parameter violations (#7980) 2026-03-29 17:02:20 -07:00
Adphi
e9c0db32dc feat(proxyproto): add proxy protocol support (#7738)
Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
2026-02-10 17:14:05 -08:00
Ville Vesilehto
0d8cbb1a6b Merge commit from fork
Add configurable resource limits to prevent potential DoS vectors
via connection/stream exhaustion on gRPC, HTTPS, and HTTPS/3 servers.

New configuration plugins:
- grpc_server: configure max_streams, max_connections
- https: configure max_connections
- https3: configure max_streams

Changes:
- Use netutil.LimitListener for connection limiting
- Use gRPC MaxConcurrentStreams and message size limits
- Add QUIC MaxIncomingStreams for HTTPS/3 stream limiting
- Set secure defaults: 256 max streams, 200 max connections
- Setting any limit to 0 means unbounded/fallback to previous impl

Defaults are applied automatically when plugins are omitted from
config.

Includes tests and integration tests.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
2025-12-17 19:08:59 -08:00
Ilya Kulakov
c90e70339c dnsserver.Server: Export timeout values (#7497)
Plugins need access to timeout values that are actually used by
TCP dns.Server

Signed-off-by: Ilya Kulakov <kulakov.ilya@gmail.com>
2025-09-09 19:06:44 -07:00
Ville Vesilehto
abef207695 fix(https): propagate HTTP request context (#7491) 2025-09-02 14:33:16 -07:00
Ilya Kulakov
dc8f3b08e5 Improve caddy.GracefulServer conformance checks (#7416)
Signed-off-by: Ilya Kulakov <kulakov.ilya@gmail.com>
2025-08-05 11:34:20 -07:00
Johnny Bergström
909ce9386d core: set cache-control max-age as integer, not float (#6764)
As specified in rfc2616, the max-age is an integer.
Setting a float might make the header get ignored in some cases.
2024-10-24 15:20:19 -04:00
Rich
e7ad486b50 plugin/timeouts - Allow ability to configure listening server timeouts (#5784) 2022-12-28 12:14:16 +01:00
Chris O'Haver
b56b080a7c plugin/view: Advanced routing interface and new 'view' plugin (#5538)
* introduce new interface "dnsserver.Viewer", that allows a plugin implementing it to decide if a query should be routed into its server block.
* add new plugin "view", that uses the new interface to enable a user to define expression based conditions that must be met for a query to be routed to its server block.

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2022-09-08 14:56:27 -04:00
Ondřej Benkovský
c2dbb7141a add golangci-lint linter (#5499) 2022-07-10 11:06:33 -07:00
Ondřej Benkovský
d7f8202dc3 log DoH HTTP server error logs in CoreDNS format (#5457)
Signed-off-by: Ondřej Benkovský <ondrej.benkovsky@jamf.com>
2022-06-23 15:46:42 -04:00
Ondřej Benkovský
af4d84d915 plugin/trace: read trace context info from headers for DOH (#5439)
Signed-off-by: Ondřej Benkovský <ondrej.benkovsky@jamf.com>
2022-06-20 07:08:53 -07:00
Rudolf Schönecker
c121aaab34 Add metric counting DNS-over-HTTPS responses (#5130)
Signed-off-by: Rudolf Schonecker <rudolf.schonecker@jamf.com>
2022-02-17 08:37:40 -05:00
Ondřej Benkovský
b8439789f4 support plain HTTP for DoH (#4997)
Signed-off-by: Ondřej Benkovský <ondrej.benkovsky@jamf.com>
2021-11-23 14:03:26 +01:00
Johnny Bergström
fe2b5f630d doh: set http request in writer (#4445)
Makes it possible to read the current http request while serving DNS

Signed-off-by: Johnny Bergström <johnny@klaudify.se>
2021-02-17 20:45:04 +01:00
Miek Gieben
342eae9b4b plugin/file: guard against cname loops (#4387)
Automatically submitted.
2021-01-15 18:26:04 +00:00
Johnny Bergström
be955daa37 custom DoH request validation (#4329)
* custom DoH request validation

Signed-off-by: Johnny Bergström <johnny@klaudify.se>

* add comment and test

Signed-off-by: Johnny Bergström <johnny@klaudify.se>

* NewServerHTTPS comment typo

Signed-off-by: Johnny Bergström <johnny@klaudify.se>
2020-12-15 14:26:07 +01:00
Johnny Bergström
383cc2809b fix alpn for http/2 upgrade when using DoH (#4182)
Signed-off-by: Johnny Bergström <johnny@klaudify.se>
2020-10-06 15:38:12 +02:00
Miek Gieben
5235b35e3f doh support: make no TLS config fatal (#4162)
without TLS you can't have a functioning DoH server as no client will be
able to talk to it. Make this a fatal failure.

Add some extra docs on how to start a DoH capable server.

Signed-off-by: Miek Gieben <miek@miek.nl>
2020-09-30 17:17:24 +02:00
Miek Gieben
b003d06003 For caddy v1 in our org (#4018)
* For caddy v1 in our org

This RP changes all imports for caddyserver/caddy to coredns/caddy. This
is the v1 code of caddy.

For the coredns/caddy repo the following changes have been made:

* anything not needed by us is deleted
* all `telemetry` stuff is deleted
* all its import paths are also changed to point to coredns/caddy
* the v1 branch has been moved to the master branch
* a v1.1.0 tag has been added to signal the latest release

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

* Fix imports

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

* Group coredns/caddy with out plugins

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

* remove this file

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

* Relax import ordering

github.com/coredns is now also a coredns dep, this makes
github.com/coredns/caddy fit more natural in the list.

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

* Fix final import

Signed-off-by: Miek Gieben <miek@miek.nl>
2020-09-24 18:14:41 +02:00
Hu Shuai
e233f59ee8 Fix some typos in comments. (#4100)
Signed-off-by: Hu Shuai <hus.fnst@cn.fujitsu.com>
2020-09-01 09:10:45 +02:00
milgradesec
418c24c062 Add timeouts for http server (#3920)
Signed-off-by: milgradesec <milgradesec@gmail.com>
2020-07-02 16:07:29 +02:00
Zou Nengren
a74a209129 validate object implements the corresponding interface (#3724)
Signed-off-by: zouyee <zounengren@cmss.chinamobile.com>
2020-03-06 09:25:07 +01:00
Miek Gieben
e14e053d3d create pkg/reuseport (#3455)
* create pkg/reuseport

Move the core server listening functions to a new package so plugins can
use them.

Also make *all* servers use the functions here; as only the udp/tcp
listeners where using SO_REUSEPORT (if available). This is the only
actual change in this PR; in it's core it's just a move of 2 files.

This can also be used to cleanup the dance we're doing now for
re-acquiring the sockets in e.g. the metrics plugins and the ready
plugin.

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

* Also push a small doc update

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-11-16 18:02:46 -08:00
Guangming Wang
081e45afa3 cleanup: remove redundant return statement (#3297)
Signed-off-by: Guangming Wang <guangming.wang@daocloud.io>
2019-09-23 14:40:14 +01:00
Andrey Meshkov
aebbc4883d Add server instance to the context in ServerTLS and ServerHTTPS (#2840)
* Add server instance to the context in ServerTLS and ServerHTTPS

The problem with the current code is that there's no way to get the server instance inside a plugin.
Because of that "metrics" plugin sets empty "server" label for requests served over TLS or HTTPS.

* use s.Server instead of s

* Added server to the context of grpc requests
2019-05-27 15:52:47 +01:00
Andrey Meshkov
2b6fb578c3 DoH: Fixing panic in case if there's no response (#2577)
* Fixing panic in case if there's no response

There could be a situation when there's no response after ServeDNS call. With the current implementation, this leads to panic.

* Add comment
2019-02-25 16:16:17 +00:00
Miek Gieben
c349446a23 Cleanup ParseHostOrFile (#2100)
Create plugin/pkg/transport that holds the transport related functions.
This needed to be a new pkg to prevent cyclic import errors.

This cleans up a bunch of duplicated code in core/dnsserver that also
tried to parse a transport (now all done in transport.Parse).

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-09-19 07:29:37 +01:00
Miek Gieben
30a788fd3a Doh: put in pkg/doh (#1946)
* DoH: put in pkg/doh

Factor out the DoH stuff into its own package, add function to request
a DoH response. This can be used by forward (and maybe proxy) to
implement DoH client support.

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

* lint

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

* ... and make it compile

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-07-07 08:22:07 +01:00
Miek Gieben
dae506b563 Fix max-age in http server (#1890)
* Fix max-age in http server

Move the minMsgTTL to dnsutil and rename it MinimalTTL, move some
constants there as well.
Use these new function in server_https to correctly set the max-age
HTTP header.

Fixes: #1823

* Linter
2018-06-27 21:12:27 +01:00
Miek Gieben
0df5eb98fe Remove the hyphen from server-https (#1844)
We use "_" every where else.

(Might add presubmit to test for this)
2018-06-01 09:34:20 +01:00