aboutsummaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/config.rs b/src/config.rs
index 98a795f..ccdb042 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -20,14 +20,14 @@ pub struct Source {
#[serde(deny_unknown_fields)]
#[derive(serde_derive::Serialize, serde_derive::Deserialize, Clone, PartialEq, Eq, Debug)]
-pub struct PeerConfig {
+pub struct GlobalConfig {
#[serde(default = "default_min_keepalive")]
pub min_keepalive: u32,
#[serde(default = "default_max_keepalive")]
pub max_keepalive: u32,
}
-impl Default for PeerConfig {
+impl Default for GlobalConfig {
#[inline]
fn default() -> Self {
Self {
@@ -37,6 +37,18 @@ impl Default for PeerConfig {
}
}
+impl GlobalConfig {
+ pub fn fix_keepalive(&self, mut k: u32) -> u32 {
+ if self.max_keepalive != 0 && (k == 0 || k > self.max_keepalive) {
+ k = self.max_keepalive;
+ }
+ if k != 0 && k < self.min_keepalive {
+ k = self.min_keepalive;
+ }
+ k
+ }
+}
+
#[serde(deny_unknown_fields)]
#[derive(serde_derive::Serialize, serde_derive::Deserialize, Clone, PartialEq, Eq, Debug)]
pub struct UpdaterConfig {
@@ -63,7 +75,7 @@ pub struct Config {
pub runtime_directory: Option<PathBuf>,
#[serde(flatten)]
- pub peer_config: PeerConfig,
+ pub global: GlobalConfig,
#[serde(flatten)]
pub updater: UpdaterConfig,
@@ -72,18 +84,6 @@ pub struct Config {
pub sources: HashMap<String, Source>,
}
-impl PeerConfig {
- pub fn fix_keepalive(&self, mut k: u32) -> u32 {
- if self.max_keepalive != 0 && (k == 0 || k > self.max_keepalive) {
- k = self.max_keepalive;
- }
- if k != 0 && k < self.min_keepalive {
- k = self.min_keepalive;
- }
- k
- }
-}
-
#[inline]
const fn default_min_keepalive() -> u32 {
10