DOHBase
in package
DNS over HTTPS client library
This class implements a DNS resolver that asks a DNS over HTTPS service instead of a regular DNS server. This is an abstract class that must not be used directly, instead use DOHGG to use Google as a DOH backend or DOHCF to use Cloudflare as a DOH backend}
Tags
Table of Contents
Methods
- getStatus() : int
- Get the status for the last DNS query
- IPtoDNS() : string
- Convert an IPv4 or IPv6 address to a DNS name valid for a PTR request.
- dns() : array<string, string>
- Execute a DNS query. The query return an array with the responses. In case of error the function returns an empty array and set "status" attribute with the error code.
Methods
getStatus()
Get the status for the last DNS query
public
static getStatus() : int
Return values
int —Status for the last operacion
IPtoDNS()
Convert an IPv4 or IPv6 address to a DNS name valid for a PTR request.
public
static IPtoDNS(string $ip) : string
Parameters
- $ip : string
-
IP address to convert
Return values
string —DNS name representing the IP
dns()
Execute a DNS query. The query return an array with the responses. In case of error the function returns an empty array and set "status" attribute with the error code.
protected
static dns(string $domain, string $type, string $how) : array<string, string>
When parameters have an invalid value, an InvalidValurException will be raised
Valid record types: NS, MX, TXT, A, AAAA, CNAME, SPF, SOA, PTR, SRV, DS, DNSKEY
status response codes:
- 0: OK
- 1: Empty response. There are not response to this query.
- 2: The DNS servers for this domain are misconfigured
- 3: The domain does not exist
- 4: Network error
- 5: Lame response
- 100: Invalid record type
- 101: Invalid IP address
- 10XX: Values above 1000 contains error code returned by DNS server
Invalid argument errors fires an InvalidArgumentException with the status codes 100 or 101
Parameters
- $domain : string
-
Name to resolve
- $type : string
-
Record type to ask for
- $how : string
-
(optional) Indicates whether the connection will be via IPv4 or IPv6 (default is IPv4)
Tags
Return values
array<string, string> —Query result