[OpenSIPS-Devel] [ opensips-Feature Requests-2173626 ] enum: discriminate different types of DNS failures

SourceForge.net noreply at sourceforge.net
Fri Oct 17 05:04:59 CEST 2008


Feature Requests item #2173626, was opened at 2008-10-16 23:04
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=1086413&aid=2173626&group_id=232389

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: modules
Group: None
Status: Open
Priority: 5
Private: No
Submitted By: Phil Vandry (vandry)
Assigned to: Nobody/Anonymous (nobody)
Summary: enum: discriminate different types of DNS failures

Initial Comment:
enum_query() returns success if records were found in DNS and returns -1 under all other conditions:

- DNS query error
- DNS returned no results
- DNS record did not exist
- transient DNS failure

But it would be very useful to know what kind of failure occurred. For example, if the DNS record did not exist at all, 404 would be an appropriate response, but if a temporary nameserver failure occurred then 503 would be the correct reply.

This patch changed enum_query() to return 4 different negative failures for the 4 conditions listed above:

- DNS query error: -1
- DNS returned no results (answer section empty): -2
- DNS record did not exist (nxdomain): -3
- temporary failure: -4

You can use it like this:

enum_query("domain.");
switch ($retcode) {
  case -1:
    sl_send_reply("500", "Server Internal Error (DNS query problem)");
    exit;
  case -2:
    sl_send_reply("404", "Not Found");
    exit;
  case -3:
    sl_send_reply("484", "Address Incomplete");
    exit;
  case -4:
    sl_send_reply("503", "DNS Failure");
    exit;
}

(The reason for the 484 response on -3 result is not obvious. If you query DNS for a completely nonexistent name then you will get nxdomain and case -2 will apply. But if you query for a name that has no resource records in DNS but has at least one extant subdomain, you get NODATA. It's a clue that if you add more digits then the query will succeed.)

TODO: Documentation

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=1086413&aid=2173626&group_id=232389



More information about the Devel mailing list