这个库旨在提供一个面向对象的封装,围绕php的dns网络工具。
0.0.1
2020-02-15 13:41 UTC
This package is auto-updated.
Last update: 2024-09-16 00:12:29 UTC
README
这个库旨在提供一个面向对象的封装,围绕php的dns网络工具。
目前,这个库为你提供了一个抽象层
dns_get_record()
用于查找所有记录或特定类型的记录gethostbyaddr()
用于执行特定名称的PTR查找
安装
要使用Composer安装,请使用以下命令。它将自动检测最新版本并将其与^绑定。
composer require christoph-kluge/dns
查找(-服务)
查找服务将始终返回一个集合,除了PTR查找。该集合实现了一个__toString()
魔法方法,以便将集合转换为字符串。此外,您还可以使用toArray()
成员函数,这将为您提供与使用dns_get_record()
相同的基本数组表示。
目前API包括以下成员函数
(new Lookup)->a('example.org')
(new Lookup)->aaaa('example.org')
(new Lookup)->cname('www,example.org')
(new Lookup)->mx('example.org')
(new Lookup)->txt('example.org')
(new Lookup)->soa('example.org')
(new Lookup)->srv('example.org')
(new Lookup)->all('example.org')
(new Lookup)->any('example.org')
以下是一个示例,如果您以文本形式显示所有记录。
echo (string) (new Lookup())->all('example.org');
example.org. 4502 IN A 93.184.216.34
example.org. 4502 IN NS b.iana-servers.net.
example.org. 4502 IN NS a.iana-servers.net.
example.org. 4502 IN SOA ns.icann.org. noc.dns.icann.org. 2019121336 7200 3600 1209600 3600
example.org. 4502 IN MX 0 .
example.org. 4502 IN TXT "v=spf1 -all"
example.org. 4502 IN TXT "2b3dee88837848bbae05e3532f427b10"
example.org. 4502 IN AAAA 2606:2800:220:1:248:1893:25c8:1946
以下是一个更短的示例,如果您只需要TXT
记录。
echo (string) (new Lookup())->txt('example.org');
example.org. 4502 IN TXT "v=spf1 -all"
example.org. 4502 IN TXT "2b3dee88837848bbae05e3532f427b10"
以下是一个示例,如果您想以数组形式显示所有记录。
print_r( (new Lookup())->all('example.org')->toArray() );
Array
(
[0] => Array
(
[host] => example.org
[ttl] => 4502
[class] => IN
[type] => A
[ip] => 93.184.216.34
)
....