5

JavaScript DNS-SD

 3 years ago
source link: https://sskaje.me/2020/05/javascript-dns-sd/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

JavaScript DNS-SD

用了 npm 包 multicast-dns https://www.npmjs.com/package/multicast-dns 。其他几个包也试过了,各种残废,要不想太多要不瞎搞,还是这个单纯。

核心的环节是,正确地响应 “_services._dns-sd._udp.local” 的query。

响应的包 answers 放 PTR,additional records 放 SRV、TXT、A。TXT可以放多个 key=value,来处理自定义配置,例如端口、是否加密,认证等信息。

Gist: https://gist.github.com/sskaje/974ec85b39f51dd3a4c6734c2bfb214f

JavaScript DNS-SD by @sskaje: https://sskaje.me/2020/05/javascript-dns-sd/
Link to this post!

Author sskajePosted on May 6, 2020May 6, 2020Categories Network, 杂七杂八, 笔记, 项目、研究Tags dns, dns service discovery, dns-sd, javascript, javascript multicast, javascript service discovery, multicast, node js, nodejs, npm, service discovery

Post navigation


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK