Commit Graph

3105 Commits

Author SHA1 Message Date
Miek Gieben 78d0037371 And add the new file... 2015-01-11 17:28:21 +00:00
Miek Gieben aaa3aba4ed Implement custom verbs for fmt.Printf use
The dns package implements String() for all RR types, but sometimes you will
need more flexibility. The functions Printf, Sprintf, etc. implemented formatted I/O
for the RR type.

Printing

The verbs:

Generic part of RRs:

     %N	the owner name of the RR
     %C	the class: IN, CH, CLASS15, etc.
     %D	the TTL in seconds
     %Y	the type: MX, A, etc.

The rdata of each RR differs, we allow each field to be printed as a string.

Rdata:

     %0	the first rdata field
     %1	the second rdata field
     %2	the third rdata field
     ..	...
     %9      the nineth rdata field
     %R	all rdata fields

The rdata fields remain a TODO, but will be implemented using
reflection.
2015-01-11 17:23:02 +00:00
Miek Gieben a07be6b2c1 Server: unlock when already started.
Closes #161
2015-01-11 09:26:00 +00:00
Miek Gieben 79f88fc5d7 fmt 2015-01-11 09:23:26 +00:00
Miek Gieben 5bde7ab7ea Put the zscan_test.go in parse_test.go 2015-01-11 09:20:04 +00:00
Miek Gieben 9af97127a9 Merge pull request #165 from xofyarg/master
add checks to prevent panic when parsing zone text.
2015-01-11 09:18:10 +00:00
anb 8ac429e4e8 add checks to prevent panic when parsing zone text. 2015-01-11 16:36:46 +08:00
Miek Gieben 8da60e45f5 Remove refs to IsMsg - we are not going to do this 2015-01-08 09:42:46 +00:00
Miek Gieben 3f504e8dab Merge pull request #160 from FiloSottile/fix_tcp_test_race
Tests: fix TestShutdownTCP race using NotifyStartedFunc
2014-12-17 14:02:00 +00:00
Filippo Valsorda 17a90cfd68 Tests: fix TestShutdownTCP race using NotifyStartedFunc 2014-12-17 13:46:50 +00:00
Miek Gieben 2c1a31d550 Small cleanup of the docs 2014-12-12 12:57:47 +00:00
Miek Gieben ab5f43b1a4 Merge pull request #159 from hlandauf/racefix
Add NotifyStartedFunc field to Server
2014-12-12 12:54:26 +00:00
Hugo Landau f039fd8203 Add NotifyStartedFunc field to Server
Adds a field, NotifyStartedFunc func() to Server.

If non-nil, it is called after a server starts listening. This is useful
for synchronization purposes, for example when a daemon needs to drop
privileges after binding. Otherwise, there is no way to determine when
the server has begun listening and hardcoded delays (!) must be used or
race conditions may occur.
2014-12-12 12:51:17 +00:00
Miek Gieben bb020c579e Merge pull request #158 from FiloSottile/loc_fixes
Add tests for LOC record String() generation and fix small problems
2014-12-10 14:06:03 +00:00
John Graham-Cumming 3e97ddb0e0 Add tests for LOC record String() generation and fix small problems
Added tests for the cmToM function to make sure that it's output is
correct. Modified the way the Altitude is written to a string. Previously,
if the altitude was an exact number of meters it would always be reported
with two decimal places. This is not needed. Conversely if it was not
an exact number of meters the cm were removed.
2014-12-10 13:39:58 +00:00
Miek Gieben 877e47b4c3 Merge pull request #157 from FiloSottile/intermittent_errors
Fix some intermittent errors
2014-12-09 15:37:00 +00:00
Filippo Valsorda e613ea6d07 Tests: silence a data race detected during server tests 2014-12-06 10:27:29 +00:00
Filippo Valsorda ddb0b0f565 Tests: wait for the server to be started before proceeding 2014-12-06 10:27:29 +00:00
Filippo Valsorda 0afbf1143c Extend the fixed-length int representation fixes to sig0.go 2014-12-06 10:27:27 +00:00
Filippo Valsorda c47471f80e [DNSSEC] Make int to bytes conversions fixed length in DSA (RFC 2536)
This fixes DSA key generation.
2014-12-06 10:26:56 +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
Filippo Valsorda bcc05715b3 Make some ECDSA failures more informative/accurate 2014-12-05 18:39:06 +00:00
Miek Gieben f01e44c2fd Merge pull request #156 from hlandauf/master
Remove extraneous spaces in String() methods
2014-11-28 20:47:24 +00:00
Hugo Landau d170819bc7 Remove extraneous spaces in String() methods
Some types append a space after Hdr.String(). However, since Hdr.String() appends its own space, this leads to the output of two spaces.
2014-11-28 19:12:16 +00:00
Miek Gieben cd2048a15a Add Unsafe member to dns.Server
This stops it from checking if the incoming requests have the QR bit
unset, so be careful when enabling this. This can be useful in
combination with mDNS.

