使用 PHP 查找 SRV 记录

发布于 2024-07-10 07:51:07 字数 256 浏览 5 评论 0原文

如果您键入

nslookup -type=SRV _xmpp-server._tcp.gmail.com

(或在 OSX 中使用 dig 命令),您会得到一些与 google 聊天相关的 SRV 记录

我想在 PHP 中复制此功能,有人有任何好主意如何做到这一点吗?

我想避免使用 exec() 因为这不会在 OSX/*NIX/WINDOWS 上返回 100% 标准响应

谢谢!

If you type

nslookup -type=SRV _xmpp-server._tcp.gmail.com

(or use the dig command in OSX) you get some SRV records relating to google chat

I would like to replicate this functionality in PHP, does anyone have any good ideas how to do this?

I would like to avoid using exec() as this does not return 100% standard responses across OSX/*NIX/WINDOWS

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

纸伞微斜 2024-07-17 07:51:07

dns_get_record() 。 根据文档,它可以采用 int $type 参数,它引用一组常量,其中一个是 DNS_SRV

There is dns_get_record(). According to the docs it can take an int $type argument, which refers to a set of constants, one of them being DNS_SRV.

恏ㄋ傷疤忘ㄋ疼 2024-07-17 07:51:07

您可以使用 Pear Net_DNS。 我设法让它在 Linux 上运行,但还没有在 Windows 或任何其他操作系统上进行测试:

require_once('Net/DNS.php');
$resolver = new Net_DNS_Resolver();
$response = $resolver->query('_xmpp-server._tcp.gmail.com', 'SRV');
if ($response) {
    foreach ($response->answer as $rr) {
        $rr->display();
    }
}

我修改了他们文档中的示例。 希望这可以帮助

You could use Pear Net_DNS. I managed to get this to work on Linux, but haven't tested it on Windows or any others:

require_once('Net/DNS.php');
$resolver = new Net_DNS_Resolver();
$response = $resolver->query('_xmpp-server._tcp.gmail.com', 'SRV');
if ($response) {
    foreach ($response->answer as $rr) {
        $rr->display();
    }
}

I modified the example from their documentation. hope this helps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文