Message
in package
This class represents an outgoing query message or an incoming response message
Tags
Table of Contents
Constants
- CLASS_IN = 1
- OPCODE_IQUERY = 1
- OPCODE_QUERY = 0
- OPCODE_STATUS = 2
- OPT_PADDING = 12
- The EDNS(0) Padding Option
- OPT_TCP_KEEPALIVE = 11
- The edns-tcp-keepalive EDNS0 Option
- RCODE_FORMAT_ERROR = 1
- RCODE_NAME_ERROR = 3
- RCODE_NOT_IMPLEMENTED = 4
- RCODE_OK = 0
- RCODE_REFUSED = 5
- RCODE_SERVER_FAILURE = 2
- TYPE_A = 1
- TYPE_AAAA = 28
- TYPE_ANY = 255
- TYPE_CAA = 257
- TYPE_CNAME = 5
- TYPE_MX = 15
- TYPE_NS = 2
- TYPE_OPT = 41
- pseudo-type for EDNS0
- TYPE_PTR = 12
- TYPE_SOA = 6
- TYPE_SPF = 99
- Sender Policy Framework (SPF) had a dedicated SPF type which has been deprecated in favor of reusing the existing TXT type.
- TYPE_SRV = 33
- TYPE_SSHFP = 44
- TYPE_TXT = 16
Properties
- $aa : bool
- $additional : array<string|int, Record>
- $answers : array<string|int, Record>
- $authority : array<string|int, Record>
- $id : int
- The 16 bit message ID
- $opcode : int
- $qr : bool
- $questions : array<string|int, Query>
- An array of Query objects
- $ra : bool
- $rcode : int
- $rd : bool
- $tc : bool
Methods
- createRequestForQuery() : self
- Creates a new request message for the given query
- createResponseWithAnswersForQuery() : self
- Creates a new response message for the given query with the given answer records
- generateId() : int
- generates a random 16 bit message ID
Constants
CLASS_IN
public
mixed
CLASS_IN
= 1
OPCODE_IQUERY
public
mixed
OPCODE_IQUERY
= 1
OPCODE_QUERY
public
mixed
OPCODE_QUERY
= 0
OPCODE_STATUS
public
mixed
OPCODE_STATUS
= 2
OPT_PADDING
The EDNS(0) Padding Option
public
mixed
OPT_PADDING
= 12
Option value contains a string
with binary data (usually variable
number of null bytes)
Tags
OPT_TCP_KEEPALIVE
The edns-tcp-keepalive EDNS0 Option
public
mixed
OPT_TCP_KEEPALIVE
= 11
Option value contains a ?float
with timeout in seconds (in 0.1s steps)
for DNS response or null
for DNS query.
Tags
RCODE_FORMAT_ERROR
public
mixed
RCODE_FORMAT_ERROR
= 1
RCODE_NAME_ERROR
public
mixed
RCODE_NAME_ERROR
= 3
RCODE_NOT_IMPLEMENTED
public
mixed
RCODE_NOT_IMPLEMENTED
= 4
RCODE_OK
public
mixed
RCODE_OK
= 0
RCODE_REFUSED
public
mixed
RCODE_REFUSED
= 5
RCODE_SERVER_FAILURE
public
mixed
RCODE_SERVER_FAILURE
= 2
TYPE_A
public
mixed
TYPE_A
= 1
TYPE_AAAA
public
mixed
TYPE_AAAA
= 28
TYPE_ANY
public
mixed
TYPE_ANY
= 255
TYPE_CAA
public
mixed
TYPE_CAA
= 257
TYPE_CNAME
public
mixed
TYPE_CNAME
= 5
TYPE_MX
public
mixed
TYPE_MX
= 15
TYPE_NS
public
mixed
TYPE_NS
= 2
TYPE_OPT
pseudo-type for EDNS0
public
mixed
TYPE_OPT
= 41
These are included in the additional section and usually not in answer section. Defined in RFC 6891 (or older RFC 2671).
The OPT record uses the "class" field to store the maximum size.
The OPT record uses the "ttl" field to store additional flags.
TYPE_PTR
public
mixed
TYPE_PTR
= 12
TYPE_SOA
public
mixed
TYPE_SOA
= 6
TYPE_SPF
Sender Policy Framework (SPF) had a dedicated SPF type which has been deprecated in favor of reusing the existing TXT type.
public
mixed
TYPE_SPF
= 99
Tags
TYPE_SRV
public
mixed
TYPE_SRV
= 33
TYPE_SSHFP
public
mixed
TYPE_SSHFP
= 44
TYPE_TXT
public
mixed
TYPE_TXT
= 16
Properties
$aa
public
bool
$aa
= false
Authoritative Answer
$additional
public
array<string|int, Record>
$additional
= array()
$answers
public
array<string|int, Record>
$answers
= array()
$authority
public
array<string|int, Record>
$authority
= array()
$id
The 16 bit message ID
public
int
$id
= 0
The response message ID has to match the request message ID. This allows the receiver to verify this is the correct response message. An outside attacker may try to inject fake responses by "guessing" the message ID, so this should use a proper CSPRNG to avoid possible cache poisoning.
16 bit message ID
Tags
$opcode
public
int
$opcode
= self::OPCODE_QUERY
specifies the kind of query (4 bit), see self::OPCODE_* constants
Tags
$qr
public
bool
$qr
= false
Query/Response flag, query=false or response=true
$questions
An array of Query objects
public
array<string|int, Query>
$questions
= array()
$questions = array(
new Query(
'reactphp.org',
Message::TYPE_A,
Message::CLASS_IN
)
);
$ra
public
bool
$ra
= false
Recursion Available
$rcode
public
int
$rcode
= \React\Dns\Model\Message::RCODE_OK
response code (4 bit), see self::RCODE_* constants
Tags
$rd
public
bool
$rd
= false
Recursion Desired
$tc
public
bool
$tc
= false
TrunCation
Methods
createRequestForQuery()
Creates a new request message for the given query
public
static createRequestForQuery(Query $query) : self
Parameters
- $query : Query
Return values
selfcreateResponseWithAnswersForQuery()
Creates a new response message for the given query with the given answer records
public
static createResponseWithAnswersForQuery(Query $query, array<string|int, Record> $answers) : self
Parameters
Return values
selfgenerateId()
generates a random 16 bit message ID
private
static generateId() : int
This uses a CSPRNG so that an outside attacker that is sending spoofed DNS response messages can not guess the message ID to avoid possible cache poisoning attacks.
The random_int()
function is only available on PHP 7+ or when
https://github.com/paragonie/random_compat is installed. As such, using
the latest supported PHP version is highly recommended. This currently
falls back to a less secure random number generator on older PHP versions
in the hope that this system is properly protected against outside
attackers, for example by using one of the common local DNS proxy stubs.