Also the check for only 1 question in the question section is relaxed
to be "at least one", even without setting Unsafe!

Also update TestServingResponse to test for Unsafe vs not using Unsafe.
2014-11-19 16:34:18 +00:00
Miek Gieben 901b88b70a Merge pull request #155 from bboreham/small_fix
Remove duplicated test for UDPSize
2014-11-18 16:15:26 +00:00
Bryan Boreham 61478ac390 Removed duplicated test for UDPSize 2014-11-18 15:59:40 +00:00
Miek Gieben dc30c7cd4e Do test -short in travis as well 2014-11-12 10:29:33 +00:00
Miek Gieben 5fc7e36983 go test -short
Added a bunch a long running test function to the list of skipped
tests when giving -short to go test. Tests are bascially *all*
DNSSEC key generation tests and 1 serving test.

PASS
ok      github.com/miekg/dns    0.782s

Compared to 13+ s, so quite a bit faster.
2014-11-12 10:19:20 +00:00
Miek Gieben f3ed7c2b59 Merge pull request #154 from andrewtj/atj-update-misc
DNS Update Misc
2014-11-12 10:06:58 +00:00
Andrew Tunnell-Jones 022d2d4a01 Lose a loop in Msg.RemoveRRset() and use copyHeader()
Per @miekg's advice
2014-11-12 09:54:56 +00:00
Andrew Tunnell-Jones 104b206d2c Make RemoveRRset work as intended 2014-11-12 07:57:16 +00:00
Andrew Tunnell-Jones ffe24e63af Test that Msg.RemoveRRset() works as intended 2014-11-12 07:57:04 +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
Andrew Tunnell-Jones 414013f99f Add test covering unpacking 0-length rdatas 2014-11-12 07:46:11 +00:00
Miek Gieben 6e3a9dd0d8 Fix tsig fudge factor
Excellent bug report from freb, about how this fails when a message
arrives in the past (because of clock skew).

Closes #153
2014-11-11 17:58:12 +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 7619917e11 Add Test for dynamic unpack failure 2014-11-09 10:04:46 +00:00
Miek Gieben 20e762df62 And add testing 2014-11-09 09:57:06 +00:00
Miek Gieben a8bb44f5e5 Move tests and start update_test.go
Put the update tests in a seperate file.
2014-11-09 09:56:22 +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
Miek Gieben a829f4a296 Merge pull request #149 from DanielMorsing/unprintable
Reduce amount of work done when unpacking unprintable characters.
2014-11-06 13:58:16 +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
Miek Gieben d92b230e89 fix buffer overrun in unpack() 2014-11-04 20:17:43 +00:00
Miek Gieben 3a660df5ae Merge branch 'andrewtj-atj-sig0' 2014-11-03 11:04:36 +00:00
Miek Gieben 26e298191a Fix package header 2014-11-03 11:04:21 +00:00
Miek Gieben a34d1f6ad7 Merge branch 'master' of github.com:miekg/dns 2014-11-03 11:02:31 +00:00