mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e20cd2088a |
@@ -1 +1 @@
|
|||||||
{"m.homeserver":{"base_url": "https://matrix.continuwuity.org"},"org.matrix.msc3575.proxy":{"url": "https://matrix.continuwuity.org"},"org.matrix.msc4143.rtc_foci":[{"type":"livekit","livekit_service_url":"https://livekit.ellis.link"}]}
|
{"m.homeserver":{"base_url": "https://matrix.continuwuity.org"},"org.matrix.msc3575.proxy":{"url": "https://matrix.continuwuity.org"}}
|
||||||
|
|||||||
@@ -30,11 +30,8 @@ pub(super) async fn show_config(&self) -> Result {
|
|||||||
|
|
||||||
#[admin_command]
|
#[admin_command]
|
||||||
pub(super) async fn reload_config(&self, path: Option<PathBuf>) -> Result {
|
pub(super) async fn reload_config(&self, path: Option<PathBuf>) -> Result {
|
||||||
let mut paths = Vec::new();
|
let path = path.as_deref().into_iter();
|
||||||
if let Some(p) = path {
|
self.services.config.reload(path)?;
|
||||||
paths.push(p);
|
|
||||||
}
|
|
||||||
self.services.config.reload(&paths)?;
|
|
||||||
|
|
||||||
self.write_str("Successfully reconfigured.").await
|
self.write_str("Successfully reconfigured.").await
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-11
@@ -6,7 +6,7 @@ pub mod proxy;
|
|||||||
use std::{
|
use std::{
|
||||||
collections::{BTreeMap, BTreeSet},
|
collections::{BTreeMap, BTreeSet},
|
||||||
net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr},
|
net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr},
|
||||||
path::PathBuf,
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
use conduwuit_macros::config_example_generator;
|
use conduwuit_macros::config_example_generator;
|
||||||
@@ -53,13 +53,9 @@ use crate::{Result, err, error::Error, utils::sys};
|
|||||||
### For more information, see:
|
### For more information, see:
|
||||||
### https://continuwuity.org/configuration.html
|
### https://continuwuity.org/configuration.html
|
||||||
"#,
|
"#,
|
||||||
ignore = "config_paths catchall well_known tls blurhashing allow_invalid_tls_certificates_yes_i_know_what_the_fuck_i_am_doing_with_this_and_i_know_this_is_insecure"
|
ignore = "catchall well_known tls blurhashing allow_invalid_tls_certificates_yes_i_know_what_the_fuck_i_am_doing_with_this_and_i_know_this_is_insecure"
|
||||||
)]
|
)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
// Paths to config file(s). Not supposed to be set manually in the config file,
|
|
||||||
// only updated dynamically from the --config option given at runtime.
|
|
||||||
pub config_paths: Option<Vec<PathBuf>>,
|
|
||||||
|
|
||||||
/// The server_name is the pretty name of this server. It is used as a
|
/// The server_name is the pretty name of this server. It is used as a
|
||||||
/// suffix for user and room IDs/aliases.
|
/// suffix for user and room IDs/aliases.
|
||||||
///
|
///
|
||||||
@@ -2227,24 +2223,26 @@ const DEPRECATED_KEYS: &[&str; 9] = &[
|
|||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
/// Pre-initialize config
|
/// Pre-initialize config
|
||||||
pub fn load(paths: &[PathBuf]) -> Result<Figment> {
|
pub fn load<'a, I>(paths: I) -> Result<Figment>
|
||||||
|
where
|
||||||
|
I: Iterator<Item = &'a Path>,
|
||||||
|
{
|
||||||
let envs = [
|
let envs = [
|
||||||
Env::var("CONDUIT_CONFIG"),
|
Env::var("CONDUIT_CONFIG"),
|
||||||
Env::var("CONDUWUIT_CONFIG"),
|
Env::var("CONDUWUIT_CONFIG"),
|
||||||
Env::var("CONTINUWUITY_CONFIG"),
|
Env::var("CONTINUWUITY_CONFIG"),
|
||||||
];
|
];
|
||||||
let mut config = envs
|
|
||||||
|
let config = envs
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.flatten()
|
.flatten()
|
||||||
.map(Toml::file)
|
.map(Toml::file)
|
||||||
.chain(paths.iter().cloned().map(Toml::file))
|
.chain(paths.map(Toml::file))
|
||||||
.fold(Figment::new(), |config, file| config.merge(file.nested()))
|
.fold(Figment::new(), |config, file| config.merge(file.nested()))
|
||||||
.merge(Env::prefixed("CONDUIT_").global().split("__"))
|
.merge(Env::prefixed("CONDUIT_").global().split("__"))
|
||||||
.merge(Env::prefixed("CONDUWUIT_").global().split("__"))
|
.merge(Env::prefixed("CONDUWUIT_").global().split("__"))
|
||||||
.merge(Env::prefixed("CONTINUWUITY_").global().split("__"));
|
.merge(Env::prefixed("CONTINUWUITY_").global().split("__"));
|
||||||
|
|
||||||
config = config.join(("config_paths", paths));
|
|
||||||
|
|
||||||
Ok(config)
|
Ok(config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-7
@@ -19,13 +19,7 @@ use conduwuit_core::{
|
|||||||
version = conduwuit_core::version(),
|
version = conduwuit_core::version(),
|
||||||
)]
|
)]
|
||||||
pub struct Args {
|
pub struct Args {
|
||||||
#[arg(
|
#[arg(short, long)]
|
||||||
short,
|
|
||||||
long,
|
|
||||||
env = "CONDUIT_CONFIG",
|
|
||||||
env = "CONDUWUIT_CONFIG",
|
|
||||||
env = "CONTINUWUITY_CONFIG"
|
|
||||||
)]
|
|
||||||
/// Path to the config TOML file (optional)
|
/// Path to the config TOML file (optional)
|
||||||
pub config: Option<Vec<PathBuf>>,
|
pub config: Option<Vec<PathBuf>>,
|
||||||
|
|
||||||
|
|||||||
+8
-3
@@ -1,4 +1,4 @@
|
|||||||
use std::sync::Arc;
|
use std::{path::PathBuf, sync::Arc};
|
||||||
|
|
||||||
use conduwuit_core::{
|
use conduwuit_core::{
|
||||||
Error, Result,
|
Error, Result,
|
||||||
@@ -38,9 +38,14 @@ impl Server {
|
|||||||
) -> Result<Arc<Self>, Error> {
|
) -> Result<Arc<Self>, Error> {
|
||||||
let _runtime_guard = runtime.map(runtime::Handle::enter);
|
let _runtime_guard = runtime.map(runtime::Handle::enter);
|
||||||
|
|
||||||
let config_paths = args.config.clone().unwrap_or_default();
|
let config_paths = args
|
||||||
|
.config
|
||||||
|
.as_deref()
|
||||||
|
.into_iter()
|
||||||
|
.flat_map(<[_]>::iter)
|
||||||
|
.map(PathBuf::as_path);
|
||||||
|
|
||||||
let config = Config::load(&config_paths)
|
let config = Config::load(config_paths)
|
||||||
.and_then(|raw| update(raw, args))
|
.and_then(|raw| update(raw, args))
|
||||||
.and_then(|raw| Config::new(&raw))?;
|
.and_then(|raw| Config::new(&raw))?;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use std::{ops::Deref, path::PathBuf, sync::Arc};
|
use std::{iter, ops::Deref, path::Path, sync::Arc};
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
@@ -51,8 +51,7 @@ fn handle_reload(&self) -> Result {
|
|||||||
])
|
])
|
||||||
.expect("failed to notify systemd of reloading state");
|
.expect("failed to notify systemd of reloading state");
|
||||||
|
|
||||||
let config_paths = self.server.config.config_paths.clone().unwrap_or_default();
|
self.reload(iter::empty())?;
|
||||||
self.reload(&config_paths)?;
|
|
||||||
|
|
||||||
#[cfg(all(feature = "systemd", target_os = "linux"))]
|
#[cfg(all(feature = "systemd", target_os = "linux"))]
|
||||||
sd_notify::notify(false, &[sd_notify::NotifyState::Ready])
|
sd_notify::notify(false, &[sd_notify::NotifyState::Ready])
|
||||||
@@ -63,7 +62,10 @@ fn handle_reload(&self) -> Result {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[implement(Service)]
|
#[implement(Service)]
|
||||||
pub fn reload(&self, paths: &[PathBuf]) -> Result<Arc<Config>> {
|
pub fn reload<'a, I>(&self, paths: I) -> Result<Arc<Config>>
|
||||||
|
where
|
||||||
|
I: Iterator<Item = &'a Path>,
|
||||||
|
{
|
||||||
let old = self.server.config.clone();
|
let old = self.server.config.clone();
|
||||||
let new = Config::load(paths).and_then(|raw| Config::new(&raw))?;
|
let new = Config::load(paths).and_then(|raw| Config::new(&raw))?;
|
||||||
|
|
||||||
|
|||||||
@@ -366,7 +366,7 @@ pub async fn mark_as_invited(
|
|||||||
.raw_aput::<8, _, _>(&roomuser_id, self.services.globals.next_count().unwrap());
|
.raw_aput::<8, _, _>(&roomuser_id, self.services.globals.next_count().unwrap());
|
||||||
self.db
|
self.db
|
||||||
.userroomid_invitesender
|
.userroomid_invitesender
|
||||||
.raw_put(&userroom_id, sender_user);
|
.insert(&userroom_id, sender_user);
|
||||||
|
|
||||||
self.db.userroomid_joined.remove(&userroom_id);
|
self.db.userroomid_joined.remove(&userroom_id);
|
||||||
self.db.roomuserid_joined.remove(&roomuser_id);
|
self.db.roomuserid_joined.remove(&roomuser_id);
|
||||||
|
|||||||
Reference in New Issue
Block a user