1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-03 09:49:30 +02:00
ampache/modules/React/Dns
2014-02-05 08:08:46 +01:00
..
Config Begin WebSocket support for Broadcast and Player control 2014-02-05 08:08:46 +01:00
doc Begin WebSocket support for Broadcast and Player control 2014-02-05 08:08:46 +01:00
Model Begin WebSocket support for Broadcast and Player control 2014-02-05 08:08:46 +01:00
Protocol Begin WebSocket support for Broadcast and Player control 2014-02-05 08:08:46 +01:00
Query Begin WebSocket support for Broadcast and Player control 2014-02-05 08:08:46 +01:00
Resolver Begin WebSocket support for Broadcast and Player control 2014-02-05 08:08:46 +01:00
BadServerException.php Begin WebSocket support for Broadcast and Player control 2014-02-05 08:08:46 +01:00
composer.json Begin WebSocket support for Broadcast and Player control 2014-02-05 08:08:46 +01:00
README.md Begin WebSocket support for Broadcast and Player control 2014-02-05 08:08:46 +01:00
RecordNotFoundException.php Begin WebSocket support for Broadcast and Player control 2014-02-05 08:08:46 +01:00

Dns Component

Async DNS resolver.

The main point of the DNS component is to provide async DNS resolution. However, it is really a toolkit for working with DNS messages, and could easily be used to create a DNS server.

Basic usage

The most basic usage is to just create a resolver through the resolver factory. All you need to give it is a nameserver, then you can start resolving names, baby!

$loop = React\EventLoop\Factory::create();
$factory = new React\Dns\Resolver\Factory();
$dns = $factory->create('8.8.8.8', $loop);

$dns->resolve('igor.io')->then(function ($ip) {
    echo "Host: $ip\n";
});

But there's more.

Caching

You can cache results by configuring the resolver to use a CachedExecutor:

$loop = React\EventLoop\Factory::create();
$factory = new React\Dns\Resolver\Factory();
$dns = $factory->createCached('8.8.8.8', $loop);

$dns->resolve('igor.io')->then(function ($ip) {
    echo "Host: $ip\n";
});

...

$dns->resolve('igor.io')->then(function ($ip) {
    echo "Host: $ip\n";
});

If the first call returns before the second, only one query will be executed. The second result will be served from cache.

Todo

  • Implement message body parsing for types other than A and CNAME: NS, SOA, PTR, MX, TXT, AAAA
  • Implement authority and additional message parts
  • Respect /etc/hosts

References

  • RFC1034 Domain Names - Concepts and Facilities
  • RFC1035 Domain Names - Implementation and Specification