mirror of
https://github.com/danog/dns.git
synced 2024-11-26 20:14:51 +01:00
Merge branch 'master' into amp_v2
This commit is contained in:
commit
badf3a9100
@ -77,4 +77,4 @@ function resolve(string $name, array $options = []): Promise {
|
|||||||
*/
|
*/
|
||||||
function query(string $name, $type, array $options = []): Promise {
|
function query(string $name, $type, array $options = []): Promise {
|
||||||
return resolver()->query($name, $type, $options);
|
return resolver()->query($name, $type, $options);
|
||||||
}
|
}
|
||||||
|
@ -7,27 +7,53 @@ use AsyncInterop\Loop;
|
|||||||
class IntegrationTest extends \PHPUnit_Framework_TestCase {
|
class IntegrationTest extends \PHPUnit_Framework_TestCase {
|
||||||
/**
|
/**
|
||||||
* @group internet
|
* @group internet
|
||||||
|
* @dataProvider provideHostnames
|
||||||
*/
|
*/
|
||||||
public function testResolve() {
|
public function testResolve($hostname) {
|
||||||
Loop::execute(\Amp\wrap(function () {
|
Loop::execute(\Amp\wrap(function () use ($hostname) {
|
||||||
$names = [
|
$result = (yield \Amp\Dns\resolve($hostname));
|
||||||
"google.com",
|
list($addr, $type, $ttl) = $result[0];
|
||||||
"github.com",
|
$inAddr = @\inet_pton($addr);
|
||||||
"stackoverflow.com",
|
$this->assertNotFalse(
|
||||||
"localhost",
|
$inAddr,
|
||||||
"192.168.0.1",
|
"Server name $hostname did not resolve to a valid IP address"
|
||||||
"::1",
|
);
|
||||||
];
|
|
||||||
|
|
||||||
foreach ($names as $name) {
|
|
||||||
$result = (yield \Amp\Dns\resolve($name));
|
|
||||||
list($addr, $type, $ttl) = $result[0];
|
|
||||||
$inAddr = @\inet_pton($addr);
|
|
||||||
$this->assertNotFalse(
|
|
||||||
$inAddr,
|
|
||||||
"Server name $name did not resolve to a valid IP address"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group internet
|
||||||
|
* @dataProvider provideServers
|
||||||
|
*/
|
||||||
|
public function testResolveWithCustomServer($server) {
|
||||||
|
Loop::execute(\Amp\wrap(function () use ($server) {
|
||||||
|
$result = (yield \Amp\Dns\resolve("google.com", [
|
||||||
|
"server" => $server
|
||||||
|
]));
|
||||||
|
list($addr, $type, $ttl) = $result[0];
|
||||||
|
$inAddr = @\inet_pton($addr);
|
||||||
|
$this->assertNotFalse(
|
||||||
|
$inAddr,
|
||||||
|
"Server name google.com did not resolve to a valid IP address via $server"
|
||||||
|
);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideHostnames() {
|
||||||
|
return [
|
||||||
|
["google.com"],
|
||||||
|
["github.com"],
|
||||||
|
["stackoverflow.com"],
|
||||||
|
["localhost"],
|
||||||
|
["192.168.0.1"],
|
||||||
|
["::1"],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideServers() {
|
||||||
|
return [
|
||||||
|
["8.8.8.8"],
|
||||||
|
["8.8.8.8:53"],
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user