pyxmpp.resolver

Package pyxmpp :: Module resolver |
[hide private]

# Module resolver

source code

DNS resolever with SRV record support.

Normative reference:
  - RFC 1035
  - RFC 2782

Functions | [hide private]
set_default_address_family(family) Select default address family. | source code
`list` of `dns.rdtypes.IN.SRV` |
shuffle_srv(records) Randomly reorder SRV records using their weights. | source code
`list` of `dns.rdtypes.IN.SRV` |
reorder_srv(records) Reorder SRV records using their priorities and weights. | source code
`list` of (`str`,`int`) |
resolve_srv(domain, service, proto=`'``tcp``'`) Resolve service domain to server name and port number using SRV records. | source code
`list` of (`int`, `int`, `int`, `str`, (`str`, `int`)) |
getaddrinfo(host, port, family=None, socktype=1, proto=0, allow_cname=True) Resolve host and port into addrinfo struct. | source code

Variables | [hide private]
| logger = `logging.getLogger("pyxmpp.resolver")`
| default_address_family = `0`
| service_aliases = ``{``'``xmpp-server``'``:` `(``'``jabber-server``'``,` `'``jabber``'``)``}``
| ipv4_re = `re.compile(r'^\d`{1,3}`\.\d`{1,3}`\.\d`{1,3}`\.\d`{1,3}`$')`
| ipv6_re = `re.compile(r'^`[`0`-`9a`-`f`]``{,4}`:`[`0`-`9a`-`f:`]``{,29}`:`(``[`0`-`9a`-`f`]``{``...``
| __package__ = ``'``pyxmpp``'``

Imports: re, socket, AF_UNSPEC, AF_INET, AF_INET6, dns, random, logging, DNSError, UnexpectedCNAMEError

Function Details | [hide private]

### set_default_address_family(family) | source code
Select default address family. Parameters: `family` - : AF_INET for IPv4, AF_INET6 for IPv6 and AF_UNSPEC for dual stack.

### shuffle_srv(records) | source code
Randomly reorder SRV records using their weights. Parameters: `records` (: sequence of `dns.rdtypes.IN.SRV`) - : SRV records to shuffle. Returns: `list` of `dns.rdtypes.IN.SRV` reordered records.

### reorder_srv(records) | source code
Reorder SRV records using their priorities and weights. Parameters: `records` (: `list` of `dns.rdtypes.IN.SRV`) - : SRV records to shuffle. Returns: `list` of `dns.rdtypes.IN.SRV` reordered records.

### resolve_srv(domain, service, proto=`'``tcp``'`) | source code
Resolve service domain to server name and port number using SRV records. A built-in service alias table will be used to lookup also some obsolete record names. Parameters: `domain` (: `unicode` or `str`) - : domain name. `service` (: `unicode` or `str`) - : service name. `proto` (: `str`) - : protocol name. Returns: `list` of (`str`,`int`) host names and port numbers for the service or None.

### getaddrinfo(host, port, family=None, socktype=1, proto=0, allow_cname=True) | source code
Resolve host and port into addrinfo struct. Does the same thing as socket.getaddrinfo, but using `dns.resolver`, so the cache content from the SRV query can be used. Parameters: `host` (: `unicode` or `str`) - : service domain name. `port` (: `int` or `str`) - : service port number or name. `family` (: `int`) - : address family (AF_INET for IPv4, AF_INET6 for IPv6 or AF_UNSPEC for either, `None` for the auto-configured default). `socktype` (: `int`) - : socket type. `proto` (: `int` or `str`) - : protocol number or name. `allow_cname` (: `bool`) - : when False CNAME responses are not allowed. Returns: `list` of (`int`, `int`, `int`, `str`, (`str`, `int`)) list of (family, socktype, proto, canonname, sockaddr).

Variables Details | [hide private]

  ### ipv6_re Value:
      re.compile(r'^[0-9a-f]{,4}:[0-9a-f:]{,29}:([0-9a-f]{,4}|\d{1,3}\.\d{1,
      3}\.\d{1,3}\.\d{1,3})$')