hsdns 1.4.1 → 1.4.2
raw patch · 8 files changed
+354/−271 lines, 8 filesdep ~basedep ~containersdep ~networkPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base, containers, network
API changes (from Hackage documentation)
Files
- COPYING +0/−165
- COPYING.LESSER +165/−0
- README +0/−61
- example/adns-reverse-lookup.hs +60/−0
- example/adns-srv-test.hs +28/−0
- example/adns-test-and-traverse.hs +49/−0
- hsdns.cabal +52/−41
- prologue.txt +0/−4
− COPYING
@@ -1,165 +0,0 @@- GNU LESSER GENERAL PUBLIC LICENSE- Version 3, 29 June 2007-- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>- Everyone is permitted to copy and distribute verbatim copies- of this license document, but changing it is not allowed.--- This version of the GNU Lesser General Public License incorporates-the terms and conditions of version 3 of the GNU General Public-License, supplemented by the additional permissions listed below.-- 0. Additional Definitions. -- As used herein, "this License" refers to version 3 of the GNU Lesser-General Public License, and the "GNU GPL" refers to version 3 of the GNU-General Public License.-- "The Library" refers to a covered work governed by this License,-other than an Application or a Combined Work as defined below.-- An "Application" is any work that makes use of an interface provided-by the Library, but which is not otherwise based on the Library.-Defining a subclass of a class defined by the Library is deemed a mode-of using an interface provided by the Library.-- A "Combined Work" is a work produced by combining or linking an-Application with the Library. The particular version of the Library-with which the Combined Work was made is also called the "Linked-Version".-- The "Minimal Corresponding Source" for a Combined Work means the-Corresponding Source for the Combined Work, excluding any source code-for portions of the Combined Work that, considered in isolation, are-based on the Application, and not on the Linked Version.-- The "Corresponding Application Code" for a Combined Work means the-object code and/or source code for the Application, including any data-and utility programs needed for reproducing the Combined Work from the-Application, but excluding the System Libraries of the Combined Work.-- 1. Exception to Section 3 of the GNU GPL.-- You may convey a covered work under sections 3 and 4 of this License-without being bound by section 3 of the GNU GPL.-- 2. Conveying Modified Versions.-- If you modify a copy of the Library, and, in your modifications, a-facility refers to a function or data to be supplied by an Application-that uses the facility (other than as an argument passed when the-facility is invoked), then you may convey a copy of the modified-version:-- a) under this License, provided that you make a good faith effort to- ensure that, in the event an Application does not supply the- function or data, the facility still operates, and performs- whatever part of its purpose remains meaningful, or-- b) under the GNU GPL, with none of the additional permissions of- this License applicable to that copy.-- 3. Object Code Incorporating Material from Library Header Files.-- The object code form of an Application may incorporate material from-a header file that is part of the Library. You may convey such object-code under terms of your choice, provided that, if the incorporated-material is not limited to numerical parameters, data structure-layouts and accessors, or small macros, inline functions and templates-(ten or fewer lines in length), you do both of the following:-- a) Give prominent notice with each copy of the object code that the- Library is used in it and that the Library and its use are- covered by this License.-- b) Accompany the object code with a copy of the GNU GPL and this license- document.-- 4. Combined Works.-- You may convey a Combined Work under terms of your choice that,-taken together, effectively do not restrict modification of the-portions of the Library contained in the Combined Work and reverse-engineering for debugging such modifications, if you also do each of-the following:-- a) Give prominent notice with each copy of the Combined Work that- the Library is used in it and that the Library and its use are- covered by this License.-- b) Accompany the Combined Work with a copy of the GNU GPL and this license- document.-- c) For a Combined Work that displays copyright notices during- execution, include the copyright notice for the Library among- these notices, as well as a reference directing the user to the- copies of the GNU GPL and this license document.-- d) Do one of the following:-- 0) Convey the Minimal Corresponding Source under the terms of this- License, and the Corresponding Application Code in a form- suitable for, and under terms that permit, the user to- recombine or relink the Application with a modified version of- the Linked Version to produce a modified Combined Work, in the- manner specified by section 6 of the GNU GPL for conveying- Corresponding Source.-- 1) Use a suitable shared library mechanism for linking with the- Library. A suitable mechanism is one that (a) uses at run time- a copy of the Library already present on the user's computer- system, and (b) will operate properly with a modified version- of the Library that is interface-compatible with the Linked- Version. -- e) Provide Installation Information, but only if you would otherwise- be required to provide such information under section 6 of the- GNU GPL, and only to the extent that such information is- necessary to install and execute a modified version of the- Combined Work produced by recombining or relinking the- Application with a modified version of the Linked Version. (If- you use option 4d0, the Installation Information must accompany- the Minimal Corresponding Source and Corresponding Application- Code. If you use option 4d1, you must provide the Installation- Information in the manner specified by section 6 of the GNU GPL- for conveying Corresponding Source.)-- 5. Combined Libraries.-- You may place library facilities that are a work based on the-Library side by side in a single library together with other library-facilities that are not Applications and are not covered by this-License, and convey such a combined library under terms of your-choice, if you do both of the following:-- a) Accompany the combined library with a copy of the same work based- on the Library, uncombined with any other library facilities,- conveyed under the terms of this License.-- b) Give prominent notice with the combined library that part of it- is a work based on the Library, and explaining where to find the- accompanying uncombined form of the same work.-- 6. Revised Versions of the GNU Lesser General Public License.-- The Free Software Foundation may publish revised and/or new versions-of the GNU Lesser General Public License from time to time. Such new-versions will be similar in spirit to the present version, but may-differ in detail to address new problems or concerns.-- Each version is given a distinguishing version number. If the-Library as you received it specifies that a certain numbered version-of the GNU Lesser General Public License "or any later version"-applies to it, you have the option of following the terms and-conditions either of that published version or of any later version-published by the Free Software Foundation. If the Library as you-received it does not specify a version number of the GNU Lesser-General Public License, you may choose any version of the GNU Lesser-General Public License ever published by the Free Software Foundation.-- If the Library as you received it specifies that a proxy can decide-whether future versions of the GNU Lesser General Public License shall-apply, that proxy's public statement of acceptance of any version is-permanent authorization for you to choose that version for the-Library.
+ COPYING.LESSER view
@@ -0,0 +1,165 @@+ GNU LESSER GENERAL PUBLIC LICENSE+ Version 3, 29 June 2007++ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>+ Everyone is permitted to copy and distribute verbatim copies+ of this license document, but changing it is not allowed.+++ This version of the GNU Lesser General Public License incorporates+the terms and conditions of version 3 of the GNU General Public+License, supplemented by the additional permissions listed below.++ 0. Additional Definitions. ++ As used herein, "this License" refers to version 3 of the GNU Lesser+General Public License, and the "GNU GPL" refers to version 3 of the GNU+General Public License.++ "The Library" refers to a covered work governed by this License,+other than an Application or a Combined Work as defined below.++ An "Application" is any work that makes use of an interface provided+by the Library, but which is not otherwise based on the Library.+Defining a subclass of a class defined by the Library is deemed a mode+of using an interface provided by the Library.++ A "Combined Work" is a work produced by combining or linking an+Application with the Library. The particular version of the Library+with which the Combined Work was made is also called the "Linked+Version".++ The "Minimal Corresponding Source" for a Combined Work means the+Corresponding Source for the Combined Work, excluding any source code+for portions of the Combined Work that, considered in isolation, are+based on the Application, and not on the Linked Version.++ The "Corresponding Application Code" for a Combined Work means the+object code and/or source code for the Application, including any data+and utility programs needed for reproducing the Combined Work from the+Application, but excluding the System Libraries of the Combined Work.++ 1. Exception to Section 3 of the GNU GPL.++ You may convey a covered work under sections 3 and 4 of this License+without being bound by section 3 of the GNU GPL.++ 2. Conveying Modified Versions.++ If you modify a copy of the Library, and, in your modifications, a+facility refers to a function or data to be supplied by an Application+that uses the facility (other than as an argument passed when the+facility is invoked), then you may convey a copy of the modified+version:++ a) under this License, provided that you make a good faith effort to+ ensure that, in the event an Application does not supply the+ function or data, the facility still operates, and performs+ whatever part of its purpose remains meaningful, or++ b) under the GNU GPL, with none of the additional permissions of+ this License applicable to that copy.++ 3. Object Code Incorporating Material from Library Header Files.++ The object code form of an Application may incorporate material from+a header file that is part of the Library. You may convey such object+code under terms of your choice, provided that, if the incorporated+material is not limited to numerical parameters, data structure+layouts and accessors, or small macros, inline functions and templates+(ten or fewer lines in length), you do both of the following:++ a) Give prominent notice with each copy of the object code that the+ Library is used in it and that the Library and its use are+ covered by this License.++ b) Accompany the object code with a copy of the GNU GPL and this license+ document.++ 4. Combined Works.++ You may convey a Combined Work under terms of your choice that,+taken together, effectively do not restrict modification of the+portions of the Library contained in the Combined Work and reverse+engineering for debugging such modifications, if you also do each of+the following:++ a) Give prominent notice with each copy of the Combined Work that+ the Library is used in it and that the Library and its use are+ covered by this License.++ b) Accompany the Combined Work with a copy of the GNU GPL and this license+ document.++ c) For a Combined Work that displays copyright notices during+ execution, include the copyright notice for the Library among+ these notices, as well as a reference directing the user to the+ copies of the GNU GPL and this license document.++ d) Do one of the following:++ 0) Convey the Minimal Corresponding Source under the terms of this+ License, and the Corresponding Application Code in a form+ suitable for, and under terms that permit, the user to+ recombine or relink the Application with a modified version of+ the Linked Version to produce a modified Combined Work, in the+ manner specified by section 6 of the GNU GPL for conveying+ Corresponding Source.++ 1) Use a suitable shared library mechanism for linking with the+ Library. A suitable mechanism is one that (a) uses at run time+ a copy of the Library already present on the user's computer+ system, and (b) will operate properly with a modified version+ of the Library that is interface-compatible with the Linked+ Version. ++ e) Provide Installation Information, but only if you would otherwise+ be required to provide such information under section 6 of the+ GNU GPL, and only to the extent that such information is+ necessary to install and execute a modified version of the+ Combined Work produced by recombining or relinking the+ Application with a modified version of the Linked Version. (If+ you use option 4d0, the Installation Information must accompany+ the Minimal Corresponding Source and Corresponding Application+ Code. If you use option 4d1, you must provide the Installation+ Information in the manner specified by section 6 of the GNU GPL+ for conveying Corresponding Source.)++ 5. Combined Libraries.++ You may place library facilities that are a work based on the+Library side by side in a single library together with other library+facilities that are not Applications and are not covered by this+License, and convey such a combined library under terms of your+choice, if you do both of the following:++ a) Accompany the combined library with a copy of the same work based+ on the Library, uncombined with any other library facilities,+ conveyed under the terms of this License.++ b) Give prominent notice with the combined library that part of it+ is a work based on the Library, and explaining where to find the+ accompanying uncombined form of the same work.++ 6. Revised Versions of the GNU Lesser General Public License.++ The Free Software Foundation may publish revised and/or new versions+of the GNU Lesser General Public License from time to time. Such new+versions will be similar in spirit to the present version, but may+differ in detail to address new problems or concerns.++ Each version is given a distinguishing version number. If the+Library as you received it specifies that a certain numbered version+of the GNU Lesser General Public License "or any later version"+applies to it, you have the option of following the terms and+conditions either of that published version or of any later version+published by the Free Software Foundation. If the Library as you+received it does not specify a version number of the GNU Lesser+General Public License, you may choose any version of the GNU Lesser+General Public License ever published by the Free Software Foundation.++ If the Library as you received it specifies that a proxy can decide+whether future versions of the GNU Lesser General Public License shall+apply, that proxy's public statement of acceptance of any version is+permanent authorization for you to choose that version for the+Library.
− README
@@ -1,61 +0,0 @@-An asynchronous DNS resolver for Haskell_-=========================================--:Latest Release: hsdns-1.4.1.tar.gz_-:Darcs: darcs_ get http://cryp.to/hsdns/--Synopsis----------- This library provides an asynchronous DNS resolver on top of- the `GNU ADNS library`_. Not all options are supported, but A,- MX, and PTR lookups work nicely. Courtesy of Lutz Donnerhacke- <lutz@iks-jena.de>, there is also support for retrieving- generic RR types, CNAMEs, and for NSEC zone walking. The- library can be expected to work with fine ADNS 1.4 or later. It- might also work with version ADNS 1.3, but that hasn't been- tested.-- The example program adns-reverse-lookup.hs_ demonstrates how- the resolver is used. Given a list of host names on the command- line, it performs an A/PTR double-lookup and checks whether the- records are consistent. The output is printed in the order in- which the DNS responses arrive::-- $ ./adns-reverse-lookup xyz.example.org ecrc.de www.example.com www.cryp.to- OK: www.example.com <-> 208.77.188.166- ERR: xyz.example.org: cannot resolve A- FAIL: www.cryp.to -> 195.234.152.69 -> ["research.cryp.to"]- FAIL: ecrc.de -> 127.0.0.1 -> ["localhost"]--Documentation---------------- `Reference Documentation`_- Haddock-generated reference of all exported functions.--Copyleft----------- Copyright (c) 2008 Peter Simons <simons@cryp.to>. All rights- reserved. This software is released under the terms of the `GNU- Lesser General Public License- <http://www.gnu.org/licenses/lgpl.html>`_.---------------------------------------------------------------------`[Homepage] <http://cryp.to/>`_--.. _Haskell: http://haskell.org/--.. _Cabal: http://haskell.org/cabal/--.. _darcs: http://abridgegame.org/darcs/--.. _GNU ADNS library: http://www.chiark.greenend.org.uk/~ian/adns/--.. _Reference Documentation: docs/index.html--.. _hsdns-1.4.1.tar.gz: http://cryp.to/hsdns/hsdns-1.4.1.tar.gz--.. _adns-reverse-lookup.hs: example/adns-reverse-lookup.hs
+ example/adns-reverse-lookup.hs view
@@ -0,0 +1,60 @@+{-+ Resolve a bunch of hostnames' A records, then resolve those+ A-record's PTR records and check whether they match. Do it+ all asynchronously. The results are printed in the order the+ answers come in.++ TODO: handle hosts that have more than one A record+-}++module Main ( main ) where++import Control.Monad ( when, replicateM_ )+import Control.Concurrent ( forkIO )+import Control.Concurrent.Chan ( Chan, newChan, writeChan, readChan )+import System.Environment ( getArgs )+import Network.Socket ( inet_ntoa )+import Data.List ( elem )+import ADNS++data CheckResult+ = OK HostName HostAddress+ | NotOK HostName HostAddress [HostName]+ | DNSError String++printResult :: CheckResult -> IO ()+printResult (OK h a) = do addr <- inet_ntoa a+ putStrLn $ "OK: " ++ h ++ " <-> " ++ addr+printResult (NotOK h a h') = do addr <- inet_ntoa a+ putStrLn $ "FAIL: " ++ h ++ " -> " ++ addr ++ " -> " ++ show h'+printResult (DNSError msg) = putStrLn $ "ERR: " ++ msg++main :: IO ()+main = do+ names <- getArgs+ when (null names) (putStrLn "Usage: hostname [hostname ...]")+ initResolver [NoErrPrint, NoServerWarn] $ \resolver -> do+ rrChannel <- newChan :: IO (Chan CheckResult)+ mapM_ (\h -> forkIO (ptrCheck resolver rrChannel h)) names+ replicateM_ (length names) (readChan rrChannel >>= printResult)++ptrCheck :: Resolver -> Chan CheckResult -> HostName -> IO ()+ptrCheck resolver chan host = do+ let returnError t = writeChan chan (DNSError (host ++ ": cannot resolve " ++ t))+ a <- queryA resolver host+ case a of+ Just [addr] -> do+ ptr <- queryPTR resolver addr+ case ptr of+ Just names | host `elem` names -> writeChan chan (OK host addr)+ | otherwise -> writeChan chan (NotOK host addr names)+ _ -> returnError "PTR"+ _ -> returnError "A"++++-- ----- Configure Emacs -----+--+-- Local Variables: ***+-- haskell-program-name: "ghci -ladns" ***+-- End: ***
+ example/adns-srv-test.hs view
@@ -0,0 +1,28 @@+{-+ Resolve a hostnames' SRV records, then show it+-}++module Main ( main ) where++import Control.Monad ( when )+import System.Environment ( getArgs )+import Network.Socket ( inet_ntoa )+import Data.List ( elem )+import ADNS++main :: IO ()+main = do+ names <- getArgs+ when (null names) (putStrLn "Usage: hostname [hostname ...]")+ initResolver [Debug] $ \resolver -> do+ a <- querySRV resolver $ head names+ case a of+ Just addr -> do+ putStrLn $ "RESULT:\n" ++ (concat $ map (\b -> (fst b) ++ (show $ snd b) ++ "\n") addr)+ _ -> putStrLn $ "Error in SRV " ++ (show a)++-- ----- Configure Emacs -----+--+-- Local Variables: ***+-- haskell-program-name: "ghci -ladns" ***+-- End: ***
+ example/adns-test-and-traverse.hs view
@@ -0,0 +1,49 @@+module Main where++import ADNS+import ADNS.Base+import Control.Concurrent.MVar+import System.Environment++main :: IO ()+main = initResolver [NoErrPrint, NoServerWarn] $ \resolver -> do+ args <- getArgs+ case args of+ [name] -> traverse resolver name+ [t,name] -> work resolver (read t) name+ _ -> putStrLn "Usage: t [typeid] fqdn"++-- | Test function to see the raw results of a given query type+work :: Resolver -> RRType -> String -> IO ()+work resolver t n = do+ putStrLn $ showString "Querying " . shows t $ showString " for " n+ print =<< takeMVar =<< resolver n t [QuoteOk_Query]++-- | Example implementation to traverse a DNSSEC signed zone.+--+-- This implementation is clearly wrong, because any real zone traversal+-- is done using the NSEC records in the authority section of a NXDOMAIN+-- response.+--+-- Unfortunly the adns library does not provide access to other sections+-- than the answer section, so this walk is done by querying NSEC directly.+--+-- If there are signed subzones, the traversal switches to the subzone+-- and stops if this subzone is traversed. You may continue the traversal+-- by providing the next entry after the subzone.+--+-- You may try this mechanism on "dnssec.iks-jena.de"+traverse :: Resolver -> String -> IO ()+traverse resolver x = do+ putStrLn x+ answer <- takeMVar =<< resolver x NSEC [QuoteOk_Query]+ case rrs answer of+ [RRNSEC y] | not (x `endsWith` ('.':y)) -> traverse resolver y+ _ -> return ()++endsWith :: String -> String -> Bool+endsWith x y = startsWith (reverse x) (reverse y)++startsWith :: String -> String -> Bool+startsWith (x:xs) (y:ys) = x == y && startsWith xs ys+startsWith _ ys = null ys
hsdns.cabal view
@@ -1,47 +1,58 @@ Name: hsdns-Version: 1.4.1-Author: Peter Simons <simons@cryp.to>,- Lutz Donnerhacke <lutz@iks-jena.de>- Григорий Холомьёв <omever@gmail.com>-Maintainer: Peter Simons <simons@cryp.to>+Version: 1.4.2+Copyright: (c) 2004-2010 Peter Simons License: LGPL-License-File: COPYING-Homepage: http://cryp.to/hsdns/-Synopsis: Asynchronous DNS Resolver-Description: Asynchronous DNS Resolver; requires GNU ADNS to be installed.+License-File: COPYING.LESSER+Author: Peter Simons <simons@cryp.to>, Lutz Donnerhacke <lutz@iks-jena.de>, Григорий Холомьёв <omever@gmail.com>+Maintainer: Peter Simons <simons@cryp.to>+Homepage: http://gitorious.org/hsdns Category: Foreign, Network-Build-Depends: base >=3.0.0.0 && <4.2.0.0, network, containers-Extensions: ForeignFunctionInterface, EmptyDataDecls-Extra-Libraries: adns-Includes: "adns.h", "errno.h"-Exposed-Modules: ADNS,+Synopsis: Asynchronous DNS Resolver+Description: This library provides an asynchronous DNS resolver on top+ of GNU ADNS <http://www.chiark.greenend.org.uk/~ian/adns/>.+ Not all options are supported, but A, MX, and PTR lookups+ work nicely. There is also support for retrieving generic+ RR types, CNAMEs, and for NSEC zone walking. The library+ can be expected to work with fine ADNS 1.4 or later. It+ might also work with version ADNS 1.3, but that hasn’t+ been tested.+ .+ The example program adns-reverse-lookup.hs demonstrates+ how the resolver is used. Given a list of host names on+ the command line, it performs an A/PTR double-lookup and+ checks whether the records are consistent. The+ output is printed in the order in which the DNS responses+ arrive:+ .+ > $ ./adns-reverse-lookup xyz.example.org ecrc.de www.example.com www.cryp.to+ > OK: www.example.com <-> 208.77.188.166+ > ERR: xyz.example.org: cannot resolve A+ > FAIL: www.cryp.to -> 195.234.152.69 -> ["research.cryp.to"]+ > FAIL: ecrc.de -> 127.0.0.1 -> ["localhost"]+Cabal-Version: >= 1.6+Build-Type: Simple+Tested-With: GHC == 6.12.1++Extra-Source-Files: example/adns-reverse-lookup.hs+ example/adns-srv-test.hs+ example/adns-test-and-traverse.hs++Source-Repository this+ Tag: v1.4.2+ Type: git+ Location: git://gitorious.org/hsdns/mainline.git++Source-Repository head+ Type: git+ Location: git://gitorious.org/hsdns/mainline.git++Library+ Build-Depends: base >= 3 && < 5, network, containers+ Extensions: ForeignFunctionInterface, EmptyDataDecls+ Extra-Libraries: adns+ Includes: "adns.h" "errno.h"+ Exposed-Modules: ADNS, ADNS.Base, ADNS.Endian, ADNS.Resolver-GHC-Options: -Wall-Data-Files: README, prologue.txt-Build-Type: Simple---- Building these executables doesn't work anymore with the latest--- cabal version. The problem is that the file ADNS/Base.hs is no--- longer generated into the source tree, but into the dist/--- directory, where the example programs won't find it during--- compilation.------ To remedy the situation, we need either a really wild search--- path so that ADNS/Base.hs is found in the build dir, or we need--- separate cabal files for building the library and the example--- programs (which would suck) or some other magic way I am--- currently unaware of but that probably exists. Whatever.------ Executable: adns-reverse-lookup--- Hs-Source-Dirs: example, .--- Main-Is: adns-reverse-lookup.hs--- Extra-Libraries: adns--- GHC-Options: -O -Wall -threaded------ Executable: adns-test-and-traverse--- Hs-Source-Dirs: example, .--- Main-Is: adns-test-and-traverse.hs--- Extra-Libraries: adns--- GHC-Options: -O -Wall -threaded+ Ghc-Options: -Wall
− prologue.txt
@@ -1,4 +0,0 @@-This package provides FFI bindings to the GNU ADNS library-<http://www.gnu.org/software/adns/> as well as an appropriate-high-level interface from the Haskell world. The code has been-been tested with ADNS version 1.4.