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
71 lines (56 loc) · 1.53 KB
/
lib.rs
File metadata and controls
71 lines (56 loc) · 1.53 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
60
61
62
63
64
65
66
67
68
69
70
71
pub use api::server::*;
pub use http::server::*;
pub use protocol::common::*;
pub use udp::server::*;
pub use self::config::*;
pub use self::tracker::*;
pub mod api;
pub mod config;
pub mod databases;
pub mod http;
pub mod jobs;
pub mod logging;
pub mod protocol;
pub mod setup;
pub mod tracker;
pub mod udp;
#[macro_use]
extern crate lazy_static;
pub mod static_time {
use std::time::SystemTime;
lazy_static! {
pub static ref TIME_AT_APP_START: SystemTime = SystemTime::now();
}
}
pub mod ephemeral_instance_keys {
use rand::rngs::ThreadRng;
use rand::Rng;
pub type Seed = [u8; 32];
lazy_static! {
pub static ref RANDOM_SEED: Seed = Rng::gen(&mut ThreadRng::default());
}
}
pub mod block_ciphers {
use blowfish::BlowfishLE;
use cipher::KeyInit;
use rand::rngs::StdRng;
use rand::SeedableRng;
pub type Cipher = BlowfishLE;
pub mod ephemeral_instance {
use super::*;
use crate::ephemeral_instance_keys::RANDOM_SEED;
lazy_static! {
pub static ref BLOCK_CIPHER_BLOWFISH: Cipher = <BlowfishLE as KeyInit>::new(&<BlowfishLE as KeyInit>::generate_key(
<StdRng as SeedableRng>::from_seed(*RANDOM_SEED)
));
}
}
pub mod testing {
use super::*;
lazy_static! {
pub static ref TEST_BLOCK_CIPHER_BLOWFISH: Cipher = <BlowfishLE as KeyInit>::new(
&<BlowfishLE as KeyInit>::generate_key(<StdRng as SeedableRng>::from_seed([0u8; 32]))
);
}
}
}