如何使用 Ruby 的 net-mdns 广播主机名?

发布于 2024-08-30 05:38:43 字数 623 浏览 3 评论 0原文

一般来说,我对 net-mdns 和 mDNS 很陌生,所以我现在对该协议的工作原理只有一个基本的了解,我希望这个问题是不言自明的。

到目前为止,我已经看到了一些如何使用 net-mdns 广告服务的示例,但我真正需要的是广播主机名别名,以便我的机器可以解析为“mybox.local” ”和“othername.local”(如果“othername.local”是实际的 DNS 别名,那就太好了,但这并不重要,A 记录就可以了)。

我发现 这个脚本 基本上可以满足我的要求,但

  • 我并不像像我使用 Ruby 一样流利地使用 Python ;-)
  • 它依赖于 avahi 并且只能在 Linux 或 BSD 上运行,而可移植到其他平台将是一个巨大的优势,
  • 在 Ruby 中执行它意味着可以轻松地将其插入 Rails 应用程序中,并且我碰巧非常熟悉 Rails。 ;-)

我似乎在文档中找不到任何关于广播主机名的提及:我临时做了一点,阅读了一些源代码,但到目前为止还没有成功。

任何帮助将不胜感激,谢谢。

I'm new to net-mdns and mDNS in general, so I have just a basic understanding of how the protocol works for now, and I hope the question is pretty self-explanatory.

So far I've seen some examples of how to advertise a service with net-mdns, but what I really need is to broadcast a hostname alias, so that my machine can be resolved as "mybox.local" and "othername.local" (it would be nice if "othername.local" were an actual DNS alias, but this is not vital and an A record would do just fine).

I've found this script that basically does what I want, but

  • I'm not as fluent in Python as I am in Ruby ;-)
  • it depends on avahi and would only run on Linux or BSD, while being portable to other platforms would be a huge plus
  • doing it in Ruby would mean plugging it easily in a Rails application, and I happen to be very fluent in Rails. ;-)

I can't seem to find any mention of broadcasting hostnames in the documentation: I've improvised a little, read some of the source code, but with no success so far.

Any help would be appreciated, thanks.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文