Commit Graph

141 Commits

Author SHA1 Message Date
Tom Thorogood 11fb61cb84 Use copy instead of loop in EDNS0_SUBNET.unpack (#825) 2018-11-27 14:32:41 +00:00
chantra 1c9c9bf4c9 properly set extended rcode when packing (#791)
* properly set extended rcode when packing

When calling `SetExtendedRcode`, we expect to get the full extended
rcode, not the rcode after we shift 4 bytes right.

* fix extended rcode

* fix TestOPTTtl test

* set error messages in TestPackExtendedBadCookie

* Set Rcode with extended rcode

* |=

* Set extended RCODE field to 0 when RCODE is not an extended one.
+ unittests

* Force setting extended rcode if we have an OPT available.

* go fmt + @tmthrgd comments

* comments and nits

* reformat comment
2018-11-17 10:30:14 +10:30
Tom Thorogood c9b812d1d9 Remove redundant parenthesis (#727)
* Remove redundant parenthesis

These were caught with:
    gofmt -r '(a) -> a' -w *.go

This commit only includes the changes where the formatting makes the
ordering of operations clear.

* Remove more redundant parenthesis

These were caught with:
    gofmt -r '(a) -> a' -w *.go

This commit includes the remaining changes where the formatting does not
make the ordering of operations as clear as the previous commit.
2018-08-16 17:05:27 +01:00
Miek Gieben 0947afec0a
Revert 6f3c0a126c (#682)
Previous behavior was correct. Checking with coredns:

current:

~~~
; <<>> DiG 9.10.3-P4-Debian <<>> +norec +noad +edns=1 +noednsneg soa miek.nl @localhost -p 1043
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: ?256, id: 35480
;; flags: qr; QUERY: 0, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 0
;; Query time: 0 msec
;; SERVER: ::1#1043(::1)
;; WHEN: Sat May 19 16:42:54 BST 2018
;; MSG SIZE  rcvd: 23
~~~

this pr:

~~~
; <<>> DiG 9.10.3-P4-Debian <<>> +norec +noad +edns=1 +noednsneg soa miek.nl @localhost -p 1043
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: BADVERS, id: 25912
;; flags: qr; QUERY: 0, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 0
;; Query time: 0 msec
;; SERVER: ::1#1043(::1)
;; WHEN: Sat May 19 16:51:28 BST 2018
;; MSG SIZE  rcvd: 23
~~~
2018-05-21 20:47:30 +01:00
Miek Gieben e508eecd67
Some linter fixes from Go report card. (#601)
Implement small linter fixes.
2017-12-06 11:31:56 +00:00
Miek Gieben 6da3249dfb
EDNS0 client subnet: drop draft option (#589)
Noone should be using this option, it has been deprecated ever since
RFC 7178 came out: May 2016. Remove code that deals with that.
2017-11-28 07:48:19 +00:00
Miek Gieben 4bcc48899c
golint fixes (#553)
* golint fixes

Comment all RR with references to relevant RFC or other docs.
Some lint fixes in edns0.go.

* Some more fixes
2017-11-07 13:45:27 +00:00
andrewtj 145266a717 Make compress generate output stable and edns.go formatting (#542)
* make compress_generate.go produce stable output

* go fmt edns.go
2017-11-03 14:41:20 +00:00
Star Brilliant f218fef126 Fix EDNS0_SUBNET compatibility with dig (#530)
Do not complain about AddressFamily=0, if SubnetNetmask is also 0.

Fixes issue #529
2017-10-13 18:04:01 +02:00
Star Brilliant 6f3c0a126c Fix EDNS Extended RCODE (#517)
* Fix EDNS Extended RCODE

Issue #516

* Fix EDNS Extended RCODE

Issue #516
2017-10-13 17:21:46 +02:00
Roland Bracewell Shoemaker 689d334b01 Implement EDNS(0) Padding option code (#520)
* Implement EDNS(0) Padding option code

* Fix EDNS0_PADDING.String
2017-09-21 13:50:49 +01:00
Miek Gieben 5a15a35f5f Golint fixes (#456)
Fixes #370
2017-02-15 20:40:16 +00:00
Curtis Brandt ec20779724 Update GoDoc reference to EDNS0_SUBNET.SourceNetmask field. (#455) 2017-02-14 22:00:34 +00:00
Matthijs Mekking 4f8d08ab3c fix comment (#430) 2016-12-16 14:48:54 +00:00
ayanamist a8a1273f08 support rfc7828 (#402) 2016-11-21 20:15:42 +00:00
Shane Kerr b96e5025a3 Simple function to clear the DO bit from an OPT resource record. (#407)
* Function to clear the DO bit from an OPT RR.

* Tests for ClearDo() function.

* Changed from ClearDo() to SetDo() with an optional argument.

* Update doc string for SetDo(). Make tests for SetDo() comprehensive.
2016-10-05 09:08:39 +01:00
Miek Gieben e048e89b44 Extra doc for DNS Cookies 2016-06-11 09:37:01 +01:00
Michael Haro a465e84f54 Use encoding/binary's conversion functions when possible. (#364)
* Remove {un,}packUint{16,32}Msg functions.

unpackUint16Msg unpackUint32Msg packUint16Msg packUint32Msg implemented
functionality that is part of the encoding/binary package.

* Use encoding/binary's encoding in more places.
2016-06-08 16:38:42 +01:00
Miek Gieben 475ab80867 Remove (most) reflection
Remove the use of reflection when packing and unpacking, instead
generate all the pack and unpack functions using msg_generate.
This will generate zmsg.go which in turn calls the helper functions from
msg_helper.go.

This increases the speed by about ~30% while cutting back on memory
usage. Not all RRs are using it, but that will be rectified in upcoming
PR.

Most of the speed increase is in the header/question section parsing.
These functions *are* not generated, but straight forward enough. The
implementation can be found in msg.go.

The new code has been fuzzed by go-fuzz, which turned up some issues.

All files that started with 'z', and not autogenerated were renamed,
i.e. zscan.go is now scan.go.

Reflection is still used, in subsequent PRs it will be removed entirely.
2016-06-03 12:45:22 +01:00
Miek Gieben 4355939008 massage edns cookie comment 2016-05-03 15:22:17 +00:00
Shumon Huque b534177a1a small patch for EDNS0 cookie support (#350)
* Add EDNS0 Cookie (option 10) support.

* Add EDNS0 Cookie processing.

* Fix nits.

* Add EDNS0 cookie support mention.
2016-05-03 16:19:28 +01:00
McStork a5cc44dc6b set ExtendedRcode return type to int instead of uint8 (#347) 2016-04-18 17:40:15 +01:00
Miek Gieben 84206d880d Put the correct extended rcode in OPT
We were off by a value of 15. This fixes it. Hard to come up with a test
as writing and reading it yourself will be consistent.
Don't allows extended rcodes smaller than 16. And fix the tests as well.
2016-04-09 16:07:18 +01:00
Filippo Valsorda 25846488f9 Apply per-type code generation to .copy()
This fixes bugs in MB and CNAME.copy() (using sprintName for copying),
IPSECKEY (missed copyIP) and OPT (partially, Options was not copied as
slice; EDNS0 objects themselves are still pointers).
2015-10-07 05:51:36 +01:00
Filippo Valsorda d4a4e089d0 Generate programmatically per-type code, including .len()
This process probably fixes a bug in NSAPPTR.len(), after a similar one was
found in HINFO.len().

This should also make it easier to make changes to these functions, and
check their correctness.

Generate the code by running "go generate".
2015-10-07 05:48:12 +01:00
Miek Gieben 9bf52083d1 golint fixes 2015-08-23 08:03:13 +01:00
Filippo Valsorda 4a26a5bbbf EDNS0_SUBNET: refactor netmask handling
Added some more symmetric sanity checks when packing and unpacking, and
simplified the logic a bit, which should still remain mostly unchanged and
incomplete.  A complete implementation of the draft would require context
about whether it's a request or reply and possibly from the request
corresponding to the reply (!£$!@$!) so screw it.
2015-08-05 00:18:02 +01:00
Filippo Valsorda 155118a341 Reject a bad EDNS0_SUBNET family on unpack (not only on pack) 2015-08-05 00:18:02 +01:00
Harvo Jones 57d8407ad7 Changes applied:
* Renamed EDNS0_CUSTOM to EDNS0_LOCAL
* Added EDNS0LOCAL constants
* Added documentation
2015-03-18 12:12:53 -07:00
Harvo Jones 8bd3ac773f Add support for custom EDNS options in GoDNS.
A handful of EDNS options have been standardized, and they each have a type defined in GoDNS.  However there is currently no way a development team can use GoDNS with internally defined options, or with new options that may be proposed in the future.

This change solves the problem by giving users an EDNS0_CUSTOM type to allow clients to send, and servers to receive, custom EDNS options.
2015-03-17 10:41:55 -07:00
Miek Gieben 64fea017a2 Move all docs to docs.go
Another golint change.
2015-02-19 13:47:50 +00:00
Miek Gieben 67945c119e A bunch of golint fixes
The proposed vars names are a nono, because they break the API.
Things left: document each RR and zscan_rr.go has some funcky if-then-elses.
2015-02-19 09:58:33 +00:00
Miek Gieben d92b230e89 fix buffer overrun in unpack() 2014-11-04 20:17:43 +00:00
Miek Gieben 089554ccd1 Rename to ExtendedRcode and fix a comment 2014-10-08 14:29:46 +00:00
Filippo Valsorda 9088298b2b Add support for extended RCODEs and detect bad RCODEs 2014-09-26 12:18:36 +01:00
Filippo Valsorda 43fe5fb12c Fix the OPT RR Version get code and simplify DO get/set 2014-09-23 17:55:36 +01:00
Miek Gieben 0aa3021a83 Remove all copyright notices
Use the central COPYRIGHT file.
2014-09-11 20:57:37 +01:00
Catalin Patulea 009c72175f Update documentation references for EDNS0 and EDNS0_SUBNET.
Only EDNS0 is defined in RFC 6891 and EDNS0_SUBNET is actually just a draft.
2014-09-05 23:56:41 -04:00
Miek Gieben a71489b611 EDNS0: implement RFC 7314
Add the new option code.
2014-07-21 19:31:28 +01:00
Miek Gieben b0342e8757 Small extension of documentation 2014-06-29 10:36:59 +01:00
Miek Gieben dd90d7942b Add more EDNS0 options 2014-06-19 11:05:28 +00:00
Miek Gieben 0364de3abf Make EDNS0 unpack return error on failure
Report these errors upwards when unpacking a message.
2014-01-24 10:09:22 +00:00
Pieter de Boer e32b05768f Fix length overrun in EDNS0 parsing.
Original text: (in Dutch)

Ik kreeg crashes (index out of range) in het parsen van een EDNS0_LLQ
optie, doordat de method: 'func (e *EDNS0_LLQ) unpack(b []byte)' een
byte slice van 1 byte groot kreeg waar dan meerdere uint16's uit gelezen
werden.
2014-01-24 09:15:56 +00:00
Andrew Tunnell-Jones eb039fb959 Return bytes when packing EDNS0_LLQ struct 2013-12-14 10:52:44 +11:00
Miek Gieben 1c343223b5 Go over the documentation again 2013-10-15 13:42:24 +00:00
Miek Gieben b97b3340fb Make TSIG work again
Start fixing and using the UDP bufsize option.
2013-09-29 10:22:27 +01:00
Miek Gieben 007c0f06e4 Return as the last statement
Be compatible with older go releases.
2013-09-20 20:24:58 +01:00
Miek Gieben 6d02134e2d Doc update 2013-09-20 08:37:22 +01:00
Ask Bjørn Hansen 55c1f95213 Support the new RFC6891 EDNS0 SUBNET option code
Also keep support for the old draft code
2013-09-19 22:31:28 -07:00
Miek Gieben 5ae9b5214f more testing and concurrent server benchmarking 2013-06-22 08:55:30 +01:00