diff options
| author | murilo ijanc | 2026-03-24 15:04:03 -0300 |
|---|---|---|
| committer | murilo ijanc | 2026-03-24 15:04:03 -0300 |
| commit | 9821aabf0b50d2487b07502d3d2cd89e7d62bdbe (patch) | |
| tree | 53da095ff90cc755bac3d4bf699172b5e8cd07d6 /src/event.rs | |
| download | tesseras-dht-0.1.0.tar.gz | |
Initial commitv0.1.0
NAT-aware Kademlia DHT library for peer-to-peer networks.
Features:
- Distributed key-value storage (iterative FIND_NODE, FIND_VALUE, STORE)
- NAT traversal via DTUN hole-punching and proxy relay
- Reliable Datagram Protocol (RDP) with 7-state connection machine
- Datagram transport with automatic fragmentation/reassembly
- Ed25519 packet authentication
- 256-bit node IDs (Ed25519 public keys)
- Rate limiting, ban list, and eclipse attack mitigation
- Persistence and metrics
- OpenBSD and Linux support
Diffstat (limited to 'src/event.rs')
| -rw-r--r-- | src/event.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/event.rs b/src/event.rs new file mode 100644 index 0000000..df7295d --- /dev/null +++ b/src/event.rs @@ -0,0 +1,30 @@ +//! Event types for typed callback integration. +//! +//! Alternative to `Box<dyn Fn>` callbacks. Applications +//! can receive events via `std::sync::mpsc::Receiver`. + +use crate::id::NodeId; +use crate::rdp::{RdpAddr, RdpEvent}; + +/// Events emitted by a Node. +#[derive(Debug, Clone)] +pub enum NodeEvent { + /// Datagram received from a peer. + DgramReceived { data: Vec<u8>, from: NodeId }, + + /// RDP event on a connection. + Rdp { + desc: i32, + addr: RdpAddr, + event: RdpEvent, + }, + + /// Peer added to routing table. + PeerAdded(NodeId), + + /// Value stored via DHT STORE. + ValueStored { key: Vec<u8> }, + + /// Node shutdown initiated. + Shutdown, +} |