Copyright | © 2017 Herbert Valerio Riedel |
---|---|
License | GPLv3 |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
This module implements an API for accessing the Domain Name Service (DNS) resolver service via the standard <windns.h>/dnsapi.dll system library on Win32 systems.
- queryA :: Name -> IO [(TTL, IPv4)]
- queryAAAA :: Name -> IO [(TTL, IPv6)]
- queryCNAME :: Name -> IO [(TTL, Name)]
- querySRV :: Name -> IO [(TTL, SRV Name)]
- queryTXT :: Name -> IO [(TTL, [CharStr])]
- newtype Name = Name ByteString
- newtype CharStr = CharStr ByteString
- data IPv4 = IPv4 !Word32
- data IPv6 = IPv6 !Word64 !Word64
- newtype TTL = TTL Int32
- data SRV l = SRV {}
High level API
queryA :: Name -> IO [(TTL, IPv4)] Source #
Query A
record (see RFC 1035, section 3.4.1).
This query returns only exact matches (modulo foldCaseName
).
E.g. in case of CNAME
responses even if the
answer section would contain A
records for the hostnames pointed
to by the CNAME
.
>>>
queryA (Name "www.google.com")
[(TTL 72,IPv4 0xd83acde4)]
queryAAAA :: Name -> IO [(TTL, IPv6)] Source #
Query AAAA
records (see RFC 3596).
This query returns only exact matches (modulo foldCaseName
).
E.g. in case of CNAME
responses even if the answer section would
contain A
records for the hostnames pointed to by the
CNAME
.
>>>
queryAAAA (Name "www.google.com")
[(TTL 299,IPv6 0x2a0014504001081e 0x2004)]
queryCNAME :: Name -> IO [(TTL, Name)] Source #
Query CNAME
records (see RFC 1035, section 3.3.1).
>>>
queryCNAME (Name "hackage.haskell.org")
[(TTL 299,Name "j.global-ssl.fastly.net.")]
querySRV :: Name -> IO [(TTL, SRV Name)] Source #
Query SRV
records (see RFC 2782).
>>>
querySRV (Name "_imap._tcp.gmail.com")
[(TTL 21599,SRV {srvPriority = 0, srvWeight = 0, srvPort = 0, srvTarget = Name "."})]
queryTXT :: Name -> IO [(TTL, [CharStr])] Source #
Query TXT
records (see RFC 1035, section 3.3.14).
>>>
queryTXT (Name "_mirrors.hackage.haskell.org")
[(TTL 299,["0.urlbase=http://hackage.fpcomplete.com/", "1.urlbase=http://objects-us-west-1.dream.io/hackage-mirror/"])]
Types
<domain-name>
as per RFC 1035, section 3.3.
A domain-name represented as a series of labels separated by dots.
<character-string>
as per RFC 1035, section 3.3.
A sequence of up to 255 octets
The limit of 255 octets is caused by the encoding which uses by a prefixed octet denoting the length.
An IPv4 address
The IP address is represented in network order, i.e. 127.0.0.1
is
represented as (IPv4 0x7f000001)
.
An IPv6 address
The IP address is represented in network order,
i.e. 2606:2800:220:1:248:1893:25c8:1946
is
represented as (IPv6 0x2606280002200001 0x248189325c81946)
.
Cache time-to-live expressed in seconds
SRV
Record data as per RFC 2782