Skip to content

exante/python-srvresolver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SRV resolver

PyPI version PyPI license PyPI format

Helper to get record from SRV address according to RFC2782.

Features

  • support of record weights and priorities
  • check service availability at specific port
  • random record selector
  • cache with ttl support

Install

The package can be installed simply by using pip:

pip install srvresolver

Example

from srvresolver.srv_resolver import SRVResolver

# get all records
SRVResolver.resolve('_service._tcp.example.com')

# get one random record with working connection 
SRVResolver.resolve_random('_service._tcp.example.com')

# get first available server
SRVResolver.resolve_first('_service._tcp.example.com')

Adds

Resolver with DNS cache

This one uses cache implemented in dnspython module.

from srvresolver.srv_resolver_cached import SRVResolverCached

# get all records
SRVResolverCached.resolve('_service._tcp.example.com')
# same but don't do dns request, load from cache if not expired
SRVResolverCached.resolve('_service._tcp.example.com')

Postgres SRV record resolver

Extract postgres records from SRV and check whether master or slave. Requires psycopg2

from srvresolver.postgres_resolver import PostgresResolver

# get random working slave record
PostgresResolver.get_slave('_postgresql._tcp.example.com', username, password)

# get random working master record
PostgresResolver.get_master('_postgresql._tcp.example.com', username, password)

About

helper to work with srv records in python

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages