mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-18 00:01:24 +01:00
remove show-config admin room command
Just `cat` the config file. Also this code would be very annoying to maintain. Getting rid of this also revealed that another config option is specific to RocksDB, so `cfg`s for that have been added.
This commit is contained in:
parent
a6087e97e1
commit
44088852cf
2 changed files with 3 additions and 107 deletions
100
src/config.rs
100
src/config.rs
|
|
@ -1,8 +1,4 @@
|
|||
use std::{
|
||||
fmt,
|
||||
fmt::Write,
|
||||
net::{IpAddr, Ipv4Addr},
|
||||
};
|
||||
use std::net::{IpAddr, Ipv4Addr};
|
||||
|
||||
use ruma::{OwnedServerName, RoomVersionId};
|
||||
use serde::Deserialize;
|
||||
|
|
@ -25,6 +21,7 @@ pub(crate) struct Config {
|
|||
pub(crate) server_name: OwnedServerName,
|
||||
pub(crate) database_backend: String,
|
||||
pub(crate) database_path: String,
|
||||
#[cfg(feature = "rocksdb")]
|
||||
#[serde(default = "default_db_cache_capacity_mb")]
|
||||
pub(crate) db_cache_capacity_mb: f64,
|
||||
#[serde(default = "default_cache_capacity_modifier")]
|
||||
|
|
@ -88,98 +85,6 @@ pub(crate) struct TlsConfig {
|
|||
pub(crate) key: String,
|
||||
}
|
||||
|
||||
impl fmt::Display for Config {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
// Prepare a list of config values to show
|
||||
let lines = [
|
||||
("Server name", self.server_name.host()),
|
||||
("Database backend", &self.database_backend),
|
||||
("Database path", &self.database_path),
|
||||
(
|
||||
"Database cache capacity (MB)",
|
||||
&self.db_cache_capacity_mb.to_string(),
|
||||
),
|
||||
(
|
||||
"Cache capacity modifier",
|
||||
&self.cache_capacity_modifier.to_string(),
|
||||
),
|
||||
#[cfg(feature = "rocksdb")]
|
||||
(
|
||||
"Maximum open files for RocksDB",
|
||||
&self.rocksdb_max_open_files.to_string(),
|
||||
),
|
||||
("PDU cache capacity", &self.pdu_cache_capacity.to_string()),
|
||||
(
|
||||
"Cleanup interval in seconds",
|
||||
&self.cleanup_second_interval.to_string(),
|
||||
),
|
||||
("Maximum request size", &self.max_request_size.to_string()),
|
||||
(
|
||||
"Maximum concurrent requests",
|
||||
&self.max_concurrent_requests.to_string(),
|
||||
),
|
||||
("Allow registration", &self.allow_registration.to_string()),
|
||||
("Allow encryption", &self.allow_encryption.to_string()),
|
||||
("Allow federation", &self.allow_federation.to_string()),
|
||||
("Allow room creation", &self.allow_room_creation.to_string()),
|
||||
(
|
||||
"JWT secret",
|
||||
match self.jwt_secret {
|
||||
Some(_) => "set",
|
||||
None => "not set",
|
||||
},
|
||||
),
|
||||
("Trusted servers", {
|
||||
let mut lst = vec![];
|
||||
for server in &self.trusted_servers {
|
||||
lst.push(server.host());
|
||||
}
|
||||
&lst.join(", ")
|
||||
}),
|
||||
(
|
||||
"TURN username",
|
||||
if self.turn_username.is_empty() {
|
||||
"not set"
|
||||
} else {
|
||||
&self.turn_username
|
||||
},
|
||||
),
|
||||
("TURN password", {
|
||||
if self.turn_password.is_empty() {
|
||||
"not set"
|
||||
} else {
|
||||
"set"
|
||||
}
|
||||
}),
|
||||
("TURN secret", {
|
||||
if self.turn_secret.is_empty() {
|
||||
"not set"
|
||||
} else {
|
||||
"set"
|
||||
}
|
||||
}),
|
||||
("Turn TTL", &self.turn_ttl.to_string()),
|
||||
("Turn URIs", {
|
||||
let mut lst = vec![];
|
||||
for item in self.turn_uris.iter().cloned().enumerate() {
|
||||
let (_, uri): (usize, String) = item;
|
||||
lst.push(uri);
|
||||
}
|
||||
&lst.join(", ")
|
||||
}),
|
||||
];
|
||||
|
||||
let mut msg: String = "Active config values:\n\n".to_owned();
|
||||
|
||||
for line in lines.into_iter().enumerate() {
|
||||
writeln!(msg, "{}: {}", line.1 .0, line.1 .1)
|
||||
.expect("write to in-memory buffer should succeed");
|
||||
}
|
||||
|
||||
write!(f, "{msg}")
|
||||
}
|
||||
}
|
||||
|
||||
fn false_fn() -> bool {
|
||||
false
|
||||
}
|
||||
|
|
@ -196,6 +101,7 @@ fn default_port() -> u16 {
|
|||
6167
|
||||
}
|
||||
|
||||
#[cfg(feature = "rocksdb")]
|
||||
fn default_db_cache_capacity_mb() -> f64 {
|
||||
300.0
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,9 +156,6 @@ enum AdminCommand {
|
|||
amount: u32,
|
||||
},
|
||||
|
||||
/// Show configuration values
|
||||
ShowConfig,
|
||||
|
||||
/// Reset user password
|
||||
ResetPassword {
|
||||
/// Username of the user for whom the password should be reset
|
||||
|
|
@ -659,13 +656,6 @@ impl Service {
|
|||
|
||||
RoomMessageEventContent::text_plain("Done.")
|
||||
}
|
||||
AdminCommand::ShowConfig => {
|
||||
// Construct and send the response
|
||||
RoomMessageEventContent::text_plain(format!(
|
||||
"{}",
|
||||
services().globals.config
|
||||
))
|
||||
}
|
||||
AdminCommand::ResetPassword {
|
||||
username,
|
||||
} => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue