# Ruby suggestion:do\_not\_reverse\_lookup = true as default

**URL:** <https://www.ruby-forum.com/t/ruby-suggestion-do-not-reverse-lookup-true-as-default/170753>\
**Category:** Ruby\
**Created:** [June 22, 2009, 12:41pm UTC](https://www.ruby-forum.com/t/ruby-suggestion-do-not-reverse-lookup-true-as-default/170753 "2009-06-22T12:41:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [June 22, 2009, 12:41pm UTC](https://www.ruby-forum.com/t/ruby-suggestion-do-not-reverse-lookup-true-as-default/170753/1 "2009-06-22T12:41:31Z")

</div>

Currently ruby socket code defaults to always doing a reverse DNS lookup  
when it can [ex: once per incoming UDP packet].  
This causes “surprising” pauses when the lookup fails, because the DNS  
waits 15s to timeout, before passing the packet back to the program,  
since the pause is unexpected.

ex: [http://betterlogic.com/roger/?p=1646](http://betterlogic.com/roger/?p=1646)  
comment out the do\_not\_reverse\_lookup on the receiver and change the  
sender to send to IP127.0.0.255

It works great [no pause]if you set BasicSocket.do\_not\_reverse\_lookup to  
true, and is much less surprising. This isn’t the first time I’ve been  
bit by ruby’s internal packet DNS lookups and so thought I’d ask for  
feedback before suggesting to core that it be turned off by default.

The other benefit is that with DNS lookups, sometimes they succeed, and  
sometimes fail, which means that normal code could run into unexpected  
pauses when put into production–which is surprising and unwanted,  
really.

Thoughts on this one?  
Thanks.

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [June 22, 2009, 1:28pm UTC](https://www.ruby-forum.com/t/ruby-suggestion-do-not-reverse-lookup-true-as-default/170753/2 "2009-06-22T13:28:16Z")

</div>

On 22 Jun 2009, at 11:41, Roger P. wrote:

> pauses when put into production–which is surprising and unwanted,  
> really.
> 
> Thoughts on this one?  
> Thanks.

I tend to agree with you on this although I’d also suggest that the  
option become do\_reverse\_lookup if it’s going to default to false,  
that avoids having to read lots of code peppered with  
do\_not\_reverse\_lookup = false when a reverse lookup is desired. Double  
negatives are a guaranteed way to scramble frazzled brains 🙂

Ellie

## Eleanor McHugh Games With Brains [http://slides.games-with-brains.net](http://slides.games-with-brains.net)

raise ArgumentError unless @reality.responds\_to? :reason

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [June 23, 2009, 7:10pm UTC](https://www.ruby-forum.com/t/ruby-suggestion-do-not-reverse-lookup-true-as-default/170753/3 "2009-06-23T19:10:52Z")

</div>

On 23 Jun 2009, at 01:19, Daniel DeLorme wrote:

> I’ve been bit by this reverse lookup in the past. Even when setting  
> Net::HTTP’s open\_timeout, this has no effect on the rDNS lookup so  
> an operation with a timeout of 1s can actually time out after 15s.  
> Very confusing.
> 
> And really, minimizing unnecessary reverse lookups is better for the  
> health of the internet in general.

Very true, especially with dynamic DNS with short-ttl zones finally  
starting to catch on.

Ellie

## Eleanor McHugh Games With Brains [http://slides.games-with-brains.net](http://slides.games-with-brains.net)

raise ArgumentError unless @reality.responds\_to? :reason

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [June 23, 2009, 9:11pm UTC](https://www.ruby-forum.com/t/ruby-suggestion-do-not-reverse-lookup-true-as-default/170753/4 "2009-06-23T21:11:01Z")

</div>

Eleanor McHugh wrote:

> Double  
> negatives are a guaranteed way to scramble frazzled brains 🙂

I am not sure that you didn’t mean to not neglect to avoid not saying  
this. 🙂

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [June 23, 2009, 2:20am UTC](https://www.ruby-forum.com/t/ruby-suggestion-do-not-reverse-lookup-true-as-default/170753/5 "2009-06-23T02:20:25Z")

</div>

Eleanor McHugh wrote:

> > Thoughts on this one?  
> > Thanks.
> 
> I tend to agree with you on this although I’d also suggest that the  
> option become do\_reverse\_lookup if it’s going to default to false, that  
> avoids having to read lots of code peppered with do\_not\_reverse\_lookup =  
> false when a reverse lookup is desired. Double negatives are a  
> guaranteed way to scramble frazzled brains 🙂

+1 on both suggestions

I’ve been bit by this reverse lookup in the past. Even when setting  
Net::HTTP’s open\_timeout, this has no effect on the rDNS lookup so an  
operation with a timeout of 1s can actually time out after 15s. Very  
confusing.

And really, minimizing unnecessary reverse lookups is better for the  
health of the internet in general.

Daniel
