| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Network.DNS.Resolver
Contents
Description
Resolver related data types.
Synopsis
- data ResolvConf
- defaultResolvConf :: ResolvConf
- resolvInfo :: ResolvConf -> FileOrNumericHost
- resolvTimeout :: ResolvConf -> Int
- resolvRetry :: ResolvConf -> Int
- resolvConcurrent :: ResolvConf -> Bool
- resolvCache :: ResolvConf -> Maybe CacheConf
- resolvQueryControls :: ResolvConf -> QueryControls
- data FileOrNumericHost
- data CacheConf
- defaultCacheConf :: CacheConf
- maximumTTL :: CacheConf -> TTL
- pruningDelay :: CacheConf -> Int
- data ResolvSeed
- makeResolvSeed :: ResolvConf -> IO ResolvSeed
- data Resolver
- withResolver :: ResolvSeed -> (Resolver -> IO a) -> IO a
- withResolvers :: [ResolvSeed] -> ([Resolver] -> IO a) -> IO a
Configuration for resolver
data ResolvConf #
Type for resolver configuration.
Use defaultResolvConf to create a new value.
An example to use Google's public DNS cache instead of resolv.conf:
>>>let conf = defaultResolvConf { resolvInfo = RCHostName "8.8.8.8" }
An example to use multiple Google's public DNS cache concurrently:
>>>let conf = defaultResolvConf { resolvInfo = RCHostNames ["8.8.8.8","8.8.4.4"], resolvConcurrent = True }
An example to disable EDNS:
>>>let conf = defaultResolvConf { resolvQueryControls = ednsEnabled FlagClear }
An example to enable query result caching:
>>>let conf = defaultResolvConf { resolvCache = Just defaultCacheConf }
An example to disable requesting recursive service.
>>>let conf = defaultResolvConf { resolvQueryControls = rdFlag FlagClear }
An example to set the AD bit in all queries by default.
>>>let conf = defaultResolvConf { resolvQueryControls = adFlag FlagSet }
An example to set the both the AD and CD bits in all queries by default.
>>>let conf = defaultResolvConf { resolvQueryControls = adFlag FlagSet <> cdFlag FlagSet }
An example with an EDNS buffer size of 1216 bytes, which is more robust with IPv6, and the DO bit set to request DNSSEC responses.
>>>let conf = defaultResolvConf { resolvQueryControls = ednsSetUdpSize (Just 1216) <> doFlag FlagSet }
Instances
| Show ResolvConf | |
Defined in Network.DNS.Types.Resolver Methods showsPrec :: Int -> ResolvConf -> ShowS # show :: ResolvConf -> String # showList :: [ResolvConf] -> ShowS # | |
defaultResolvConf :: ResolvConf #
Return a default ResolvConf:
resolvInfoisRCFilePath"/etc/resolv.conf".resolvTimeoutis 3,000,000 micro seconds.resolvRetryis 3.resolvConcurrentis False.resolvCacheis Nothing.resolvQueryControlsis an empty set of overrides.
Accessors
resolvInfo :: ResolvConf -> FileOrNumericHost #
Server information.
resolvTimeout :: ResolvConf -> Int #
Timeout in micro seconds.
resolvRetry :: ResolvConf -> Int #
The number of retries including the first try.
resolvConcurrent :: ResolvConf -> Bool #
Concurrent queries if multiple DNS servers are specified.
resolvCache :: ResolvConf -> Maybe CacheConf #
Cache configuration.
resolvQueryControls :: ResolvConf -> QueryControls #
Overrides for the default flags used for queries via resolvers that use this configuration.
Specifying DNS servers
data FileOrNumericHost #
The type to specify a cache server.
Constructors
| RCFilePath FilePath | A path for "resolv.conf" where one or more IP addresses of DNS servers should be found on Unix. Default DNS servers are automatically detected on Windows regardless of the value of the file name. |
| RCHostName HostName | A numeric IP address. Warning: host names are invalid. |
| RCHostNames [HostName] | Numeric IP addresses. Warning: host names are invalid. |
| RCHostPort HostName PortNumber | A numeric IP address and port number. Warning: host names are invalid. |
Instances
| Show FileOrNumericHost | |
Defined in Network.DNS.Types.Resolver Methods showsPrec :: Int -> FileOrNumericHost -> ShowS # show :: FileOrNumericHost -> String # showList :: [FileOrNumericHost] -> ShowS # | |
Configuring cache
Cache configuration for responses.
defaultCacheConf :: CacheConf #
Default cache configuration.
>>>defaultCacheConfCacheConf {maximumTTL = 300, pruningDelay = 10}
maximumTTL :: CacheConf -> TTL #
If RR's TTL is higher than this value, this value is used instead.
pruningDelay :: CacheConf -> Int #
Cache pruning interval in seconds.
Intermediate data type for resolver
data ResolvSeed #
Intermediate abstract data type for resolvers.
IP address information of DNS servers is generated
according to resolvInfo internally.
This value can be safely reused for withResolver.
The naming is confusing for historical reasons.
makeResolvSeed :: ResolvConf -> IO ResolvSeed Source #
Type and function for resolver
Abstract data type of DNS Resolver. This includes newly seeded identifier generators for all specified DNS servers and a cache database.
withResolver :: ResolvSeed -> (Resolver -> IO a) -> IO a Source #
Giving a thread-safe Resolver to the function of the second
argument.
withResolvers :: [ResolvSeed] -> ([Resolver] -> IO a) -> IO a Source #