Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #33372
| From | aahz@pythoncraft.com (Aahz) |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | DNS from Python (was Re: Subprocess puzzle and two questions) |
| Date | 2012-11-14 21:42 -0800 |
| Organization | The Cat & Dragon |
| Message-ID | <k81vd2$aoi$1@panix5.panix.com> (permalink) |
| References | <mailman.3664.1352867713.27098.python-list@python.org> <mailman.3684.1352904008.27098.python-list@python.org> <k80gd6$t0q$1@panix2.panix.com> <mailman.3700.1352930072.27098.python-list@python.org> |
In article <mailman.3700.1352930072.27098.python-list@python.org>,
Chris Angelico <rosuav@gmail.com> wrote:
>On Thu, Nov 15, 2012 at 3:20 AM, Roy Smith <roy@panix.com> wrote:
>>
>> My first thought to solve both of these is that it shouldn't be too
>> hard to hand-craft a minimal DNS query and send it over UDP. Then, I
>> hunted around a bit and found that somebody had already done that, in
>> spades. Take a look at http://www.dnspython.org; it might be exactly
>> what's needed here.
>
>Yeah, that sounds like a good option. I'm slightly surprised that
>there's no way with the Python stdlib to point a DNS query at a
>specific server, but dnspython might be the solution. On the flip
>side, dnspython is dauntingly large; it looks like a full
>implementation of DNS, but I don't see a simple entrypoint that wraps
>it all up into a simple function that can be bracketed with
>time.time() calls (granted, I only skimmed the docs VERY quickly). So
>it may be simpler to hand-craft an outgoing UDP packet once, save it
>as a string literal, send that, and just wait for any response. That
>eliminates all DNS protocolling and just times the round trip.
From one of my scripts lying around:
domain = MAILTO.split('@',1)[1]
server = str(dns.resolver.query(domain, 'MX')[0].exchange)
You'll need to play around a bit to find out what that does, but it
should point you in the right direction.
--
Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/
"LL YR VWL R BLNG T S" -- www.nancybuttons.com
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Subprocess puzzle and two questions wrw@mac.com - 2012-11-13 22:34 -0500
Re: Subprocess puzzle and two questions Roy Smith <roy@panix.com> - 2012-11-13 23:41 -0500
Re: Subprocess puzzle and two questions William Ray Wing <wrw@mac.com> - 2012-11-14 00:03 -0500
Re: Subprocess puzzle and two questions Roy Smith <roy@panix.com> - 2012-11-14 09:22 -0500
Re: Subprocess puzzle and two questions Chris Angelico <rosuav@gmail.com> - 2012-11-15 01:40 +1100
Re: Subprocess puzzle and two questions roy@panix.com (Roy Smith) - 2012-11-14 11:20 -0500
Re: Subprocess puzzle and two questions Chris Angelico <rosuav@gmail.com> - 2012-11-15 08:54 +1100
Re: Subprocess puzzle and two questions Roy Smith <roy@panix.com> - 2012-11-14 20:49 -0500
Re: Subprocess puzzle and two questions Chris Angelico <rosuav@gmail.com> - 2012-11-15 13:04 +1100
Re: Subprocess puzzle and two questions Roy Smith <roy@panix.com> - 2012-11-14 21:10 -0500
Re: Subprocess puzzle and two questions Chris Angelico <rosuav@gmail.com> - 2012-11-15 13:21 +1100
Re: Subprocess puzzle and two questions Dave Angel <d@davea.name> - 2012-11-14 21:55 -0500
Re: Subprocess puzzle and two questions Kushal Kumaran <kushal.kumaran+python@gmail.com> - 2012-11-15 10:23 +0530
Re: Subprocess puzzle and two questions Nobody <nobody@nowhere.com> - 2012-11-15 22:54 +0000
Re: Subprocess puzzle and two questions Roy Smith <roy@panix.com> - 2012-11-15 20:07 -0500
Re: Subprocess puzzle and two questions Nobody <nobody@nowhere.com> - 2012-11-17 00:17 +0000
DNS from Python (was Re: Subprocess puzzle and two questions) aahz@pythoncraft.com (Aahz) - 2012-11-14 21:42 -0800
Re: Subprocess puzzle and two questions wrw@mac.com - 2012-11-14 09:37 -0500
Re: Subprocess puzzle and two questions Tim Roberts <timr@probo.com> - 2012-11-13 23:17 -0800
csiph-web