Commit Graph

430 Commits

Author SHA1 Message Date
Roland Shoemaker
259969e797 Better buffer size 2015-07-21 16:04:21 -07:00
Roland Shoemaker
3d5407e128 Fix CAA packing bug 2015-07-07 20:20:25 +01:00
Roland Shoemaker
52647ae7a7 Address miekg's comments 2015-06-18 19:17:02 -07:00
Roland Shoemaker
020002b9e0 Switch setCAA, CAA.String to presentation format, add various encoding helpers 2015-06-17 16:06:31 -07:00
Roland Shoemaker
522331911d Enable CAA parsing 2015-06-16 02:01:28 -07: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
Michael Haro
f1f17ffdbc Split Copy into Copy and CopyTo.
CopyTo allows bypassing allocating a new Msg to work towards less
allocation GC churn.
2015-02-23 23:11:31 -08:00
Miek Gieben
574544eb08 Documentation updates 2015-02-20 11:39:15 +00:00
Miek Gieben
faa311bf55 golint: more docs 2015-02-19 11:26:46 +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
Daniel Morsing
a4af4dd14e Used shared backing array for Msg.Copy
If you have a system with large amounts of copies, these slice
allocations start stacking up. Use a shared slice and then subslice
them with a cap limit so that append works properly.

Also, add a benchmark and test for Msg.Copy

Benchcmp:
benchmark         old ns/op     new ns/op     delta
BenchmarkCopy     1880          1672          -11.06%

benchmark         old allocs     new allocs     delta
BenchmarkCopy     13             11             -15.38%

benchmark         old bytes     new bytes     delta
BenchmarkCopy     528           528           +0.00%
2015-02-05 13:07:07 +00:00
Miek Gieben
b6ff23905a Finish implementing IPSECKEY
Remaining tests and unpack for IPSECKEY.
2015-01-25 12:24:39 +00:00
Miek Gieben
477cb4d3fa Implement IPSECKEY
IPSECKEY is kinda strange because it has a type selector which tells
what type a later rdata field has. The type can be a domainname, address
or v6 address. You sort of wish Go would have a union type for this, but
alas.
Currently this is implemented as:

	GatewayA    net.IP `dns:"a"`
	GatewayAAAA net.IP `dns:"aaaa"`
	GatewayName string `dns:"domain-name"`

In the IPSECKEY. Only one of these is active at any one time. When
parsing/packing and unpacking the value of GatewayType is checked
to see what to do.

Parsing from strings is also implemented properly and tested. The Unpack
function still needs work.
2015-01-25 10:58:30 +00:00
Filippo Valsorda
ed475ae9fa [DNSSEC] Make int to bytes conversions fixed length in ECDSA
ECDSA public keys consist of a single value, called "Q" in FIPS
  186-3.  In DNSSEC keys, Q is a simple bit string that represents the
  uncompressed form of a curve point, "x | y".

  The ECDSA signature is the combination of two non-negative integers,
  called "r" and "s" in FIPS 186-3.  The two integers, each of which is
  formatted as a simple octet string, are combined into a single longer
  octet string for DNSSEC as the concatenation "r | s".  (Conversion of
  the integers to bit strings is described in Section C.2 of FIPS
  186-3.)  For P-256, each integer MUST be encoded as 32 octets; for
  P-384, each integer MUST be encoded as 48 octets.
2014-12-05 20:17:11 +00:00
Filippo Valsorda
0f1b1184ae Rename and simplify packing helper functions 2014-12-05 19:27:44 +00:00
Andrew Tunnell-Jones
71436daebe Make TestDynamicUpdateZeroRdataUnpack pass
Straight up: took a guess and the tests pass.
2014-11-12 07:56:21 +00:00
Miek Gieben
34f43d398b Stop parsing when hitting rdlen
Stop parsing these records when we hit rdlen.
2014-11-09 16:17:06 +00:00
Miek Gieben
11bbb59419 Rename rdlen to lenrd
More in sync with lenmsg.
2014-11-09 16:16:41 +00:00
Miek Gieben
d33af8db79 Update test and gofmt 2014-11-09 16:09:49 +00:00
Miek Gieben
eff0e9354f Apply 433ab7b569 here too
The same Sprintf was used here, so this can be optimized as well.

Thanks to @andrewtj for the ping.
2014-11-09 08:03:03 +00:00
Daniel Morsing
433ab7b569 Reduce amount of work done when unpacking unprintable characters.
Instead of going through the fmt package, we can use append int,
which saves an allocation.

benchmark                                old ns/op     new ns/op     delta
BenchmarkUnpackDomainNameUnprintable     2147          506           -76.43%
2014-11-06 13:51:29 +00:00
Andrew Tunnell-Jones
91b8c69a22 Implement SIG(0) signing and verification
This is based on @miekg's sig0 branch. That branch diverged from master
and I didn't want to wander off on a rebase.

As implemented there's no allowance for multi-envelope (TCP) support.

TODO:

* unpackUint32() could be moved out and used elsewhere
* tests
* multi-envelope support (if useful)
2014-11-01 11:32:46 +00:00
Miek Gieben
6bbae6c6ea Add CDNSKEY support 2014-10-23 22:18:23 +01:00
Miek Gieben
467e368cc1 check for overflowing msg len when unpacking A
unclebadtouches catched this.

closes #141
2014-10-22 21:08:34 +01:00
Miek Gieben
3d0face066 Fixup tests 2014-10-08 14:35:23 +00:00
Miek Gieben
de954625b6 Add ErrExtendedRcode and fix up the callers 2014-10-08 14:31:28 +00:00
Filippo Valsorda
9088298b2b Add support for extended RCODEs and detect bad RCODEs 2014-09-26 12:18:36 +01:00
Miek Gieben
9c455b0214 PrivateRR: naming naming naming
Try to find better (=more in sync with the rest of the lib) naming. My
guess is that these are better, but YMMV.
2014-09-21 08:28:38 +01:00
Alex Sergeyev
fcf9302ae1 Changed logic to typeswitch and added comments.
And also added my name to contrib list as promised before.
2014-09-20 18:15:42 -04:00
Alex Sergeyev
8aab8c6fb2 Lots of renamed funcs and structures. More readability. 2014-09-20 18:07:36 -04:00
Alex Sergeyev
5b8552609c Added docstrings, tests and example for PrivateRRs.
(renamed CustomRR to PrivateRR)
2014-09-19 17:30:10 -04:00
Alex Sergeyev
7c507e7592 New functionality for adding private RRs to dns lib. 2014-09-19 17:28:53 -04:00
Miek Gieben
02dd474056 Dont export typeToRR (old rr_mk) 2014-09-16 07:31:20 +01:00
Miek Gieben
bcb640ccaf Make rr_mk public and call it TypeToRR 2014-09-16 07:15:06 +01:00
Miek Gieben
0aa3021a83 Remove all copyright notices
Use the central COPYRIGHT file.
2014-09-11 20:57:37 +01:00
Miek Gieben
8fecf17714 Check that off <= lenmsg
Defense in depth, this should happen, but it happens... So check
for it and return an error.

Maybe (there is no testcase) fixes #106
2014-08-23 07:43:00 +01:00
Miek Gieben
34f5a12bfc Don't crash on emtpy string in compressionLenSearch
Fixes #105
2014-08-22 08:46:24 +00:00
Miek Gieben
4d3dac9c36 Add the OPENPGPKEY RR. 2014-08-14 09:18:08 +01:00
Miek Gieben
4dd48338af documentation tweaks 2014-07-30 07:35:06 +01:00
Miek Gieben
1243dcbc89 Make Id a variable to points to id (renamed from Id())
This way the Id function can be overruled by clients to have
another implementation for the Id function:

To make it static: dns.Id = func() uint16 { return 1234 }
2014-07-30 07:17:13 +01:00
Miek Gieben
060e66250e Add IsMsg()
A quick validating function that checks if a buffer is a valid
DNS message.
The code is *far* from complete.
2014-05-18 09:02:00 +01:00
Andrew Tunnell-Jones
8772f9064c Make PackRR enforce RR data length limit
• Make rawSetRdlength return false if length would overflow
• Make PackRR assume rawSetRdlength returning false indicates an overflow
2014-04-29 05:03:01 +00:00
Miek Gieben
b7a8c14d7d Add dns.Name as a type
This can be used for printing names.
2014-04-23 21:06:17 +01:00
Miek Gieben
fcbb2e7a9a Check and better errors 2014-04-08 00:09:26 +01:00
Miek Gieben
abe6de223d Add some more checks 2014-04-05 08:06:49 +01:00
Miek Gieben
a211645d0a Also check for msg length 2014-04-04 19:43:39 +01:00
Miek Gieben
541776149c Merge pull request #85 from andrewtj/atj-encoding
Parsing and Stringer Changes
2014-03-02 16:48:46 +00:00
Andrew Tunnell-Jones
38d78bafe4 Escape @ when printing/unpacking domain names 2014-03-01 22:30:52 +00:00
Andrew Tunnell-Jones
3ba746b6ca Convention is Txt not TXT in msg.go function names 2014-03-01 22:25:24 +00:00