[Twisted-Python] DNS SRV support for Connectors
![](https://secure.gravatar.com/avatar/0b90087ed4aef703541f1cafdb4b49a1.jpg?s=120&d=mm&r=g)
Hi. I wanted to have SRV record (RFC 2782) support connecting to services. So here we go. The following patch adds a new Connector class that takes service (smtp, http, ldap, ..) and domain (example.com), looks for a DNS SRV record and falls back sanely if not found. itamar pointed out that this might be more suitable in twisted.names.client -- feel free to point out what is the "right" place. Please give feedback. The patch also fixes the output of SRV-using example; it used to not output the interesting bits. The patch is attached, and the latest version is at http://www.twistedmatrix.com/users/tv/connectTCPService.patch -- :(){ :|:&};:
![](https://secure.gravatar.com/avatar/0b90087ed4aef703541f1cafdb4b49a1.jpg?s=120&d=mm&r=g)
On Mon, Dec 30, 2002 at 12:47:04AM +0200, Tommi Virtanen wrote:
Please comment. I'm not familiar enough on what *YOU* want to do with reactors to know the right place for this, and whether e.g. a function like connectTCPService() should exist at all (and if so, how to implement it for other reactors). If I get no comments, I will 1. Commit the change to TCPConnector that makes it accept service names as port. 2. Find and wear my asbestos underwear. 3. Commit the TCPServiceConnector class. 4. Sit and wait for flames. 5. Commit the connectTCPService function. 6. Run away. -- :(){ :|:&};:
![](https://secure.gravatar.com/avatar/433365de0f787faa3ed3e6dd1da5884f.jpg?s=120&d=mm&r=g)
On Tue, 31 Dec 2002 22:32:45 +0200 Tommi Virtanen <tv@twistedmatrix.com> wrote:
On Mon, Dec 30, 2002 at 12:47:04AM +0200, Tommi Virtanen wrote:
It should not be in twisted.internet.default, or in any reactor for that matter. Where you should put is another question (twisted.names?). -- Itamar Shtull-Trauring http://itamarst.org/ Available for Python, Twisted, Zope and Java consulting ***> http://VoteNoWar.org -- vote/donate/volunteer <***
![](https://secure.gravatar.com/avatar/56e4cc78ea7fcf3bb37888ebf23bc1f0.jpg?s=120&d=mm&r=g)
On Mon, Dec 30, 2002 at 12:47:04AM +0200, Tommi Virtanen wrote:
Hooray. :) One thing that concerns me is that these won't be serialized correctly. I -thought- you might be able to drop the resulting connector into theApplication.tcpConnectors by hand, but at a closer look it doesn't seem that would work. Does anyone have any ideas on this? Since connectTCPService does depend on t.names, I agree with itamar that it isn't appropriate for inclusion in t.internet, which rules out changing Application to suit it specifically. Perhaps a general interface for user-specified connector functions? Something like... app.connectWith(connectTCPService, 'service', 'domain', ...) so that the call info could be serialized and re-invoked on the next run. Good? Bad? Jp -- "The problem is, of course, that not only is economics bankrupt but it has always been nothing more than politics in disguise ... economics is a form of brain damage." -- Hazel Henderson -- 12:00am up 16 days, 9:46, 4 users, load average: 0.08, 0.09, 0.08
![](https://secure.gravatar.com/avatar/0b90087ed4aef703541f1cafdb4b49a1.jpg?s=120&d=mm&r=g)
On Mon, Dec 30, 2002 at 12:47:04AM +0200, Tommi Virtanen wrote:
Please comment. I'm not familiar enough on what *YOU* want to do with reactors to know the right place for this, and whether e.g. a function like connectTCPService() should exist at all (and if so, how to implement it for other reactors). If I get no comments, I will 1. Commit the change to TCPConnector that makes it accept service names as port. 2. Find and wear my asbestos underwear. 3. Commit the TCPServiceConnector class. 4. Sit and wait for flames. 5. Commit the connectTCPService function. 6. Run away. -- :(){ :|:&};:
![](https://secure.gravatar.com/avatar/433365de0f787faa3ed3e6dd1da5884f.jpg?s=120&d=mm&r=g)
On Tue, 31 Dec 2002 22:32:45 +0200 Tommi Virtanen <tv@twistedmatrix.com> wrote:
On Mon, Dec 30, 2002 at 12:47:04AM +0200, Tommi Virtanen wrote:
It should not be in twisted.internet.default, or in any reactor for that matter. Where you should put is another question (twisted.names?). -- Itamar Shtull-Trauring http://itamarst.org/ Available for Python, Twisted, Zope and Java consulting ***> http://VoteNoWar.org -- vote/donate/volunteer <***
![](https://secure.gravatar.com/avatar/56e4cc78ea7fcf3bb37888ebf23bc1f0.jpg?s=120&d=mm&r=g)
On Mon, Dec 30, 2002 at 12:47:04AM +0200, Tommi Virtanen wrote:
Hooray. :) One thing that concerns me is that these won't be serialized correctly. I -thought- you might be able to drop the resulting connector into theApplication.tcpConnectors by hand, but at a closer look it doesn't seem that would work. Does anyone have any ideas on this? Since connectTCPService does depend on t.names, I agree with itamar that it isn't appropriate for inclusion in t.internet, which rules out changing Application to suit it specifically. Perhaps a general interface for user-specified connector functions? Something like... app.connectWith(connectTCPService, 'service', 'domain', ...) so that the call info could be serialized and re-invoked on the next run. Good? Bad? Jp -- "The problem is, of course, that not only is economics bankrupt but it has always been nothing more than politics in disguise ... economics is a form of brain damage." -- Hazel Henderson -- 12:00am up 16 days, 9:46, 4 users, load average: 0.08, 0.09, 0.08
participants (3)
-
Itamar Shtull-Trauring
-
Jp Calderone
-
Tommi Virtanen