| Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
|---|---|
| License | LGPL-2.1 |
| Maintainer | Iñaki García Etxebarria |
| Safe Haskell | None |
| Language | Haskell2010 |
GI.Gio.Objects.Resolver
Contents
- Exported types
- Methods
- Overloaded methods
- getDefault
- lookupByAddress
- lookupByAddressAsync
- lookupByAddressFinish
- lookupByName
- lookupByNameAsync
- lookupByNameFinish
- lookupByNameWithFlags
- lookupByNameWithFlagsAsync
- lookupByNameWithFlagsFinish
- lookupRecords
- lookupRecordsAsync
- lookupRecordsFinish
- lookupService
- lookupServiceAsync
- lookupServiceFinish
- setDefault
- Signals
Description
Resolver provides cancellable synchronous and asynchronous DNS
resolution, for hostnames (resolverLookupByAddress,
resolverLookupByName and their async variants) and SRV
(service) records (resolverLookupService).
NetworkAddress and NetworkService provide wrappers around
Resolver functionality that also implement SocketConnectable,
making it easy to connect to a remote host/service.
Synopsis
- newtype Resolver = Resolver (ManagedPtr Resolver)
- class (GObject o, IsDescendantOf Resolver o) => IsResolver o
- toResolver :: (MonadIO m, IsResolver o) => o -> m Resolver
- noResolver :: Maybe Resolver
- resolverGetDefault :: (HasCallStack, MonadIO m) => m Resolver
- resolverLookupByAddress :: (HasCallStack, MonadIO m, IsResolver a, IsInetAddress b, IsCancellable c) => a -> b -> Maybe c -> m Text
- resolverLookupByAddressAsync :: (HasCallStack, MonadIO m, IsResolver a, IsInetAddress b, IsCancellable c) => a -> b -> Maybe c -> Maybe AsyncReadyCallback -> m ()
- resolverLookupByAddressFinish :: (HasCallStack, MonadIO m, IsResolver a, IsAsyncResult b) => a -> b -> m Text
- resolverLookupByName :: (HasCallStack, MonadIO m, IsResolver a, IsCancellable b) => a -> Text -> Maybe b -> m [InetAddress]
- resolverLookupByNameAsync :: (HasCallStack, MonadIO m, IsResolver a, IsCancellable b) => a -> Text -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- resolverLookupByNameFinish :: (HasCallStack, MonadIO m, IsResolver a, IsAsyncResult b) => a -> b -> m [InetAddress]
- resolverLookupByNameWithFlags :: (HasCallStack, MonadIO m, IsResolver a, IsCancellable b) => a -> Text -> [ResolverNameLookupFlags] -> Maybe b -> m [InetAddress]
- resolverLookupByNameWithFlagsAsync :: (HasCallStack, MonadIO m, IsResolver a, IsCancellable b) => a -> Text -> [ResolverNameLookupFlags] -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- resolverLookupByNameWithFlagsFinish :: (HasCallStack, MonadIO m, IsResolver a, IsAsyncResult b) => a -> b -> m [InetAddress]
- resolverLookupRecords :: (HasCallStack, MonadIO m, IsResolver a, IsCancellable b) => a -> Text -> ResolverRecordType -> Maybe b -> m [GVariant]
- resolverLookupRecordsAsync :: (HasCallStack, MonadIO m, IsResolver a, IsCancellable b) => a -> Text -> ResolverRecordType -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- resolverLookupRecordsFinish :: (HasCallStack, MonadIO m, IsResolver a, IsAsyncResult b) => a -> b -> m [GVariant]
- resolverLookupService :: (HasCallStack, MonadIO m, IsResolver a, IsCancellable b) => a -> Text -> Text -> Text -> Maybe b -> m [SrvTarget]
- resolverLookupServiceAsync :: (HasCallStack, MonadIO m, IsResolver a, IsCancellable b) => a -> Text -> Text -> Text -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- resolverLookupServiceFinish :: (HasCallStack, MonadIO m, IsResolver a, IsAsyncResult b) => a -> b -> m [SrvTarget]
- resolverSetDefault :: (HasCallStack, MonadIO m, IsResolver a) => a -> m ()
- type C_ResolverReloadCallback = Ptr () -> Ptr () -> IO ()
- type ResolverReloadCallback = IO ()
- afterResolverReload :: (IsResolver a, MonadIO m) => a -> ResolverReloadCallback -> m SignalHandlerId
- genClosure_ResolverReload :: MonadIO m => ResolverReloadCallback -> m (GClosure C_ResolverReloadCallback)
- mk_ResolverReloadCallback :: C_ResolverReloadCallback -> IO (FunPtr C_ResolverReloadCallback)
- noResolverReloadCallback :: Maybe ResolverReloadCallback
- onResolverReload :: (IsResolver a, MonadIO m) => a -> ResolverReloadCallback -> m SignalHandlerId
- wrap_ResolverReloadCallback :: ResolverReloadCallback -> C_ResolverReloadCallback
Exported types
Memory-managed wrapper type.
Constructors
| Resolver (ManagedPtr Resolver) |
Instances
| Eq Resolver Source # | |
| GObject Resolver Source # | |
Defined in GI.Gio.Objects.Resolver Methods gobjectType :: IO GType # | |
| IsGValue Resolver Source # | Convert |
| HasParentTypes Resolver Source # | |
Defined in GI.Gio.Objects.Resolver | |
| type ParentTypes Resolver Source # | |
Defined in GI.Gio.Objects.Resolver | |
class (GObject o, IsDescendantOf Resolver o) => IsResolver o Source #
Type class for types which can be safely cast to Resolver, for instance with toResolver.
Instances
| (GObject o, IsDescendantOf Resolver o) => IsResolver o Source # | |
Defined in GI.Gio.Objects.Resolver | |
toResolver :: (MonadIO m, IsResolver o) => o -> m Resolver Source #
Methods
Overloaded methods
getDefault
Arguments
| :: (HasCallStack, MonadIO m) | |
| => m Resolver | Returns: the default |
lookupByAddress
resolverLookupByAddress Source #
Arguments
| :: (HasCallStack, MonadIO m, IsResolver a, IsInetAddress b, IsCancellable c) | |
| => a |
|
| -> b |
|
| -> Maybe c |
|
| -> m Text | Returns: a hostname (either ASCII-only, or in ASCII-encoded
form), or |
Synchronously reverse-resolves address to determine its
associated hostname.
If the DNS resolution fails, error (if non-Nothing) will be set to
a value from ResolverError.
If cancellable is non-Nothing, it can be used to cancel the
operation, in which case error (if non-Nothing) will be set to
IOErrorEnumCancelled.
Since: 2.22
lookupByAddressAsync
resolverLookupByAddressAsync Source #
Arguments
| :: (HasCallStack, MonadIO m, IsResolver a, IsInetAddress b, IsCancellable c) | |
| => a |
|
| -> b |
|
| -> Maybe c |
|
| -> Maybe AsyncReadyCallback |
|
| -> m () |
Begins asynchronously reverse-resolving address to determine its
associated hostname, and eventually calls callback, which must
call resolverLookupByAddressFinish to get the final result.
Since: 2.22
lookupByAddressFinish
resolverLookupByAddressFinish Source #
Arguments
| :: (HasCallStack, MonadIO m, IsResolver a, IsAsyncResult b) | |
| => a |
|
| -> b |
|
| -> m Text | Returns: a hostname (either ASCII-only, or in ASCII-encoded
form), or |
Retrieves the result of a previous call to
resolverLookupByAddressAsync.
If the DNS resolution failed, error (if non-Nothing) will be set to
a value from ResolverError. If the operation was cancelled,
error will be set to IOErrorEnumCancelled.
Since: 2.22
lookupByName
Arguments
| :: (HasCallStack, MonadIO m, IsResolver a, IsCancellable b) | |
| => a |
|
| -> Text |
|
| -> Maybe b |
|
| -> m [InetAddress] | Returns: a non-empty |
Synchronously resolves hostname to determine its associated IP
address(es). hostname may be an ASCII-only or UTF-8 hostname, or
the textual form of an IP address (in which case this just becomes
a wrapper around inetAddressNewFromString).
On success, resolverLookupByName will return a non-empty List of
InetAddress, sorted in order of preference and guaranteed to not
contain duplicates. That is, if using the result to connect to
hostname, you should attempt to connect to the first address
first, then the second if the first fails, etc. If you are using
the result to listen on a socket, it is appropriate to add each
result using e.g. socketListenerAddAddress.
If the DNS resolution fails, error (if non-Nothing) will be set to a
value from ResolverError and Nothing will be returned.
If cancellable is non-Nothing, it can be used to cancel the
operation, in which case error (if non-Nothing) will be set to
IOErrorEnumCancelled.
If you are planning to connect to a socket on the resolved IP
address, it may be easier to create a NetworkAddress and use its
SocketConnectable interface.
Since: 2.22
lookupByNameAsync
resolverLookupByNameAsync Source #
Arguments
| :: (HasCallStack, MonadIO m, IsResolver a, IsCancellable b) | |
| => a |
|
| -> Text |
|
| -> Maybe b |
|
| -> Maybe AsyncReadyCallback |
|
| -> m () |
Begins asynchronously resolving hostname to determine its
associated IP address(es), and eventually calls callback, which
must call resolverLookupByNameFinish to get the result.
See resolverLookupByName for more details.
Since: 2.22
lookupByNameFinish
resolverLookupByNameFinish Source #
Arguments
| :: (HasCallStack, MonadIO m, IsResolver a, IsAsyncResult b) | |
| => a |
|
| -> b |
|
| -> m [InetAddress] | Returns: a |
Retrieves the result of a call to
resolverLookupByNameAsync.
If the DNS resolution failed, error (if non-Nothing) will be set to
a value from ResolverError. If the operation was cancelled,
error will be set to IOErrorEnumCancelled.
Since: 2.22
lookupByNameWithFlags
resolverLookupByNameWithFlags Source #
Arguments
| :: (HasCallStack, MonadIO m, IsResolver a, IsCancellable b) | |
| => a |
|
| -> Text |
|
| -> [ResolverNameLookupFlags] |
|
| -> Maybe b |
|
| -> m [InetAddress] | Returns: a non-empty |
This differs from resolverLookupByName in that you can modify
the lookup behavior with flags. For example this can be used to limit
results with G_RESOLVER_NAME_LOOKUP_FLAGS_IPV4_ONLY.
Since: 2.60
lookupByNameWithFlagsAsync
resolverLookupByNameWithFlagsAsync Source #
Arguments
| :: (HasCallStack, MonadIO m, IsResolver a, IsCancellable b) | |
| => a |
|
| -> Text |
|
| -> [ResolverNameLookupFlags] |
|
| -> Maybe b |
|
| -> Maybe AsyncReadyCallback |
|
| -> m () |
Begins asynchronously resolving hostname to determine its
associated IP address(es), and eventually calls callback, which
must call resolverLookupByNameWithFlagsFinish to get the result.
See resolverLookupByName for more details.
Since: 2.60
lookupByNameWithFlagsFinish
resolverLookupByNameWithFlagsFinish Source #
Arguments
| :: (HasCallStack, MonadIO m, IsResolver a, IsAsyncResult b) | |
| => a |
|
| -> b |
|
| -> m [InetAddress] | Returns: a |
Retrieves the result of a call to
resolverLookupByNameWithFlagsAsync.
If the DNS resolution failed, error (if non-Nothing) will be set to
a value from ResolverError. If the operation was cancelled,
error will be set to IOErrorEnumCancelled.
Since: 2.60
lookupRecords
resolverLookupRecords Source #
Arguments
| :: (HasCallStack, MonadIO m, IsResolver a, IsCancellable b) | |
| => a |
|
| -> Text |
|
| -> ResolverRecordType |
|
| -> Maybe b |
|
| -> m [GVariant] | Returns: a non-empty |
Synchronously performs a DNS record lookup for the given rrname and returns
a list of records as GVariant tuples. See ResolverRecordType for
information on what the records contain for each recordType.
If the DNS resolution fails, error (if non-Nothing) will be set to
a value from ResolverError and Nothing will be returned.
If cancellable is non-Nothing, it can be used to cancel the
operation, in which case error (if non-Nothing) will be set to
IOErrorEnumCancelled.
Since: 2.34
lookupRecordsAsync
resolverLookupRecordsAsync Source #
Arguments
| :: (HasCallStack, MonadIO m, IsResolver a, IsCancellable b) | |
| => a |
|
| -> Text |
|
| -> ResolverRecordType |
|
| -> Maybe b |
|
| -> Maybe AsyncReadyCallback |
|
| -> m () |
Begins asynchronously performing a DNS lookup for the given
rrname, and eventually calls callback, which must call
resolverLookupRecordsFinish to get the final result. See
resolverLookupRecords for more details.
Since: 2.34
lookupRecordsFinish
resolverLookupRecordsFinish Source #
Arguments
| :: (HasCallStack, MonadIO m, IsResolver a, IsAsyncResult b) | |
| => a |
|
| -> b |
|
| -> m [GVariant] | Returns: a non-empty |
Retrieves the result of a previous call to
resolverLookupRecordsAsync. Returns a non-empty list of records as
GVariant tuples. See ResolverRecordType for information on what the
records contain.
If the DNS resolution failed, error (if non-Nothing) will be set to
a value from ResolverError. If the operation was cancelled,
error will be set to IOErrorEnumCancelled.
Since: 2.34
lookupService
resolverLookupService Source #
Arguments
| :: (HasCallStack, MonadIO m, IsResolver a, IsCancellable b) | |
| => a |
|
| -> Text |
|
| -> Text |
|
| -> Text |
|
| -> Maybe b |
|
| -> m [SrvTarget] | Returns: a non-empty |
Synchronously performs a DNS SRV lookup for the given service and
protocol in the given domain and returns an array of SrvTarget.
domain may be an ASCII-only or UTF-8 hostname. Note also that the
service and protocol arguments do not include the leading underscore
that appears in the actual DNS entry.
On success, resolverLookupService will return a non-empty List of
SrvTarget, sorted in order of preference. (That is, you should
attempt to connect to the first target first, then the second if
the first fails, etc.)
If the DNS resolution fails, error (if non-Nothing) will be set to
a value from ResolverError and Nothing will be returned.
If cancellable is non-Nothing, it can be used to cancel the
operation, in which case error (if non-Nothing) will be set to
IOErrorEnumCancelled.
If you are planning to connect to the service, it is usually easier
to create a NetworkService and use its SocketConnectable
interface.
Since: 2.22
lookupServiceAsync
resolverLookupServiceAsync Source #
Arguments
| :: (HasCallStack, MonadIO m, IsResolver a, IsCancellable b) | |
| => a |
|
| -> Text |
|
| -> Text |
|
| -> Text |
|
| -> Maybe b |
|
| -> Maybe AsyncReadyCallback |
|
| -> m () |
Begins asynchronously performing a DNS SRV lookup for the given
service and protocol in the given domain, and eventually calls
callback, which must call resolverLookupServiceFinish to
get the final result. See resolverLookupService for more
details.
Since: 2.22
lookupServiceFinish
resolverLookupServiceFinish Source #
Arguments
| :: (HasCallStack, MonadIO m, IsResolver a, IsAsyncResult b) | |
| => a |
|
| -> b |
|
| -> m [SrvTarget] | Returns: a non-empty |
Retrieves the result of a previous call to
resolverLookupServiceAsync.
If the DNS resolution failed, error (if non-Nothing) will be set to
a value from ResolverError. If the operation was cancelled,
error will be set to IOErrorEnumCancelled.
Since: 2.22
setDefault
Arguments
| :: (HasCallStack, MonadIO m, IsResolver a) | |
| => a |
|
| -> m () |
Sets resolver to be the application's default resolver (reffing
resolver, and unreffing the previous default resolver, if any).
Future calls to resolverGetDefault will return this resolver.
This can be used if an application wants to perform any sort of DNS
caching or "pinning"; it can implement its own Resolver that
calls the original default resolver for DNS operations, and
implements its own cache policies on top of that, and then set
itself as the default resolver for all later code to use.
Since: 2.22
Signals
reload
type C_ResolverReloadCallback = Ptr () -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
type ResolverReloadCallback = IO () Source #
Emitted when the resolver notices that the system resolver configuration has changed.
afterResolverReload :: (IsResolver a, MonadIO m) => a -> ResolverReloadCallback -> m SignalHandlerId Source #
Connect a signal handler for the reload signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after resolver #reload callback
genClosure_ResolverReload :: MonadIO m => ResolverReloadCallback -> m (GClosure C_ResolverReloadCallback) Source #
Wrap the callback into a GClosure.
mk_ResolverReloadCallback :: C_ResolverReloadCallback -> IO (FunPtr C_ResolverReloadCallback) Source #
Generate a function pointer callable from C code, from a C_ResolverReloadCallback.
noResolverReloadCallback :: Maybe ResolverReloadCallback Source #
A convenience synonym for .Nothing :: Maybe ResolverReloadCallback
onResolverReload :: (IsResolver a, MonadIO m) => a -> ResolverReloadCallback -> m SignalHandlerId Source #
Connect a signal handler for the reload signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on resolver #reload callback