p2plib 1.1.0+0 p2plib: ^1.1.0+0 copied to clipboard
Tooling for encrypted udp datagram peer to peer communication
P2Plib Dart
P2Plib is a minimalistic library for peer-to-peer communication over UDP. Key features:- written in pure Dart;
- no legacy, the project is simple and self-sufficient.
Installation #
Clone the project:
git clone git@github.com:GuardianLabs/p2plib-dart.git
Usage #
The main entity is the Router - and it also serves as the entry point for the incoming packets. The Router is assigned handlers, each of which:
- subscribes to its own type of message (topic);
- defines how to react to the incoming message (e.g. invoke a callback).
Peers are identified by 64-byte public keys: a 32-byte encryption key + a 32-byte public key for signing.
Basic Handlers #
- EchoHandler, similar to ping;
- BootstrapHandler, used to introduce peers through the server (server code is given in the examples).
Note: To create a custom handler, implement the TopicHandler interface.
To use bootstrap server #
The peers are introduced to each other through the bootstrap server accessed by pre-defined ip-port tuple. If you want to run your own bootstrap service, you can run it in the Docker container as follows:
docker build -t p2pbootstrap .
docker run --rm -d --network host p2pbootstrap
Usage examples #
You can see an example of using this library in practice in our project: https://github.com/GuardianLabs/guardian-keyper
Contributing #
Any contributions you make are greatly appreciated.
If you have a suggestion that would make P2Plib better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Contacts #
- If you want to report a bug, open an Issue
- If you have a general question or a suggestion, create a GitHub Discussion