Commit Graph

483 Commits

Author SHA1 Message Date
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
Skinner, Alex
edd235088a Added TYPE65534 record type so that zone scanning doesn't die upon encountering one. Fixed DNSSEC signature verification. 2013-12-04 12:58:20 -05:00
Miek Gieben
9b8e8578e4 comment tweak 2013-11-10 18:41:55 +00:00
Miek Gieben
27263c64b1 gofmt 2013-10-19 21:41:13 +01:00
Miek Gieben
ff7806469c Implement EID and NIMLOC records 2013-10-19 21:31:12 +01:00
Miek Gieben
f569ea2f95 Allow "dns:-" tag in msg to mean dont pack this 2013-10-17 18:26:26 +01:00
Miek Gieben
b435d836c6 gofmt 2013-10-15 14:21:47 +00:00
Miek Gieben
35bcc78d76 Implement PX record 2013-10-13 13:23:02 +01:00
Miek Gieben
cc2c42cc91 Implement GPOS record 2013-10-13 13:01:33 +01:00
Miek Gieben
961e137891 Add NSAP and NSAP-PTR record 2013-10-13 12:25:08 +01:00
Miek Gieben
fc7a8472dc isnt used 2013-10-01 10:27:08 +00:00
Miek Gieben
67065da09c Fix the CAA type 2013-09-27 08:51:20 +00:00
Miek Gieben
4e6b3a5afc Check for the end of the message 2013-09-22 19:35:10 +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
9c1ee5d5ca Update IsDomainName
This new functions just compiles the domain to wire format, if that
works, the name is deemed OK. It is also much less strict than the
older code. Almost everything is allowed in the name, except two
dots back to back (there is an explicit test for that).
2013-09-10 18:09:22 +00:00
Miek Gieben
b6a2d1fb5e Allow empty rdata in records
Empty or no rdata is allowed for dynamic updates, so test if this
works for packing/unpacking. It only fails for TSIG (which is
never seen in zone files), SOA (which is not seen like this in dyn.
updates) and WKS (just an old record).
2013-08-31 20:24:52 +01:00
Miek Gieben
fdcdc6dbf6 Add test to zero rdata (for dyn updates)
This triggerd a bunch of failures, the most important one
is the packing and zero length domain name now works.
2013-08-26 21:11:24 -07:00
Miek Gieben
6ef2debe4e Add copy for an entire message, private for now 2013-08-23 22:53:05 +00:00
Miek Gieben
09d7d3e79d Some TODO updates 2013-06-29 09:50:43 +01:00
Miek Gieben
9fa50d8ac2 Fix the nsec/3 length calculation
This overshoots, 'cause it only counts the windows, not the
actual bitmap sizes in the window. But it keeps the code
simple and fast.
2013-06-27 20:19:02 +01:00
Miek Gieben
55aa4480c7 Fix some typos 2013-06-27 19:46:26 +01:00
Miek Gieben
61919d8713 Add all the compressible types to Len()
Len() now performs its duty, question is, *is* this now faster/better
than just packing a Msg, checkings its lenght and discarding the buffer.
2013-06-27 09:07:01 +00:00
Miek Gieben
1ad76fe65b Added packLen
packLen() returns the length of an uncompressed packet buffer, this
is used when packing a packet. This is needed for compression. When
compression is used, we first create the full packet and *then*
compress it. If we use Len() which accounts for compression, we can
get buffer overruns, when packing the (then still uncompressed) packet.
2013-06-26 22:18:09 +01:00
Miek Gieben
38ea608d79 Rename the Label* functions
SplitLabels -> SplitDomainName
CompareLabels -> CompareDomainName
LenLabels -> CountLabel
          -> NextLabel was added as a simple iterator-like function
2013-06-22 07:21:15 +00:00
Miek Gieben
a317648fa3 Add some more TODOs to Pack and kill the println
This closes #46 (for now :-) )
2013-06-20 07:28:51 +01:00
Miek Gieben
5f6228d4cc Use the non-exported version err 2013-06-20 07:27:28 +01:00
Miek Gieben
70f9c6b964 Make err non-exported 2013-06-20 07:25:29 +01:00
Miek Gieben
b697d25ed9 Remove unneed string conversion here 2013-06-14 11:38:04 +00:00
Miek Gieben
9ee7c27e18 Fix rawSetRdlength
When searching for the start of the rdata, the offset wasn't properly
calculated. This only impacted names with \DDD in it (weirdly enough).
2013-06-14 11:35:06 +00:00
Miek Gieben
3f348f173b \DDD to buf parsing fails (sometimes)
Added test (that fails for now)
2013-06-14 07:31:22 +01:00
Miek Gieben
c66494c6c5 Resolv merge conflicts 2013-05-12 19:08:37 +02:00
Miek Gieben
98b677a97c Update the copy right for the original GO files 2013-05-12 16:07:06 +02:00
Miek Gieben
320d981509 Add Algo-signal-draft impl. for EDNS0 2013-05-11 21:02:17 +02:00
Miek Gieben
ec9ac92fad Half the parsing of the EDNS LLQ package 2013-05-08 23:03:02 +02:00
Miek Gieben
6ecde82c20 Remove UPDATE_LEASE to UL
The "other" edns0 option will then become LONG_LIVED_QUERIES which
is way to long to be practical, so I want to make it LLQ, UPDATE_LEASE
then needs to be come UL.

