Commit Graph

395 Commits

Author SHA1 Message Date
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
Marek Majkowski 999a3ce301 Reduce number of memory allocations in msg.Copy
Right now we allocate memory even for empty slices. This is inefficient, sticking "nil" as a slice is good enough if there are no items.
2014-02-28 07:03:21 -08:00
Andrew Tunnell-Jones 3f834a04fb Update domain name and TXT string escape behaviour
Changes to domain name packing and unpacking:
* Escape dot, backslash, brackets, double-quote, semi-colon and space
* Tab, line feed and carriage return become \t, \n and \r

Changes to TXT string packing and unpacking:
* Escape backslash and double-quote
* Tab, line feed and carriage return become \t, \n and \r
* Other unprintables to \DDD

Stringers do the equivalent of putting domain names and TXT strings
to the wire and back.

There is some duplication of logic. I found performance suffered when
I broke the logic out into smaller functions. I think this may have
been due to functions not being inlined for various reasons.
2014-02-26 10:55:11 +00:00
Andrew Tunnell-Jones c500de0e7a Fix HIP record unpacking
* limit decoding of Hit to HitLength
* limit decoding of PublicKey to PublicKeyLength
* limit decoding of RendezvousServers to rdata's length
2014-02-22 05:28:48 +00:00
Andrew Tunnell-Jones 4bf3023c78 Handle label ending in an escaped dot in PackDomain 2014-02-15 00:40:53 +00:00
Miek Gieben 87b380cad5 Revert "Use dLen for domain name length"
This reverts commit b595183834.

Fix up the tests too.
2014-02-14 20:20:22 +00:00
Miek Gieben 89cc033428 Be much more precice in msg.Len()
There is still a one-off in EDNS0 records, but I'm not too bothered with
that one.
2014-02-12 12:59:42 +00:00
Miek Gieben 31102c38b7 Make Len() much more accurate for compressed messages.
Lots of changes made and bugs fixed.
2014-02-11 23:01:47 +00:00
Miek Gieben 8f334b52a0 Merge branch 'master' of github.com:miekg/dns 2014-02-10 15:31:20 +00:00
Miek Gieben 6293844a72 Check compression lengths 2014-02-10 12:43:38 +00:00
Miek Gieben 0cba5240c3 More tests lenght 2014-02-10 12:43:09 +00:00
Miek Gieben 56e0bb46d8 Remove packLen() and fix bug in Len()
packLen() was a featureless mirror of Len(). Remove it, and just use
Len() internally too.
Fix bug in Len() too, where the length of the additional section was
not counted.
2014-02-10 12:23:53 +00:00
Miek Gieben 5ecc38c003 Better docs 2014-02-06 10:32:38 +00:00
Miek Gieben 4f6fef6777 If the TC bit is set return a valid but smaller message
If the TC bit is set in a message, we will probably try to parse
half a message, which will fail. To fix this just return a message
header and the question section and don't parse the rest.
2014-02-05 21:47:26 +00:00
Miek Gieben 95fd782f44 Fix documentation for these public functions 2014-02-05 21:38:12 +00:00
Alex Ciuba 16d6ebe1c1 Use slice to build domain string 2014-02-01 01:29:00 -05:00
Miek Gieben 9ba617e870 Revert "Share the message buffer if we have room"
This reverts commit 17ce0cd52f.
2014-01-28 22:43:48 +00:00
Miek Gieben 27abc83e6a Merge pull request #80 from millerkil/optimize
A couple optimizations
2014-01-27 23:58:06 -08:00
Alex Ciuba 17ce0cd52f Share the message buffer if we have room 2014-01-27 19:45:45 -05:00
Miek Gieben 9c0ff1489b Merge branch 'master' of github.com:miekg/dns 2014-01-27 14:32:07 +00:00
Miek Gieben bb2ef9e3fc Add generic Copy function that copies RRs
Don't export all the copy() functions, instead add a Copy() function
that use the RR interface
2014-01-27 14:25:24 +00:00
Alex Ciuba b8262501a8 Minimize reflection calls 2014-01-26 16:14:32 -05:00
Alex Ciuba f73d400eb2 Reduce string allocations 2014-01-26 16:14:32 -05:00
Alex Ciuba 3768fa0083 Optimize compressionLenHelper 2014-01-25 21:09:28 -05: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
Miek Gieben ce360dab57 fmt 2014-01-12 10:22:04 +00:00
Miek Gieben 00a08d77fc PackBuffer: slight cleanup in docs 2014-01-12 10:21:23 +00:00
Miek Gieben 7f8964662e Merge branch 'majek/packwithbuffer' of https://github.com/majek/dns into bufpack 2014-01-12 10:17:35 +00:00
Miek Gieben a56060b558 Cleanups for Copy()
Docs and slight code formatting issues.
2014-01-12 10:04:38 +00:00
Marek Majkowski 2cfad667d7 msg.Copy() makes a deep-copy of the msg object
There was a copy function that did shallow copies of the msg
object. Export it and make it support proper deep copying.
2014-01-10 08:49:45 -08:00
Marek Majkowski d18d87b37d Introduce msg.PackBuffer() - it's like msg.Pack() but can reuse a byte buffer
msg.Pack() always allocates a byte slice. This is good for simplicity,
but in a serious application it's preferable to reuse byte slices to
reduce the GC overhead. This patch introduces a new public method:
PackBuffer(). It's exaclty like Pack() but is able to reuse a
given byte slice. It will still allocate a new slice if the given one
is too small.
2014-01-10 07:46:24 -08:00
Miek Gieben 9f5db7b72c Disable the unfinished CAA support
CAA was partially implemented, it's better to do it 100% until that
time handle CAA as an unknown record.

Closes #70:
2014-01-07 07:44:06 +00:00
Miek Gieben 7a27e05cb7 Remove setting compress to nil
Useless operation as compress is already nil from the
initialization.
2014-01-05 08:06:29 +00:00
soh335 e8a5f90957 if txt rdlength is 0, not read anymore 2014-01-04 17:30:08 +09:00
Miek Gieben 70ee966106 Fix the unknown record sign test
Don't make up new error in msg.Pack when there are perfectly fine
errors to return.
2013-12-06 09:43:26 +00:00
Miek Gieben ca52132cef reverse this until I have evidence it would be needed 2013-12-05 19:48:08 +00:00