DoH/dns.php
2024-08-16 22:39:01 +00:00

26 lines
808 B
PHP
Executable File

<?php
if (isset($_SERVER['CONTENT_TYPE']) && $_SERVER['CONTENT_TYPE'] == 'application/dns-message')
{
$request = file_get_contents("php://input");
header("Content-Type: application/dns-message");
$s = fsockopen("udp://127.0.0.1", 53, $errno, $errstr);
if ($s)
{
fwrite($s, $request);
echo fread($s, 4096);
fclose($s);
}
}
else if (isset($_GET['dns']))
{
$request = base64_decode(str_replace(array('-', '_'), array('+', '/'), $_GET['dns']));
header("Content-Type: application/dns-message");
$s = fsockopen("udp://127.0.0.1", 53, $errno, $errstr);
if ($s)
{
fwrite($s, $request);
echo fread($s, 4096);
fclose($s);
}
}