以诺书 af904671ad | ||
---|---|---|
src | ||
composer.json | ||
readme.md |
readme.md
Webman-Dnsclient
- The English version of this document is machine translated and for reference only
Webman的DNS客户端扩展。目前主要用于实现PHP原生不支持的向自定义DNS服务器发送请求,通过本插件可以实现对自定义DNS服务器发送请求,同时采用异步方案,性能相比原生函数快3~5倍。 DNS client extension for Webman. At present, it is mainly used to send DNS requests to custom dns servers that are not supported by PHP native functions. Through this plug-in, it can send requests to custom DNS servers. At the same time, it adopts asynchronous scheme, and the performance is 3~5 times faster than the native function.
这是对Workerman协议扩展Dnsclient(for Workerman)在Webman下的封装 This is an encapsulation of the Workerman protocol extension Dnsclient(for Workerman) under Webman
安装Installation
首先你需要PHP环境和Composer,具体方式请自行百度 First you need the PHP environment and Composer, please ask Google for details
由于这是一个Webman插件,需要安装Webman
Since this is a Webman plug-in, you need to install Webman
composer composer create-project workerman/webman
cd webman
此外,需要用到Redis,你需要确保PHP-Cli安装了redis扩展、以及一个Redis服务器,同时安装Webman的Redis扩展。
In addition, in order to use Redis, you need to make sure that PHP-Cli has the redis extension installed, as well as a Redis server, as well as the Redis extension for Webman.
composer require -W illuminate/redis illuminate/events
最后,安装本插件
Finally, install this plug-in
composer require laysense/dnsclient
配置文件Configuration
配置文件位于 The configuration file is located in
config/plugin/laysense/dnsclient/app.php
内容类似如下 Content similar to the following
<?php
return [
'enable' => true,
'DefaultServer'=>'119.29.29.29',
'DefaultTimeout'=>3,
'RedisExpire'=>10
];
DefaultServer是当未传入DNS服务器时,默认的DNS请求服务器 DefaultTimeout是默认请求超时时间,单位未秒 RedisExpire是获得请求值之后存入Redis后,自动销毁的时间,单位为秒。如需要永久保存,请改为-1 DefaultServer is the default DNS request server when no DNS server is passed in DefaultTimeout Indicates the timeout period of the request, in seconds RedisExpire is the automatic destruction time after obtaining the requested value and storing it in Redis, in seconds. For permanent storage, change to -1
您还需要配置redis,请在config/redis.php
新增一个名为dnsc
的Redis配置
You also need to configure redis, add a redis configurationdnsc
in config/redis.php
<?php
return [
'default' => [
*****(Your Default Redis Configuration)
],
'dnsc' => [
'host' => '127.0.0.1',
'password' => null,
'port' => 6379,
'database' => 0,
],
];
请将127.0.0.1、null、6379、0等改为您实际的Redis服务器配置 Please change 127.0.0.1, null, 6379, 0, etc. to your actual Redis server configuration
示例Examples
#app/controller/IndexController.php
<?php
namespace app\controller;
use support\Request;
use support\Redis;
use Laysense\Dnsclient\Client;
class IndexController
{
public function index(Request $request)
{
$dns=new Client();
$id=$dns->server('8.8.8.8')->domain('laysense.com')->query('A');
return redirect('/index/?id='$id);
}
public function get(Request $request)
{
$id='dnsc_'.$request->input('id');
$redis = Redis::connection('dnsc');
if($redis->exists($id)=='1'){
return json(json_decode($redis->get($id)));
}else{
return 'NotFound';
}
}
}
##作者 Author 上海来笙信息科技有限公司(Shanghai Laysense Information Technology Co. Ltd.) mail: public@laysense.cn ##Copyright&License http://www.apache.org/licenses/ Apache License, Version 2.0
Current version
- 2024/02/25 0.0.1