Saved,由于原有whoisAPI失效,改用WHOIS命令查询,速度更快,但是需要安装whois命令,RHEL下yum install whois即可
This commit is contained in:
parent
2a00928da5
commit
872eabc111
47
app/controller/DnsController.php
Normal file
47
app/controller/DnsController.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller;
|
||||
include_once base_path().'/vendor/laysense/dns/src/resource/ipv6.php';
|
||||
use dnstools\ipv6; #用于IPv6相关
|
||||
/**
|
||||
* $ipv6=new IPv6;
|
||||
* $ipv6->ip2bin($ip);
|
||||
*/
|
||||
|
||||
class DnsController
|
||||
{
|
||||
public function DNS($type,$name,$rip,$id,$query)
|
||||
{
|
||||
#输出信息
|
||||
#echo "\n Type:$type \n Domain: $name\n Client IP: $rip \n";
|
||||
|
||||
|
||||
#此处请根据业务需要,通过判断$name和$rip返回正确的数据
|
||||
#详情请参见 https://github.com/ywnsya/workerman-dns 尤其是 https://github.com/ywnsya/Workerman-DNS/blob/master/start.php 中的用法
|
||||
|
||||
if($type=='PTR'){
|
||||
$send['detail']='dns.laysense.com';
|
||||
$send['ttl']=30;
|
||||
$send['type']='PTR';
|
||||
}
|
||||
if($type=='A'){
|
||||
$send['type']='A';
|
||||
$send['detail'][1]='119.29.29.29';
|
||||
$send['detail'][2]='8.8.8.8';
|
||||
$send['ttl']=30;
|
||||
};
|
||||
if($type=='AAAA'){
|
||||
$ipv6=new IPv6;
|
||||
$send['type']='AAAA';
|
||||
$send['detail'][1]=bin2hex($ipv6->ip2bin("fe80::2c5f")); #此操作可以还原被简化的IPv6地址 协议内不再对IPv6地址进行处理,请按照本方式传递16进制无":"的完整16位IPv6
|
||||
$send['detail'][2]=bin2hex($ipv6->ip2bin("2001:0:2851:b9d0:2c5f:f0d9:21be:4b96"));
|
||||
$send['ttl']=600;
|
||||
}
|
||||
|
||||
#此处无需修改
|
||||
$send['id']=$id;
|
||||
$send['query']=$query;
|
||||
$return=json_encode($send);
|
||||
return $return;
|
||||
}
|
||||
}
|
@ -11,12 +11,11 @@ use yzh52521\EasyHttp\Http;
|
||||
use yzh52521\EasyHttp\Response;
|
||||
use yzh52521\EasyHttp\RequestException;
|
||||
|
||||
|
||||
class api
|
||||
{
|
||||
public function search(Request $request)
|
||||
{
|
||||
$content=$request->input('content','0');
|
||||
$content=trim($request->input('content','0'));
|
||||
$contenttype=v::ip()->validate($content);
|
||||
if(!$contenttype){
|
||||
$contenttype=v::domain(false)->validate($content);
|
||||
@ -25,6 +24,9 @@ class api
|
||||
}else{
|
||||
$contenttype='domain';
|
||||
$msg['DNS']=dns_get_record("$content",DNS_ANY);
|
||||
$msg['IP']=gethostbyname("$content");
|
||||
exec("whois $content",$msg['WHOIS']);
|
||||
/**
|
||||
$whois = Http::get('https://api.devopsclub.cn/api/whoisquery?type=json&standard=true', ['domain' => "$content"])->body();
|
||||
$whois=json_decode($whois);
|
||||
if($whois->code !=0){
|
||||
@ -46,6 +48,7 @@ class api
|
||||
$msg['Wx-Safe']=$safe->data->wx;
|
||||
$msg['QQ-Safe']=$safe->data->qq;
|
||||
}
|
||||
**/
|
||||
}
|
||||
}else{
|
||||
$contenttype='ip';
|
||||
|
@ -269,7 +269,7 @@
|
||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<span class="mr-2 d-none d-lg-inline text-gray-600 small"><?php echo($userinfo->name);?></span>
|
||||
<img class="img-profile rounded-circle"
|
||||
src="<?php echo('https://cravatar.cn/avatar/' . md5(strtolower(trim( $userinfo->email ))));?>">
|
||||
src="<?php echo('https://headimg.b-cdn.net/' . md5(strtolower(trim( $userinfo->email ))));?>">
|
||||
</a>
|
||||
<!-- Dropdown - User Information -->
|
||||
<div class="dropdown-menu dropdown-menu-right shadow animated--grow-in"
|
||||
|
@ -41,7 +41,7 @@ include('common_head.html');?>
|
||||
<?php
|
||||
foreach($user as $us){
|
||||
$us=json_decode($us);
|
||||
$headurl='https://cravatar.cn/avatar/' . md5(strtolower(trim( $us->email )));
|
||||
$headurl='https://headimg.b-cdn.net/' . md5(strtolower(trim( $us->email )));
|
||||
$name='name';
|
||||
$email='email';
|
||||
$password='password';
|
||||
|
@ -35,7 +35,8 @@
|
||||
"illuminate/events": "^9.45",
|
||||
"yzh52521/webman-throttle": "^1.0",
|
||||
"workerman/validation": "^3.0",
|
||||
"yzh52521/easyhttp": "^1.0"
|
||||
"yzh52521/easyhttp": "^1.0",
|
||||
"laysense/dns": "^0.0.4"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-event": "For better performance. "
|
||||
|
23
composer.lock
generated
23
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "207e7fe0024016fbc9df51ddb8b5018c",
|
||||
"content-hash": "3edd07c2752c38f6dc9f08d472ff44ca",
|
||||
"packages": [
|
||||
{
|
||||
"name": "composer/ca-bundle",
|
||||
@ -1156,6 +1156,27 @@
|
||||
},
|
||||
"time": "2022-12-20T14:03:34+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laysense/dns",
|
||||
"version": "0.0.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://git.laysense.com/enoch/Webman-Dns.git",
|
||||
"reference": "e6c19f90a14d4b7ef69305b6441889bea545bbce"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Laysense\\Dns\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "Webman plugin laysense/dns. You can making a DNS Server with Webman now",
|
||||
"time": "2024-01-29T09:20:41+00:00"
|
||||
},
|
||||
{
|
||||
"name": "maxmind-db/reader",
|
||||
"version": "v1.11.0",
|
||||
|
@ -17,5 +17,6 @@ return [
|
||||
base_path() . '/app/functions.php',
|
||||
base_path() . '/support/Request.php',
|
||||
base_path() . '/support/Response.php',
|
||||
#base_path() . '/phpWhois.org/src/whois.main.php'
|
||||
]
|
||||
];
|
||||
|
4
config/plugin/laysense/dns/app.php
Normal file
4
config/plugin/laysense/dns/app.php
Normal file
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
return [
|
||||
'enable' => true,
|
||||
];
|
10
config/plugin/laysense/dns/process.php
Normal file
10
config/plugin/laysense/dns/process.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
return [
|
||||
'Dns' => [
|
||||
'handler' => process\DnsProcess::class,
|
||||
'listen' => 'Dns://0.0.0.0:53',
|
||||
'transport' => 'udp',
|
||||
'count' => 4
|
||||
#cpu_count() * 1
|
||||
],
|
||||
];
|
@ -39,12 +39,4 @@ return [
|
||||
]
|
||||
]
|
||||
],
|
||||
'Dns' => [
|
||||
'handler' => process\DnsProcess::class,
|
||||
'listen' => 'Dns://0.0.0.0:53',
|
||||
'transport' => 'udp',
|
||||
'count' => cpu_count() * 4
|
||||
],
|
||||
|
||||
|
||||
];
|
||||
|
@ -15,15 +15,15 @@
|
||||
return [
|
||||
#Default保存限流插件和账号密码等,dns仅保存DNS信息
|
||||
'default' => [
|
||||
'host' => '121.228.166.201',
|
||||
'password' => 'Qi2005112!',
|
||||
'port' => 16379,
|
||||
'host' => 'localhost',
|
||||
'password' => 'qi2005112',
|
||||
'port' => 6379,
|
||||
'database' => 0,
|
||||
],
|
||||
'dns' => [
|
||||
'host' => '121.228.166.201',
|
||||
'password' => 'Qi2005112!',
|
||||
'port' => 16379,
|
||||
'host' => 'localhost',
|
||||
'password' => 'qi2005112',
|
||||
'port' => 6379,
|
||||
'database' => 1,
|
||||
],
|
||||
];
|
||||
|
@ -13,7 +13,7 @@
|
||||
*/
|
||||
|
||||
return [
|
||||
'listen' => 'http://0.0.0.0:8787',
|
||||
'listen' => 'http://0.0.0.0:4680',
|
||||
'transport' => 'tcp',
|
||||
'context' => [],
|
||||
'name' => 'webman',
|
||||
|
1
phpWhois.org
Submodule
1
phpWhois.org
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit c0997b4f513d71a139a21d7178616ec28f0733d3
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace process;
|
||||
use Workerman\Connection\TcpConnection;
|
||||
use app\controller\DnsController;
|
||||
|
||||
class DnsProcess
|
||||
{
|
||||
@ -12,6 +13,11 @@ class DnsProcess
|
||||
$name=$data->name; #查询内容(一般是域名,PTR时为倒序IP)
|
||||
$rip=$connection->getRemoteIp(); #客户端IP
|
||||
|
||||
#输出信息
|
||||
#echo "\n Type:$type \n Domain: $name\n Client IP: $rip \n";
|
||||
|
||||
$dns=new DnsController;
|
||||
$return=$dns->DNS($type,$name,$rip,$data->id,$data->query);
|
||||
$connection->send($return);
|
||||
}
|
||||
|
||||
|
7
so.php
Normal file
7
so.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
$json = new stdClass();
|
||||
$json->passwd='A9960454D30A135729BCFC6572776BB12BB20282F2EA1CCE8DBC3040C41ACFC9';
|
||||
$json->email='ywnsya@126.com';
|
||||
$json->name='以诺书';
|
||||
echo json_encode($json);
|
||||
echo hash("sha256", 'qi2005112');
|
27
test.php
27
test.php
@ -7,6 +7,29 @@ use yzh52521\EasyHttp\Http;
|
||||
use yzh52521\EasyHttp\RequestException;
|
||||
use GeoIp2\Database\Reader;
|
||||
|
||||
$whois = Http::get('https://api.devopsclub.cn/api/whoisquery?type=json&standard=true', ['domain' => "laysense.com"])->body();
|
||||
print_r(json_decode($whois));
|
||||
declare(ticks = 1);
|
||||
function whoislookup($domain){
|
||||
$whois = new Whois();
|
||||
$query = $domain;
|
||||
$result = $whois->Lookup($query,false);
|
||||
echo '<pre>';
|
||||
print_r($result);
|
||||
echo '</pre>';
|
||||
}
|
||||
function sig()
|
||||
{
|
||||
throw new Exception;
|
||||
}
|
||||
try
|
||||
{
|
||||
pcntl_alarm(5);
|
||||
pcntl_signal(SIGALRM, "sig");
|
||||
whoislookup('layso.de');
|
||||
pcntl_alarm(0);
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
echo "timeout\n";
|
||||
}
|
||||
|
||||
?>
|
29
timeout.php
Normal file
29
timeout.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
declare(ticks = 1);
|
||||
function a()
|
||||
{
|
||||
|
||||
}
|
||||
function b()
|
||||
{
|
||||
echo "Stop\n";
|
||||
}
|
||||
function c()
|
||||
{
|
||||
usleep(100000);
|
||||
}
|
||||
function sig()
|
||||
{
|
||||
throw new Exception;
|
||||
}
|
||||
try
|
||||
{
|
||||
pcntl_alarm(5);
|
||||
pcntl_signal(SIGALRM, "sig");
|
||||
a();
|
||||
pcntl_alarm(0);
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
echo "timeout\n";
|
||||
}
|
4
vendor/composer/autoload_psr4.php
vendored
4
vendor/composer/autoload_psr4.php
vendored
@ -38,7 +38,7 @@ return array(
|
||||
'Respect\\Stringifier\\' => array($vendorDir . '/respect/stringifier/src'),
|
||||
'Psr\\SimpleCache\\' => array($vendorDir . '/psr/simple-cache/src'),
|
||||
'Psr\\Log\\' => array($vendorDir . '/psr/log/src'),
|
||||
'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src', $vendorDir . '/psr/http-factory/src'),
|
||||
'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-factory/src', $vendorDir . '/psr/http-message/src'),
|
||||
'Psr\\Http\\Client\\' => array($vendorDir . '/psr/http-client/src'),
|
||||
'Psr\\Container\\' => array($vendorDir . '/psr/container/src'),
|
||||
'Psr\\Cache\\' => array($vendorDir . '/psr/cache/src'),
|
||||
@ -46,7 +46,7 @@ return array(
|
||||
'MaxMind\\WebService\\' => array($vendorDir . '/maxmind/web-service-common/src/WebService'),
|
||||
'MaxMind\\Exception\\' => array($vendorDir . '/maxmind/web-service-common/src/Exception'),
|
||||
'MaxMind\\Db\\' => array($vendorDir . '/maxmind-db/reader/src/MaxMind/Db'),
|
||||
'Laysense\\Dns\\' => array($vendorDir . '/laysense/dns/src'),
|
||||
'Laysense\\Dns\\' => array($vendorDir . '/laysense/dns/src', $vendorDir . '/laysense/dns/src'),
|
||||
'Illuminate\\Support\\' => array($vendorDir . '/illuminate/collections', $vendorDir . '/illuminate/conditionable', $vendorDir . '/illuminate/macroable', $vendorDir . '/illuminate/support'),
|
||||
'Illuminate\\Redis\\' => array($vendorDir . '/illuminate/redis'),
|
||||
'Illuminate\\Pipeline\\' => array($vendorDir . '/illuminate/pipeline'),
|
||||
|
5
vendor/composer/autoload_static.php
vendored
5
vendor/composer/autoload_static.php
vendored
@ -267,8 +267,8 @@ class ComposerStaticInitfdb689ed918f2ee4ecdf1e51d93bd946
|
||||
),
|
||||
'Psr\\Http\\Message\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/psr/http-message/src',
|
||||
1 => __DIR__ . '/..' . '/psr/http-factory/src',
|
||||
0 => __DIR__ . '/..' . '/psr/http-factory/src',
|
||||
1 => __DIR__ . '/..' . '/psr/http-message/src',
|
||||
),
|
||||
'Psr\\Http\\Client\\' =>
|
||||
array (
|
||||
@ -301,6 +301,7 @@ class ComposerStaticInitfdb689ed918f2ee4ecdf1e51d93bd946
|
||||
'Laysense\\Dns\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/laysense/dns/src',
|
||||
1 => __DIR__ . '/..' . '/laysense/dns/src',
|
||||
),
|
||||
'Illuminate\\Support\\' =>
|
||||
array (
|
||||
|
24
vendor/composer/installed.json
vendored
24
vendor/composer/installed.json
vendored
@ -1198,6 +1198,30 @@
|
||||
},
|
||||
"install-path": "../illuminate/support"
|
||||
},
|
||||
{
|
||||
"name": "laysense/dns",
|
||||
"version": "0.0.4",
|
||||
"version_normalized": "0.0.4.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://git.laysense.com/enoch/Webman-Dns.git",
|
||||
"reference": "e6c19f90a14d4b7ef69305b6441889bea545bbce"
|
||||
},
|
||||
"time": "2024-01-29T09:20:41+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "source",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Laysense\\Dns\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "Webman plugin laysense/dns. You can making a DNS Server with Webman now",
|
||||
"install-path": "../laysense/dns"
|
||||
},
|
||||
{
|
||||
"name": "maximebf/debugbar",
|
||||
"version": "v1.18.1",
|
||||
|
13
vendor/composer/installed.php
vendored
13
vendor/composer/installed.php
vendored
@ -3,7 +3,7 @@
|
||||
'name' => 'laysense/highspeaker',
|
||||
'pretty_version' => 'dev-master',
|
||||
'version' => 'dev-master',
|
||||
'reference' => '84fc1030a769226c8382dbc9fd171ff45107eaba',
|
||||
'reference' => '2a00928da5ff5423aef1d1833239266003781e49',
|
||||
'type' => 'project',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
@ -154,10 +154,19 @@
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'laysense/dns' => array(
|
||||
'pretty_version' => '0.0.4',
|
||||
'version' => '0.0.4.0',
|
||||
'reference' => 'e6c19f90a14d4b7ef69305b6441889bea545bbce',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../laysense/dns',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'laysense/highspeaker' => array(
|
||||
'pretty_version' => 'dev-master',
|
||||
'version' => 'dev-master',
|
||||
'reference' => '84fc1030a769226c8382dbc9fd171ff45107eaba',
|
||||
'reference' => '2a00928da5ff5423aef1d1833239266003781e49',
|
||||
'type' => 'project',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
|
1
vendor/laysense/dns
vendored
Submodule
1
vendor/laysense/dns
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit e6c19f90a14d4b7ef69305b6441889bea545bbce
|
53
vendor/workerman/workerman/Protocols/Dns.php
vendored
53
vendor/workerman/workerman/Protocols/Dns.php
vendored
@ -369,8 +369,11 @@ class Dns
|
||||
*/
|
||||
public static function decode($buffer)
|
||||
{
|
||||
/**
|
||||
$data=bin2hex($buffer);
|
||||
echo $data;
|
||||
$id=substr($data,0,4);
|
||||
$flag=substr($data,5,4);
|
||||
$type=substr($data,-8,4);
|
||||
switch($type){
|
||||
case '0001':
|
||||
@ -410,8 +413,58 @@ class Dns
|
||||
}
|
||||
$realname=substr($realname,1,-1);
|
||||
$query=substr($data,24);
|
||||
***/
|
||||
|
||||
#$returndata="$type".'|||'."$realname";
|
||||
$data=bin2hex($buffer);
|
||||
$id=substr($data,0,4);
|
||||
$flag=substr($data,4,4);
|
||||
$questions=substr($data,8,4);
|
||||
$answerRRs=substr($data,12,4);
|
||||
$authorityRRs=substr($data,16,4);
|
||||
$additionalRRs=substr($data,20,4);
|
||||
$startbyte=24;
|
||||
$dlen=substr($data,$startbyte,2);
|
||||
$startbyte=26;
|
||||
$i=1;
|
||||
while($dlen!='00'){
|
||||
$domain[$i]=hex2bin(substr($data,$startbyte,hexdec($dlen)*2));
|
||||
$startbyte=$startbyte+(hexdec($dlen)*2);
|
||||
$dlen=substr($data,$startbyte,2);
|
||||
$startbyte=$startbyte+2;
|
||||
$i++;
|
||||
}
|
||||
$realname=join(".",$domain);
|
||||
$type=substr($data,$startbyte,4);
|
||||
switch($type){
|
||||
case '0001':
|
||||
$type='A';
|
||||
break;
|
||||
case '0002':
|
||||
$type='NS';
|
||||
break;
|
||||
case '000c':
|
||||
$type='PTR';
|
||||
break;
|
||||
case '0006':
|
||||
$type='SOA';
|
||||
break;
|
||||
case '001c':
|
||||
$type='AAAA';
|
||||
break;
|
||||
case '0005':
|
||||
$type='CNAME';
|
||||
break;
|
||||
case '0010':
|
||||
$type='TEXT';
|
||||
break;
|
||||
case '000f':
|
||||
$type='MX';
|
||||
break;
|
||||
}
|
||||
$query=substr($data,24,$startbyte-16);
|
||||
|
||||
|
||||
$returndata= json_encode(array('type' => $type, 'name' => "$realname", 'id'=>"$id", 'query'=>"$query"));
|
||||
|
||||
return $returndata;
|
||||
|
Loading…
Reference in New Issue
Block a user