Package pyxmpp :: Module resolver
[show private | hide private]
[frames | no frames]

Module pyxmpp.resolver

DNS resolever with SRV record support.

Normative reference:

Function Summary
list of (int, int, int, str, (str, int)) getaddrinfo(host, port, family, socktype, proto, allow_cname)
Resolve host and port into addrinfo struct.
list of dns.rdtypes.IN.SRV reorder_srv(records)
Reorder SRV records using their priorities and weights.
list of (str,`int`) resolve_srv(domain, service, proto)
Resolve service domain to server name and port number using SRV records.
list of dns.rdtypes.IN.SRV shuffle_srv(records)
Randomly reorder SRV records using their weights.

Variable Summary
str __revision__ = '$Id: resolver.py 503 2005-01-03 21:59:36...
SRE_Pattern ip_re = \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}
dict service_aliases = {'xmpp-server': ('jabber-server', 'jab...

Imported modules:
dns, encodings.idna, random, re, socket
Function Details

getaddrinfo(host, port, family=0, socktype=1, proto=0, allow_cname=True)

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 - service domain name.
           (type=unicode or str)
port - service port number or name.
           (type=int or str)
family - address family.
           (type=int)
socktype - socket type.
           (type=int)
proto - protocol number or name.
           (type=int or str)
allow_cname - when False CNAME responses are not allowed.
           (type=bool)
Returns:
list of (family, socktype, proto, canonname, sockaddr).
           (type=list of (int, int, int, str, (str, int)))

reorder_srv(records)

Reorder SRV records using their priorities and weights.
Parameters:
records - SRV records to shuffle.
           (type=list of dns.rdtypes.IN.SRV)
Returns:
reordered records.
           (type=list of dns.rdtypes.IN.SRV)

resolve_srv(domain, service, proto='tcp')

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 - domain name.
           (type=unicode or str)
service - service name.
           (type=unicode or str)
proto - protocol name.
           (type=str)
Returns:
host names and port numbers for the service or None.
           (type=list of (str,`int`))

shuffle_srv(records)

Randomly reorder SRV records using their weights.
Parameters:
records - SRV records to shuffle.
           (type=sequence of dns.rdtypes.IN.SRV)
Returns:
reordered records.
           (type=list of dns.rdtypes.IN.SRV)

Variable Details

__revision__

Type:
str
Value:
'$Id: resolver.py 503 2005-01-03 21:59:36Z jajcus $'                   

ip_re

Type:
SRE_Pattern
Value:
\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}                                     

service_aliases

Type:
dict
Value:
{'xmpp-server': ('jabber-server', 'jabber')}