final class EventDnsBase (View source)

EventDnsBase.

Represents Libevent's DNS base structure. Used to resolve DNS asyncronously, parse configuration files like resolv.conf etc.

Constants

OPTION_SEARCH

OPTION_NAMESERVERS

OPTION_MISC

OPTION_HOSTSFILE

OPTIONS_ALL

Methods

__construct(EventBase $base, bool $initialize)

__construct.

bool
addNameserverIp(string $ip)

addNameserverIp.

void
addSearch(string $domain)

addSearch.

void
clearSearch()

clearSearch.

int
countNameservers()

countNameservers.

bool
loadHosts(string $hosts)

loadHosts.

bool
parseResolvConf(int $flags, string $filename)

parseResolvConf.

bool
setOption(string $option, string $value)

setOption.

void
setSearchNdots(int $ndots)

setSearchNdots.

Details

__construct(EventBase $base, bool $initialize)

__construct.

Constructs EventDnsBase object.

Parameters

EventBase $base

Event base.

bool $initialize

If initialize is true, it attempts to use the underlying operating system defaults to configure the DNS base sensibly. If it is false, the DNS base is left unconfigured, with no nameservers or options set. In the latter case the DNS base should be configured manually, e.g. with EventDnsBase::parseResolvConf. If initialize is an integer, it must be one of the following flags: Flag Description EventDnsBase::DISABLE_WHEN_INACTIVE Do not prevent the libevent event loop from exiting when we have no active DNS requests. EventDnsBase::INITIALIZE_NAMESERVERS Process the resolv.conf. EventDnsBase::NAMESERVERS_NO_DEFAULT Do not add default nameserver if there are no nameservers in the resolv.conf.

See also

https://secure.php.net/manual/en/eventdnsbase.construct.php

bool addNameserverIp(string $ip)

addNameserverIp.

Adds a nameserver to the DNS base.

Parameters

string $ip

The nameserver string, either as an IPv4 address, an IPv6 address, an IPv4 address with a port ( IPv4:Port ), or an IPv6 address with a port ( [IPv6]:Port ).

Return Value

bool

Returns true on success or false on failure.

See also

https://secure.php.net/manual/en/eventdnsbase.addnameserverip.php

void addSearch(string $domain)

addSearch.

Adds a domain to the list of search domains.

Parameters

string $domain

Search domain.

Return Value

void

See also

https://secure.php.net/manual/en/eventdnsbase.addsearch.php

void clearSearch()

clearSearch.

Removes all current search suffixes.

int countNameservers()

countNameservers.

Gets the number of configured nameservers.

Return Value

int

Returns the number of configured nameservers(not necessarily the number of running nameservers). This is useful for double-checking whether our calls to the various nameserver configuration functions have been successful.

See also

https://secure.php.net/manual/en/eventdnsbase.countnameservers.php

bool loadHosts(string $hosts)

loadHosts.

Loads a hosts file (in the same format as /etc/hosts) from hosts file.

Parameters

string $hosts

Path to the hosts' file.

Return Value

bool

Returns true on success or false on failure.

See also

https://secure.php.net/manual/en/eventdnsbase.loadhosts.php

bool parseResolvConf(int $flags, string $filename)

parseResolvConf.

Scans the resolv.conf-formatted file.

Parameters

int $flags

Determines what information is parsed from the resolv.conf file. See the man page for resolv.conf for the format of this file. The following directives are not parsed from the file: sortlist, rotate, no-check-names, inet6, debug. If this function encounters an error, the possible return values are: 1 = failed to open file 2 = failed to stat file 3 = file too large 4 = out of memory 5 = short read from file 6 = no nameservers listed in the file

string $filename

Path to resolv.conf file.

Return Value

bool

Returns true on success or false on failure.

See also

https://secure.php.net/manual/en/eventdnsbase.parseresolvconf.php

bool setOption(string $option, string $value)

setOption.

Set the value of a configuration option.

Parameters

string $option

The currently available configuration options are: "ndots", "timeout", "max-timeouts", "max-inflight", and "attempts".

string $value

Option value.

Return Value

bool

Returns true on success or false on failure.

See also

https://secure.php.net/manual/en/eventdnsbase.setoption.php

void setSearchNdots(int $ndots)

setSearchNdots.

Set the 'ndots' parameter for searches.

Parameters

int $ndots

The number of dots.

Return Value

void

Returns true on success or false on failure.

See also

https://secure.php.net/manual/en/eventdnsbase.setsearchndots.php