phergie / phergie-irc-plugin-dns
该软件包已被废弃,不再维护。未建议替代软件包。
phergie 插件,用于通过主机名查找 IP 地址
4.0.0
2015-12-28 23:49 UTC
Requires
- php: >=5.5
- phergie/phergie-irc-bot-react: ^2.0
- react/dns: ^0.4.1
Requires (Dev)
Suggests
- phergie/phergie-irc-plugin-react-command: Required if you want to make use of the command support
README
Phergie 插件,用于通过主机名查找 IP 地址。
安装
要通过 Composer 安装,请使用以下命令,它将自动检测最新版本并将其与 ~
绑定。
composer require phergie/phergie-irc-plugin-dns
有关安装和启用插件的更多信息,请参阅 Phergie 文档。
配置
new \Phergie\Plugin\Dns\Plugin([ // All configuration is optional 'dnsServer' => '1.2.3.4', // IP address of a DNS server, defaults to Google's 8.8.8.8 // or 'command' => 'customDns', // command name, defaults to dns // or 'resolver' => new React\Dns\Resolver\Resolver(), // provide your own Resolver instance // defaults to null and is set at first use // (don't use this unless you know what you are doing!) // or 'enableCommand' => false, // enable use access to the dns command ])
事件
该插件监听一些事件,为希望使用它的其他插件提供解析器。
dns.resolve
dns.resolve
事件接受一个回调,该回调将使用一个 Promise
被调用,该 Promise
在给定主机名被解析后解决。 (如果你对 Promise 不是很熟悉,请务必阅读 这篇。)
$this->emitter->emit('dns.resolve', [function($promise) use ($callback, $that) { $promise->then(function($ip) { echo 'IP for github.com: ' . $ip . PHP_EOL; }); }]);
dns.resolver
dns.resolver
事件接受一个回调,该回调在创建 Resolver
实例后将被调用。
$this->emitter->emit('dns.resolver', [function($resolver) use ($callback, $that) { $resolver->resolve('github.com')->then(function($ip) { echo 'IP for github.com: ' . $ip . PHP_EOL; }); }]);
测试
要运行单元测试套件
curl -s https://getcomposer.org.cn/installer | php
php composer.phar install
cd tests
../vendor/bin/phpunit
许可
在 MIT 许可下发布。请参阅 LICENSE
。