Comments (9)
Okay so what I think is happening here is that it's mixing the responses, and valid queries are somehow getting the error responses. Some of the responses are actually erroneous. If you run the requests in series by replacing the for
loop with:
for (
$current_ip_raw = $start_ip_raw - IPS_TO_LOAD;
$current_ip_raw < $start_ip_raw + IPS_TO_LOAD;
$current_ip_raw++
) {
$current_ip = long2ip($current_ip_raw);
$ips[] = $current_ip;
try {
$succeeded[$current_ip] = (yield Amp\Dns\query($current_ip, Amp\Dns\Record::PTR));
} catch (Exception $ex) {
$failed[$current_ip] = $ex;
}
}
and removing the list($failed, $succeeded) = (yield Amp\any($lookups));
line, you'll see that one request constantly fails. If you change IPS_TO_LOAD
to 10, you'll see two requests consistently fail (209.141.56.28
and 209.141.56.35
). However, when running these requests in parallel via Amp\any
, other requests also fail.
from dns.
This is still an issue in the Amp v2 version, additionally we leak the exception there.
<?php
use Amp\Loop;
require __DIR__ . '/vendor/autoload.php';
function format_exception(Exception $ex, $indent = 0) {
$output = get_class($ex) . ' - ' . $ex->getMessage();
if ($ex instanceof Amp\CombinatorException) {
foreach ($ex->getExceptions() as $inner) {
$output .= "\n" . str_repeat(' ', $indent) . ' --> ' . format_exception($inner, $indent + 1);
}
} else {
$prev = $ex->getPrevious();
if ($prev) {
$output .= "\n" . str_repeat(' ', $indent) . ' --> ' . format_exception($prev, $indent + 1);
}
}
return $output;
}
const IPS_TO_LOAD = 2;
Loop::run(function () {
$start_ip = '209.141.56.29';
$start_ip_raw = ip2long($start_ip);
for (
$current_ip_raw = $start_ip_raw - IPS_TO_LOAD;
$current_ip_raw < $start_ip_raw + IPS_TO_LOAD;
$current_ip_raw++
) {
$current_ip = long2ip($current_ip_raw);
$ips[] = $current_ip;
$lookups[$current_ip] = Amp\Dns\query($current_ip, Amp\Dns\Record::PTR);
}
list($failed, $succeeded) = (yield Amp\Promise\any($lookups));
echo '**** ', count($failed), " failures! ****\n\n";
foreach ($ips as $ip) {
if (array_key_exists($ip, $succeeded)) {
$result = $succeeded[$ip][0]->getValue();
echo $ip, ': ', $result, "\n";
} else if (array_key_exists($ip, $failed)) {
$ex = $failed[$ip];
if ($ex instanceof Amp\Dns\NoRecordException) {
echo $ip, ": No reverse DNS\n";
} else {
echo $ip, ': EXCEPTION: ', format_exception($ex), "\n";
}
} else {
echo $ip, ": UNKNOWN\n";
}
}
});
from dns.
Okay so what I think is happening here is that it's mixing the responses, and valid queries are somehow getting the error responses. Some of the responses are actually erroneous.
This is nothing caused by our library, it's the server responding with an empty domain name.
from dns.
I see no problems in the server response.
The failure is here or within libdns - I'm looking.
from dns.
@bwoebi It's in LibDNS.
from dns.
@bwoebi Seems like empty entries are indeed disallowed.
from dns.
Don't remember in which RFC I read that they're disallowed, can't find it again.
@DaveRandom ping.
from dns.
You sometimes get empty results now, but no more decode exceptions.
from dns.
LibDNS is being majorly refactored, one of the things that it will do is cease to validate things like this - i.e. context-dependent things (a domain name consisting of only the empty top-level label is, I suppose, theoretically valid).
In a case like this, however, I think it still makes sense for an exception to be throw by amp/dns (i.e. the client implementation). An empty domain name in response to a PTR query definitely does not make sense and is exceptional, even if it is dependent on external data.
One could perhaps have this behaviour controlled by an option to convert the response into the same behaviour as "non-existent record" when talking to buggy servers, but the default behaviour should be to throw. IMHO.
from dns.
Related Issues (20)
- Too many time to resolve localhost domain HOT 7
- getting could not load the system's DNS configuration, using synchronous, blocking fallback error HOT 9
- Incomplete packet error (still exists) HOT 1
- Could Not Resolve Host HOT 3
- Backport queue errors on closure
- Rename Record and Resolver as well?
- Amp\Dns\resolve misses optional Cancellation parameter
- Async example? HOT 1
- Resolution where NDots > 1 failing
- Remove amphp/file dependency
- Bump the minimum version of amphp/uri HOT 4
- DNS resolution not working on Kubernetes HOT 5
- Subtype 'Too many redirects' DnsException HOT 1
- CreateProcess failed, error 193 HOT 6
- Libdns bug HOT 5
- Are dotless domains valid? HOT 3
- DNS frequently fails on Windows HOT 3
- Incomplete packet error HOT 4
- etc/resolve ndots set to 1 HOT 1
- Ignore ServFail / NxDomain for search list, e.g. in Kubernetes cluster HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dns.