[Twisted-Python] Writing a simple nameserver
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.) Best regards, Yves
On Wed, 9 Aug 2006 16:24:59 +0200, Yves Glodt <y.glodt@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
On Wednesday 09 August 2006 16:39, Jean-Paul Calderone wrote:
On Wed, 9 Aug 2006 16:24:59 +0200, Yves Glodt <y.glodt@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:
Hi Paul, thanks for your answer, I'll take a look at it, although I'm by far no expert in python nor dns I hope I find my way through the provided examples :-) Best regards, Yves
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
participants (2)
-
Jean-Paul Calderone
-
Yves Glodt