-
Notifications
You must be signed in to change notification settings - Fork 1
JDWX DNSQuery Notifier
The main dynamic DNS notifier class.
This class provides functions to handle DNS notify requests as defined by RFC 1996.
This is separate from the Resolver class, as while the underlying protocol is the same, the functionality is completely different.
Generally, query (recursive) lookups are done against caching server, while notify requests are done against authoritative servers.
- Class name: Notifier
- Namespace: \JDWX\DNSQuery
- Parent class: JDWX\DNSQuery\BaseQuery
const VERSION = '2.0.0'
const RESOLV_CONF = '/etc/resolv.conf'
private packet
- Visibility: private
protected authSignature = null
- Visibility: protected
protected dnsPort = 53
- Visibility: protected
protected dnssec = false
- Visibility: protected
protected dnssecADFlag = false
- Visibility: protected
protected dnssecCDFlag = false
- Visibility: protected
protected dnssecPayloadSize = 4000
- Visibility: protected
protected domain = ''
- Visibility: protected
protected lastException = null
- Visibility: protected
protected lastExceptionList = []
- Visibility: protected
protected localAddress = ''
- Visibility: protected
protected localPort
- Visibility: protected
protected nsRandom = false
- Visibility: protected
protected searchList = []
- Visibility: protected
protected timeout = 5
- Visibility: protected
protected transportManager
- Visibility: protected
protected useResolvOptions = false
- Visibility: protected
protected useTCP = false
- Visibility: protected
private nameServers = []
- Visibility: private
mixed JDWX\DNSQuery\BaseQuery::__construct(array|string|null i_nameServers, ?string i_resolvConf)
Constructor - base constructor for the Notifier, Resolver and Updater
- Visibility: public
- This method is defined by JDWX\DNSQuery\BaseQuery
- i_nameServers array|string|null
- i_resolvConf ?string
bool JDWX\DNSQuery\Notifier::add(\JDWX\DNSQuery\RR\RR rr)
3.7 - Add RR to notify
- Visibility: public
- rr JDWX\DNSQuery\RR\RR - the RR object to be sent in the "notify" message
bool JDWX\DNSQuery\Notifier::notify(?\JDWX\DNSQuery\Packet\ResponsePacket response)
executes the notify request
- Visibility: public
- response ?\JDWX\DNSQuery\Packet\ResponsePacket - contains a reference to the response object after running
\JDWX\DNSQuery\Packet\RequestPacket JDWX\DNSQuery\Notifier::packet()
returns the current internal packet object.
- Visibility: public
void JDWX\DNSQuery\Notifier::_checkName(string name)
checks that the given name matches the name for the zone we're notifying
- Visibility: private
- name string - The name to be checked.
string JDWX\DNSQuery\BaseQuery::expandIPv6(string i_address)
formats the given IPv6 address as a fully expanded IPv6 address
- Visibility: public
- This method is static.
- This method is defined by JDWX\DNSQuery\BaseQuery
- i_address string - the IPv6 address to expand
string JDWX\DNSQuery\BaseQuery::expandUint32(int i_int)
PHP doesn't support unsigned integers, but many of the RRs return unsigned values (like SOA), so there is the possibility that the value will overrun on 32bit systems, and you'll end up with a negative value.
64bit systems are not affected, as their PHP_INT_MAX value should be 64bit (ie 9223372036854775807)
This function returns a negative integer value, as a string, with the correct unsigned value.
- Visibility: public
- This method is static.
- This method is defined by JDWX\DNSQuery\BaseQuery
- i_int int - the unsigned integer value to check
bool JDWX\DNSQuery\BaseQuery::isIPv4(string i_address)
returns true/false if the given address is a valid IPv4 address
- Visibility: public
- This method is static.
- This method is defined by JDWX\DNSQuery\BaseQuery
- i_address string - the IPv4 address to check
bool JDWX\DNSQuery\BaseQuery::isIPv6(string i_address)
returns true/false if the given address is a valid IPv6 address
- Visibility: public
- This method is static.
- This method is defined by JDWX\DNSQuery\BaseQuery
- i_address string - the IPv6 address to check
void JDWX\DNSQuery\BaseQuery::closeSockets()
give users access to close all open sockets on the resolver object; resetting each array, calls the destructor on the Socket object, which calls the close() method on each object.
- Visibility: public
- This method is defined by JDWX\DNSQuery\BaseQuery
string[] JDWX\DNSQuery\BaseQuery::getNameServers()
Gets the currently-configured name servers or loads them from the default resolv.conf if none are specified.
- Visibility: public
- This method is defined by JDWX\DNSQuery\BaseQuery
static JDWX\DNSQuery\BaseQuery::setDNSPort(int i_dnsPort)
Set the DNS server port to use. (Default is 53 for both TCP and UDP DNS.)
- Visibility: public
- This method is defined by JDWX\DNSQuery\BaseQuery
- i_dnsPort int
static JDWX\DNSQuery\BaseQuery::setDNSSEC(bool i_dnssec)
Request DNSSEC values, by setting the DO flag to 1; this actually makes the resolver add an OPT RR to the additional section, and sets the DO flag in this RR to 1
- Visibility: public
- This method is defined by JDWX\DNSQuery\BaseQuery
- i_dnssec bool - Whether to use DNSSEC.
static JDWX\DNSQuery\BaseQuery::setDNSSECADFlag(bool i_dnssecADFlag)
set the DNSSEC AD (Authentic Data) bit on/off; the AD bit on the request side was previously undefined, and resolvers we instructed to always clear the AD bit when sending a request.
RFC6840 section 5.7 defines setting the AD bit in the query as a signal to the server that it wants the value of the AD bit, without needed to request all the DNSSEC data via the DO bit.
- Visibility: public
- This method is defined by JDWX\DNSQuery\BaseQuery
- i_dnssecADFlag bool
static JDWX\DNSQuery\BaseQuery::setDNSSECCDFlag(bool i_dnssecCDFlag)
set the DNSSEC CD (Checking Disabled) bit on/off; turning this off means that the DNS resolver will perform its own signature validation so the DNS servers simply pass through all the details.
- Visibility: public
- This method is defined by JDWX\DNSQuery\BaseQuery
- i_dnssecCDFlag bool
static JDWX\DNSQuery\BaseQuery::setDNSSECPayloadSize(int i_dnssecPayloadSize)
the EDNS(0) UDP payload size to use when making DNSSEC requests see RFC 4035 section 4.1 - EDNS Support.
there are some different ideas on the suggested size to support; but it seems to be "at least" 1220 bytes, but SHOULD support 4000 bytes. If this is not set, the default is 4000 bytes.
- Visibility: public
- This method is defined by JDWX\DNSQuery\BaseQuery
- i_dnssecPayloadSize int - Payload size in bytes.
static JDWX\DNSQuery\BaseQuery::setLocalAddress(string i_localHost)
Set the local IP address to use. (Default is empty, which means to use the default local IP address.)
- Visibility: public
- This method is defined by JDWX\DNSQuery\BaseQuery
- i_localHost string
static JDWX\DNSQuery\BaseQuery::setLocalPort(int i_localPort)
Set the local port to use. (Default is 0, which means to use a local port selected by the OS.)
- Visibility: public
- This method is defined by JDWX\DNSQuery\BaseQuery
- i_localPort int - Local port value to use
mixed JDWX\DNSQuery\BaseQuery::setNameServer(string i_nameServer)
Shortcut to set a single name server.
- Visibility: public
- This method is defined by JDWX\DNSQuery\BaseQuery
- i_nameServer string - IPv4 or IPv6 address of the desired name server
mixed JDWX\DNSQuery\BaseQuery::setNameServers(string[] i_nameServers)
Sets the name servers to be used, specified as IPv4 or IPv6 addresses.
- Visibility: public
- This method is defined by JDWX\DNSQuery\BaseQuery
- i_nameServers string[] - a list of IPv4 or IPv6 addresses
static JDWX\DNSQuery\BaseQuery::setRandomizeNameServers(bool i_randomize)
Set whether to randomize the name server list. (Default is false.)
- Visibility: public
- This method is defined by JDWX\DNSQuery\BaseQuery
- i_randomize bool - True to randomize the name server list, false to not randomize
static JDWX\DNSQuery\BaseQuery::setTimeout(int i_timeout)
Set the timeout value to use for socket connections. (Default is 5 seconds.)
- Visibility: public
- This method is defined by JDWX\DNSQuery\BaseQuery
- i_timeout int - Timeout value in seconds.
static JDWX\DNSQuery\BaseQuery::setUseResolvOptions(bool i_useResolvOptions)
Set whether to use options found in resolv.conf if one is parsed.
Note that this will not affect the use of the resolv.conf file if it is loaded from the constructor. So if you want this option, set it and then manually call useResolvConf().
- Visibility: public
- This method is defined by JDWX\DNSQuery\BaseQuery
- i_useResolvOptions bool - Whether to use options found in resolv.conf
static JDWX\DNSQuery\BaseQuery::setUseTCP(bool i_useTCP)
Default to using TCP for requests. (TCP will always be used for large requests or AXFR requests.)
- Visibility: public
- This method is defined by JDWX\DNSQuery\BaseQuery
- i_useTCP bool - Whether to use TCP for requests by default.
void JDWX\DNSQuery\BaseQuery::signSIG0(\JDWX\DNSQuery\RR\SIG|string i_filename)
Add a SIG RR object for authentication.
- Visibility: public
- This method is defined by JDWX\DNSQuery\BaseQuery
- i_filename JDWX\DNSQuery\RR\SIG|string - a signature or the name of a file to load the signature from.
void JDWX\DNSQuery\BaseQuery::signTSIG(\JDWX\DNSQuery\RR\TSIG|string i_keyName, string i_signature, string i_algorithm)
Add a TSIG RR object for authentication
- Visibility: public
- This method is defined by JDWX\DNSQuery\BaseQuery
- i_keyName JDWX\DNSQuery\RR\TSIG|string - Key name to use for the TSIG RR
- i_signature string - Key to sign the request.
- i_algorithm string - Algorithm to use
static JDWX\DNSQuery\BaseQuery::useResolvConf(?string i_resolvConf)
sets the name servers to be used, specified as IPv4 or IPv6 addresses
- Visibility: public
- This method is defined by JDWX\DNSQuery\BaseQuery
- i_resolvConf ?string - Filename to parse in the resolv.conf format or null to use the default resolv.conf file
\JDWX\DNSQuery\Packet\ResponsePacket JDWX\DNSQuery\BaseQuery::sendPacket(\JDWX\DNSQuery\Packet\RequestPacket i_request, bool i_useTCP)
Sends a RequestPacket
- Visibility: protected
- This method is defined by JDWX\DNSQuery\BaseQuery
- i_request JDWX\DNSQuery\Packet\RequestPacket - Packet object to send
- i_useTCP bool - True to skip straight to TCP, false to try UDP first.
void JDWX\DNSQuery\BaseQuery::parseOptions(string i_options)
parses the options line from a resolv.conf file; we don't support all the options yet, and using them is optional.
- Visibility: private
- This method is defined by JDWX\DNSQuery\BaseQuery
- i_options string - The "options" string from the resolv.conf file.
\JDWX\DNSQuery\Packet\ResponsePacket JDWX\DNSQuery\BaseQuery::sendTCPRequest(string i_ns, string i_data, bool i_axfr)
sends a DNS request using TCP
- Visibility: private
- This method is defined by JDWX\DNSQuery\BaseQuery
- i_ns string - Name server to use for the request
- i_data string - Raw DNS packet data
- i_axfr bool - Whether this is a zone transfer request
\JDWX\DNSQuery\Packet\ResponsePacket JDWX\DNSQuery\BaseQuery::sendUDPRequest(string i_ns, string i_data)
sends a DNS request using UDP
- Visibility: private
- This method is defined by JDWX\DNSQuery\BaseQuery
- i_ns string - the name server to use for the request
- i_data string - the raw DNS packet data