This will probably impact no-one, because noone uses this (I hope)
2013-05-08 22:28:19 +02:00
Miek Gieben
709d11aa2c update documentation 2013-05-06 22:23:13 +02:00
Miek Gieben
d53d9eab81 gofmt 2013-05-05 20:30:44 +02:00
Miek Gieben
495b7d6552 Add UID/GID/UINFO record 2013-04-30 16:42:04 +02:00
Miek Gieben
8285ae4e56 add uinfo uid gid and unspec rr type number 2013-04-30 15:20:01 +02:00
Miek Gieben
cb4c191bd3 more docs 2013-04-27 17:12:22 +01:00
Miek Gieben
8d0b1a32cf Add the code, but does fit in the map anymore 2013-04-27 17:02:28 +01:00
Miek Gieben
d075d4cad1 update readme 2013-04-27 16:57:33 +01:00
Miek Gieben
f43b7368bd Add tests for EUIxx 2013-04-16 08:41:35 +01:00
Miek Gieben
ba6c414fe4 Return an error when packStruct fails
When doing the recursion be sure to catch the error that
might be generated.

Reported-by: madotsuki
2013-03-18 17:56:48 +00:00
Miek Gieben
99d23ee4a7 docs 2013-03-01 09:12:43 +01:00
Miek Gieben
ed28992106 Merge branch 'master' of github.com:miekg/dns 2013-02-09 08:36:28 +01:00
Miek Gieben
cd10853288 Make Len() and Copy() private
I don't think anybody will needs these, msg.Len() is still
available. Severly cuts back on the amount of exported functions.
2013-02-09 08:35:17 +01:00
Miek Gieben
8adb7c519c Flag bad rdlength as an error 2013-02-08 16:39:21 +01:00
Miek Gieben
ababac6b57 Exclude msg.Compress from json 2013-01-24 20:46:07 +01:00
Miek Gieben
951af98c7e fix multiple edns0 option code 2013-01-22 16:41:41 +01:00
Miek Gieben
81c44fbac6 Grree, typo 2013-01-20 18:16:47 +01:00
Miek Gieben
e66c2a1324 m.Size isnt used 2012-12-14 13:33:24 +01:00
Miek Gieben
9147aad21e need to add test for dynamic updates 2012-12-09 21:17:16 +01:00
Miek Gieben
29fa0ac7c0 unpack: allow for multiple edns0 options 2012-12-09 21:11:15 +01:00
Miek Gieben
9705bb8077 gofmt 2012-12-09 20:18:11 +01:00
Miek Gieben
f56b237012 Fix zonesigning branch 2012-12-09 20:16:46 +01:00
Miek Gieben
940b786161 Merge conflict resolution 2012-12-09 20:15:31 +01:00
Miek Gieben
7fb499889a Type rename 2012-12-09 20:11:56 +01:00
Miek Gieben
235e892dfc Rename the RR types drop the RR_ prefix
This is also done in the official Go library. It also make the
code shorter.
2012-12-09 19:23:25 +01:00
Miek Gieben
3609f3e7a5 gofmt -s 2012-12-09 19:07:31 +01:00
Miek Gieben
ff22456520 Also check when unpacking for domainnames > 255 2012-12-06 10:55:31 +01:00
Miek Gieben
4c6d89f727 PackDomainName: check for 255 or more octects
Adhire to the spec.
2012-12-06 10:48:55 +01:00
Miek Gieben
f732827187 Add new error and fmt it 2012-12-06 10:40:14 +01:00
Miek Gieben
d758825590 more documentation 2012-12-02 10:14:53 +01:00
Miek Gieben
2a3b818b95 Use much more descriptive names for the maps
Alg_str -> AlgorithmToString
 Rr_str  -> TypeToString

And for the reverse maps also.
2012-12-02 09:29:54 +01:00
Miek Gieben
db014f9891 remove NSEC3 errors 2012-12-02 09:21:38 +01:00
Miek Gieben
ac39024a25 gofmt 2012-11-21 23:20:56 +01:00
Miek Gieben
9e02a40cc8 Merge branch 'reader' 2012-11-21 22:32:23 +01:00
Miek Gieben
7bd7a65e4d Add CAA 2012-11-20 16:53:58 +01:00
Miek Gieben
67343920d5 Add CDS type 2012-11-20 16:52:18 +01:00
Miek Gieben
4737bfa319 Add the all important RKEY 2012-11-20 16:48:28 +01:00
Miek Gieben
3686d24ca7 Add NINFO record 2012-11-20 16:42:16 +01:00
Miek Gieben
f7956a96e6 ATMA 2012-11-20 14:32:06 +01:00
Miek Gieben
d34c05f4fc Add def. of SIDN RR 2012-11-20 14:14:00 +01:00
Miek Gieben
f6896bea4f Add X25 Resource Record 2012-11-20 14:07:16 +01:00
Miek Gieben
35744e52f8 semi add the NULL record 2012-11-20 13:53:41 +01:00
Miek Gieben
534b3ddfd8 Actually parse the uint64 as uint64, not as uint48 2012-11-19 12:30:42 +01:00
Miek Gieben
27de9bad36 Actually parse the whole uint64 2012-11-19 12:26:13 +01:00
Miek Gieben
4aea3d193b Add L32 record 2012-11-17 21:32:02 +01:00
Miek Gieben
0c3a90193a Add the NID record 2012-11-17 21:26:48 +01:00
Miek Gieben
bf85adb03e Fix \DDD printing and parsing 2012-11-15 14:26:08 +01:00
Miek Gieben
5cb0346b60 \DDD in PackDomain works
Unpacking does not insert \DDD yet
2012-11-15 13:51:15 +01:00
Alex Polvi
ec8d3d51d1 initial stab at edns update lease http://files.dns-sd.org/draft-sekar-dns-ul.txt 2012-10-15 18:37:19 +01:00
Miek Gieben
3c5c9da8be we already know the length of message 2012-10-11 13:06:27 +02:00
Miek Gieben
c5f0ecbdd8 in case of error do get the exact tag 2012-10-11 12:58:43 +02:00
Miek Gieben
6e43b3b666 Remove Tag.Get() and just look at the raw strings 2012-10-11 12:57:08 +02:00
Miek Gieben
506a4237e5 no nil checks 2012-10-10 21:00:47 +02:00
Miek Gieben
83b362dce6 optimization 2012-10-09 22:06:35 +02:00
Miek Gieben
d0d9c92612 fix typo 2012-10-09 22:01:57 +02:00
Miek Gieben
f38ce1b9b5 These non descriptive errors can go 2012-10-09 21:19:12 +02:00
Miek Gieben
570bf8dc69 Use proper error in packing and unpacking
All the relevant functions now return an error instead of
a simple boolean. This greatly approves the feedback to coders.

Spotted some fishy error handling along the way and fix that too.
2012-10-09 21:17:54 +02:00
Miek Gieben
099c19d5b2 Fix errors 2012-10-09 20:25:25 +02:00
Miek Gieben
4ebfc6b220 Merge branch 'v2' 2012-09-19 21:01:39 +02:00
Miek Gieben
3e1111c6b3 concurrent signing implementation 2012-09-12 21:22:28 +02:00
Miek Gieben
449c2c013d Rename ErrXfrSoa to ErrSOA 2012-09-12 21:13:57 +02:00
Miek Gieben
3a6edfa2c9 fmt 2012-09-10 20:51:19 +02:00
Miek Gieben
379cb2483a I dont think these need to be exported 2012-09-09 13:24:21 +02:00
Miek Gieben
e9ea2d7750 Fix more robust, but also nack more about non qualified names 2012-08-31 20:57:16 +02:00
Miek Gieben
7be4f3b18d comment out all println, no need to worry people with that 2012-08-31 10:23:50 +02:00
Miek Gieben
86b16ccd9e make PackDomainName faster by removing these ifs. also fix test 2012-08-30 16:45:11 +02:00
Miek Gieben
a2b2a604e2 dont panic, just return 2012-08-28 18:25:55 +02:00
Miek Gieben
e4fb00c34d Fix handling of non fully qualified domain names
When PackDomain sees such a name it calls panic.
All panic now use the prefix 'dns:'
2012-08-28 18:21:23 +02:00
Miek Gieben
468d937c8f much stricter memory allocation for msg
Only allocate what you need=+1 (just to be sure)
2012-08-26 22:29:48 +02:00
Miek Gieben
03af57964a Add a length that taks compression into account
Currently only ownername compression is done, but its a good
start.
2012-08-26 20:46:24 +02:00
Miek Gieben
7444d67bfd tweaks 2012-08-25 22:40:32 +02:00
Miek Gieben
2a391d079b fmt 2012-08-25 11:32:11 +02:00
Miek Gieben
845f4a6992 dont export - minimize api 2012-08-24 12:42:41 +02:00
Miek Gieben
6f7aad15d8 documenation 2012-08-21 17:36:58 +02:00
Miek Gieben
b0fc5a2f22 re-export these - I use them in unbound 2012-08-20 18:03:15 +02:00
Miek Gieben
7b406f80ce dont export 2012-08-17 08:34:46 +02:00
Miek Gieben
b1140cec5f dont export 2012-08-17 08:34:17 +02:00
Miek Gieben
73b6d37885 cleanup api, dont export Year68 2012-08-17 08:29:45 +02:00
Miek Gieben
a9126f1b54 Add RT type 2012-08-10 09:22:50 +02:00