Documentation

Config
in package

FinalYes

Table of Contents

Properties

$nameservers  : mixed

Methods

loadResolvConfBlocking()  : self
Loads a resolv.conf file (from the given path or default location)
loadSystemConfigBlocking()  : self
Loads the system DNS configuration
loadWmicBlocking()  : self
Loads the DNS configurations from Windows's WMIC (from the given command or default command)

Properties

$nameservers

public mixed $nameservers = array()

Methods

loadResolvConfBlocking()

Loads a resolv.conf file (from the given path or default location)

public static loadResolvConfBlocking([string|null $path = null ]) : self

Note that this method blocks while loading the given path and should thus be used with care! While this should be relatively fast for normal resolv.conf files, this may be an issue if this file is located on a slow device or contains an excessive number of entries. In particular, this method should only be executed before the loop starts, not while it is running.

Note that this method will throw if the given file can not be loaded, such as if it is not readable or does not exist. In particular, this file is not available on Windows.

Currently, this will only parse valid "nameserver X" lines from the given file contents. Lines can be commented out with "#" and ";" and invalid lines will be ignored without complaining. See also man resolv.conf for more details.

Note that the previous section implies that this may return an empty Config object if no valid "nameserver X" lines can be found. See also man resolv.conf which suggests that the DNS server on the localhost should be used in this case. This is left up to higher level consumers of this API.

Parameters
$path : string|null = null

(optional) path to resolv.conf file or null=load default location

Tags
throws
RuntimeException

if the path can not be loaded (does not exist)

Return values
self

loadSystemConfigBlocking()

Loads the system DNS configuration

public static loadSystemConfigBlocking() : self

Note that this method may block while loading its internal files and/or commands and should thus be used with care! While this should be relatively fast for most systems, it remains unknown if this may block under certain circumstances. In particular, this method should only be executed before the loop starts, not while it is running.

Note that this method will try to access its files and/or commands and try to parse its output. Currently, this will only parse valid nameserver entries from its output and will ignore all other output without complaining.

Note that the previous section implies that this may return an empty Config object if no valid nameserver entries can be found.

Tags
codeCoverageIgnore
Return values
self

loadWmicBlocking()

Loads the DNS configurations from Windows's WMIC (from the given command or default command)

public static loadWmicBlocking([string|null $command = null ]) : self

Note that this method blocks while loading the given command and should thus be used with care! While this should be relatively fast for normal WMIC commands, it remains unknown if this may block under certain circumstances. In particular, this method should only be executed before the loop starts, not while it is running.

Note that this method will only try to execute the given command try to parse its output, irrespective of whether this command exists. In particular, this command is only available on Windows. Currently, this will only parse valid nameserver entries from the command output and will ignore all other output without complaining.

Note that the previous section implies that this may return an empty Config object if no valid nameserver entries can be found.

Parameters
$command : string|null = null

(advanced) should not be given (NULL) unless you know what you're doing

Tags
link
https://ss64.com/nt/wmic.html
Return values
self

        
On this page

Search results