dns 1.4.3 → 1.4.4
raw patch · 4 files changed
+96/−2 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Network/DNS/Encode.hs +7/−1
- dns.cabal +1/−1
- test/DecodeSpec.hs +9/−0
- test/EncodeSpec.hs +79/−0
Network/DNS/Encode.hs view
@@ -127,7 +127,7 @@ (RD_DNAME dom) -> encodeDomain dom (RD_PTR dom) -> encodeDomain dom (RD_MX prf dom) -> mconcat [putInt16 prf, encodeDomain dom]- (RD_TXT txt) -> putByteString txt+ (RD_TXT txt) -> putByteStringWithLength txt (RD_OTH bytes) -> mconcat $ map putInt8 bytes (RD_SOA d1 d2 serial refresh retry expire min') -> mconcat [ encodeDomain d1@@ -144,6 +144,12 @@ , putInt16 port , encodeDomain dom ]++-- In the case of the TXT record, we need to put the string length+putByteStringWithLength :: BS.ByteString -> SPut+putByteStringWithLength bs =+ putInt8 (fromIntegral $ BS.length bs) -- put the length of the given string+ +++ putByteString bs ----------------------------------------------------------------
dns.cabal view
@@ -1,5 +1,5 @@ Name: dns-Version: 1.4.3+Version: 1.4.4 Author: Kazu Yamamoto <kazu@iij.ad.jp> Maintainer: Kazu Yamamoto <kazu@iij.ad.jp> License: BSD3
test/DecodeSpec.hs view
@@ -17,6 +17,9 @@ test_doublePointer :: BL.ByteString test_doublePointer = "f7eb8500000100010007000404736563330561706e696303636f6d0000010001c00c0001000100001c200004ca0c1c8cc0110002000100001c20000f036e73310561706e6963036e657400c0300002000100001c200006036e7333c040c0300002000100001c200006036e7334c040c0300002000100001c20001004736563310561706e696303636f6d00c0300002000100001c20001704736563310761757468646e730472697065036e657400c0300002000100001c20001004736563320561706e696303636f6d00c0300002000100001c2000070473656333c0bfc07b0001000100001c200004ca0c1d3bc07b001c000100001c20001020010dc02001000a4608000000000059c0ba0001000100001c200004ca0c1d3cc0d6001c000100001c20001020010dc0000100004777000000000140" +test_txt :: BL.ByteString+test_txt = "463181800001000100000000076e69636f6c6173046b766462076e647072696d6102696f0000100001c00c0010000100000e10000c6e69636f6c61732e6b766462"+ test_dname :: BL.ByteString test_dname = "b3c0818000010005000200010377777706376b616e616c02636f02696c0000010001c0100027000100000003000c0769737261656c3702727500c00c0005000100000003000603777777c02ec046000500010000255b0002c02ec02e000100010000003d000451daf938c02e000100010000003d0004c33ce84ac02e000200010005412b000c036e7332026137036f726700c02e000200010005412b0006036e7331c08a0000291000000000000000" @@ -32,6 +35,12 @@ x3 `shouldBe` x2 it "decodes dname" $ do let Right x1 = decode $ fromHexString test_dname+ Right x2 = decode (encode x1)+ Right x3 = decode (encode x2)+ print x1+ x3 `shouldBe` x2+ it "decodes txt" $ do+ let Right x1 = decode $ fromHexString test_txt Right x2 = decode (encode x1) Right x3 = decode (encode x2) print x1
test/EncodeSpec.hs view
@@ -14,12 +14,14 @@ check1 testQueryA check1 testQueryAAAA check1 testResponseA+ check1 testResponseTXT describe "decode" $ do it "decodes DNSFormat correctly" $ do check2 testQueryA check2 testQueryAAAA check2 testResponseA+ check2 testResponseTXT check1 :: DNSFormat -> Expectation check1 inp = out `shouldBe` Right inp@@ -133,6 +135,83 @@ , rrttl = 568 , rdlen = 4 , rdata = RD_A $ toIPv4 [119, 147, 15, 100]+ }+ ]+ , authority = [ ResourceRecord {+ rrname = "qzone.qq.com."+ , rrtype = NS+ , rrttl = 45919+ , rdlen = 10+ , rdata = RD_NS "ns-tel2.qq.com."+ }+ , ResourceRecord {+ rrname = "qzone.qq.com."+ , rrtype = NS+ , rrttl = 45919+ , rdlen = 10+ , rdata = RD_NS "ns-tel1.qq.com."+ }+ ]+ , additional = [ ResourceRecord {+ rrname = "ns-tel1.qq.com."+ , rrtype = A+ , rrttl = 46520+ , rdlen = 4+ , rdata = RD_A $ toIPv4 [121, 14, 73, 115]+ }+ , ResourceRecord {+ rrname = "ns-tel2.qq.com."+ , rrtype = A+ , rrttl = 2890+ , rdlen = 4+ , rdata = RD_A $ toIPv4 [222, 73, 76, 226]+ }+ , ResourceRecord {+ rrname = "ns-tel2.qq.com."+ , rrtype = A+ , rrttl = 2890+ , rdlen = 4+ , rdata = RD_A $ toIPv4 [183, 60, 3, 202]+ }+ , ResourceRecord {+ rrname = "ns-tel2.qq.com."+ , rrtype = A+ , rrttl = 2890+ , rdlen = 4+ , rdata = RD_A $ toIPv4 [218, 30, 72, 180]+ }+ ]+ }++testResponseTXT :: DNSFormat+testResponseTXT = DNSFormat {+ header = DNSHeader {+ identifier = 48724+ , flags = DNSFlags {+ qOrR = QR_Response+ , opcode = OP_STD+ , authAnswer = False+ , trunCation = False+ , recDesired = True+ , recAvailable = True+ , rcode = NoErr+ }+ , qdCount = 1+ , anCount = 1+ , nsCount = 2+ , arCount = 4+ }+ , question = [Question {+ qname = "492056364.qzone.qq.com."+ , qtype = TXT+ }+ ]+ , answer = [ResourceRecord {+ rrname = "492056364.qzone.qq.com."+ , rrtype = TXT+ , rrttl = 0+ , rdlen = 16+ , rdata = RD_TXT "simple txt line" } ] , authority = [ ResourceRecord {