Class: Gio::Resolver

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Direct Known Subclasses

ThreadedResolver

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.defaultGio::Resolver

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.

Returns:

.free_addresses(addresses) ⇒ nil

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

Parameters:

  • addresses (GLib::List<GObject>)

    a #GList of GInet::Address

Returns:

  • (nil)

.free_targets(targets) ⇒ nil

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

Parameters:

  • targets (GLib::List<GObject>)

    a #GList of GSrv::Target

Returns:

  • (nil)

Instance Method Details

#lookup_by_address(address, cancellable) ⇒ String

Synchronously reverse-resolves address to determine its associated hostname.

If the DNS resolution fails, error (if non-nil) will be set to a value from GResolver::Error.

If cancellable is non-nil, it can be used to cancel the operation, in which case error (if non-nil) will be set to %G_IO_ERROR_CANCELLED.

Parameters:

Returns:

  • (String)

    a hostname (either ASCII-only, or in ASCII-encoded form), or nil on error.

#lookup_by_address_async(address, cancellable, callback, user_data) ⇒ nil

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.

Parameters:

  • address (Gio::InetAddress)

    the address to reverse-resolve

  • cancellable (Gio::Cancellable)

    a #GCancellable, or nil

  • callback (Gio::AsyncReadyCallback)

    callback to call after resolution completes

  • user_data (GObject)

    data for callback

Returns:

  • (nil)

#lookup_by_address_finish(result) ⇒ String

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

If the DNS resolution failed, error (if non-nil) will be set to a value from GResolver::Error. If the operation was cancelled, error will be set to %G_IO_ERROR_CANCELLED. form), or nil on error.

Parameters:

Returns:

  • (String)

    a hostname (either ASCII-only, or in ASCII-encoded

#lookup_by_name(hostname, cancellable) ⇒ GLib::List<Gio::InetAddress>

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

On success, g_resolver_lookup_by_name() will return a non-empty #GList of GInet::Address, 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. g_socket_listener_add_address().

If the DNS resolution fails, error (if non-nil) will be set to a value from GResolver::Error and nil will be returned.

If cancellable is non-nil, it can be used to cancel the operation, in which case error (if non-nil) will be set to %G_IO_ERROR_CANCELLED.

If you are planning to connect to a socket on the resolved IP address, it may be easier to create a GNetwork::Address and use its GSocket::Connectable interface. of GInet::Address, or nil on error. You must unref each of the addresses and free the list when you are done with it. (You can use g_resolver_free_addresses() to do this.)

Parameters:

  • hostname (String)

    the hostname to look up

  • cancellable (Gio::Cancellable)

    a #GCancellable, or nil

Returns:

#lookup_by_name_async(hostname, cancellable, callback, user_data) ⇒ nil

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.

Parameters:

  • hostname (String)

    the hostname to look up the address of

  • cancellable (Gio::Cancellable)

    a #GCancellable, or nil

  • callback (Gio::AsyncReadyCallback)

    callback to call after resolution completes

  • user_data (GObject)

    data for callback

Returns:

  • (nil)

#lookup_by_name_finish(result) ⇒ GLib::List<Gio::InetAddress>

Retrieves the result of a call to g_resolver_lookup_by_name_async().

If the DNS resolution failed, error (if non-nil) will be set to a value from GResolver::Error. If the operation was cancelled, error will be set to %G_IO_ERROR_CANCELLED. of GInet::Address, or nil on error. See g_resolver_lookup_by_name() for more details.

Parameters:

Returns:

#lookup_by_name_with_flags(hostname, flags, cancellable) ⇒ GLib::List<Gio::InetAddress>

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. of GInet::Address, or nil on error. You must unref each of the addresses and free the list when you are done with it. (You can use g_resolver_free_addresses() to do this.)

Parameters:

Returns:

#lookup_by_name_with_flags_async(hostname, flags, cancellable, callback, user_data) ⇒ nil

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.

Parameters:

  • hostname (String)

    the hostname to look up the address of

  • flags (Gio::ResolverNameLookupFlags)

    extra GResolver::NameLookupFlags for the lookup

  • cancellable (Gio::Cancellable)

    a #GCancellable, or nil

  • callback (Gio::AsyncReadyCallback)

    callback to call after resolution completes

  • user_data (GObject)

    data for callback

Returns:

  • (nil)

#lookup_by_name_with_flags_finish(result) ⇒ GLib::List<Gio::InetAddress>

Retrieves the result of a call to g_resolver_lookup_by_name_with_flags_async().

If the DNS resolution failed, error (if non-nil) will be set to a value from GResolver::Error. If the operation was cancelled, error will be set to %G_IO_ERROR_CANCELLED. of GInet::Address, or nil on error. See g_resolver_lookup_by_name() for more details.

Parameters:

Returns:

#lookup_records(rrname, record_type, cancellable) ⇒ GLib::List<GLib::Variant>

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

If the DNS resolution fails, error (if non-nil) will be set to a value from GResolver::Error and nil will be returned.

If cancellable is non-nil, it can be used to cancel the operation, in which case error (if non-nil) will be set to %G_IO_ERROR_CANCELLED. #GVariant, or nil on error. You must free each of the records and the list when you are done with it. (You can use g_list_free_full() with g_variant_unref() to do this.)

Parameters:

  • rrname (String)

    the DNS name to look up the record for

  • record_type (Gio::ResolverRecordType)

    the type of DNS record to look up

  • cancellable (Gio::Cancellable)

    a #GCancellable, or nil

Returns:

  • (GLib::List<GLib::Variant>)

    a non-empty #GList of

#lookup_records_async(rrname, record_type, cancellable, callback, user_data) ⇒ nil

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.

Parameters:

  • rrname (String)

    the DNS name to look up the record for

  • record_type (Gio::ResolverRecordType)

    the type of DNS record to look up

  • cancellable (Gio::Cancellable)

    a #GCancellable, or nil

  • callback (Gio::AsyncReadyCallback)

    callback to call after resolution completes

  • user_data (GObject)

    data for callback

Returns:

  • (nil)

#lookup_records_finish(result) ⇒ GLib::List<GLib::Variant>

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

If the DNS resolution failed, error (if non-nil) will be set to a value from GResolver::Error. If the operation was cancelled, error will be set to %G_IO_ERROR_CANCELLED. #GVariant, or nil on error. You must free each of the records and the list when you are done with it. (You can use g_list_free_full() with g_variant_unref() to do this.)

Parameters:

Returns:

  • (GLib::List<GLib::Variant>)

    a non-empty #GList of

#lookup_service(service, protocol, domain, cancellable) ⇒ GLib::List<Gio::SrvTarget>

Synchronously performs a DNS SRV lookup for the given service and protocol in the given domain and returns an array of GSrv::Target. 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, g_resolver_lookup_service() will return a non-empty #GList of GSrv::Target, 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-nil) will be set to a value from GResolver::Error and nil will be returned.

If cancellable is non-nil, it can be used to cancel the operation, in which case error (if non-nil) will be set to %G_IO_ERROR_CANCELLED.

If you are planning to connect to the service, it is usually easier to create a GNetwork::Service and use its #GSocketConnectable interface. GSrv::Target, or nil on error. You must free each of the targets and the list when you are done with it. (You can use g_resolver_free_targets() to do this.)

Parameters:

  • service (String)

    the service type to look up (eg, "ldap")

  • protocol (String)

    the networking protocol to use for service (eg, "tcp")

  • domain (String)

    the DNS domain to look up the service in

  • cancellable (Gio::Cancellable)

    a #GCancellable, or nil

Returns:

  • (GLib::List<Gio::SrvTarget>)

    a non-empty #GList of

#lookup_service_async(service, protocol, domain, cancellable, callback, user_data) ⇒ nil

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.

Parameters:

  • service (String)

    the service type to look up (eg, "ldap")

  • protocol (String)

    the networking protocol to use for service (eg, "tcp")

  • domain (String)

    the DNS domain to look up the service in

  • cancellable (Gio::Cancellable)

    a #GCancellable, or nil

  • callback (Gio::AsyncReadyCallback)

    callback to call after resolution completes

  • user_data (GObject)

    data for callback

Returns:

  • (nil)

#lookup_service_finish(result) ⇒ GLib::List<Gio::SrvTarget>

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

If the DNS resolution failed, error (if non-nil) will be set to a value from GResolver::Error. If the operation was cancelled, error will be set to %G_IO_ERROR_CANCELLED. GSrv::Target, or nil on error. See g_resolver_lookup_service() for more details.

Parameters:

Returns:

  • (GLib::List<Gio::SrvTarget>)

    a non-empty #GList of

#set_defaultnil

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.

This can be used if an application wants to perform any sort of DNS caching or "pinning"; it can implement its own #GResolver 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.

Returns:

  • (nil)

#timeoutInteger

The timeout applied to all resolver lookups, in milliseconds.

This may be changed through the lifetime of the #GResolver. The new value will apply to any lookups started after the change, but not to any already-ongoing lookups.

If this is 0, no timeout is applied to lookups.

No timeout was applied to lookups before this property was added in GLib 2.78.

Returns:

  • (Integer)

    timeout

#timeout=(timeout) ⇒ Integer

The timeout applied to all resolver lookups, in milliseconds.

This may be changed through the lifetime of the #GResolver. The new value will apply to any lookups started after the change, but not to any already-ongoing lookups.

If this is 0, no timeout is applied to lookups.

No timeout was applied to lookups before this property was added in GLib 2.78.

Parameters:

  • timeout (Integer)

Returns:

  • (Integer)

    timeout

  • (Integer)

    timeout