Documentation

HostsFileExecutor
in package
implements ExecutorInterface

FinalYes

Resolves hosts from the given HostsFile or falls back to another executor

If the host is found in the hosts file, it will not be passed to the actual DNS executor. If the host is not found in the hosts file, it will be passed to the DNS executor as a fallback.

Table of Contents

Interfaces

ExecutorInterface

Properties

$fallback  : mixed
$hosts  : mixed

Methods

__construct()  : mixed
query()  : PromiseInterface<string|int, Message>
Executes a query and will return a response message
getIpFromHost()  : mixed

Properties

Methods

query()

Executes a query and will return a response message

public query(Query $query) : PromiseInterface<string|int, Message>

It returns a Promise which either fulfills with a response React\Dns\Model\Message on success or rejects with an Exception if the query is not successful. A response message may indicate an error condition in its rcode, but this is considered a valid response message.

$executor->query($query)->then(
    function (React\Dns\Model\Message $response) {
        // response message successfully received
        var_dump($response->rcode, $response->answers);
    },
    function (Exception $error) {
        // failed to query due to $error
    }
);

The returned Promise MUST be implemented in such a way that it can be cancelled when it is still pending. Cancelling a pending promise MUST reject its value with an Exception. It SHOULD clean up any underlying resources and references as applicable.

$promise = $executor->query($query);

$promise->cancel();
Parameters
$query : Query
Return values
PromiseInterface<string|int, Message>

getIpFromHost()

private getIpFromHost(mixed $host) : mixed
Parameters
$host : mixed

        
On this page

Search results