Package pyxmpp :: Module resolver
[hide private]

Module resolver

source code

DNS resolever with SRV record support.

Normative reference:
Functions [hide private]
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=0, socktype=1, proto=0, allow_cname=True)
Resolve host and port into addrinfo struct.
source code
Variables [hide private]
  __revision__ = '$Id: resolver.py 714 2010-04-05 10:20:10Z jajc...
  service_aliases = {'xmpp-server': ('jabber-server', 'jabber')}
  ip_re = re.compile(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}')
  __package__ = 'pyxmpp'

Imports: re, socket, dns, random, idna


Function Details [hide private]

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=0, 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 pyxmpp.resolver. This makes it possible to reuse data (A records from the additional section of DNS reply) returned with SRV records lookup done using this module.

Parameters:
  • host (unicode or str) - service domain name.
  • port (int or str) - service port number or name.
  • family (int) - address family.
  • 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]

__revision__

Value:
'$Id: resolver.py 714 2010-04-05 10:20:10Z jajcus $'