[Twisted-Python] Writing a simple nameserver

Jean-Paul Calderone exarkun at divmod.com
Wed Aug 9 08:39:43 MDT 2006


On Wed, 9 Aug 2006 16:24:59 +0200, Yves Glodt <y.glodt at sitasoftware.lu> wrote:
>Hello,
>
>I have a database which contains a list of hosts with their IP-addresses, and
>I need to be able to connect to them by their name.
>
>The plan is to write a simple daemon using twisted names which accepts the dns
>query, looks up the requested address in the database, and answers the dns
>query.
>
>How would I do that with twisted names?
>
>p.s.
>(I skimmed over the documentation but got blinded by "Undocumented" labels.)
>

You want to implement an authority.  There is basically no documentation
for this, as you discovered.  You can take a look at one of the existing
authority implementations for some hints:

  http://twistedmatrix.com/trac/browser/trunk/twisted/names/authority.py#L61

Once you have an authority, you just need to construct a server based on
it.  You can see an example of this in the tap module:

  http://twistedmatrix.com/trac/browser/trunk/twisted/names/tap.py

This basically amounts to passing a list of authorities to a protocol
instance and then using listenUDP with it.

Twisted Names has never really received any polish.  The API it presents
for doing this is not necessarily well thought out or completely consistent.
If you would like to improve it, please feel free.

Jean-Paul




More information about the Twisted-Python mailing list