diff --git a/app/controller/DnsController.php b/app/controller/DnsController.php
new file mode 100644
index 0000000..ae853b5
--- /dev/null
+++ b/app/controller/DnsController.php
@@ -0,0 +1,47 @@
+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;
+ }
+}
\ No newline at end of file
diff --git a/app/controller/api.php b/app/controller/api.php
index 37998ef..505999a 100644
--- a/app/controller/api.php
+++ b/app/controller/api.php
@@ -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,20 +24,23 @@ 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){
- $msg['Whois']='Whois查询失败';
- };
- if($whois->data->status !=0){
- $msg['Whois']='Whois查询出错,请稍后重试';
- };
- if($whois->data->status ==2 || $whois->data->status ==3 ){
- $msg['Whois']='该域名未注册或该后缀暂不支持查询';
- };
- if($whois->code == 0 && $whois->data->status == 0){
- $msg['Whois']=$whois->data->data;
- }
+ if($whois->code !=0){
+ $msg['Whois']='Whois查询失败';
+ };
+ if($whois->data->status !=0){
+ $msg['Whois']='Whois查询出错,请稍后重试';
+ };
+ if($whois->data->status ==2 || $whois->data->status ==3 ){
+ $msg['Whois']='该域名未注册或该后缀暂不支持查询';
+ };
+ if($whois->code == 0 && $whois->data->status == 0){
+ $msg['Whois']=$whois->data->data;
+ }
$safe = Http::get('https://api.devopsclub.cn/api/dcheck', ['url' => "$content"])->body();
$safe=json_decode($safe);
if($safe->code == 0){
@@ -46,6 +48,7 @@ class api
$msg['Wx-Safe']=$safe->data->wx;
$msg['QQ-Safe']=$safe->data->qq;
}
+ **/
}
}else{
$contenttype='ip';
diff --git a/app/view/common_head.html b/app/view/common_head.html
index 55021fe..dccaf06 100644
--- a/app/view/common_head.html
+++ b/app/view/common_head.html
@@ -269,7 +269,7 @@
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
name);?>
+ src="email ))));?>">
email )));
+ $headurl='https://headimg.b-cdn.net/' . md5(strtolower(trim( $us->email )));
$name='name';
$email='email';
$password='password';
diff --git a/composer.json b/composer.json
index 32835e8..a2883d3 100644
--- a/composer.json
+++ b/composer.json
@@ -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. "
diff --git a/composer.lock b/composer.lock
index 7de5323..75be152 100644
--- a/composer.lock
+++ b/composer.lock
@@ -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",
diff --git a/config/autoload.php b/config/autoload.php
index 69a8135..8a82a48 100644
--- a/config/autoload.php
+++ b/config/autoload.php
@@ -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'
]
];
diff --git a/config/plugin/laysense/dns/app.php b/config/plugin/laysense/dns/app.php
new file mode 100644
index 0000000..8f9c426
--- /dev/null
+++ b/config/plugin/laysense/dns/app.php
@@ -0,0 +1,4 @@
+ true,
+];
\ No newline at end of file
diff --git a/config/plugin/laysense/dns/process.php b/config/plugin/laysense/dns/process.php
new file mode 100644
index 0000000..9f16606
--- /dev/null
+++ b/config/plugin/laysense/dns/process.php
@@ -0,0 +1,10 @@
+ [
+ 'handler' => process\DnsProcess::class,
+ 'listen' => 'Dns://0.0.0.0:53',
+ 'transport' => 'udp',
+ 'count' => 4
+ #cpu_count() * 1
+ ],
+];
\ No newline at end of file
diff --git a/config/process.php b/config/process.php
index f10e286..30530d7 100644
--- a/config/process.php
+++ b/config/process.php
@@ -39,12 +39,4 @@ return [
]
]
],
- 'Dns' => [
- 'handler' => process\DnsProcess::class,
- 'listen' => 'Dns://0.0.0.0:53',
- 'transport' => 'udp',
- 'count' => cpu_count() * 4
- ],
-
-
];
diff --git a/config/redis.php b/config/redis.php
index 712ed47..3d38217 100644
--- a/config/redis.php
+++ b/config/redis.php
@@ -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,
],
];
diff --git a/config/server.php b/config/server.php
index b72116a..e340ed0 100644
--- a/config/server.php
+++ b/config/server.php
@@ -13,7 +13,7 @@
*/
return [
- 'listen' => 'http://0.0.0.0:8787',
+ 'listen' => 'http://0.0.0.0:4680',
'transport' => 'tcp',
'context' => [],
'name' => 'webman',
diff --git a/phpWhois.org b/phpWhois.org
new file mode 160000
index 0000000..c0997b4
--- /dev/null
+++ b/phpWhois.org
@@ -0,0 +1 @@
+Subproject commit c0997b4f513d71a139a21d7178616ec28f0733d3
diff --git a/process/DnsProcess.php b/process/DnsProcess.php
index bee3412..3f4f2d5 100644
--- a/process/DnsProcess.php
+++ b/process/DnsProcess.php
@@ -1,6 +1,7 @@
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);
}
diff --git a/so.php b/so.php
new file mode 100644
index 0000000..3b11679
--- /dev/null
+++ b/so.php
@@ -0,0 +1,7 @@
+passwd='A9960454D30A135729BCFC6572776BB12BB20282F2EA1CCE8DBC3040C41ACFC9';
+$json->email='ywnsya@126.com';
+$json->name='以诺书';
+echo json_encode($json);
+echo hash("sha256", 'qi2005112');
\ No newline at end of file
diff --git a/test.php b/test.php
index 99ca150..5040a60 100644
--- a/test.php
+++ b/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 '
';
+ print_r($result);
+ echo '
';
+}
+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";
+}
+
?>
\ No newline at end of file
diff --git a/timeout.php b/timeout.php
new file mode 100644
index 0000000..a4b96a2
--- /dev/null
+++ b/timeout.php
@@ -0,0 +1,29 @@
+ 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'),
diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php
index 959e3d7..f1cbdd2 100644
--- a/vendor/composer/autoload_static.php
+++ b/vendor/composer/autoload_static.php
@@ -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 (
diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json
index 824f714..7cad160 100644
--- a/vendor/composer/installed.json
+++ b/vendor/composer/installed.json
@@ -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",
diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php
index bc2a95e..170ec51 100644
--- a/vendor/composer/installed.php
+++ b/vendor/composer/installed.php
@@ -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(),
diff --git a/vendor/laysense/dns b/vendor/laysense/dns
new file mode 160000
index 0000000..e6c19f9
--- /dev/null
+++ b/vendor/laysense/dns
@@ -0,0 +1 @@
+Subproject commit e6c19f90a14d4b7ef69305b6441889bea545bbce
diff --git a/vendor/workerman/workerman/Protocols/Dns.php b/vendor/workerman/workerman/Protocols/Dns.php
index f44ee5d..134c880 100644
--- a/vendor/workerman/workerman/Protocols/Dns.php
+++ b/vendor/workerman/workerman/Protocols/Dns.php
@@ -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;