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
//! # aria2-core
//!
//! Core library for the aria2-rust download utility — a high-performance,
//! multi-protocol download manager rewritten in Rust.
//!
//! ## Supported Protocols & Features
//!
//! | Protocol / Feature | Status | Notes |
//! |---|---|---|
//! | HTTP / HTTPS | ✅ Full | Range requests, redirects, cookies, gzip/bzip2/chunked decoding |
//! | FTP / SFTP | ✅ Full | Passive/active mode, REST resume, LIST/MLSD parsing |
//! | BitTorrent | ✅ Full | Piece picker, choke algorithm, DHT, tracker (HTTP/UDP), seeding |
//! | Metalink | ✅ Full | v3/v4 parsing, multi-source, checksum verification, signature |
//! | Auth: Basic (RFC 7617) | ✅ | Base64 credential encoding, HTTPS-only enforcement |
//! | Auth: Digest (RFC 7616) | ✅ | MD5/SHA256/SHA512 HA1→HA2→Response chain, nonce/qop/stale |
//! | LPD (BEP 14) | ✅ | UDP multicast peer discovery on 239.192.152.143:6771 |
//! | MSE (BEP 10) | ✅ | X25519 DH key exchange, RC4 encryption, plaintext fallback |
//! | Stream Filters | ✅ | Composable GZip/BZip2/Chunked decoder pipeline |
//! | Post-Download Hooks | ✅ | Move/Rename/Touch/Exec hook chain with env injection |
//! | BT Progress Persistence | ✅ | Atomic .aria2 file save/load, C++ format compatible |
//!
//! ## Module Overview
//!
//! - **[`config`]** — Configuration system with ~95 core options, multi-source
//! merging (defaults → env → file → CLI), `ConfigManager` runtime manager,
//! NetRC authentication parser, and URI list file parser.
//!
//! - **[`engine`]** — Download engine with event-loop architecture (`DownloadEngine`),
//! command queue, timer system, tick-based scheduling. Includes `BtDownloadCommand`
//! with pluggable progress/LPD/hook managers.
//!
//! - **[`request`]** — Request management layer: `RequestGroupMan` (global task manager),
//! `RequestGroup` (per-task lifecycle: Waiting → Active → Paused → Complete/Error/Removed),
//! segment tracking, and bitfield management.
//!
//! - **[`auth`]** — HTTP authentication: [`BasicAuthProvider`](auth::basic_auth::BasicAuthProvider),
//! [`DigestAuthProvider`](auth::digest_auth::DigestAuthProvider), thread-safe
//! [`CredentialStore`](auth::credential_store::CredentialStore) with automatic secret zeroing.
//!
//! - **[`http`]** — HTTP client with connection pooling, redirect following (iterative with loop detection),
//! stream filters ([`GzDecoder`](http::stream_filter::GzDecoder), [`ChunkedDecoder`](http::stream_filter::ChunkedDecoder)),
//! cookie jar, and auth header builders.
//!
//! - **[`ftp`]** — FTP/SFTP protocol handler with passive/active modes, fast-path LIST parser,
//! REST resume support, and control file management.
//!
//! - **[`filesystem`]** — Disk I/O abstraction: `DiskAdaptor`, `DiskWriter`,
//! file pre-allocation strategies, write cache (LRU eviction), and checksum verification.
//!
//! - **[`ui`]** — Console UI components: `ProgressBar`, `MultiProgress` (multi-task summary),
//! `StatusPanel`, and formatting utilities (`format_size`, `format_speed`, `format_duration`).
//!
//! ## Quick Start
//!
//! ```rust,no_run
//! use aria2_core::config::ConfigManager;
//! use aria2_core::request::request_group_man::RequestGroupMan;
//! use aria2_core::request::request_group::DownloadOptions;
//! use aria2_core::config::OptionValue;
//!
//! #[tokio::main]
//! async fn main() {
//! let mut config = ConfigManager::new();
//! config.set_global_option("dir", OptionValue::Str("./downloads".into())).await.unwrap();
//! config.set_global_option("split", OptionValue::Int(4)).await.unwrap();
//!
//! let man = RequestGroupMan::new();
//! let opts = DownloadOptions {
//! split: Some(4),
//! ..Default::default()
//! };
//!
//! match man.add_group(vec!["http://example.com/file.zip".into()], opts).await {
//! Ok(gid) => println!("Started: #{}", gid.value()),
//! Err(e) => eprintln!("Error: {}", e),
//! }
//! }
//! ```
// Re-export commonly used types for downstream crates.
// This avoids forcing consumers to depend on internal module paths.
pub use TorrentFileEntry;
pub use ;
/// Initialize the logging subsystem with optional file output.
///
/// Sets up `tracing-subscriber` with console output (colorized) and optionally
/// writes to a log file. The log level controls verbosity (DEBUG/INFO/WARN/ERROR).