-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathhttp_tracker.rs
More file actions
50 lines (41 loc) · 1.46 KB
/
http_tracker.rs
File metadata and controls
50 lines (41 loc) · 1.46 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
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use serde::{Deserialize, Serialize};
use serde_with::serde_as;
use crate::TslConfig;
/// Configuration for each HTTP tracker.
#[serde_as]
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Clone)]
pub struct HttpTracker {
/// The address the tracker will bind to.
/// The format is `ip:port`, for example `0.0.0.0:6969`. If you want to
/// listen to all interfaces, use `0.0.0.0`. If you want the operating
/// system to choose a random port, use port `0`.
#[serde(default = "HttpTracker::default_bind_address")]
pub bind_address: SocketAddr,
/// TSL config.
#[serde(default = "HttpTracker::default_tsl_config")]
pub tsl_config: Option<TslConfig>,
/// Weather the tracker should collect statistics about tracker usage.
#[serde(default = "HttpTracker::default_tracker_usage_statistics")]
pub tracker_usage_statistics: bool,
}
impl Default for HttpTracker {
fn default() -> Self {
Self {
bind_address: Self::default_bind_address(),
tsl_config: Self::default_tsl_config(),
tracker_usage_statistics: Self::default_tracker_usage_statistics(),
}
}
}
impl HttpTracker {
fn default_bind_address() -> SocketAddr {
SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), 7070)
}
fn default_tsl_config() -> Option<TslConfig> {
None
}
fn default_tracker_usage_statistics() -> bool {
false
}
}