Compare commits
No commits in common. "6415c3dee6198ff7cae4ea283e35a9fe0d7cb6f3" and "d4d22ec674b34ea21942407b9cb55ec59fed8c89" have entirely different histories.
6415c3dee6
...
d4d22ec674
4 changed files with 5 additions and 37 deletions
|
@ -55,13 +55,6 @@ server_settings:
|
||||||
# presence of multiple IPs.
|
# presence of multiple IPs.
|
||||||
# external_ip: ~
|
# external_ip: ~
|
||||||
|
|
||||||
# Settings for geo IP analytics
|
|
||||||
metric_settings:
|
|
||||||
# Whether to enable geo IP analytics
|
|
||||||
# enable_geoip: false
|
|
||||||
# geoip_license_key: none
|
|
||||||
|
|
||||||
|
|
||||||
# These settings are unique to the Rust client, and may be ignored or behave
|
# These settings are unique to the Rust client, and may be ignored or behave
|
||||||
# differently from the official client.
|
# differently from the official client.
|
||||||
extended_options:
|
extended_options:
|
||||||
|
|
|
@ -91,7 +91,6 @@ pub struct Config {
|
||||||
pub unstable_options: Vec<UnstableOptions>,
|
pub unstable_options: Vec<UnstableOptions>,
|
||||||
pub override_upstream: Option<Url>,
|
pub override_upstream: Option<Url>,
|
||||||
pub enable_metrics: bool,
|
pub enable_metrics: bool,
|
||||||
pub geoip_license_key: Option<ClientSecret>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
|
@ -185,13 +184,6 @@ impl Config {
|
||||||
// Unstable options (and related) should never be in yaml config
|
// Unstable options (and related) should never be in yaml config
|
||||||
unstable_options: cli_args.unstable_options,
|
unstable_options: cli_args.unstable_options,
|
||||||
override_upstream: cli_args.override_upstream,
|
override_upstream: cli_args.override_upstream,
|
||||||
geoip_license_key: file_args.metric_settings.and_then(|args| {
|
|
||||||
if args.enable_geoip.unwrap_or_default() {
|
|
||||||
args.geoip_license_key
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,8 +230,7 @@ struct YamlArgs {
|
||||||
// Naming is legacy
|
// Naming is legacy
|
||||||
max_cache_size_in_mebibytes: Mebibytes,
|
max_cache_size_in_mebibytes: Mebibytes,
|
||||||
server_settings: YamlServerSettings,
|
server_settings: YamlServerSettings,
|
||||||
metric_settings: Option<YamlMetricSettings>,
|
// This implementation custom options
|
||||||
// This implementation's custom options
|
|
||||||
extended_options: Option<YamlExtendedOptions>,
|
extended_options: Option<YamlExtendedOptions>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,12 +247,6 @@ struct YamlServerSettings {
|
||||||
external_ip: Option<IpAddr>,
|
external_ip: Option<IpAddr>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
|
||||||
struct YamlMetricSettings {
|
|
||||||
enable_geoip: Option<bool>,
|
|
||||||
geoip_license_key: Option<ClientSecret>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Deserialize, Default)]
|
#[derive(Deserialize, Default)]
|
||||||
struct YamlExtendedOptions {
|
struct YamlExtendedOptions {
|
||||||
memory_quota: Option<Mebibytes>,
|
memory_quota: Option<Mebibytes>,
|
||||||
|
@ -408,7 +393,6 @@ mod config {
|
||||||
hostname: None,
|
hostname: None,
|
||||||
external_ip: None,
|
external_ip: None,
|
||||||
},
|
},
|
||||||
metric_settings: None,
|
|
||||||
extended_options: Some(YamlExtendedOptions {
|
extended_options: Some(YamlExtendedOptions {
|
||||||
memory_quota: Some(Mebibytes::new(50)),
|
memory_quota: Some(Mebibytes::new(50)),
|
||||||
cache_type: Some(CacheType::Lru),
|
cache_type: Some(CacheType::Lru),
|
||||||
|
|
14
src/ping.rs
14
src/ping.rs
|
@ -1,4 +1,3 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
use std::sync::atomic::Ordering;
|
use std::sync::atomic::Ordering;
|
||||||
use std::{io::BufReader, sync::Arc};
|
use std::{io::BufReader, sync::Arc};
|
||||||
|
|
||||||
|
@ -30,24 +29,19 @@ pub struct Request<'a> {
|
||||||
network_speed: BytesPerSecond,
|
network_speed: BytesPerSecond,
|
||||||
build_version: usize,
|
build_version: usize,
|
||||||
tls_created_at: Option<String>,
|
tls_created_at: Option<String>,
|
||||||
ip_address: Option<IpAddr>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl<'a> Request<'a> {
|
||||||
fn from_config_and_state(secret: &'a ClientSecret, config: &Config) -> Self {
|
fn from_config_and_state(secret: &'a ClientSecret, config: &Config) -> Self {
|
||||||
Self {
|
Self {
|
||||||
secret,
|
secret,
|
||||||
port: config
|
port: config.port,
|
||||||
.external_address
|
|
||||||
.and_then(|v| Port::new(v.port()))
|
|
||||||
.unwrap_or(config.port),
|
|
||||||
disk_space: config.disk_quota,
|
disk_space: config.disk_quota,
|
||||||
network_speed: config.network_speed.into(),
|
network_speed: config.network_speed.into(),
|
||||||
build_version: CLIENT_API_VERSION,
|
build_version: CLIENT_API_VERSION,
|
||||||
tls_created_at: TLS_PREVIOUSLY_CREATED
|
tls_created_at: TLS_PREVIOUSLY_CREATED
|
||||||
.get()
|
.get()
|
||||||
.map(|v| v.load().as_ref().clone()),
|
.map(|v| v.load().as_ref().clone()),
|
||||||
ip_address: config.external_address.as_ref().map(SocketAddr::ip),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,15 +50,11 @@ impl<'a> From<(&'a ClientSecret, &Config)> for Request<'a> {
|
||||||
fn from((secret, config): (&'a ClientSecret, &Config)) -> Self {
|
fn from((secret, config): (&'a ClientSecret, &Config)) -> Self {
|
||||||
Self {
|
Self {
|
||||||
secret,
|
secret,
|
||||||
port: config
|
port: config.port,
|
||||||
.external_address
|
|
||||||
.and_then(|v| Port::new(v.port()))
|
|
||||||
.unwrap_or(config.port),
|
|
||||||
disk_space: config.disk_quota,
|
disk_space: config.disk_quota,
|
||||||
network_speed: config.network_speed.into(),
|
network_speed: config.network_speed.into(),
|
||||||
build_version: CLIENT_API_VERSION,
|
build_version: CLIENT_API_VERSION,
|
||||||
tls_created_at: None,
|
tls_created_at: None,
|
||||||
ip_address: config.external_address.as_ref().map(SocketAddr::ip),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ impl Port {
|
||||||
self.0.get()
|
self.0.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
pub fn new(amt: u16) -> Option<Self> {
|
pub fn new(amt: u16) -> Option<Self> {
|
||||||
NonZeroU16::new(amt).map(Self)
|
NonZeroU16::new(amt).map(Self)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue