Commit Graph

5 Commits

Author SHA1 Message Date
Brian Shea 034f791cf8
answer queries with no matching handler with RcodeRefused (#1151)
* answer queries with no matching handler with RcodeRefused

* update documentation

* mark HandleFailed deprecated

* add handleRefused and use it to answer requests matching no handler

* silence noise maker

Co-authored-by: Brian <brian@pop-os.localdomain>
2020-08-20 08:41:45 +02:00
Jan Včelák 524a80c35d
CanonicalName function to return domain name in canonical form (#1073)
* add Canonical function to get name in canonical form

* replace strings.ToLower with Canonical

* rename Canonical to CanonicalName

* replace Fqdn with CanonicalName in ServeMux
2020-03-18 11:21:59 +01:00
Tom Thorogood ba5bfd0295 Use strings.ToLower in ServeMux.match (#1010)
This has been a long standing TODO. golang.org/cl/137575 was included in
go1.12 which is the oldest officially supported release.
2019-09-21 08:50:53 +01:00
Tom Thorogood 068c7e7c81 Rework and optimise ServeMux (#754)
* Avoid using pointer to sync.RWMutex in ServeMux

* Initialize ServeMux.z only when needed.

This means the zero ServeMux is now valid and empty.

* Add benchmark for ServeMux.match

* Use strings.ToLower once in ServeMux.match

strings.ToLower has a special path for ASCII-only (which q always should
be), and avoids all allocations if the string is already lowercase
(which most DNS labels should be).

* Move NextLabel into for clause in ServeMux.match

* Make ServeMux.ServeDNS easier to read

* Fix the documentation of ServeMux.ServeDNS

* Invoke HandleFailed directly in ServeMux.ServeDNS

* Bail early in ServeMux.match if Handle never called

* Fix typo in ServeMux.match

* Improve documentation of ServeMux

This just splits the massive wall of text up so it's easier to follow.

* Fix typo in ServeMux.HandleRemove documentation

* Replace strings.ToLower with once-allocating version

strings.ToLower allocates twice for uppercase ASCII which causes an
overall regression for this changeset. By writing our own custom version
here we can avoid that allocation.

When https://go-review.googlesource.com/c/go/+/137575 lands in a go
release this can be removed.
2018-09-27 07:48:02 +01:00
Tom Thorogood 60d113313c Move ServeMux into seperate file (#753)
This reduces the clutter in server.go.
2018-09-26 10:20:48 +01:00