REDROOM
PHP 8.2.31
Path:
Logout
Edit File
Size: 3.00 KB
Close
//opt/cpanel/ea-wappspector/vendor/rector/rector/vendor/react/dns/src/Query/HostsFileExecutor.php
Text
Base64
<?php namespace RectorPrefix202411\React\Dns\Query; use RectorPrefix202411\React\Dns\Config\HostsFile; use RectorPrefix202411\React\Dns\Model\Message; use RectorPrefix202411\React\Dns\Model\Record; use RectorPrefix202411\React\Promise; /** * Resolves hosts from the given HostsFile or falls back to another executor * * If the host is found in the hosts file, it will not be passed to the actual * DNS executor. If the host is not found in the hosts file, it will be passed * to the DNS executor as a fallback. */ final class HostsFileExecutor implements ExecutorInterface { private $hosts; private $fallback; public function __construct(HostsFile $hosts, ExecutorInterface $fallback) { $this->hosts = $hosts; $this->fallback = $fallback; } public function query(Query $query) { if ($query->class === Message::CLASS_IN && ($query->type === Message::TYPE_A || $query->type === Message::TYPE_AAAA)) { // forward lookup for type A or AAAA $records = array(); $expectsColon = $query->type === Message::TYPE_AAAA; foreach ($this->hosts->getIpsForHost($query->name) as $ip) { // ensure this is an IPv4/IPV6 address according to query type if ((\strpos($ip, ':') !== \false) === $expectsColon) { $records[] = new Record($query->name, $query->type, $query->class, 0, $ip); } } if ($records) { return Promise\resolve(Message::createResponseWithAnswersForQuery($query, $records)); } } elseif ($query->class === Message::CLASS_IN && $query->type === Message::TYPE_PTR) { // reverse lookup: extract IPv4 or IPv6 from special `.arpa` domain $ip = $this->getIpFromHost($query->name); if ($ip !== null) { $records = array(); foreach ($this->hosts->getHostsForIp($ip) as $host) { $records[] = new Record($query->name, $query->type, $query->class, 0, $host); } if ($records) { return Promise\resolve(Message::createResponseWithAnswersForQuery($query, $records)); } } } return $this->fallback->query($query); } private function getIpFromHost($host) { if (\substr($host, -13) === '.in-addr.arpa') { // IPv4: read as IP and reverse bytes $ip = @\inet_pton(\substr($host, 0, -13)); if ($ip === \false || isset($ip[4])) { return null; } return \inet_ntop(\strrev($ip)); } elseif (\substr($host, -9) === '.ip6.arpa') { // IPv6: replace dots, reverse nibbles and interpret as hexadecimal string $ip = @\inet_ntop(\pack('H*', \strrev(\str_replace('.', '', \substr($host, 0, -9))))); if ($ip === \false) { return null; } return $ip; } else { return null; } } }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 13
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
CachingExecutor.php
2.58 KB
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
CancellationException.php
118 B
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
CoopExecutor.php
3.38 KB
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
ExecutorInterface.php
1.45 KB
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
FallbackExecutor.php
1.71 KB
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
HostsFileExecutor.php
3.00 KB
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Query.php
2.01 KB
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
RetryExecutor.php
2.57 KB
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
SelectiveTransportExecutor.php
3.01 KB
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
TcpTransportExecutor.php
13.64 KB
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
TimeoutException.php
106 B
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
TimeoutExecutor.php
2.74 KB
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
UdpTransportExecutor.php
8.33 KB
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).