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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
//! # Torrust-Actix BitTorrent Tracker
//!
//! A high-performance, feature-rich BitTorrent tracker built with Rust and the Actix-web framework.
//!
//! ## Overview
//!
//! Torrust-Actix is a modern BitTorrent tracker that supports multiple protocols (HTTP/HTTPS, UDP),
//! various database backends (SQLite, MySQL, PostgreSQL), and optional caching layers (Redis, Memcache).
//! It implements the BitTorrent Enhancement Proposals (BEPs) for tracker functionality.
//!
//! ## Features
//!
//! - **Multi-Protocol Support**: HTTP/HTTPS and UDP tracker protocols
//! - **Database Agnostic**: SQLite, MySQL, and PostgreSQL support with customizable schemas
//! - **Caching Layer**: Optional Redis or Memcache caching for improved performance
//! - **Clustering**: Master/slave architecture via WebSocket for horizontal scaling
//! - **User Management**: Optional user accounts with per-user statistics tracking
//! - **Security**: Whitelist/blacklist support, API keys, and user authentication keys
//! - **SSL/TLS**: Hot-reloadable SSL certificates without server restart
//! - **Monitoring**: Real-time statistics, Prometheus metrics, and Sentry integration
//!
//! ## BEP Compliance
//!
//! This tracker implements the following BitTorrent Enhancement Proposals:
//! - BEP 3: The BitTorrent Protocol Specification
//! - BEP 7: IPv6 Tracker Extension
//! - BEP 15: UDP Tracker Protocol
//! - BEP 23: Tracker Returns Compact Peer Lists
//! - BEP 41: UDP Tracker Protocol Extensions
//! - BEP 48: Tracker Protocol Extension: Scrape
//!
//! ## Quick Start
//!
//! ```rust,ignore
//! use torrust_actix::config::Configuration;
//! use torrust_actix::tracker::TorrentTracker;
//!
//! // Load configuration from file
//! let config = Configuration::load_from_file("config.toml").await?;
//!
//! // Create tracker instance
//! let tracker = TorrentTracker::new(config).await?;
//! ```
//!
//! ## Modules
//!
//! - [`api`] - REST API endpoints for tracker management and statistics
//! - [`cache`] - Redis and Memcache caching implementations
//! - [`common`] - Shared utilities, error handling, and helper functions
//! - [`config`] - Configuration management and TOML parsing
//! - [`database`] - Multi-database backend support (SQLite, MySQL, PostgreSQL)
//! - [`http`] - HTTP/HTTPS tracker protocol implementation
//! - [`ssl`] - SSL/TLS certificate management with hot-reload support
//! - [`stats`] - Real-time statistics tracking and monitoring
//! - [`structs`] - CLI argument parsing and common data structures
//! - [`tracker`] - Core tracker logic, peer management, and torrent handling
//! - [`udp`] - UDP tracker protocol implementation (BEP 15)
//! - [`websocket`] - WebSocket-based clustering for master/slave architecture
/// REST API module for tracker management and statistics.
///
/// Provides HTTP endpoints for managing torrents, users, whitelists, blacklists,
/// API keys, and retrieving tracker statistics. Includes Swagger UI documentation
/// and Prometheus metrics endpoints.
/// Caching layer module supporting Redis and Memcache.
///
/// Implements peer data caching to reduce database load and improve response times
/// for high-traffic tracker deployments.
/// Common utilities and shared functionality.
///
/// Contains helper functions for query parsing, IP validation, hex conversion,
/// logging setup, and error handling used across all modules.
/// Configuration management module.
///
/// Handles loading, parsing, and validating configuration from TOML files
/// and environment variables. Supports customizable database schemas and
/// multi-server configurations.
/// Database backend module with multi-database support.
///
/// Provides a unified interface for SQLite, MySQL, and PostgreSQL backends
/// with support for custom table and column names. Includes query builders
/// and connection pooling.
/// HTTP/HTTPS tracker protocol implementation.
///
/// Handles announce and scrape requests over HTTP/HTTPS according to the
/// BitTorrent tracker protocol specification. Supports multiple concurrent
/// server instances with configurable SSL/TLS.
/// SSL/TLS certificate management module.
///
/// Provides certificate storage, hot-reloading capabilities, and dynamic
/// certificate resolution for SNI-based virtual hosting.
/// Statistics tracking and monitoring module.
///
/// Collects real-time metrics on tracker activity including peer counts,
/// announce/scrape requests, protocol-specific statistics, and cluster activity.
/// Supports Prometheus metrics export.
/// CLI argument parsing and common data structures.
///
/// Defines command-line interface options for the tracker binary including
/// configuration generation, database setup, and data import/export.
/// Core tracker logic module.
///
/// Contains the main tracker implementation including peer management,
/// torrent tracking, user accounts, sharding for scalability, and the
/// announce/scrape request handling logic.
/// UDP tracker protocol implementation (BEP 15).
///
/// Implements the UDP tracker protocol with support for connect, announce,
/// and scrape actions. Includes proxy protocol support for load balancer
/// compatibility.
/// WebSocket-based clustering module.
///
/// Enables horizontal scaling through master/slave architecture. The master
/// node maintains the authoritative tracker state while slave nodes forward
/// requests and serve cached responses.