Infinity.NameResolver

g GObject.Object GObject.Object Infinity.NameResolver Infinity.NameResolver GObject.Object->Infinity.NameResolver

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new (io, hostname, service, srv)

finished ()

get_address (index)

get_hostname ()

get_n_addresses ()

get_port (index)

get_service ()

get_srv ()

lookup_backup ()

start ()

Virtual Methods

Inherited:

GObject.Object (7)

do_resolved (error)

Properties

Name

Type

Flags

Short Description

hostname

str

r/w/c

The hostname to be looked up

io

Infinity.Io

r/w/c

I/O handler

service

str

r/w/c

The expected service at the remote endpoint

srv

str

r/w/c

The SRV record to look up for the given hostname, e.g. _jabber._tcp

Signals

Inherited:

GObject.Object (1)

Name

Short Description

resolved

This signal is emitted when the hostname has been resolved.

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

GObject.Object

r

Class Details

class Infinity.NameResolver(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Infinity.NameResolverClass

Infinity.NameResolver is an opaque data type. You should only access it via the public API functions.

classmethod new(io, hostname, service, srv)
Parameters:
  • io (Infinity.Io) – A Infinity.Io object used to schedule events in the main thread.

  • hostname (str) – The hostname to look up.

  • service (str or None) – The name of the service to look up, or None.

  • srv (str or None) – The SRV record to look up, or None.

Returns:

A new Infinity.NameResolver. Free with GObject.Object.unref().

Return type:

Infinity.NameResolver

Creates a new Infinity.NameResolver. Use Infinity.NameResolver.start() to start resolving the hostname.

If service is not None, it should be a decimal port number or a well-known service name that is translated into a port number, such as "http&quot. If srv is not None, the function will first attempt a SRV lookup, and fall back to a regular A/AAAA lookup in case no SRV record exists. Otherwise the SRV result is taken. If service is provided, it always overwrites the port number obtained from the hostname lookup.

The recommended procedure is to call this function with service equal to the port number entered by the user, or None if the user did not provide an explicit port number. If the resulting port number obtained with Infinity.NameResolver.get_port() is then different from 0, then use that port number, otherwise the default port number for the service.

finished()
Returns:

Whether a call to Infinity.NameResolver.start() can be made.

Return type:

bool

Returns whether the resolver is currently looking up a hostname, or whether it is ready to start a new lookup with Infinity.NameResolver.start().

get_address(index)
Parameters:

index (int) – The index for which to return the address, in case multiple IP addresses correspond to the same hostname.

Returns:

The looked up Infinity.IpAddress.

Return type:

Infinity.IpAddress

Returns the index th address looked up in the last hostname resolution operation.

get_hostname()
Returns:

The currently configured hostname.

Return type:

str or None

Returns the currently configured hostname that self will look up.

get_n_addresses()
Returns:

The number of addresses available.

Return type:

int

Returns the number of resolved addresses that belongs to the hostname that was looked up.

get_port(index)
Parameters:

index (int) – The index for which to return the port, in case multiple IP addresses correspond to the same hostname.

Returns:

The looked up Infinity.IpAddress.

Return type:

int

Returns the index th port looked up in the last hostname resolution operation. This can be 0 if the service parameter in Infinity.NameResolver.start() has been set to None and no SRV record has been found.

get_service()
Returns:

The currently configured service.

Return type:

str or None

Returns the currently configured service that self will look up.

get_srv()
Returns:

The currently configured SRV record.

Return type:

str or None

Returns the currently configured SRV record that self will look up.

lookup_backup()
Raises:

GLib.Error

Returns:

True if looking up backup addresses is attempted, or False otherwise.

Return type:

bool

Tries to look up backup addresses for the configured hostname. This should be used if connecting to none of the initially reported addresses works. The function returns False if there are no backup addresses available, or True otherwise. If it returns True, it the Infinity.NameResolver ::resolved signal will be emitted again, and when it is, more addresses might be available from the resolver object.

start()
Raises:

GLib.Error

Returns:

True on success or False if a (synchronous) error occurred.

Return type:

bool

Starts the name resolution for the hostname configured with self.

When the hostname lookup has finished, the Infinity.NameResolver ::resolved signal is emitted. The function can only be called again once this signal has been emitted. When this function is called, the previously looked up result can no longer be obtained with the Infinity.NameResolver.get_address() and Infinity.NameResolver.get_port() functions.

do_resolved(error) virtual
Parameters:

error (GLib.Error) –

Signal Details

Infinity.NameResolver.signals.resolved(name_resolver, error)
Signal Name:

resolved

Flags:

RUN_LAST

Parameters:

This signal is emitted when the hostname has been resolved. The function Infinity.NameResolver.get_address() and Infinity.NameResolver.get_port() can be called to obtain the resolved addresses.

Property Details

Infinity.NameResolver.props.hostname
Name:

hostname

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT

The hostname to be looked up

Infinity.NameResolver.props.io
Name:

io

Type:

Infinity.Io

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT

I/O handler

Infinity.NameResolver.props.service
Name:

service

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT

The expected service at the remote endpoint

Infinity.NameResolver.props.srv
Name:

srv

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT

The SRV record to look up for the given hostname, e.g. _jabber._tcp