Download the PHP package icicleio/dns without Composer

On this page you can find all versions of the php package icicleio/dns. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package dns

Asynchronous DNS for Icicle

This library is a component for Icicle, providing an asynchronous DNS query executor, resolver, and client connector. An asynchronous DNS server is currently under development and will be added to this component in the future. Like other Icicle components, this library uses Generators to make writing asynchronous code more like writing synchronous code.

Build Status Coverage Status Semantic Version @icicleio on Twitter

Requirements
Installation

The recommended way to install is with the Composer package manager. (See the Composer installation guide for information on installing and using Composer.)

Run the following command to use this library in your project:

You can also manually edit composer.json to add this library as a project requirement.

Example

The example below uses the Icicle\Dns\resolver() function to asynchronously find the IP address for the domain icicle.io.

Documentation

Methods returning a Generator can be used to create a Coroutine (e.g., new Coroutine($executor->execute(...))) or yielded within another Coroutine (use yield from in PHP 7 for better performance).

This library uses LibDNS to create and parse DNS messages. Unfortunately the documentation for this library is currently limited to DocComments in the source code. If only using resolvers and connectors in this library, there is no need to worry about how LibDNS works. Executors returns coroutines that are resolved with LibDNS\Messages\Message instances, representing the response from the DNS server. Using these objects is simple and will be described in the executor section below.

Function prototypes

Prototypes for object instance methods are described below using the following syntax:

Executors

Executors are the foundation of the DNS component, performing any DNS query and returning the full results of that query. Resolvers and connectors depend on executors to perform the DNS query required for their operation.

Each executor implements Icicle\Dns\Executor\Executor that defines a single method, execute().

Option Type Description
timeout float Timeout until query fails. Default is 2 seconds.
retries int Number of times to attempt the query before failing. Default is 5 times.

An executor will retry a query a number of times if it doesn't receive a response within timeout seconds. The number of times a query will be retried before failing is defined by retries, with timeout seconds elapsing between each query attempt.

Resolution Type Description
Fulfilled LibDNS\Message\Message Query response. Usage described below.
Rejected Icicle\Dns\Exception\FailureException If sending the request or parsing the response fails.
Rejected \Icicle\Dns\Exception\MessageException If the server returns a non-zero response code or no response is received.

execute() Function

The simplest way to perform a DNS query is to use the Icicle\Dns\execute() function. This function uses an Icicle\Dns\Executor\Executor object that can be set or retrieved using the Icicle\Dns\executor() function.

Example using the execute() function to find the A record for a domain:

Creating an Executor

The simplest executor is Icicle\Dns\Executor\BasicExecutor, created by providing the constructor with the IP address of a DNS server to use to perform queries. It is recommended to use a DNS server closest to you, such as the local router. If this is not possible, Google operates two DNS server that also can be used at 8.8.8.8 and 8.8.4.4.

The Icicle\Dns\Executor\BasicExecutor constructor also accepts an instance of Icicle\Socket\Connector\Connector as the second argument if custom behavior is desired when connecting to the name server. If no instance is given, the default global connector is used (see Icicle\Socket\connector()).

Using an Executor

Once created, an executor is used by calling the execute() method with the domain and type of DNS query to be performed. The type may be a case-insensitive string naming a record type (e.g., 'A', 'MX', 'NS', 'PTR', 'AAAA') or the integer value corresponding to a record type (LibDNS\Records\ResourceQTypes defines constants corresponding to a the integer value of a type). execute() returns a coroutine fulfilled with an instance of LibDNS\Messages\Message that represents the response from the name server. LibDNS\Messages\Message objects have several methods that will need to be used to fetch the data in the response.

DNS records in the traversable LibDNS\Records\RecordCollection objects are represented as instances of LibDNS\Records\Resource. These objects have several methods to access the data associated with the record.

Below is an example of how an executor can be used to find the NS records for a domain.

MultiExecutor

The Icicle\Dns\Executor\MultiExecutor class can be used to combine multiple executors to send queries to several name servers so queries can be resolved even if some name servers stop responding.

Queries using the above executor will automatically send requests to the second name server if the first does not respond. Subsequent queries are initially sent to the last server that successfully responded to a query.

Resolver

A resolver finds the IP addresses for a given domain. Icicle\Dns\Resolver\BasicResolver implements Icicle\Dns\Resolver\Resolver, which defines a single method, resolve(). A resolver is essentially a specialized executor that performs only A queries, fulfilling the coroutine returned from resolve() with an array of IP addresses (even if only one or zero IP addresses is found, the coroutine is still resolved with an array).

Option Type Description
mode int Resolution mode: IPv4 or IPv6. Use the constants ResolverInterface::IPv4 or `ResolverInterface::IPv6.
timeout float Timeout until query fails. Default is 2 seconds.
retries int Number of times to attempt the query before failing. Default is 5 times.

resolve() Function

The simplest way find the IP address for a domain is to use the Icicle\Dns\resolve() function. This function uses an Icicle\Dns\Resolver\Resolver object that can be set or retrieved using the Icicle\Dns\resolver() function.

Example using the resolve() function to resolve the IP address of a domain:

Like executors, a resolver will retry a query retries times if the name server does not respond within timeout seconds.

The Icicle\Resolver\BasicResolver class is constructed by passing an Icicle\Executor\Executor instance that is used to execute queries to resolve domains. If no executor is given, one will be created by default, using 8.8.8.8 and 8.8.4.4 as DNS servers for the executor.

Resolution Type Description
Fulfilled array Array of resolved IP addresses. May be empty.
Rejected Icicle\Dns\Exception\FailureException If sending the request or parsing the response fails.
Rejected \Icicle\Dns\Exception\MessageException If the server returns a non-zero response code or no response is received.
Example

Connector

The connector component connects to a server by first resolving the hostname provided, then making the connection and resolving the returned coroutine with an instance of Icicle\Socket\Socket.

Icicle\Dns\Connector\Connector defines a single method, connect() that should resolve a host name and connect to one of the resolved servers, resolving the coroutine with the connected client.

connect() Function

The simplest way to resolve a domain name and connect to a port on the resolved host is with the Icicle\Dns\connect() function. This function uses an Icicle\Dns\Connector\Connector object that can be set or retrieved using the Icicle\Dns\connector() function.

Example using the connect() function to resolve the IP address of a domain and connect to port 443:

Icicle\Dns\Connector\DefaultConnector will attempt to connect to one of the IP addresses found for a given host name. If the server at that IP is unresponsive, the connector will attempt to establish a connection to the next IP in the list until a server accepts the connection. Only if the connector is unable to connect to all of the IPs will it reject the coroutine returned from connect(). The constructor also optionally accepts an instance of Icicle\Socket\Connector\Connector if custom behavior is desired when connecting to the resolved host.

Option Type Description
mode int Resolution mode: IPv4 or IPv6. Use the constants Resolver::IPv4 or `Resolver::IPv6.
timeout float Timeout until query fails. Default is 2 seconds.
retries int Number of times to attempt the query before failing. Default is 5 times.

Additionally, all the other options available to Icicle\Socket\Connector\Connector::connect() may also be used.

Resolution Type Description
Fulfilled Icicle\Socket\Socket Connected client.
Rejected Icicle\Socket\Exception\FailureException If resolving the IP or connecting fails.
Example

All versions of dns with dependencies

PHP Build Version
Package Version
Requires icicleio/icicle Version ^0.9.1
icicleio/socket Version ^0.5
daverandom/libdns Version ^1
paragonie/random_compat Version ^1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package icicleio/dns contains the following files

Loading the files please wait ....