我有一个 IOT 设备破坏了 mDNS 响应器,有没有办法通过react-native/Expo 应用程序找到该设备?
我找到了一个react-native库(react-native-zeroconf)。然而,它需要react-native-link,而expo不支持。
我还找到了一个纯 Java 脚本库 ( multicast-dns )。但是,我不确定是否可以将其移植到react-native/Expo。
我应该分离并使用本机模块吗?我现在把它作为最后的手段。
我对DNSServiceRegister具有以下声明:
function DNSServiceRegister
(
var sdRef: TDNSServiceRef;
const flags: TDNSServiceFlags;
const interfaceIndex: uint32_t;
const name: PUTF8String; //* may be NULL */
const regType: PUTF8String;
const domain: PUTF8String; //* may be NULL */
const host: PUTF8String; //* may be NULL */
const port: uint16_t;
const txtLen: uint16_t;
const txtRecord: Pointer; //* may be NULL */
const callBack: TDNSServiceRegisterReply; //* may be NULL */
const context: Pointer //* may be NULL */
): TDNSServiceErrorType; stdcall; external DNSSD_DLL;
Run Code Online (Sandbox Code Playgroud)
在我的Bonjour框架中,对于已启用的已宣布服务(即实际上开始通过Bonjour宣布自身),我有以下响应:
procedure TAnnouncedService.Activate;
var
flags: …Run Code Online (Sandbox Code Playgroud) 我想弄清楚如何扫描网络以查找由 avahi 发布的设备。
#!/usr/bin/python3
from zeroconf import ServiceBrowser, Zeroconf
from time import sleep
class MyListener:
def remove_service(self, zeroconf, type, name):
print("Service % removed" % (name))
def add_service(self, zeroconf, type, name):
info = zeroconf.get_service_info(type, name)
info = str(info)
info = info.split(",")[6]
print(info)
zeroconf = Zeroconf()
listener = MyListener()
browser = ServiceBrowser(zeroconf, "_http._tcp.local.", listener)
try:
sleep(1)
finally:
zeroconf.close()
Run Code Online (Sandbox Code Playgroud)
它有效,但它没有给我任何 IPv4 地址。输出(示例):
ServiceInfo(type='_http._tcp.local.', name='Barco ptp-owsserver-2237._http._tcp.local.', address=b'\n\x80Cj', port=80, weight=0, priority =0, server='ptp-owsserver-2237.local.', properties={b'root': b'/'})
请有人告诉我如何获取 avahi 在我们网络中发布的设备的 IPv4 地址?
2005 年由 Stuart Cheshire 和 Daniel H. Steinberg撰写的《零配置网络 - 明确指南》一书描述了一个dns-sd命令行测试工具,它应该可用于 macOS、Windows 和 Linux。在第 6 章(第 92 页)的开头,他描述了该工具,但它不是关于如何下载和安装它的明确指南,只是可以从 Darwin 开源存储库中获得。
该工具提供诸如dns-sd -B浏览服务实例之类的命令。
我是 Windows 和 Linux 用户,但在找到该工具时遇到问题。我的 Windows 系统上已经安装了 Bonjour,但我不清楚这是否足够,或者我是否需要明确下载该工具。当我dns-sd在 windows 命令行上输入时,它说这个命令是未知的。如何使其可用?
我试图让MZClient在OSX 10.7.3上运行,并且无法通过ProviderFactory模块在/ bin目录中找不到任何可接受的条目.我已经尝试过尝试对文件名进行硬编码,但尚未使其工作.关于如何实现这一目标的任何建议?
我在运行Fedora 20的linux机器上安装了zeroconf.我已经安装了zeroconf所依赖的所有软件包.但是,当我尝试运行testcert.py时,我遇到以下错误:
Traceback (most recent call last):
File "./testcert.py", line 49, in <module>
import _mdns
File "/opt/home/gcp_cert_test/_mdns.py", line 23, in <module>
from zeroconf import InterfaceChoice
File "/usr/lib/python2.7/site-packages/zeroconf-0.17.4-py2.7.egg/zeroconf.py", line 1257, in <module>
@enum.unique
AttributeError: 'module' object has no attribute 'unique'
Run Code Online (Sandbox Code Playgroud)
我需要安装任何其他包吗?我使用的是Python 2.7.
zeroconf ×6
bonjour ×2
python ×2
delphi ×1
delphi-2009 ×1
dns-sd ×1
expo ×1
ipv4 ×1
javascript ×1
linux ×1
macos ×1
mdns ×1
mono ×1
networking ×1
python-2.7 ×1
react-native ×1