6.0.0-beta1
7/6/25

[#7374] speed up hostname lookups on broken DNS
Summary speed up hostname lookups on broken DNS
Queue Horde Framework Packages
Queue Version HEAD
Type Enhancement
State Resolved
Priority 2. Medium
Owners jan (at) horde (dot) org
Requester adrieder (at) sbox (dot) tugraz (dot) at
Created 09/22/2008 (6131 days ago)
Due 09/22/2008 (6131 days ago)
Updated 05/01/2009 (5910 days ago)
Assigned 11/11/2008 (6081 days ago)
Resolved 04/04/2009 (5937 days ago)
Milestone 3.3.4
Patch Yes

History
05/01/2009 06:04:43 PM CVS Commit Comment #29 Reply to this comment
05/01/2009 06:01:18 PM CVS Commit Comment #28 Reply to this comment
04/06/2009 08:19:14 AM Jan Schneider Comment #27 Reply to this comment
Makes sense.
04/06/2009 06:34:41 AM Matt Selsky Comment #26 Reply to this comment
Should we add a test for Net_DNS to test.php?
04/04/2009 12:31:54 PM Jan Schneider State ⇒ Resolved
 
04/04/2009 12:31:11 PM Jan Schneider Comment #25
Assigned to Jan Schneider
Taken from Horde DevelopersHorde Developers
Reply to this comment
Tweaked and committed, thanks.
04/04/2009 10:15:08 AM Jan Schneider Deleted Original Message
 
02/09/2009 08:33:13 AM adrieder (at) sbox (dot) tugraz (dot) at Comment #22
New Attachment: net_dns_FRAMEWORK_3.patch Download
Reply to this comment
here is the patch against FRAMEWORK_3 from cvs.
01/24/2009 06:02:46 PM Jan Schneider Milestone ⇒ 3.3.4
 
11/11/2008 07:24:27 AM Chuck Hagenbuch State ⇒ Assigned
 
11/10/2008 02:17:36 AM Matt Selsky Comment #21 Reply to this comment
I did look and it seemed mostly cosmetic.  Looking closer, I see that 
some of those places provide more useful data to users.
11/10/2008 01:04:10 AM Jan Schneider Comment #20 Reply to this comment
Of course, did you take a look at places where this patch works? Most 
of those are externally provided hostnames, e.g. when doing country 
lookups etc.
11/10/2008 12:54:06 AM Matt Selsky Comment #19 Reply to this comment
Does having the hostname, instead of just the IP address, have enough 
value to justify the multiple possible delays?
11/09/2008 11:24:30 PM Jan Schneider Comment #18 Reply to this comment
I personally have temporary timeouts for whatever reason here. An 
immediate reload is successful most of the time.
11/09/2008 08:10:00 PM Chuck Hagenbuch State ⇒ Feedback
 
11/09/2008 08:04:11 PM Matt Selsky Comment #17 Reply to this comment
Is there a real advantage to bothering to retry?  Is it more likely to 
work if tried again?  I think we are just trying to avoid waiting for 
a DNS server that will never respond, so a single try, with any 
timeout shorter than 60 seconds would put it in a better situation.
11/09/2008 10:57:34 AM adrieder (at) sbox (dot) tugraz (dot) at Comment #16
New Attachment: net_dns_v3.patch Download
Reply to this comment
here is an updated patch, with the defaults set to 2 seconds. 
Personally I think that a name server should always have a fast 
internet connection and the connection between the server running 
horde and the name server will normally also be quite fast.
10/07/2008 01:34:23 PM arjen+horde (at) de-korte (dot) org Comment #15 Reply to this comment
Defaulting to a 1 second timeout and 1 retry only will result in 
failed hostname lookups on slow connections. Wouldn't it be better to 
use more conservative defaults (5 seconds, 3 retries) and have 
administrators lower these values should they feel this provides a 
better performance?
10/07/2008 12:30:26 PM Jan Schneider Assigned to Horde DevelopersHorde Developers
State ⇒ Assigned
Milestone ⇒ 3.3.1
Patch ⇒ Yes
 
10/07/2008 12:30:07 PM Jan Schneider Deleted Original Message
 
10/07/2008 12:30:01 PM Jan Schneider Deleted Original Message
 
10/07/2008 12:29:57 PM Jan Schneider Deleted Original Message
 
10/07/2008 12:29:51 PM Jan Schneider Deleted Original Message
 
10/02/2008 11:07:08 PM Chuck Hagenbuch Deleted Original Message
 
10/02/2008 09:55:28 PM adrieder (at) sbox (dot) tugraz (dot) at Comment #14
New Attachment: net_dns_v2.patch
Reply to this comment
there was a typo in my net_dns.patch please use the net_dns_v2.patch
09/24/2008 07:16:41 PM adrieder (at) sbox (dot) tugraz (dot) at Comment #13
New Attachment: net_dns.patch
Reply to this comment
attached is a patch which makes the use of Net/DNS optionally. If the 
module is not found it falls back to the php gethostbyaddr. The patch 
also makes the timeouts configurable in horde.

The patch obsoletes the previously uploaded patches.



Is there any chance to have it included into the code base?
09/23/2008 11:55:29 AM adrieder (at) sbox (dot) tugraz (dot) at Comment #12
New Attachment: sessions.php.patch
Reply to this comment
and finally sessions.php.patch
09/22/2008 07:32:45 PM adrieder (at) sbox (dot) tugraz (dot) at Comment #11
New Attachment: Headers.php.patch
Reply to this comment
...Headers.php patch
09/22/2008 07:32:06 PM adrieder (at) sbox (dot) tugraz (dot) at Comment #10
New Attachment: NLS.php.patch
Reply to this comment
...NLS.php patch
09/22/2008 07:19:18 PM adrieder (at) sbox (dot) tugraz (dot) at Comment #9
New Attachment: Auth.php.patch
Reply to this comment
and here is a patch for Auth.php
09/22/2008 06:10:21 PM adrieder (at) sbox (dot) tugraz (dot) at Comment #8 Reply to this comment
...and here without setting the RES_OPTIONS env. vars.



<?php

require_once 'Net/DNS.php';



$now = time();



$resolver = new Net_DNS_Resolver();

$resolver->retry = 1;

$resolver->retrans = 1;

$response = $resolver->query('153.19.206.48');

if ($response) {

     foreach ($response->answer as $rr) {

         $rr->display();

     }

}



print time() - $now . "\n";

?>


09/22/2008 06:06:10 PM adrieder (at) sbox (dot) tugraz (dot) at Comment #7 Reply to this comment
That's it, if using an external pear module it ok :-)



The following cod works fine:



<?php

require_once 'Net/DNS.php';



$resolver = new Net_DNS_Resolver();

$now = time();



putenv('RES_OPTIONS=retrans:1 retry:1 timeout:1 attempts:1');

require_once 'Net/DNS.php';



$response = $resolver->query('153.19.206.48');

if ($response) {

     foreach ($response->answer as $rr) {

         $rr->display();

     }

}

print time() - $now . "\n";

?>


09/22/2008 05:56:47 PM Matt Selsky Comment #6 Reply to this comment
09/22/2008 05:48:00 PM adrieder (at) sbox (dot) tugraz (dot) at Comment #5 Reply to this comment
after quite a time of searching for a solution I came also to the 
conclusion that this is the only possible way in php to solve this.

The following posting should also be noted:

http://us2.php.net/manual/en/function.gethostbyaddr.php#58970
09/22/2008 05:27:25 PM Chuck Hagenbuch Comment #4 Reply to this comment
Something like 
http://us2.php.net/manual/en/function.gethostbyaddr.php#46869 is the 
only thing I see. This feels awfully hackish though.
09/22/2008 04:41:42 PM adrieder (at) sbox (dot) tugraz (dot) at Comment #3 Reply to this comment
How much do we get from doing the lookup, as opposed to just showing
the IP address?
Well I think not much, except that it looks "nicer" in:



- the "last login" line (see ./framework/Auth/Auth.php)

- in the MIME headers of the sent messages (see 
./framework/MIME/MIME/Headers.php)

- in the active sessions view for the admin (see ./admin/sessions.php)



I guess in ./framework/NLS/NLS.php the IP needs to be resolved, so 
"timeoutable" lookup could help most here.


09/22/2008 04:20:04 PM Chuck Hagenbuch Comment #2
State ⇒ Feedback
Reply to this comment
How much do we get from doing the lookup, as opposed to just showing 
the IP address?
09/22/2008 01:18:48 PM adrieder (at) sbox (dot) tugraz (dot) at Comment #1
State ⇒ New
Priority ⇒ 2. Medium
Type ⇒ Enhancement
Summary ⇒ speed up hostname lookups on broken DNS
Due ⇒ 09/22/2008
Queue ⇒ Horde Framework Packages
Milestone ⇒
Patch ⇒ No
Reply to this comment
There are some strange providers out there who configure there 
nameserver to block DNS-lookups of IPs in their networks so that they 
run into a time out. This is very annoying since the login into 
Horde/IMP takes very long (> 60 sec.) until the gethostbyaddr() calls 
time out. This leads to strange behavior afterwards e.g. IMP can't 
save sent messages in the sent-mail folder or move messages to the 
trash folder (permission denied).



It would by good to have a dns lookup with a short timeout. 
Unfortunately the php gethostbyaddr() function does not have a timeout 
option.



e.g.

<?php

$now = time();

print gethostbyaddr('153.19.206.48') . "\n";

print time() - $now . "\n";

?>

results in:

153.19.206.48

70




Saved Queries