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

Module pyxmpp.resolver

DNS resolever with SRV record support.

Normative reference:
  - `RFC 1035 <http://www.ietf.org/rfc/rfc1035.txt>`__
  - `RFC 2782 <http://www.ietf.org/rfc/rfc2782.txt>`__

Function Summary
  getaddrinfo(host, port, family, socktype, proto, allow_cname)
Resolve host and port into addrinfo struct.
  reorder_srv(records)
Reorder SRV records using their priorities and weights.
  resolve_srv(domain, service, proto)
Resolve service domain to server name and port number using SRV records.
  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.
    - `port`: service port number or name.
    - `family`: address family.
    - `socktype`: socket type.
    - `proto`: protocol number or name.
    - `allow_cname`: when False CNAME responses are not allowed.
:Types:
    - `host`: `unicode` or `str`
    - `port`: `int` or `str`
    - `family`: `int`
    - `socktype`: `int`
    - `proto`: `int` or `str`
    - `allow_cname`: `bool`

:return: list of (family, socktype, proto, canonname, sockaddr).
:returntype: `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.
:Types:
    - `records`: `list` of `dns.rdtypes.IN.SRV`

:return: reordered records.
:returntype: `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.
    - `service`: service name.
    - `proto`: protocol name.
:Types:
    - `domain`: `unicode` or `str`
    - `service`: `unicode` or `str`
    - `proto`: `str`

:return: host names and port numbers for the service or None.
:returntype: `list` of (`str`,`int`)

shuffle_srv(records)

Randomly reorder SRV records using their weights.

:Parameters:
    - `records`: SRV records to shuffle.
:Types:
    - `records`: sequence of `dns.rdtypes.IN.SRV`

:return: reordered records.
:returntype: `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')}                           

Generated by Epydoc 2.1 on Wed May 31 22:36:58 2006 http://epydoc.sf.net