make everything pub(crate) instead of pub
conduwuit is not a library Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
472c32f453
commit
66bb88a03a
135 changed files with 1366 additions and 1247 deletions
|
@ -12,7 +12,7 @@ use std::{
|
|||
|
||||
use argon2::Argon2;
|
||||
use base64::{engine::general_purpose, Engine as _};
|
||||
pub use data::Data;
|
||||
pub(crate) use data::Data;
|
||||
use hickory_resolver::TokioAsyncResolver;
|
||||
use ipaddress::IPAddress;
|
||||
use regex::RegexSet;
|
||||
|
@ -32,9 +32,9 @@ use url::Url;
|
|||
|
||||
use crate::{services, Config, Result};
|
||||
|
||||
pub mod client;
|
||||
mod client;
|
||||
mod data;
|
||||
pub mod resolver;
|
||||
mod resolver;
|
||||
|
||||
type RateLimitState = (Instant, u32); // Time if last failed try, number of failed tries
|
||||
type SyncHandle = (
|
||||
|
@ -42,32 +42,32 @@ type SyncHandle = (
|
|||
Receiver<Option<Result<sync_events::v3::Response>>>, // rx
|
||||
);
|
||||
|
||||
pub struct Service<'a> {
|
||||
pub db: &'static dyn Data,
|
||||
pub(crate) struct Service<'a> {
|
||||
pub(crate) db: &'static dyn Data,
|
||||
|
||||
pub tracing_reload_handle: tracing_subscriber::reload::Handle<EnvFilter, Registry>,
|
||||
pub config: Config,
|
||||
pub cidr_range_denylist: Vec<IPAddress>,
|
||||
pub(crate) tracing_reload_handle: tracing_subscriber::reload::Handle<EnvFilter, Registry>,
|
||||
pub(crate) config: Config,
|
||||
pub(crate) cidr_range_denylist: Vec<IPAddress>,
|
||||
keypair: Arc<ruma::signatures::Ed25519KeyPair>,
|
||||
jwt_decoding_key: Option<jsonwebtoken::DecodingKey>,
|
||||
pub resolver: Arc<resolver::Resolver>,
|
||||
pub client: client::Client,
|
||||
pub stable_room_versions: Vec<RoomVersionId>,
|
||||
pub unstable_room_versions: Vec<RoomVersionId>,
|
||||
pub bad_event_ratelimiter: Arc<RwLock<HashMap<OwnedEventId, RateLimitState>>>,
|
||||
pub bad_signature_ratelimiter: Arc<RwLock<HashMap<Vec<String>, RateLimitState>>>,
|
||||
pub bad_query_ratelimiter: Arc<RwLock<HashMap<OwnedServerName, RateLimitState>>>,
|
||||
pub servername_ratelimiter: Arc<RwLock<HashMap<OwnedServerName, Arc<Semaphore>>>>,
|
||||
pub sync_receivers: RwLock<HashMap<(OwnedUserId, OwnedDeviceId), SyncHandle>>,
|
||||
pub roomid_mutex_insert: RwLock<HashMap<OwnedRoomId, Arc<Mutex<()>>>>,
|
||||
pub roomid_mutex_state: RwLock<HashMap<OwnedRoomId, Arc<Mutex<()>>>>,
|
||||
pub roomid_mutex_federation: RwLock<HashMap<OwnedRoomId, Arc<Mutex<()>>>>, // this lock will be held longer
|
||||
pub roomid_federationhandletime: RwLock<HashMap<OwnedRoomId, (OwnedEventId, Instant)>>,
|
||||
pub stateres_mutex: Arc<Mutex<()>>,
|
||||
pub(crate) resolver: Arc<resolver::Resolver>,
|
||||
pub(crate) client: client::Client,
|
||||
pub(crate) stable_room_versions: Vec<RoomVersionId>,
|
||||
pub(crate) unstable_room_versions: Vec<RoomVersionId>,
|
||||
pub(crate) bad_event_ratelimiter: Arc<RwLock<HashMap<OwnedEventId, RateLimitState>>>,
|
||||
pub(crate) bad_signature_ratelimiter: Arc<RwLock<HashMap<Vec<String>, RateLimitState>>>,
|
||||
pub(crate) bad_query_ratelimiter: Arc<RwLock<HashMap<OwnedServerName, RateLimitState>>>,
|
||||
pub(crate) servername_ratelimiter: Arc<RwLock<HashMap<OwnedServerName, Arc<Semaphore>>>>,
|
||||
pub(crate) sync_receivers: RwLock<HashMap<(OwnedUserId, OwnedDeviceId), SyncHandle>>,
|
||||
pub(crate) roomid_mutex_insert: RwLock<HashMap<OwnedRoomId, Arc<Mutex<()>>>>,
|
||||
pub(crate) roomid_mutex_state: RwLock<HashMap<OwnedRoomId, Arc<Mutex<()>>>>,
|
||||
pub(crate) roomid_mutex_federation: RwLock<HashMap<OwnedRoomId, Arc<Mutex<()>>>>, // this lock will be held longer
|
||||
pub(crate) roomid_federationhandletime: RwLock<HashMap<OwnedRoomId, (OwnedEventId, Instant)>>,
|
||||
pub(crate) stateres_mutex: Arc<Mutex<()>>,
|
||||
pub(crate) rotate: RotationHandler,
|
||||
|
||||
pub shutdown: AtomicBool,
|
||||
pub argon: Argon2<'a>,
|
||||
pub(crate) shutdown: AtomicBool,
|
||||
pub(crate) argon: Argon2<'a>,
|
||||
}
|
||||
|
||||
/// Handles "rotation" of long-polling requests. "Rotation" in this context is
|
||||
|
@ -78,12 +78,12 @@ pub struct Service<'a> {
|
|||
pub(crate) struct RotationHandler(broadcast::Sender<()>, ());
|
||||
|
||||
impl RotationHandler {
|
||||
pub fn new() -> Self {
|
||||
fn new() -> Self {
|
||||
let (s, _r) = broadcast::channel(1);
|
||||
Self(s, ())
|
||||
}
|
||||
|
||||
pub fn watch(&self) -> impl Future<Output = ()> {
|
||||
pub(crate) fn watch(&self) -> impl Future<Output = ()> {
|
||||
let mut r = self.0.subscribe();
|
||||
|
||||
async move {
|
||||
|
@ -91,7 +91,7 @@ impl RotationHandler {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn fire(&self) { _ = self.0.send(()); }
|
||||
fn fire(&self) { _ = self.0.send(()); }
|
||||
}
|
||||
|
||||
impl Default for RotationHandler {
|
||||
|
@ -99,7 +99,7 @@ impl Default for RotationHandler {
|
|||
}
|
||||
|
||||
impl Service<'_> {
|
||||
pub fn load(
|
||||
pub(crate) fn load(
|
||||
db: &'static dyn Data, config: &Config,
|
||||
tracing_reload_handle: tracing_subscriber::reload::Handle<EnvFilter, Registry>,
|
||||
) -> Result<Self> {
|
||||
|
@ -187,171 +187,179 @@ impl Service<'_> {
|
|||
}
|
||||
|
||||
/// Returns this server's keypair.
|
||||
pub fn keypair(&self) -> &ruma::signatures::Ed25519KeyPair { &self.keypair }
|
||||
pub(crate) fn keypair(&self) -> &ruma::signatures::Ed25519KeyPair { &self.keypair }
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn next_count(&self) -> Result<u64> { self.db.next_count() }
|
||||
pub(crate) fn next_count(&self) -> Result<u64> { self.db.next_count() }
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn current_count(&self) -> Result<u64> { self.db.current_count() }
|
||||
pub(crate) fn current_count(&self) -> Result<u64> { self.db.current_count() }
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn last_check_for_updates_id(&self) -> Result<u64> { self.db.last_check_for_updates_id() }
|
||||
pub(crate) fn last_check_for_updates_id(&self) -> Result<u64> { self.db.last_check_for_updates_id() }
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn update_check_for_updates_id(&self, id: u64) -> Result<()> { self.db.update_check_for_updates_id(id) }
|
||||
pub(crate) fn update_check_for_updates_id(&self, id: u64) -> Result<()> { self.db.update_check_for_updates_id(id) }
|
||||
|
||||
pub async fn watch(&self, user_id: &UserId, device_id: &DeviceId) -> Result<()> {
|
||||
pub(crate) async fn watch(&self, user_id: &UserId, device_id: &DeviceId) -> Result<()> {
|
||||
self.db.watch(user_id, device_id).await
|
||||
}
|
||||
|
||||
pub fn cleanup(&self) -> Result<()> { self.db.cleanup() }
|
||||
pub(crate) fn cleanup(&self) -> Result<()> { self.db.cleanup() }
|
||||
|
||||
pub fn flush(&self) -> Result<()> { self.db.flush() }
|
||||
pub(crate) fn flush(&self) -> Result<()> { self.db.flush() }
|
||||
|
||||
pub fn server_name(&self) -> &ServerName { self.config.server_name.as_ref() }
|
||||
pub(crate) fn server_name(&self) -> &ServerName { self.config.server_name.as_ref() }
|
||||
|
||||
pub fn max_request_size(&self) -> u32 { self.config.max_request_size }
|
||||
pub(crate) fn max_request_size(&self) -> u32 { self.config.max_request_size }
|
||||
|
||||
pub fn max_fetch_prev_events(&self) -> u16 { self.config.max_fetch_prev_events }
|
||||
pub(crate) fn max_fetch_prev_events(&self) -> u16 { self.config.max_fetch_prev_events }
|
||||
|
||||
pub fn allow_registration(&self) -> bool { self.config.allow_registration }
|
||||
pub(crate) fn allow_registration(&self) -> bool { self.config.allow_registration }
|
||||
|
||||
pub fn allow_guest_registration(&self) -> bool { self.config.allow_guest_registration }
|
||||
pub(crate) fn allow_guest_registration(&self) -> bool { self.config.allow_guest_registration }
|
||||
|
||||
pub fn allow_guests_auto_join_rooms(&self) -> bool { self.config.allow_guests_auto_join_rooms }
|
||||
pub(crate) fn allow_guests_auto_join_rooms(&self) -> bool { self.config.allow_guests_auto_join_rooms }
|
||||
|
||||
pub fn log_guest_registrations(&self) -> bool { self.config.log_guest_registrations }
|
||||
pub(crate) fn log_guest_registrations(&self) -> bool { self.config.log_guest_registrations }
|
||||
|
||||
pub fn allow_encryption(&self) -> bool { self.config.allow_encryption }
|
||||
pub(crate) fn allow_encryption(&self) -> bool { self.config.allow_encryption }
|
||||
|
||||
pub fn allow_federation(&self) -> bool { self.config.allow_federation }
|
||||
pub(crate) fn allow_federation(&self) -> bool { self.config.allow_federation }
|
||||
|
||||
pub fn allow_public_room_directory_over_federation(&self) -> bool {
|
||||
pub(crate) fn allow_public_room_directory_over_federation(&self) -> bool {
|
||||
self.config.allow_public_room_directory_over_federation
|
||||
}
|
||||
|
||||
pub fn allow_public_room_directory_without_auth(&self) -> bool {
|
||||
pub(crate) fn allow_public_room_directory_without_auth(&self) -> bool {
|
||||
self.config.allow_public_room_directory_without_auth
|
||||
}
|
||||
|
||||
pub fn allow_device_name_federation(&self) -> bool { self.config.allow_device_name_federation }
|
||||
pub(crate) fn allow_device_name_federation(&self) -> bool { self.config.allow_device_name_federation }
|
||||
|
||||
pub fn allow_room_creation(&self) -> bool { self.config.allow_room_creation }
|
||||
pub(crate) fn allow_room_creation(&self) -> bool { self.config.allow_room_creation }
|
||||
|
||||
pub fn allow_unstable_room_versions(&self) -> bool { self.config.allow_unstable_room_versions }
|
||||
pub(crate) fn allow_unstable_room_versions(&self) -> bool { self.config.allow_unstable_room_versions }
|
||||
|
||||
pub fn default_room_version(&self) -> RoomVersionId { self.config.default_room_version.clone() }
|
||||
pub(crate) fn default_room_version(&self) -> RoomVersionId { self.config.default_room_version.clone() }
|
||||
|
||||
pub fn new_user_displayname_suffix(&self) -> &String { &self.config.new_user_displayname_suffix }
|
||||
pub(crate) fn new_user_displayname_suffix(&self) -> &String { &self.config.new_user_displayname_suffix }
|
||||
|
||||
pub fn allow_check_for_updates(&self) -> bool { self.config.allow_check_for_updates }
|
||||
pub(crate) fn allow_check_for_updates(&self) -> bool { self.config.allow_check_for_updates }
|
||||
|
||||
pub fn trusted_servers(&self) -> &[OwnedServerName] { &self.config.trusted_servers }
|
||||
pub(crate) fn trusted_servers(&self) -> &[OwnedServerName] { &self.config.trusted_servers }
|
||||
|
||||
pub fn query_trusted_key_servers_first(&self) -> bool { self.config.query_trusted_key_servers_first }
|
||||
pub(crate) fn query_trusted_key_servers_first(&self) -> bool { self.config.query_trusted_key_servers_first }
|
||||
|
||||
pub fn dns_resolver(&self) -> &TokioAsyncResolver { &self.resolver.resolver }
|
||||
pub(crate) fn dns_resolver(&self) -> &TokioAsyncResolver { &self.resolver.resolver }
|
||||
|
||||
pub fn query_all_nameservers(&self) -> bool { self.config.query_all_nameservers }
|
||||
pub(crate) fn query_all_nameservers(&self) -> bool { self.config.query_all_nameservers }
|
||||
|
||||
pub fn actual_destinations(&self) -> &Arc<RwLock<resolver::WellKnownMap>> { &self.resolver.destinations }
|
||||
pub(crate) fn actual_destinations(&self) -> &Arc<RwLock<resolver::WellKnownMap>> { &self.resolver.destinations }
|
||||
|
||||
pub fn jwt_decoding_key(&self) -> Option<&jsonwebtoken::DecodingKey> { self.jwt_decoding_key.as_ref() }
|
||||
pub(crate) fn jwt_decoding_key(&self) -> Option<&jsonwebtoken::DecodingKey> { self.jwt_decoding_key.as_ref() }
|
||||
|
||||
pub fn turn_password(&self) -> &String { &self.config.turn_password }
|
||||
pub(crate) fn turn_password(&self) -> &String { &self.config.turn_password }
|
||||
|
||||
pub fn turn_ttl(&self) -> u64 { self.config.turn_ttl }
|
||||
pub(crate) fn turn_ttl(&self) -> u64 { self.config.turn_ttl }
|
||||
|
||||
pub fn turn_uris(&self) -> &[String] { &self.config.turn_uris }
|
||||
pub(crate) fn turn_uris(&self) -> &[String] { &self.config.turn_uris }
|
||||
|
||||
pub fn turn_username(&self) -> &String { &self.config.turn_username }
|
||||
pub(crate) fn turn_username(&self) -> &String { &self.config.turn_username }
|
||||
|
||||
pub fn turn_secret(&self) -> &String { &self.config.turn_secret }
|
||||
pub(crate) fn turn_secret(&self) -> &String { &self.config.turn_secret }
|
||||
|
||||
pub fn auto_join_rooms(&self) -> &[OwnedRoomId] { &self.config.auto_join_rooms }
|
||||
pub(crate) fn auto_join_rooms(&self) -> &[OwnedRoomId] { &self.config.auto_join_rooms }
|
||||
|
||||
pub fn allow_profile_lookup_federation_requests(&self) -> bool {
|
||||
pub(crate) fn allow_profile_lookup_federation_requests(&self) -> bool {
|
||||
self.config.allow_profile_lookup_federation_requests
|
||||
}
|
||||
|
||||
pub fn notification_push_path(&self) -> &String { &self.config.notification_push_path }
|
||||
pub(crate) fn notification_push_path(&self) -> &String { &self.config.notification_push_path }
|
||||
|
||||
pub fn emergency_password(&self) -> &Option<String> { &self.config.emergency_password }
|
||||
pub(crate) fn emergency_password(&self) -> &Option<String> { &self.config.emergency_password }
|
||||
|
||||
pub fn url_preview_domain_contains_allowlist(&self) -> &Vec<String> {
|
||||
pub(crate) fn url_preview_domain_contains_allowlist(&self) -> &Vec<String> {
|
||||
&self.config.url_preview_domain_contains_allowlist
|
||||
}
|
||||
|
||||
pub fn url_preview_domain_explicit_allowlist(&self) -> &Vec<String> {
|
||||
pub(crate) fn url_preview_domain_explicit_allowlist(&self) -> &Vec<String> {
|
||||
&self.config.url_preview_domain_explicit_allowlist
|
||||
}
|
||||
|
||||
pub fn url_preview_domain_explicit_denylist(&self) -> &Vec<String> {
|
||||
pub(crate) fn url_preview_domain_explicit_denylist(&self) -> &Vec<String> {
|
||||
&self.config.url_preview_domain_explicit_denylist
|
||||
}
|
||||
|
||||
pub fn url_preview_url_contains_allowlist(&self) -> &Vec<String> { &self.config.url_preview_url_contains_allowlist }
|
||||
pub(crate) fn url_preview_url_contains_allowlist(&self) -> &Vec<String> {
|
||||
&self.config.url_preview_url_contains_allowlist
|
||||
}
|
||||
|
||||
pub fn url_preview_max_spider_size(&self) -> usize { self.config.url_preview_max_spider_size }
|
||||
pub(crate) fn url_preview_max_spider_size(&self) -> usize { self.config.url_preview_max_spider_size }
|
||||
|
||||
pub fn url_preview_check_root_domain(&self) -> bool { self.config.url_preview_check_root_domain }
|
||||
pub(crate) fn url_preview_check_root_domain(&self) -> bool { self.config.url_preview_check_root_domain }
|
||||
|
||||
pub fn forbidden_alias_names(&self) -> &RegexSet { &self.config.forbidden_alias_names }
|
||||
pub(crate) fn forbidden_alias_names(&self) -> &RegexSet { &self.config.forbidden_alias_names }
|
||||
|
||||
pub fn forbidden_usernames(&self) -> &RegexSet { &self.config.forbidden_usernames }
|
||||
pub(crate) fn forbidden_usernames(&self) -> &RegexSet { &self.config.forbidden_usernames }
|
||||
|
||||
pub fn allow_local_presence(&self) -> bool { self.config.allow_local_presence }
|
||||
pub(crate) fn allow_local_presence(&self) -> bool { self.config.allow_local_presence }
|
||||
|
||||
pub fn allow_incoming_presence(&self) -> bool { self.config.allow_incoming_presence }
|
||||
pub(crate) fn allow_incoming_presence(&self) -> bool { self.config.allow_incoming_presence }
|
||||
|
||||
pub fn allow_outgoing_presence(&self) -> bool { self.config.allow_outgoing_presence }
|
||||
pub(crate) fn allow_outgoing_presence(&self) -> bool { self.config.allow_outgoing_presence }
|
||||
|
||||
pub fn presence_idle_timeout_s(&self) -> u64 { self.config.presence_idle_timeout_s }
|
||||
pub(crate) fn presence_idle_timeout_s(&self) -> u64 { self.config.presence_idle_timeout_s }
|
||||
|
||||
pub fn presence_offline_timeout_s(&self) -> u64 { self.config.presence_offline_timeout_s }
|
||||
pub(crate) fn presence_offline_timeout_s(&self) -> u64 { self.config.presence_offline_timeout_s }
|
||||
|
||||
pub fn allow_incoming_read_receipts(&self) -> bool { self.config.allow_incoming_read_receipts }
|
||||
pub(crate) fn allow_incoming_read_receipts(&self) -> bool { self.config.allow_incoming_read_receipts }
|
||||
|
||||
pub fn allow_outgoing_read_receipts(&self) -> bool { self.config.allow_outgoing_read_receipts }
|
||||
pub(crate) fn allow_outgoing_read_receipts(&self) -> bool { self.config.allow_outgoing_read_receipts }
|
||||
|
||||
pub fn rocksdb_log_level(&self) -> &String { &self.config.rocksdb_log_level }
|
||||
pub(crate) fn rocksdb_log_level(&self) -> &String { &self.config.rocksdb_log_level }
|
||||
|
||||
pub fn rocksdb_max_log_file_size(&self) -> usize { self.config.rocksdb_max_log_file_size }
|
||||
pub(crate) fn rocksdb_max_log_file_size(&self) -> usize { self.config.rocksdb_max_log_file_size }
|
||||
|
||||
pub fn rocksdb_log_time_to_roll(&self) -> usize { self.config.rocksdb_log_time_to_roll }
|
||||
pub(crate) fn rocksdb_log_time_to_roll(&self) -> usize { self.config.rocksdb_log_time_to_roll }
|
||||
|
||||
pub fn rocksdb_optimize_for_spinning_disks(&self) -> bool { self.config.rocksdb_optimize_for_spinning_disks }
|
||||
pub(crate) fn rocksdb_optimize_for_spinning_disks(&self) -> bool { self.config.rocksdb_optimize_for_spinning_disks }
|
||||
|
||||
pub fn rocksdb_parallelism_threads(&self) -> usize { self.config.rocksdb_parallelism_threads }
|
||||
pub(crate) fn rocksdb_parallelism_threads(&self) -> usize { self.config.rocksdb_parallelism_threads }
|
||||
|
||||
pub fn rocksdb_compression_algo(&self) -> &String { &self.config.rocksdb_compression_algo }
|
||||
pub(crate) fn rocksdb_compression_algo(&self) -> &String { &self.config.rocksdb_compression_algo }
|
||||
|
||||
pub fn rocksdb_compression_level(&self) -> i32 { self.config.rocksdb_compression_level }
|
||||
pub(crate) fn rocksdb_compression_level(&self) -> i32 { self.config.rocksdb_compression_level }
|
||||
|
||||
pub fn rocksdb_bottommost_compression_level(&self) -> i32 { self.config.rocksdb_bottommost_compression_level }
|
||||
pub(crate) fn rocksdb_bottommost_compression_level(&self) -> i32 {
|
||||
self.config.rocksdb_bottommost_compression_level
|
||||
}
|
||||
|
||||
pub fn prevent_media_downloads_from(&self) -> &[OwnedServerName] { &self.config.prevent_media_downloads_from }
|
||||
pub(crate) fn prevent_media_downloads_from(&self) -> &[OwnedServerName] {
|
||||
&self.config.prevent_media_downloads_from
|
||||
}
|
||||
|
||||
pub fn forbidden_remote_server_names(&self) -> &[OwnedServerName] { &self.config.forbidden_remote_server_names }
|
||||
pub(crate) fn forbidden_remote_server_names(&self) -> &[OwnedServerName] {
|
||||
&self.config.forbidden_remote_server_names
|
||||
}
|
||||
|
||||
pub fn forbidden_remote_room_directory_server_names(&self) -> &[OwnedServerName] {
|
||||
pub(crate) fn forbidden_remote_room_directory_server_names(&self) -> &[OwnedServerName] {
|
||||
&self.config.forbidden_remote_room_directory_server_names
|
||||
}
|
||||
|
||||
pub fn ip_range_denylist(&self) -> &[String] { &self.config.ip_range_denylist }
|
||||
pub(crate) fn ip_range_denylist(&self) -> &[String] { &self.config.ip_range_denylist }
|
||||
|
||||
pub fn well_known_support_page(&self) -> &Option<Url> { &self.config.well_known.support_page }
|
||||
pub(crate) fn well_known_support_page(&self) -> &Option<Url> { &self.config.well_known.support_page }
|
||||
|
||||
pub fn well_known_support_role(&self) -> &Option<ContactRole> { &self.config.well_known.support_role }
|
||||
pub(crate) fn well_known_support_role(&self) -> &Option<ContactRole> { &self.config.well_known.support_role }
|
||||
|
||||
pub fn well_known_support_email(&self) -> &Option<String> { &self.config.well_known.support_email }
|
||||
pub(crate) fn well_known_support_email(&self) -> &Option<String> { &self.config.well_known.support_email }
|
||||
|
||||
pub fn well_known_support_mxid(&self) -> &Option<OwnedUserId> { &self.config.well_known.support_mxid }
|
||||
pub(crate) fn well_known_support_mxid(&self) -> &Option<OwnedUserId> { &self.config.well_known.support_mxid }
|
||||
|
||||
pub fn block_non_admin_invites(&self) -> bool { self.config.block_non_admin_invites }
|
||||
pub(crate) fn block_non_admin_invites(&self) -> bool { self.config.block_non_admin_invites }
|
||||
|
||||
pub fn supported_room_versions(&self) -> Vec<RoomVersionId> {
|
||||
pub(crate) fn supported_room_versions(&self) -> Vec<RoomVersionId> {
|
||||
let mut room_versions: Vec<RoomVersionId> = vec![];
|
||||
room_versions.extend(self.stable_room_versions.clone());
|
||||
if self.allow_unstable_room_versions() {
|
||||
|
@ -367,7 +375,7 @@ impl Service<'_> {
|
|||
///
|
||||
/// This doesn't actually check that the keys provided are newer than the
|
||||
/// old set.
|
||||
pub fn add_signing_key(
|
||||
pub(crate) fn add_signing_key(
|
||||
&self, origin: &ServerName, new_keys: ServerSigningKeys,
|
||||
) -> Result<BTreeMap<OwnedServerSigningKeyId, VerifyKey>> {
|
||||
self.db.add_signing_key(origin, new_keys)
|
||||
|
@ -375,7 +383,7 @@ impl Service<'_> {
|
|||
|
||||
/// This returns an empty `Ok(BTreeMap<..>)` when there are no keys found
|
||||
/// for the server.
|
||||
pub fn signing_keys_for(&self, origin: &ServerName) -> Result<BTreeMap<OwnedServerSigningKeyId, VerifyKey>> {
|
||||
pub(crate) fn signing_keys_for(&self, origin: &ServerName) -> Result<BTreeMap<OwnedServerSigningKeyId, VerifyKey>> {
|
||||
let mut keys = self.db.signing_keys_for(origin)?;
|
||||
if origin == self.server_name() {
|
||||
keys.insert(
|
||||
|
@ -391,11 +399,13 @@ impl Service<'_> {
|
|||
Ok(keys)
|
||||
}
|
||||
|
||||
pub fn database_version(&self) -> Result<u64> { self.db.database_version() }
|
||||
pub(crate) fn database_version(&self) -> Result<u64> { self.db.database_version() }
|
||||
|
||||
pub fn bump_database_version(&self, new_version: u64) -> Result<()> { self.db.bump_database_version(new_version) }
|
||||
pub(crate) fn bump_database_version(&self, new_version: u64) -> Result<()> {
|
||||
self.db.bump_database_version(new_version)
|
||||
}
|
||||
|
||||
pub fn get_media_folder(&self) -> PathBuf {
|
||||
pub(crate) fn get_media_folder(&self) -> PathBuf {
|
||||
let mut r = PathBuf::new();
|
||||
r.push(self.config.database_path.clone());
|
||||
r.push("media");
|
||||
|
@ -406,7 +416,7 @@ impl Service<'_> {
|
|||
/// flag enabled and database migrated uses SHA256 hash of the base64 key as
|
||||
/// the file name
|
||||
#[cfg(feature = "sha256_media")]
|
||||
pub fn get_media_file_new(&self, key: &[u8]) -> PathBuf {
|
||||
pub(crate) fn get_media_file_new(&self, key: &[u8]) -> PathBuf {
|
||||
let mut r = PathBuf::new();
|
||||
r.push(self.config.database_path.clone());
|
||||
r.push("media");
|
||||
|
@ -420,7 +430,7 @@ impl Service<'_> {
|
|||
/// old base64 file name media function
|
||||
/// This is the old version of `get_media_file` that uses the full base64
|
||||
/// key as the filename.
|
||||
pub fn get_media_file(&self, key: &[u8]) -> PathBuf {
|
||||
pub(crate) fn get_media_file(&self, key: &[u8]) -> PathBuf {
|
||||
let mut r = PathBuf::new();
|
||||
r.push(self.config.database_path.clone());
|
||||
r.push("media");
|
||||
|
@ -428,13 +438,13 @@ impl Service<'_> {
|
|||
r
|
||||
}
|
||||
|
||||
pub fn well_known_client(&self) -> &Option<Url> { &self.config.well_known.client }
|
||||
pub(crate) fn well_known_client(&self) -> &Option<Url> { &self.config.well_known.client }
|
||||
|
||||
pub fn well_known_server(&self) -> &Option<OwnedServerName> { &self.config.well_known.server }
|
||||
pub(crate) fn well_known_server(&self) -> &Option<OwnedServerName> { &self.config.well_known.server }
|
||||
|
||||
pub fn unix_socket_path(&self) -> &Option<PathBuf> { &self.config.unix_socket_path }
|
||||
pub(crate) fn unix_socket_path(&self) -> &Option<PathBuf> { &self.config.unix_socket_path }
|
||||
|
||||
pub fn valid_cidr_range(&self, ip: &IPAddress) -> bool {
|
||||
pub(crate) fn valid_cidr_range(&self, ip: &IPAddress) -> bool {
|
||||
for cidr in &self.cidr_range_denylist {
|
||||
if cidr.includes(ip) {
|
||||
return false;
|
||||
|
@ -444,7 +454,7 @@ impl Service<'_> {
|
|||
true
|
||||
}
|
||||
|
||||
pub fn shutdown(&self) {
|
||||
pub(crate) fn shutdown(&self) {
|
||||
self.shutdown.store(true, atomic::Ordering::Relaxed);
|
||||
// On shutdown
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue