wankdanker / node-discover

Automatic and decentralized discovery and monitoring of nodejs instances with built in support for a variable number of master processes, service advertising and channel messaging.
229 stars 59 forks source link

Send broadcast messages to all interfaces #38

Open aikar opened 4 years ago

aikar commented 4 years ago

Look up all available interfaces and build an array of destinations for each for broadcast.

Resolves a TODO you had here.

Used a library to implement the logic of turning an address and netmask into a broadcast address.

Have tested this locally where I have 2 ifaces available (wireless and wired), another machine only had 1 (wireless) Previously had issues where my outbound packets only went out wired, so the wireless client could not receive mine, however I could receive the wireless packets as I was also on wireless.

This resolves the issue by sending my outbound over both wired and wireless.

Resolves #26

wankdanker commented 4 years ago

Awesome. One thought I have is if options.address has been specified, then we should probably only resolve the broadcast address for the interface that has that address. Reason being, if I am specifying the address I want things bound to, I probably don't want packets broadcast on all interfaces.

It is possible that there is not an interface with the specified address though (sysctl -w net.ipv4.ip_nonlocal_bind=1), so, in that case I'd probably just broadcast to all interfaces.

aikar commented 4 years ago

Oh, to follow on that feedback i noticed you said address now and not broadcast.

I can see what you mean now. Not sure best way to implement that though.

I assume would have to compare address to cidr/netmask to compare?

Are you able to implement those changes? (you do have push to my branch for this PR)

YindSoft commented 1 year ago

Hi!, are you merging this fix? because I'm having the same issue, my node connects to the other nodes an receives data but those nodes doesn't know about mine and I can't send data. I change the code with this PR and it worked.