1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! WebSocket-based clustering module for horizontal scaling.
//!
//! This module enables running multiple tracker instances in a master/slave
//! architecture, allowing horizontal scaling for high-traffic deployments.
//!
//! # Cluster Modes
//!
//! - **Standalone**: Single instance mode (no clustering)
//! - **Master**: Authoritative node that maintains tracker state
//! - **Slave**: Forwards requests to master, serves cached responses
//!
//! # Architecture
//!
//! ```text
//! ┌─────────┐
//! │ Master │
//! │ Tracker │
//! └────┬────┘
//! ┌───────────┼───────────┐
//! ▼ ▼ ▼
//! ┌────────┐ ┌────────┐ ┌────────┐
//! │ Slave │ │ Slave │ │ Slave │
//! │ 1 │ │ 2 │ │ 3 │
//! └────────┘ └────────┘ └────────┘
//! ```
//!
//! # Features
//!
//! - WebSocket-based communication
//! - Multiple encoding formats (binary, JSON, MessagePack)
//! - SSL/TLS support for secure connections
//! - Automatic reconnection handling
//! - Authentication with shared secret
//! - Keep-alive with configurable intervals
//!
//! # Protocol
//!
//! Slave nodes forward announce/scrape requests to the master node,
//! which processes them and returns the response. This ensures all
//! nodes have consistent peer data.
/// Protocol type and request type enumerations.
/// Message structures for cluster communication.
/// Data encoding/decoding (binary, JSON, MessagePack).
/// Master node server implementation.
/// Slave node client implementation.