Commit inicial con archivos existentes
This commit is contained in:
230
vendor/react/dns/src/Model/Message.php
vendored
Executable file
230
vendor/react/dns/src/Model/Message.php
vendored
Executable file
@@ -0,0 +1,230 @@
|
||||
<?php
|
||||
|
||||
namespace React\Dns\Model;
|
||||
|
||||
use React\Dns\Query\Query;
|
||||
|
||||
/**
|
||||
* This class represents an outgoing query message or an incoming response message
|
||||
*
|
||||
* @link https://tools.ietf.org/html/rfc1035#section-4.1.1
|
||||
*/
|
||||
final class Message
|
||||
{
|
||||
const TYPE_A = 1;
|
||||
const TYPE_NS = 2;
|
||||
const TYPE_CNAME = 5;
|
||||
const TYPE_SOA = 6;
|
||||
const TYPE_PTR = 12;
|
||||
const TYPE_MX = 15;
|
||||
const TYPE_TXT = 16;
|
||||
const TYPE_AAAA = 28;
|
||||
const TYPE_SRV = 33;
|
||||
const TYPE_SSHFP = 44;
|
||||
|
||||
/**
|
||||
* pseudo-type for EDNS0
|
||||
*
|
||||
* These are included in the additional section and usually not in answer section.
|
||||
* Defined in [RFC 6891](https://tools.ietf.org/html/rfc6891) (or older
|
||||
* [RFC 2671](https://tools.ietf.org/html/rfc2671)).
|
||||
*
|
||||
* The OPT record uses the "class" field to store the maximum size.
|
||||
*
|
||||
* The OPT record uses the "ttl" field to store additional flags.
|
||||
*/
|
||||
const TYPE_OPT = 41;
|
||||
|
||||
/**
|
||||
* Sender Policy Framework (SPF) had a dedicated SPF type which has been
|
||||
* deprecated in favor of reusing the existing TXT type.
|
||||
*
|
||||
* @deprecated https://datatracker.ietf.org/doc/html/rfc7208#section-3.1
|
||||
* @see self::TYPE_TXT
|
||||
*/
|
||||
const TYPE_SPF = 99;
|
||||
|
||||
const TYPE_ANY = 255;
|
||||
const TYPE_CAA = 257;
|
||||
|
||||
const CLASS_IN = 1;
|
||||
|
||||
const OPCODE_QUERY = 0;
|
||||
const OPCODE_IQUERY = 1; // inverse query
|
||||
const OPCODE_STATUS = 2;
|
||||
|
||||
const RCODE_OK = 0;
|
||||
const RCODE_FORMAT_ERROR = 1;
|
||||
const RCODE_SERVER_FAILURE = 2;
|
||||
const RCODE_NAME_ERROR = 3;
|
||||
const RCODE_NOT_IMPLEMENTED = 4;
|
||||
const RCODE_REFUSED = 5;
|
||||
|
||||
/**
|
||||
* The edns-tcp-keepalive EDNS0 Option
|
||||
*
|
||||
* Option value contains a `?float` with timeout in seconds (in 0.1s steps)
|
||||
* for DNS response or `null` for DNS query.
|
||||
*
|
||||
* @link https://tools.ietf.org/html/rfc7828
|
||||
*/
|
||||
const OPT_TCP_KEEPALIVE = 11;
|
||||
|
||||
/**
|
||||
* The EDNS(0) Padding Option
|
||||
*
|
||||
* Option value contains a `string` with binary data (usually variable
|
||||
* number of null bytes)
|
||||
*
|
||||
* @link https://tools.ietf.org/html/rfc7830
|
||||
*/
|
||||
const OPT_PADDING = 12;
|
||||
|
||||
/**
|
||||
* Creates a new request message for the given query
|
||||
*
|
||||
* @param Query $query
|
||||
* @return self
|
||||
*/
|
||||
public static function createRequestForQuery(Query $query)
|
||||
{
|
||||
$request = new Message();
|
||||
$request->id = self::generateId();
|
||||
$request->rd = true;
|
||||
$request->questions[] = $query;
|
||||
|
||||
return $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new response message for the given query with the given answer records
|
||||
*
|
||||
* @param Query $query
|
||||
* @param Record[] $answers
|
||||
* @return self
|
||||
*/
|
||||
public static function createResponseWithAnswersForQuery(Query $query, array $answers)
|
||||
{
|
||||
$response = new Message();
|
||||
$response->id = self::generateId();
|
||||
$response->qr = true;
|
||||
$response->rd = true;
|
||||
|
||||
$response->questions[] = $query;
|
||||
|
||||
foreach ($answers as $record) {
|
||||
$response->answers[] = $record;
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* generates a random 16 bit message ID
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @return int
|
||||
* @see self::getId()
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
private static function generateId()
|
||||
{
|
||||
if (function_exists('random_int')) {
|
||||
return random_int(0, 0xffff);
|
||||
}
|
||||
return mt_rand(0, 0xffff);
|
||||
}
|
||||
|
||||
/**
|
||||
* The 16 bit message ID
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @var int 16 bit message ID
|
||||
* @see self::generateId()
|
||||
*/
|
||||
public $id = 0;
|
||||
|
||||
/**
|
||||
* @var bool Query/Response flag, query=false or response=true
|
||||
*/
|
||||
public $qr = false;
|
||||
|
||||
/**
|
||||
* @var int specifies the kind of query (4 bit), see self::OPCODE_* constants
|
||||
* @see self::OPCODE_QUERY
|
||||
*/
|
||||
public $opcode = self::OPCODE_QUERY;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var bool Authoritative Answer
|
||||
*/
|
||||
public $aa = false;
|
||||
|
||||
/**
|
||||
* @var bool TrunCation
|
||||
*/
|
||||
public $tc = false;
|
||||
|
||||
/**
|
||||
* @var bool Recursion Desired
|
||||
*/
|
||||
public $rd = false;
|
||||
|
||||
/**
|
||||
* @var bool Recursion Available
|
||||
*/
|
||||
public $ra = false;
|
||||
|
||||
/**
|
||||
* @var int response code (4 bit), see self::RCODE_* constants
|
||||
* @see self::RCODE_OK
|
||||
*/
|
||||
public $rcode = Message::RCODE_OK;
|
||||
|
||||
/**
|
||||
* An array of Query objects
|
||||
*
|
||||
* ```php
|
||||
* $questions = array(
|
||||
* new Query(
|
||||
* 'reactphp.org',
|
||||
* Message::TYPE_A,
|
||||
* Message::CLASS_IN
|
||||
* )
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* @var Query[]
|
||||
*/
|
||||
public $questions = array();
|
||||
|
||||
/**
|
||||
* @var Record[]
|
||||
*/
|
||||
public $answers = array();
|
||||
|
||||
/**
|
||||
* @var Record[]
|
||||
*/
|
||||
public $authority = array();
|
||||
|
||||
/**
|
||||
* @var Record[]
|
||||
*/
|
||||
public $additional = array();
|
||||
}
|
||||
153
vendor/react/dns/src/Model/Record.php
vendored
Executable file
153
vendor/react/dns/src/Model/Record.php
vendored
Executable file
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
|
||||
namespace React\Dns\Model;
|
||||
|
||||
/**
|
||||
* This class represents a single resulting record in a response message
|
||||
*
|
||||
* It uses a structure similar to `\React\Dns\Query\Query`, but does include
|
||||
* fields for resulting TTL and resulting record data (IPs etc.).
|
||||
*
|
||||
* @link https://tools.ietf.org/html/rfc1035#section-4.1.3
|
||||
* @see \React\Dns\Query\Query
|
||||
*/
|
||||
final class Record
|
||||
{
|
||||
/**
|
||||
* @var string hostname without trailing dot, for example "reactphp.org"
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var int see Message::TYPE_* constants (UINT16)
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* Defines the network class, usually `Message::CLASS_IN`.
|
||||
*
|
||||
* For `OPT` records (EDNS0), this defines the maximum message size instead.
|
||||
*
|
||||
* @var int see Message::CLASS_IN constant (UINT16)
|
||||
* @see Message::CLASS_IN
|
||||
*/
|
||||
public $class;
|
||||
|
||||
/**
|
||||
* Defines the maximum time-to-live (TTL) in seconds
|
||||
*
|
||||
* For `OPT` records (EDNS0), this defines additional flags instead.
|
||||
*
|
||||
* @var int maximum TTL in seconds (UINT32, most significant bit always unset)
|
||||
* @link https://tools.ietf.org/html/rfc2181#section-8
|
||||
* @link https://tools.ietf.org/html/rfc6891#section-6.1.3 for `OPT` records (EDNS0)
|
||||
*/
|
||||
public $ttl;
|
||||
|
||||
/**
|
||||
* The payload data for this record
|
||||
*
|
||||
* The payload data format depends on the record type. As a rule of thumb,
|
||||
* this library will try to express this in a way that can be consumed
|
||||
* easily without having to worry about DNS internals and its binary transport:
|
||||
*
|
||||
* - A:
|
||||
* IPv4 address string, for example "192.168.1.1".
|
||||
*
|
||||
* - AAAA:
|
||||
* IPv6 address string, for example "::1".
|
||||
*
|
||||
* - CNAME / PTR / NS:
|
||||
* The hostname without trailing dot, for example "reactphp.org".
|
||||
*
|
||||
* - TXT:
|
||||
* List of string values, for example `["v=spf1 include:example.com"]`.
|
||||
* This is commonly a list with only a single string value, but this
|
||||
* technically allows multiple strings (0-255 bytes each) in a single
|
||||
* record. This is rarely used and depending on application you may want
|
||||
* to join these together or handle them separately. Each string can
|
||||
* transport any binary data, its character encoding is not defined (often
|
||||
* ASCII/UTF-8 in practice). [RFC 1464](https://tools.ietf.org/html/rfc1464)
|
||||
* suggests using key-value pairs such as `["name=test","version=1"]`, but
|
||||
* interpretation of this is not enforced and left up to consumers of this
|
||||
* library (used for DNS-SD/Zeroconf and others).
|
||||
*
|
||||
* - MX:
|
||||
* Mail server priority (UINT16) and target hostname without trailing dot,
|
||||
* for example `{"priority":10,"target":"mx.example.com"}`.
|
||||
* The payload data uses an associative array with fixed keys "priority"
|
||||
* (also commonly referred to as weight or preference) and "target" (also
|
||||
* referred to as exchange). If a response message contains multiple
|
||||
* records of this type, targets should be sorted by priority (lowest
|
||||
* first) - this is left up to consumers of this library (used for SMTP).
|
||||
*
|
||||
* - SRV:
|
||||
* Service priority (UINT16), service weight (UINT16), service port (UINT16)
|
||||
* and target hostname without trailing dot, for example
|
||||
* `{"priority":10,"weight":50,"port":8080,"target":"example.com"}`.
|
||||
* The payload data uses an associative array with fixed keys "priority",
|
||||
* "weight", "port" and "target" (also referred to as name).
|
||||
* The target may be an empty host name string if the service is decidedly
|
||||
* not available. If a response message contains multiple records of this
|
||||
* type, targets should be sorted by priority (lowest first) and selected
|
||||
* randomly according to their weight - this is left up to consumers of
|
||||
* this library, see also [RFC 2782](https://tools.ietf.org/html/rfc2782)
|
||||
* for more details.
|
||||
*
|
||||
* - SSHFP:
|
||||
* Includes algorithm (UNIT8), fingerprint type (UNIT8) and fingerprint
|
||||
* value as lower case hex string, for example:
|
||||
* `{"algorithm":1,"type":1,"fingerprint":"0123456789abcdef..."}`
|
||||
* See also https://www.iana.org/assignments/dns-sshfp-rr-parameters/dns-sshfp-rr-parameters.xhtml
|
||||
* for algorithm and fingerprint type assignments.
|
||||
*
|
||||
* - SOA:
|
||||
* Includes master hostname without trailing dot, responsible person email
|
||||
* as hostname without trailing dot and serial, refresh, retry, expire and
|
||||
* minimum times in seconds (UINT32 each), for example:
|
||||
* `{"mname":"ns.example.com","rname":"hostmaster.example.com","serial":
|
||||
* 2018082601,"refresh":3600,"retry":1800,"expire":60000,"minimum":3600}`.
|
||||
*
|
||||
* - CAA:
|
||||
* Includes flag (UNIT8), tag string and value string, for example:
|
||||
* `{"flag":128,"tag":"issue","value":"letsencrypt.org"}`
|
||||
*
|
||||
* - OPT:
|
||||
* Special pseudo-type for EDNS0. Includes an array of additional opt codes
|
||||
* with a value according to the respective OPT code. See `Message::OPT_*`
|
||||
* for list of supported OPT codes. Any other OPT code not currently
|
||||
* supported will be an opaque binary string containing the raw data
|
||||
* as transported in the DNS record. For forwards compatibility, you should
|
||||
* not rely on this format for unknown types. Future versions may add
|
||||
* support for new types and this may then parse the payload data
|
||||
* appropriately - this will not be considered a BC break. See also
|
||||
* [RFC 6891](https://tools.ietf.org/html/rfc6891) for more details.
|
||||
*
|
||||
* - Any other unknown type:
|
||||
* An opaque binary string containing the RDATA as transported in the DNS
|
||||
* record. For forwards compatibility, you should not rely on this format
|
||||
* for unknown types. Future versions may add support for new types and
|
||||
* this may then parse the payload data appropriately - this will not be
|
||||
* considered a BC break. See the format definition of known types above
|
||||
* for more details.
|
||||
*
|
||||
* @var string|string[]|array
|
||||
*/
|
||||
public $data;
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param int $type
|
||||
* @param int $class
|
||||
* @param int $ttl
|
||||
* @param string|string[]|array $data
|
||||
*/
|
||||
public function __construct($name, $type, $class, $ttl, $data)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->type = $type;
|
||||
$this->class = $class;
|
||||
$this->ttl = $ttl;
|
||||
$this->data = $data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user