Handling MDNS request from localhost
jdesai61 opened this issue · comments
Jatin Desai commented
Currently, the code throws an exception and exits if MDNS request is received from localhost (127.0.0.1)
Here is the message and my workaround
/home/me/tmp/node-matter/build/util/Network.js:42
throw new Error(`Cannot find the device IP on the subnet containing ${remoteAddress}`);
^
Error: Cannot find the device IP on the subnet containing 127.0.0.1
at getIpMacOnInterface (/home/me/tmp/node-matter/build/util/Network.js:42:11)
at MdnsServer.handleDnsMessage (/home/me/tmp/node-matter/build/mdns/MdnsServer.js:33:63)
at /home/me/tmp/node-matter/build/mdns/MdnsServer.js:24:63
at Socket.<anonymous> (/home/me/tmp/node-matter/build/io/udp/UdpMulticastServer.js:28:77)
at Socket.emit (node:events:513:28)
at UDP.onMessage [as onmessage] (node:dgram:922:8)
Node.js v18.7.0
$:~/tmp/node-matter$ diff node-matter/build/mdns/MdnsServer.js node-matter.x/build/mdns/MdnsServer.js
24c24,27
< multicastServer.onMessage((message, remoteIp) => this.handleDnsMessage(message, remoteIp));
---
> multicastServer.onMessage((message, remoteIp) => { try {
> this.handleDnsMessage(message, remoteIp);
> }
> catch (e) { } });
mfucci commented
Thanks! Here is a fix to handle MDNS requests from localhost: #19
Let me know if this fixes the issue!
Jatin Desai commented
I have tested the fix - it works.