autodiscover-rs
autodiscover-rs implements a simple algorithm to detect peers on an IP network, connects to them, and calls back with the connected stream. The algorithm supports both UDP broadcast and multicasting.
Usage
Cargo.toml
= "0.1.0"
In your app:
use ;
use thread;
use ;
use env_logger;
Notes
The algorithm for peer discovery is to:
- Send a message to the broadcast/multicast address with the configured 'listen address' compressed to a 6 byte (IPv4) or 18 byte (IPv6) packet
- Start listening for new messages on the broadcast/multicast address; when one is recv., connect to it and run the callback
This has a few gotchas:
- If a broadcast packet goes missing, some connections won't be made
Packet format
The IP address we are broadcasting is of the form:
IPv4:
buff.clone_from_slice;
buff.clone_from_slice;
IPv6:
buff.clone_from_slice;
buff.clone_from_slice;
TODO
- Provide features for async frameworks (such as async_std and tokio)
- Figure out some way of testing this
- Provides some mechanism to stop the thread listening for discovery