forked from torrust/torrust-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.rs
More file actions
59 lines (47 loc) · 1.63 KB
/
lib.rs
File metadata and controls
59 lines (47 loc) · 1.63 KB
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
pub mod connection_cookie;
pub mod container;
pub mod crypto;
pub mod event;
pub mod services;
pub mod statistics;
use torrust_tracker_clock::clock;
/// This code needs to be copied into each crate.
/// Working version, for production.
#[cfg(not(test))]
#[allow(dead_code)]
pub(crate) type CurrentClock = clock::Working;
/// Stopped version, for testing.
#[cfg(test)]
#[allow(dead_code)]
pub(crate) type CurrentClock = clock::Stopped;
use crypto::ephemeral_instance_keys;
use tracing::instrument;
#[macro_use]
extern crate lazy_static;
/// The maximum number of connection id errors per ip. Clients will be banned if
/// they exceed this limit.
pub const MAX_CONNECTION_ID_ERRORS_PER_IP: u32 = 10;
pub const UDP_TRACKER_LOG_TARGET: &str = "UDP TRACKER";
/// It initializes the static values.
#[instrument(skip())]
pub fn initialize_static() {
// Initialize the Ephemeral Instance Random Seed
lazy_static::initialize(&ephemeral_instance_keys::RANDOM_SEED);
// Initialize the Ephemeral Instance Random Cipher
lazy_static::initialize(&ephemeral_instance_keys::RANDOM_CIPHER_BLOWFISH);
// Initialize the Zeroed Cipher
lazy_static::initialize(&ephemeral_instance_keys::ZEROED_TEST_CIPHER_BLOWFISH);
}
#[cfg(test)]
pub(crate) mod tests {
use bittorrent_primitives::info_hash::InfoHash;
/// # Panics
///
/// Will panic if the string representation of the info hash is not a valid info hash.
#[must_use]
pub fn sample_info_hash() -> InfoHash {
"3b245504cf5f11bbdbe1201cea6a6bf45aee1bc0" // DevSkim: ignore DS173237
.parse::<InfoHash>()
.expect("String should be a valid info hash")
}
}