Resolver

GResolver provides cancellable synchronous and asynchronous DNS resolution, for hostnames (g_resolver_lookup_by_address(), g_resolver_lookup_by_name() and their async variants) and SRV (service) records (g_resolver_lookup_service()).

GNetworkAddress and GNetworkService provide wrappers around GResolver functionality that also implement GSocketConnectable, making it easy to connect to a remote host/service.

class Resolver : ObjectG {}

Constructors

this
this(GResolver* gResolver, bool ownedRef = false)

Sets our main struct and passes it to the parent class.

Members

Functions

addOnReload
gulong addOnReload(void delegate(Resolver) dlg, ConnectFlags connectFlags = cast(ConnectFlags)0)

Emitted when the resolver notices that the system resolver configuration has changed.

getResolverStruct
GResolver* getResolverStruct(bool transferOwnership = false)

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

lookupByAddress
string lookupByAddress(InetAddress address, Cancellable cancellable)

Synchronously reverse-resolves address to determine its associated hostname.

lookupByAddressAsync
void lookupByAddressAsync(InetAddress address, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)

Begins asynchronously reverse-resolving address to determine its associated hostname, and eventually calls callback, which must call g_resolver_lookup_by_address_finish() to get the final result.

lookupByAddressFinish
string lookupByAddressFinish(AsyncResultIF result)

Retrieves the result of a previous call to g_resolver_lookup_by_address_async().

lookupByName
ListG lookupByName(string hostname, Cancellable cancellable)

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 g_inet_address_new_from_string()).

lookupByNameAsync
void lookupByNameAsync(string hostname, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)

Begins asynchronously resolving hostname to determine its associated IP address(es), and eventually calls callback, which must call g_resolver_lookup_by_name_finish() to get the result. See g_resolver_lookup_by_name() for more details.

lookupByNameFinish
ListG lookupByNameFinish(AsyncResultIF result)

Retrieves the result of a call to g_resolver_lookup_by_name_async().

lookupByNameWithFlags
ListG lookupByNameWithFlags(string hostname, GResolverNameLookupFlags flags, Cancellable cancellable)

This differs from g_resolver_lookup_by_name() 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

lookupByNameWithFlagsAsync
void lookupByNameWithFlagsAsync(string hostname, GResolverNameLookupFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)

Begins asynchronously resolving hostname to determine its associated IP address(es), and eventually calls callback, which must call g_resolver_lookup_by_name_with_flags_finish() to get the result. See g_resolver_lookup_by_name() for more details.

lookupByNameWithFlagsFinish
ListG lookupByNameWithFlagsFinish(AsyncResultIF result)

Retrieves the result of a call to g_resolver_lookup_by_name_with_flags_async().

lookupRecords
ListG lookupRecords(string rrname, GResolverRecordType recordType, Cancellable cancellable)

Synchronously performs a DNS record lookup for the given rrname and returns a list of records as GVariant tuples. See GResolverRecordType for information on what the records contain for each record_type.

lookupRecordsAsync
void lookupRecordsAsync(string rrname, GResolverRecordType recordType, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)

Begins asynchronously performing a DNS lookup for the given rrname, and eventually calls callback, which must call g_resolver_lookup_records_finish() to get the final result. See g_resolver_lookup_records() for more details.

lookupRecordsFinish
ListG lookupRecordsFinish(AsyncResultIF result)

Retrieves the result of a previous call to g_resolver_lookup_records_async(). Returns a non-empty list of records as GVariant tuples. See GResolverRecordType for information on what the records contain.

lookupService
ListG lookupService(string service, string protocol, string domain, Cancellable cancellable)

Synchronously performs a DNS SRV lookup for the given service and protocol in the given domain and returns an array of GSrvTarget 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.

lookupServiceAsync
void lookupServiceAsync(string service, string protocol, string domain, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)

Begins asynchronously performing a DNS SRV lookup for the given service and protocol in the given domain, and eventually calls callback, which must call g_resolver_lookup_service_finish() to get the final result. See g_resolver_lookup_service() for more details.

lookupServiceFinish
ListG lookupServiceFinish(AsyncResultIF result)

Retrieves the result of a previous call to g_resolver_lookup_service_async().

setDefault
void setDefault()

Sets resolver to be the application's default resolver (reffing resolver, and unreffing the previous default resolver, if any). Future calls to g_resolver_get_default() will return this resolver.

Static functions

freeAddresses
void freeAddresses(ListG addresses)

Frees addresses (which should be the return value from g_resolver_lookup_by_name() or g_resolver_lookup_by_name_finish()). (This is a convenience method; you can also simply free the results by hand.)

freeTargets
void freeTargets(ListG targets)

Frees targets (which should be the return value from g_resolver_lookup_service() or g_resolver_lookup_service_finish()). (This is a convenience method; you can also simply free the results by hand.)

getDefault
Resolver getDefault()

Gets the default GResolver You should unref it when you are done with it. GResolver may use its reference count as a hint about how many threads it should allocate for concurrent DNS resolutions.

getType
GType getType()

Variables

gResolver
GResolver* gResolver;

the main Gtk struct