willemmulder / Diont

Easy Service Discovery on Local Networks in 100% pure Javascript / Typescript
43 stars 6 forks source link

Send data on differents network #7

Open ptorrent opened 1 year ago

ptorrent commented 1 year ago

Hello there,

Thanks for your tool !

I would like to be able to use it in this scenario:

By example, my device has 2 networks adaptaters:

eth0 : 192.168.1.2 ppp0 : LTE connection

Internet come from LTE. (ip route add default via ppp)

The problem I've is that I'm not able to find the device because default route is set on ppp. To be able to make it work, i've to do that:

ip route add 224.0.0.236 dev eth0

Is there a way to send multicast message on the correct interface ? Actually I'm able to listen multicast message on my device but not to send message without this route

ptorrent commented 1 year ago

I was able to make it work with:

    socket.setMulticastInterface('192.168.1.2'); //LOCAL INTERFACE IP
    socket.send(buffer, 0, buffer.length, port,multicastAddress, function(){

    });

Maybe a good feature to add :)

willemmulder commented 1 year ago

Hey @ptorrent that's an interesting feature, and certainly useful!

A user would need to announce two distinct services though, because otherwise the one service would have two different local addresses on two separate networks.

I think what we should is to check the 'host' property of the service that you're announcing, and try to find a local interface that matches that host address, and then send it through that interface. What do you think?