MediaWiki REL1_40
DnsSrvDiscoverer Class Reference

Public Member Functions

 __construct (string $service, string $protocol='tcp', ?string $domain=null, ?callable $resolver=null)
 Construct a new discoverer for the given domain, service, and protocol.
 
 getRecords ()
 Queries the resolver for an SRV resource record matching the service, protocol, and domain and returns all target/port/priority/weight records.
 
 getServers ()
 Performs discovery for the domain, service, and protocol, and returns a list of resolved server name/ip and port number pairs sorted by each record's priority, with servers of the same priority randomly shuffled.
 
 getSrvName ()
 Returns the SRV resource record name.
 

Detailed Description

Since
1.29

Definition at line 26 of file DnsSrvDiscoverer.php.

Constructor & Destructor Documentation

◆ __construct()

DnsSrvDiscoverer::__construct ( string $service,
string $protocol = 'tcp',
?string $domain = null,
?callable $resolver = null )

Construct a new discoverer for the given domain, service, and protocol.

Parameters
string$serviceName of the service to discover.
string$protocolService protocol. Defaults to 'tcp'
?string$domainThe hostname/domain on which to perform discovery of the given service and protocol. Defaults to null which effectively performs a query relative to the host's configured search domain.
?callable$resolverResolver function. Defaults to using dns_get_record. Primarily useful in testing.

Definition at line 58 of file DnsSrvDiscoverer.php.

Member Function Documentation

◆ getRecords()

DnsSrvDiscoverer::getRecords ( )

Queries the resolver for an SRV resource record matching the service, protocol, and domain and returns all target/port/priority/weight records.

Returns
array

Definition at line 80 of file DnsSrvDiscoverer.php.

References getSrvName().

Referenced by getServers().

◆ getServers()

DnsSrvDiscoverer::getServers ( )

Performs discovery for the domain, service, and protocol, and returns a list of resolved server name/ip and port number pairs sorted by each record's priority, with servers of the same priority randomly shuffled.

Returns
array

Definition at line 113 of file DnsSrvDiscoverer.php.

References getRecords().

◆ getSrvName()

DnsSrvDiscoverer::getSrvName ( )

Returns the SRV resource record name.

Returns
string

Definition at line 138 of file DnsSrvDiscoverer.php.

Referenced by getRecords().


The documentation for this class was generated from the following file: