2024-10-04 19:10:20 +00:00
pub mod check ;
pub mod proxy ;
2022-01-20 11:51:31 +01:00
use std ::{
2024-10-22 06:21:57 +00:00
collections ::{ BTreeMap , BTreeSet , HashSet } ,
2024-07-11 02:22:37 +00:00
fmt ,
2024-06-02 22:36:00 +00:00
net ::{ IpAddr , Ipv4Addr , Ipv6Addr , SocketAddr } ,
2023-07-29 21:57:41 +00:00
path ::PathBuf ,
2022-01-20 11:51:31 +01:00
} ;
2022-02-03 13:30:04 +01:00
2024-09-08 22:17:02 +00:00
use conduit_macros ::config_example_generator ;
2024-04-03 20:33:47 -07:00
use either ::{
Either ,
Either ::{ Left , Right } ,
} ;
2024-07-25 02:59:54 +00:00
use figment ::providers ::{ Env , Format , Toml } ;
pub use figment ::{ value ::Value as FigmentValue , Figment } ;
2024-02-08 19:11:48 -05:00
use itertools ::Itertools ;
use regex ::RegexSet ;
2024-04-06 18:42:00 -04:00
use ruma ::{
2024-11-02 20:55:40 -04:00
api ::client ::discovery ::discover_support ::ContactRole , OwnedRoomOrAliasId , OwnedServerName , OwnedUserId ,
RoomVersionId ,
2024-04-06 18:42:00 -04:00
} ;
2024-03-22 23:42:22 -04:00
use serde ::{ de ::IgnoredAny , Deserialize } ;
2024-04-11 20:17:30 -04:00
use url ::Url ;
2022-02-03 13:30:04 +01:00
2024-05-09 15:59:08 -07:00
pub use self ::check ::check ;
use self ::proxy ::ProxyConfig ;
2024-10-04 19:10:20 +00:00
use crate ::{ err , error ::Error , utils ::sys , Result } ;
2024-03-04 20:42:09 -05:00
2024-01-16 20:44:20 -05:00
/// all the config options for conduwuit
2024-03-22 22:44:31 -04:00
#[ allow(clippy::struct_excessive_bools) ]
2024-10-05 19:39:27 +00:00
#[ allow(rustdoc::broken_intra_doc_links, rustdoc::bare_urls) ]
2024-10-22 22:16:59 +00:00
#[ derive(Clone, Debug, Deserialize) ]
#[ config_example_generator(
filename = " conduwuit-example.toml " ,
section = " global " ,
undocumented = " # This item is undocumented. Please contribute documentation for it. " ,
2024-11-10 20:16:38 -05:00
header = " ### conduwuit Configuration \n ### \n ### THIS FILE IS GENERATED. CHANGES/CONTRIBUTIONS IN THE REPO WILL \n ### BE \
OVERWRITTEN ! \ n ###\ n ### You should rename this file before configuring your server . Changes \ n ### to \
documentation and defaults can be contributed in source code at \ n ### src / core / config / mod . rs . This file \
is generated when building . \ n ###\ n ### Any values pre - populated are the default values for said config \
option . \ n ###\ n ### At the minimum , you MUST edit all the config options to your environment \ n ### that say \
\ " YOU NEED TO EDIT THIS \" . \n ### See https://conduwuit.puppyirl.gay/configuration.html for ways to \n ### configure conduwuit \n " ,
2024-10-22 22:16:59 +00:00
ignore = " catchall well_known tls "
) ]
2024-05-09 15:59:08 -07:00
pub struct Config {
2024-10-05 19:39:27 +00:00
/// The server_name is the pretty name of this server. It is used as a
2024-11-10 20:16:38 -05:00
/// suffix for user and room IDs/aliases.
2024-10-05 19:39:27 +00:00
///
2024-11-10 20:16:38 -05:00
/// See the docs for reverse proxying and delegation: https://conduwuit.puppyirl.gay/deploying/generic.html#setting-up-the-reverse-proxy
/// Also see the `[global.well_known]` config section at the very bottom.
2024-10-05 19:39:27 +00:00
///
2024-11-10 20:16:38 -05:00
/// Examples of delegation:
/// - https://puppygock.gay/.well-known/matrix/server
/// - https://puppygock.gay/.well-known/matrix/client
2024-10-05 19:39:27 +00:00
///
2024-11-10 20:16:38 -05:00
/// YOU NEED TO EDIT THIS. THIS CANNOT BE CHANGED AFTER WITHOUT A DATABASE
/// WIPE.
///
/// example: "conduwuit.woof"
2024-10-05 19:39:27 +00:00
pub server_name : OwnedServerName ,
2024-11-10 20:16:38 -05:00
/// default address (IPv4 or IPv6) conduwuit will listen on.
///
/// If you are using Docker or a container NAT networking setup, this must
/// be "0.0.0.0".
///
/// To listen on multiple addresses, specify a vector e.g. ["127.0.0.1",
/// "::1"]
2024-10-05 19:39:27 +00:00
///
2024-10-22 10:09:14 +00:00
/// default: ["127.0.0.1", "::1"]
2022-01-20 11:51:31 +01:00
#[ serde(default = " default_address " ) ]
2024-06-02 22:36:00 +00:00
address : ListeningAddr ,
2024-10-05 19:39:27 +00:00
2024-11-10 20:16:38 -05:00
/// The port(s) conduwuit will be running on.
///
/// See https://conduwuit.puppyirl.gay/deploying/generic.html#setting-up-the-reverse-proxy for reverse proxying.
///
/// Docker users: Don't change this, you'll need to map an external port to
/// this.
///
/// To listen on multiple ports, specify a vector e.g. [8080, 8448]
2024-10-05 19:39:27 +00:00
///
2024-10-22 10:09:14 +00:00
/// default: 8008
2022-01-20 11:51:31 +01:00
#[ serde(default = " default_port " ) ]
2024-04-22 23:48:57 -04:00
port : ListeningPort ,
2024-10-05 19:39:27 +00:00
2024-10-22 22:16:59 +00:00
// external structure; separate section
2024-11-24 00:19:55 +00:00
#[ serde(default) ]
pub tls : TlsConfig ,
2024-10-05 19:39:27 +00:00
/// Uncomment unix_socket_path to listen on a UNIX socket at the specified
2024-11-10 20:16:38 -05:00
/// path. If listening on a UNIX socket, you MUST remove/comment the
/// 'address' key if definedm AND add your reverse proxy to the 'conduwuit'
2024-10-05 19:39:27 +00:00
/// group, unless world RW permissions are specified with unix_socket_perms
/// (666 minimum).
2024-11-10 20:16:38 -05:00
///
/// example: "/run/conduwuit/conduwuit.sock"
2024-05-09 15:59:08 -07:00
pub unix_socket_path : Option < PathBuf > ,
2024-10-05 19:39:27 +00:00
2024-11-10 20:16:38 -05:00
/// The default permissions (in octal) to create the UNIX socket with.
///
2024-10-22 10:09:14 +00:00
/// default: 660
2023-07-29 21:57:41 +00:00
#[ serde(default = " default_unix_socket_perms " ) ]
2024-05-09 15:59:08 -07:00
pub unix_socket_perms : u32 ,
2024-10-05 19:39:27 +00:00
/// This is the only directory where conduwuit will save its data, including
2024-11-10 20:16:38 -05:00
/// media.
/// Note: this was previously "/var/lib/matrix-conduit"
///
/// YOU NEED TO EDIT THIS.
///
/// example: "/var/lib/conduwuit"
2024-05-09 15:59:08 -07:00
pub database_path : PathBuf ,
2024-10-05 19:39:27 +00:00
2024-11-10 20:16:38 -05:00
/// conduwuit supports online database backups using RocksDB's Backup engine
/// API. To use this, set a database backup path that conduwuit can write
/// to.
///
/// See https://conduwuit.puppyirl.gay/maintenance.html#backups for more information.
///
/// example: "/opt/conduwuit-db-backups"
2024-05-09 15:59:08 -07:00
pub database_backup_path : Option < PathBuf > ,
2024-10-05 19:39:27 +00:00
2024-11-10 20:16:38 -05:00
/// The amount of online RocksDB database backups to keep/retain, if using
/// "database_backup_path", before deleting the oldest one.
///
/// default: 1
2024-03-19 04:37:35 -07:00
#[ serde(default = " default_database_backups_to_keep " ) ]
2024-05-09 15:59:08 -07:00
pub database_backups_to_keep : i16 ,
2024-10-05 19:39:27 +00:00
/// Set this to any float value in megabytes for conduwuit to tell the
/// database engine that this much memory is available for database-related
2024-11-10 20:16:38 -05:00
/// caches.
///
/// May be useful if you have significant memory to spare to increase
/// performance.
///
/// Similar to the individual LRU caches, this is scaled up with your CPU
/// core count.
2024-10-22 10:09:14 +00:00
///
2024-11-10 20:16:38 -05:00
/// This defaults to 128.0 + (64.0 * CPU core count)
2022-02-03 13:30:04 +01:00
#[ serde(default = " default_db_cache_capacity_mb " ) ]
2024-05-09 15:59:08 -07:00
pub db_cache_capacity_mb : f64 ,
2024-10-05 19:39:27 +00:00
/// Option to control adding arbitrary text to the end of the user's
/// displayname upon registration with a space before the text. This was the
/// lightning bolt emoji option, just replaced with support for adding your
2024-11-10 20:16:38 -05:00
/// own custom text or emojis. To disable, set this to "" (an empty string).
2024-10-22 10:09:14 +00:00
///
2024-11-10 20:16:38 -05:00
/// The default is the trans pride flag.
///
/// example: "🏳️⚧️"
///
/// default: "🏳️⚧️"
2024-02-20 23:08:53 -05:00
#[ serde(default = " default_new_user_displayname_suffix " ) ]
2024-05-09 15:59:08 -07:00
pub new_user_displayname_suffix : String ,
2024-10-05 19:39:27 +00:00
/// If enabled, conduwuit will send a simple GET request periodically to
/// `https://pupbrain.dev/check-for-updates/stable` for any new
/// announcements made. Despite the name, this is not an update check
2024-11-10 20:16:38 -05:00
/// endpoint, it is simply an announcement check endpoint.
///
/// This is disabled by default as this is rarely used except for security
/// updates or major updates.
2024-03-11 19:24:27 -04:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub allow_check_for_updates : bool ,
2024-04-03 17:27:43 -07:00
2024-10-05 19:39:27 +00:00
/// Set this to any float value to multiply conduwuit's in-memory LRU caches
2024-11-10 20:16:38 -05:00
/// with such as "auth_chain_cache_capacity".
///
/// May be useful if you have significant memory to spare to increase
2024-10-22 10:09:14 +00:00
/// performance. This was previously called
/// `conduit_cache_capacity_modifier`.
2024-10-05 19:39:27 +00:00
///
2024-11-10 20:16:38 -05:00
/// If you have low memory, reducing this may be viable.
///
/// By default, the individual caches such as "auth_chain_cache_capacity"
/// are scaled by your CPU core count.
///
/// default: 1.0
2024-07-13 16:46:13 -04:00
#[ serde(default = " default_cache_capacity_modifier " , alias = " conduit_cache_capacity_modifier " ) ]
pub cache_capacity_modifier : f64 ,
2024-10-05 19:39:27 +00:00
2024-11-10 20:16:38 -05:00
/// default: varies by system
#[ serde(default = " default_pdu_cache_capacity " ) ]
pub pdu_cache_capacity : u32 ,
/// default: varies by system
2024-04-03 17:27:43 -07:00
#[ serde(default = " default_auth_chain_cache_capacity " ) ]
2024-05-09 15:59:08 -07:00
pub auth_chain_cache_capacity : u32 ,
2024-10-05 19:39:27 +00:00
2024-11-10 20:16:38 -05:00
/// default: varies by system
2024-04-03 17:27:43 -07:00
#[ serde(default = " default_shorteventid_cache_capacity " ) ]
2024-05-09 15:59:08 -07:00
pub shorteventid_cache_capacity : u32 ,
2024-10-05 19:39:27 +00:00
2024-11-10 20:16:38 -05:00
/// default: varies by system
2024-04-03 17:27:43 -07:00
#[ serde(default = " default_eventidshort_cache_capacity " ) ]
2024-05-09 15:59:08 -07:00
pub eventidshort_cache_capacity : u32 ,
2024-10-05 19:39:27 +00:00
2024-11-21 23:45:16 -05:00
/// default: varies by system
#[ serde(default = " default_eventid_pdu_cache_capacity " ) ]
pub eventid_pdu_cache_capacity : u32 ,
2024-11-10 20:16:38 -05:00
/// default: varies by system
2024-04-03 17:27:43 -07:00
#[ serde(default = " default_shortstatekey_cache_capacity " ) ]
2024-05-09 15:59:08 -07:00
pub shortstatekey_cache_capacity : u32 ,
2024-10-05 19:39:27 +00:00
2024-11-10 20:16:38 -05:00
/// default: varies by system
2024-04-03 17:27:43 -07:00
#[ serde(default = " default_statekeyshort_cache_capacity " ) ]
2024-05-09 15:59:08 -07:00
pub statekeyshort_cache_capacity : u32 ,
2024-10-05 19:39:27 +00:00
2024-11-25 16:08:30 -05:00
/// default: varies by system
#[ serde(default = " default_servernameevent_data_cache_capacity " ) ]
pub servernameevent_data_cache_capacity : u32 ,
2024-11-10 20:16:38 -05:00
/// default: varies by system
2024-04-03 17:27:43 -07:00
#[ serde(default = " default_server_visibility_cache_capacity " ) ]
2024-05-09 15:59:08 -07:00
pub server_visibility_cache_capacity : u32 ,
2024-10-05 19:39:27 +00:00
2024-11-10 20:16:38 -05:00
/// default: varies by system
2024-04-03 17:27:43 -07:00
#[ serde(default = " default_user_visibility_cache_capacity " ) ]
2024-05-09 15:59:08 -07:00
pub user_visibility_cache_capacity : u32 ,
2024-10-05 19:39:27 +00:00
2024-11-10 20:16:38 -05:00
/// default: varies by system
2024-04-03 17:27:43 -07:00
#[ serde(default = " default_stateinfo_cache_capacity " ) ]
2024-05-09 15:59:08 -07:00
pub stateinfo_cache_capacity : u32 ,
2024-10-05 19:39:27 +00:00
2024-11-10 20:16:38 -05:00
/// default: varies by system
2024-04-03 17:27:43 -07:00
#[ serde(default = " default_roomid_spacehierarchy_cache_capacity " ) ]
2024-05-09 15:59:08 -07:00
pub roomid_spacehierarchy_cache_capacity : u32 ,
2024-04-03 17:27:43 -07:00
2024-10-05 19:39:27 +00:00
/// Maximum entries stored in DNS memory-cache. The size of an entry may
/// vary so please take care if raising this value excessively. Only
/// decrease this when using an external DNS cache. Please note
2024-11-10 20:16:38 -05:00
/// that systemd-resolved does *not* count as an external cache, even when
/// configured to do so.
///
/// default: 32768
2024-03-24 23:59:28 -07:00
#[ serde(default = " default_dns_cache_entries " ) ]
2024-05-09 15:59:08 -07:00
pub dns_cache_entries : u32 ,
2024-10-05 19:39:27 +00:00
/// Minimum time-to-live in seconds for entries in the DNS cache. The
2024-11-10 20:16:38 -05:00
/// default may appear high to most administrators; this is by design as the
/// majority of NXDOMAINs are correct for a long time (e.g. the server is no
/// longer running Matrix). Only decrease this if you are using an external
/// DNS cache.
///
/// default_dns_min_ttl: 259200
2024-03-24 23:59:28 -07:00
#[ serde(default = " default_dns_min_ttl " ) ]
2024-05-09 15:59:08 -07:00
pub dns_min_ttl : u64 ,
2024-10-05 19:39:27 +00:00
/// Minimum time-to-live in seconds for NXDOMAIN entries in the DNS cache.
/// This value is critical for the server to federate efficiently.
/// NXDOMAIN's are assumed to not be returning to the federation
/// and aggressively cached rather than constantly rechecked.
///
/// Defaults to 3 days as these are *very rarely* false negatives.
2024-11-10 20:16:38 -05:00
///
/// default: 259200
2024-03-24 23:59:28 -07:00
#[ serde(default = " default_dns_min_ttl_nxdomain " ) ]
2024-05-09 15:59:08 -07:00
pub dns_min_ttl_nxdomain : u64 ,
2024-10-05 19:39:27 +00:00
/// Number of retries after a timeout.
2024-11-10 20:16:38 -05:00
///
/// default: 10
2024-03-24 23:59:28 -07:00
#[ serde(default = " default_dns_attempts " ) ]
2024-05-09 15:59:08 -07:00
pub dns_attempts : u16 ,
2024-10-05 19:39:27 +00:00
/// The number of seconds to wait for a reply to a DNS query. Please note
/// that recursive queries can take up to several seconds for some domains,
2024-11-10 20:16:38 -05:00
/// so this value should not be too low, especially on slower hardware or
/// resolvers.
///
/// default: 10
2024-03-24 23:59:28 -07:00
#[ serde(default = " default_dns_timeout " ) ]
2024-05-09 15:59:08 -07:00
pub dns_timeout : u64 ,
2024-10-05 19:39:27 +00:00
/// Fallback to TCP on DNS errors. Set this to false if unsupported by
/// nameserver.
2024-04-16 05:41:55 -07:00
#[ serde(default = " true_fn " ) ]
2024-05-09 15:59:08 -07:00
pub dns_tcp_fallback : bool ,
2024-10-05 19:39:27 +00:00
/// Enable to query all nameservers until the domain is found. Referred to
2024-10-22 10:09:14 +00:00
/// as "trust_negative_responses" in hickory_resolver. This can avoid
/// useless DNS queries if the first nameserver responds with NXDOMAIN or
/// an empty NOERROR response.
2024-04-17 19:49:19 -04:00
#[ serde(default = " true_fn " ) ]
2024-05-09 15:59:08 -07:00
pub query_all_nameservers : bool ,
2024-10-05 19:39:27 +00:00
/// Enables using *only* TCP for querying your specified nameservers instead
/// of UDP.
///
2024-11-10 20:16:38 -05:00
/// If you are running conduwuit in a container environment, this config option may need to be enabled. See https://conduwuit.puppyirl.gay/troubleshooting.html#potential-dns-issues-when-using-docker for more details.
2024-04-29 14:47:31 -04:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub query_over_tcp_only : bool ,
2024-10-05 19:39:27 +00:00
/// DNS A/AAAA record lookup strategy
///
/// Takes a number of one of the following options:
/// 1 - Ipv4Only (Only query for A records, no AAAA/IPv6)
2024-11-10 20:16:38 -05:00
///
2024-10-05 19:39:27 +00:00
/// 2 - Ipv6Only (Only query for AAAA records, no A/IPv4)
2024-11-10 20:16:38 -05:00
///
2024-10-05 19:39:27 +00:00
/// 3 - Ipv4AndIpv6 (Query for A and AAAA records in parallel, uses whatever
2024-11-10 20:16:38 -05:00
/// returns a successful response first)
///
/// 4 - Ipv6thenIpv4 (Query for AAAA record, if that fails then query the A
/// record)
2024-10-05 19:39:27 +00:00
///
2024-11-10 20:16:38 -05:00
/// 5 - Ipv4thenIpv6 (Query for A record, if that fails then query the AAAA
/// record)
2024-10-05 19:39:27 +00:00
///
2024-11-10 20:16:38 -05:00
/// If you don't have IPv6 networking, then for better DNS performance it
/// may be suitable to set this to Ipv4Only (1) as you will never ever use
/// the AAAA record contents even if the AAAA record is successful instead
/// of the A record.
2024-10-22 10:09:14 +00:00
///
/// default: 5
2024-04-29 14:25:11 -04:00
#[ serde(default = " default_ip_lookup_strategy " ) ]
2024-05-09 15:59:08 -07:00
pub ip_lookup_strategy : u8 ,
2024-04-22 10:55:48 -07:00
2024-11-10 20:16:38 -05:00
/// Max request size for file uploads in bytes. Defaults to 20MB.
2024-10-22 10:09:14 +00:00
///
/// default: 20971520
2022-02-03 13:30:04 +01:00
#[ serde(default = " default_max_request_size " ) ]
2024-07-07 19:59:04 +00:00
pub max_request_size : usize ,
2024-10-05 19:39:27 +00:00
2024-11-10 20:16:38 -05:00
/// default: 192
2022-09-09 19:17:29 +02:00
#[ serde(default = " default_max_fetch_prev_events " ) ]
2024-05-09 15:59:08 -07:00
pub max_fetch_prev_events : u16 ,
2024-04-22 10:55:48 -07:00
2024-10-22 10:09:14 +00:00
/// Default/base connection timeout (seconds). This is used only by URL
/// previews and update/news endpoint checks.
2024-10-05 19:39:27 +00:00
///
2024-10-22 10:09:14 +00:00
/// default: 10
2024-03-16 15:54:58 -07:00
#[ serde(default = " default_request_conn_timeout " ) ]
2024-05-09 15:59:08 -07:00
pub request_conn_timeout : u64 ,
2024-10-05 19:39:27 +00:00
2024-10-22 10:09:14 +00:00
/// Default/base request timeout (seconds). The time waiting to receive more
/// data from another server. This is used only by URL previews,
/// update/news, and misc endpoint checks.
2024-10-05 19:39:27 +00:00
///
2024-10-22 10:09:14 +00:00
/// default: 35
2024-03-16 15:54:58 -07:00
#[ serde(default = " default_request_timeout " ) ]
2024-05-09 15:59:08 -07:00
pub request_timeout : u64 ,
2024-10-05 19:39:27 +00:00
2024-10-22 10:09:14 +00:00
/// Default/base request total timeout (seconds). The time limit for a whole
/// request. This is set very high to not cancel healthy requests while
/// serving as a backstop. This is used only by URL previews and
/// update/news endpoint checks.
2024-10-05 19:39:27 +00:00
///
2024-10-22 10:09:14 +00:00
/// default: 320
2024-04-20 14:10:57 -07:00
#[ serde(default = " default_request_total_timeout " ) ]
2024-05-09 15:59:08 -07:00
pub request_total_timeout : u64 ,
2024-10-05 19:39:27 +00:00
2024-10-22 10:09:14 +00:00
/// Default/base idle connection pool timeout (seconds). This is used only
/// by URL previews and update/news endpoint checks.
2024-10-05 19:39:27 +00:00
///
2024-10-22 10:09:14 +00:00
/// default: 5
2024-03-16 15:54:58 -07:00
#[ serde(default = " default_request_idle_timeout " ) ]
2024-05-09 15:59:08 -07:00
pub request_idle_timeout : u64 ,
2024-10-05 19:39:27 +00:00
2024-10-22 10:09:14 +00:00
/// Default/base max idle connections per host. This is used only by URL
/// previews and update/news endpoint checks. Defaults to 1 as generally the
/// same open connection can be re-used.
2024-10-05 19:39:27 +00:00
///
2024-10-22 10:09:14 +00:00
/// default: 1
2024-04-20 14:10:57 -07:00
#[ serde(default = " default_request_idle_per_host " ) ]
2024-05-09 15:59:08 -07:00
pub request_idle_per_host : u16 ,
2024-10-05 19:39:27 +00:00
2024-10-22 10:09:14 +00:00
/// Federation well-known resolution connection timeout (seconds)
2024-10-05 19:39:27 +00:00
///
2024-10-22 10:09:14 +00:00
/// default: 6
2024-03-16 15:54:58 -07:00
#[ serde(default = " default_well_known_conn_timeout " ) ]
2024-05-09 15:59:08 -07:00
pub well_known_conn_timeout : u64 ,
2024-10-05 19:39:27 +00:00
2024-10-22 10:09:14 +00:00
/// Federation HTTP well-known resolution request timeout (seconds)
2024-10-05 19:39:27 +00:00
///
2024-10-22 10:09:14 +00:00
/// default: 10
2024-03-16 15:54:58 -07:00
#[ serde(default = " default_well_known_timeout " ) ]
2024-05-09 15:59:08 -07:00
pub well_known_timeout : u64 ,
2024-10-05 19:39:27 +00:00
2024-10-22 10:09:14 +00:00
/// Federation client request timeout (seconds). You most definitely want
/// this to be high to account for extremely large room joins, slow
/// homeservers, your own resources etc.
2024-10-05 19:39:27 +00:00
///
2024-10-22 10:09:14 +00:00
/// default: 300
2024-03-16 15:54:58 -07:00
#[ serde(default = " default_federation_timeout " ) ]
2024-05-09 15:59:08 -07:00
pub federation_timeout : u64 ,
2024-10-05 19:39:27 +00:00
2024-10-22 10:09:14 +00:00
/// Federation client idle connection pool timeout (seconds)
2024-10-05 19:39:27 +00:00
///
2024-10-22 10:09:14 +00:00
/// default: 25
2024-03-16 15:54:58 -07:00
#[ serde(default = " default_federation_idle_timeout " ) ]
2024-05-09 15:59:08 -07:00
pub federation_idle_timeout : u64 ,
2024-10-05 19:39:27 +00:00
2024-10-22 10:09:14 +00:00
/// Federation client max idle connections per host. Defaults to 1 as
/// generally the same open connection can be re-used
2024-10-05 19:39:27 +00:00
///
2024-10-22 10:09:14 +00:00
/// default: 1
2024-04-20 14:10:57 -07:00
#[ serde(default = " default_federation_idle_per_host " ) ]
2024-05-09 15:59:08 -07:00
pub federation_idle_per_host : u16 ,
2024-10-05 19:39:27 +00:00
2024-10-22 10:09:14 +00:00
/// Federation sender request timeout (seconds). The time it takes for the
/// remote server to process sent transactions can take a while.
2024-10-05 19:39:27 +00:00
///
2024-10-22 10:09:14 +00:00
/// default: 180
2024-03-16 15:54:58 -07:00
#[ serde(default = " default_sender_timeout " ) ]
2024-05-09 15:59:08 -07:00
pub sender_timeout : u64 ,
2024-10-05 19:39:27 +00:00
2024-10-22 10:09:14 +00:00
/// Federation sender idle connection pool timeout (seconds)
2024-10-05 19:39:27 +00:00
///
2024-10-22 10:09:14 +00:00
/// default: 180
2024-03-16 15:54:58 -07:00
#[ serde(default = " default_sender_idle_timeout " ) ]
2024-05-09 15:59:08 -07:00
pub sender_idle_timeout : u64 ,
2024-10-05 19:39:27 +00:00
2024-10-22 10:09:14 +00:00
/// Federation sender transaction retry backoff limit (seconds)
2024-10-05 19:39:27 +00:00
///
2024-10-22 10:09:14 +00:00
/// default: 86400
2024-04-22 10:55:48 -07:00
#[ serde(default = " default_sender_retry_backoff_limit " ) ]
2024-05-09 15:59:08 -07:00
pub sender_retry_backoff_limit : u64 ,
2024-10-05 19:39:27 +00:00
2024-10-22 10:09:14 +00:00
/// Appservice URL request connection timeout. Defaults to 35 seconds as
/// generally appservices are hosted within the same network.
2024-10-05 19:39:27 +00:00
///
2024-10-22 10:09:14 +00:00
/// default: 35
2024-03-16 15:54:58 -07:00
#[ serde(default = " default_appservice_timeout " ) ]
2024-05-09 15:59:08 -07:00
pub appservice_timeout : u64 ,
2024-10-05 19:39:27 +00:00
2024-10-22 10:09:14 +00:00
/// Appservice URL idle connection pool timeout (seconds)
2024-10-05 19:39:27 +00:00
///
2024-10-22 10:09:14 +00:00
/// default: 300
2024-03-16 15:54:58 -07:00
#[ serde(default = " default_appservice_idle_timeout " ) ]
2024-05-09 15:59:08 -07:00
pub appservice_idle_timeout : u64 ,
2024-10-05 19:39:27 +00:00
/// Notification gateway pusher idle connection pool timeout
///
2024-11-10 20:16:38 -05:00
/// default: 15
2024-03-16 15:54:58 -07:00
#[ serde(default = " default_pusher_idle_timeout " ) ]
2024-05-09 15:59:08 -07:00
pub pusher_idle_timeout : u64 ,
2024-04-22 10:55:48 -07:00
2024-10-05 19:39:27 +00:00
/// Enables registration. If set to false, no users can register on this
/// server.
///
/// If set to true without a token configured, users can register with no
2024-11-10 20:16:38 -05:00
/// form of 2nd-step only if you set
2024-10-05 19:39:27 +00:00
/// `yes_i_am_very_very_sure_i_want_an_open_registration_server_prone_to_abuse` to
/// true in your config.
///
/// If you would like registration only via token reg, please configure
/// `registration_token` or `registration_token_file`.
2023-12-24 00:37:23 -05:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub allow_registration : bool ,
2024-10-05 19:39:27 +00:00
2023-12-24 00:37:23 -05:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub yes_i_am_very_very_sure_i_want_an_open_registration_server_prone_to_abuse : bool ,
2024-10-05 19:39:27 +00:00
/// A static registration token that new users will have to provide when
/// creating an account. If unset and `allow_registration` is true,
2024-11-10 20:16:38 -05:00
/// registration is open without any condition.
///
/// YOU NEED TO EDIT THIS OR USE registration_token_file.
///
/// example: "o&^uCtes4HPf0Vu@F20jQeeWE7"
2024-05-09 15:59:08 -07:00
pub registration_token : Option < String > ,
2024-10-05 19:39:27 +00:00
2024-11-10 20:16:38 -05:00
/// Path to a file on the system that gets read for the registration token.
/// this config option takes precedence/priority over "registration_token".
2024-10-05 19:39:27 +00:00
///
/// conduwuit must be able to access the file, and it must not be empty
///
2024-11-10 20:16:38 -05:00
/// example: "/etc/conduwuit/.reg_token"
2024-09-29 01:54:07 -04:00
pub registration_token_file : Option < PathBuf > ,
2024-10-05 19:39:27 +00:00
2024-10-22 10:09:14 +00:00
/// Controls whether encrypted rooms and events are allowed.
2022-02-03 13:30:04 +01:00
#[ serde(default = " true_fn " ) ]
2024-05-09 15:59:08 -07:00
pub allow_encryption : bool ,
2024-10-05 19:39:27 +00:00
2024-11-10 20:16:38 -05:00
/// Controls whether federation is allowed or not. It is not recommended to
/// disable this after the fact due to potential federation breakage.
2024-01-27 16:28:57 -05:00
#[ serde(default = " true_fn " ) ]
2024-05-09 15:59:08 -07:00
pub allow_federation : bool ,
2024-10-05 19:39:27 +00:00
2023-12-24 00:37:23 -05:00
#[ serde(default) ]
2024-08-17 03:39:09 +00:00
pub federation_loopback : bool ,
2024-10-05 19:39:27 +00:00
2024-10-26 12:32:47 -04:00
/// Set this to true to require authentication on the normally
/// unauthenticated profile retrieval endpoints (GET)
/// "/_matrix/client/v3/profile/{userId}".
///
/// This can prevent profile scraping.
#[ serde(default) ]
pub require_auth_for_profile_requests : bool ,
2024-10-05 19:39:27 +00:00
/// Set this to true to allow your server's public room directory to be
/// federated. Set this to false to protect against /publicRooms spiders,
/// but will forbid external users from viewing your server's public room
/// directory. If federation is disabled entirely (`allow_federation`),
/// this is inherently false.
2024-08-17 03:39:09 +00:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub allow_public_room_directory_over_federation : bool ,
2024-10-05 19:39:27 +00:00
/// Set this to true to allow your server's public room directory to be
/// queried without client authentication (access token) through the Client
/// APIs. Set this to false to protect against /publicRooms spiders.
2023-12-24 00:37:23 -05:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub allow_public_room_directory_without_auth : bool ,
2024-10-05 19:39:27 +00:00
/// allow guests/unauthenticated users to access TURN credentials
///
/// this is the equivalent of Synapse's `turn_allow_guests` config option.
2024-11-10 20:16:38 -05:00
/// this allows any unauthenticated user to call the endpoint
2024-10-05 19:39:27 +00:00
/// `/_matrix/client/v3/voip/turnServer`.
///
2024-11-10 20:16:38 -05:00
/// It is unlikely you need to enable this as all major clients support
/// authentication for this endpoint and prevents misuse of your TURN server
/// from potential bots.
2023-12-24 00:37:23 -05:00
#[ serde(default) ]
2024-06-05 18:42:56 -04:00
pub turn_allow_guests : bool ,
2024-10-05 19:39:27 +00:00
/// Set this to true to lock down your server's public room directory and
/// only allow admins to publish rooms to the room directory. Unpublishing
/// is still allowed by all users with this enabled.
2024-06-05 18:42:56 -04:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub lockdown_public_room_directory : bool ,
2024-10-05 19:39:27 +00:00
/// Set this to true to allow federating device display names / allow
/// external users to see your device display name. If federation is
/// disabled entirely (`allow_federation`), this is inherently false. For
2024-11-10 20:16:38 -05:00
/// privacy reasons, this is best left disabled.
2024-03-30 22:58:20 -04:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub allow_device_name_federation : bool ,
2024-10-05 19:39:27 +00:00
/// Config option to allow or disallow incoming federation requests that
/// obtain the profiles of our local users from
/// `/_matrix/federation/v1/query/profile`
///
2024-10-27 12:37:44 -04:00
/// Increases privacy of your local user's such as display names, but some
/// remote users may get a false "this user does not exist" error when they
/// try to invite you to a DM or room. Also can protect against profile
/// spiders.
2024-10-05 19:39:27 +00:00
///
2024-10-27 12:37:44 -04:00
/// This is inherently false if `allow_federation` is disabled
#[ serde(default = " true_fn " , alias = " allow_profile_lookup_federation_requests " ) ]
pub allow_inbound_profile_lookup_federation_requests : bool ,
2024-10-05 19:39:27 +00:00
2024-11-10 20:16:38 -05:00
/// controls whether standard users are allowed to create rooms. appservices
/// and admins are always allowed to create rooms
2024-04-07 22:38:33 -04:00
#[ serde(default = " true_fn " ) ]
2024-05-09 15:59:08 -07:00
pub allow_room_creation : bool ,
2024-10-05 19:39:27 +00:00
/// Set to false to disable users from joining or creating room versions
/// that aren't 100% officially supported by conduwuit.
2024-11-10 20:16:38 -05:00
///
/// conduwuit officially supports room versions 6 - 11.
///
/// conduwuit has slightly experimental (though works fine in practice)
/// support for versions 3 - 5
2021-11-01 01:58:26 +00:00
#[ serde(default = " true_fn " ) ]
2024-05-09 15:59:08 -07:00
pub allow_unstable_room_versions : bool ,
2024-10-05 19:39:27 +00:00
2024-11-10 20:16:38 -05:00
/// default room version conduwuit will create rooms with.
///
/// per spec, room version 10 is the default.
///
2024-10-22 22:16:59 +00:00
/// default: 10
2021-11-01 01:58:26 +00:00
#[ serde(default = " default_default_room_version " ) ]
2024-05-09 15:59:08 -07:00
pub default_room_version : RoomVersionId ,
2024-10-05 19:39:27 +00:00
2024-10-22 22:16:59 +00:00
// external structure; separate section
2024-04-11 21:50:40 -04:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub well_known : WellKnownConfig ,
2024-10-05 19:39:27 +00:00
2023-12-24 00:37:23 -05:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub allow_jaeger : bool ,
2024-10-05 19:39:27 +00:00
2024-10-22 22:16:59 +00:00
/// default: "info"
2024-07-11 05:26:43 +00:00
#[ serde(default = " default_jaeger_filter " ) ]
pub jaeger_filter : String ,
2024-10-05 19:39:27 +00:00
2024-11-10 20:16:38 -05:00
/// If the 'perf_measurements' compile-time feature is enabled, enables
/// collecting folded stack trace profile of tracing spans using
/// tracing_flame. The resulting profile can be visualized with inferno[1],
/// speedscope[2], or a number of other tools.
///
/// [1]: https://github.com/jonhoo/inferno
2024-10-05 19:39:27 +00:00
/// [2]: www.speedscope.app
2023-12-24 00:37:23 -05:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub tracing_flame : bool ,
2024-10-05 19:39:27 +00:00
2024-10-22 22:16:59 +00:00
/// default: "info"
2024-04-26 18:23:02 -07:00
#[ serde(default = " default_tracing_flame_filter " ) ]
2024-05-09 15:59:08 -07:00
pub tracing_flame_filter : String ,
2024-10-05 19:39:27 +00:00
2024-10-22 22:16:59 +00:00
/// default: "./tracing.folded"
2024-04-26 18:49:58 -07:00
#[ serde(default = " default_tracing_flame_output_path " ) ]
2024-05-09 15:59:08 -07:00
pub tracing_flame_output_path : String ,
2024-10-05 19:39:27 +00:00
2024-10-22 22:16:59 +00:00
/// Examples:
/// - No proxy (default):
/// proxy ="none"
///
/// - For global proxy, create the section at the bottom of this file:
/// [global.proxy]
/// global = { url = "socks5h://localhost:9050" }
///
/// - To proxy some domains:
/// [global.proxy]
/// [[global.proxy.by_domain]]
/// url = "socks5h://localhost:9050"
/// include = ["*.onion", "matrix.myspecial.onion"]
/// exclude = ["*.myspecial.onion"]
///
/// Include vs. Exclude:
/// - If include is an empty list, it is assumed to be `["*"]`.
/// - If a domain matches both the exclude and include list, the proxy will
/// only be used if it was included because of a more specific rule than
/// it was excluded. In the above example, the proxy would be used for
/// `ordinary.onion`, `matrix.myspecial.onion`, but not
/// `hello.myspecial.onion`.
///
/// default: "none"
2022-02-03 13:30:04 +01:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub proxy : ProxyConfig ,
2024-10-05 19:39:27 +00:00
2024-05-09 15:59:08 -07:00
pub jwt_secret : Option < String > ,
2024-10-05 19:39:27 +00:00
/// Servers listed here will be used to gather public keys of other servers
/// (notary trusted key servers).
///
2024-11-10 20:16:38 -05:00
/// Currently, conduwuit doesn't support inbound batched key requests, so
/// this list should only contain other Synapse servers
///
/// example: ["matrix.org", "constellatory.net", "tchncs.de"]
2024-10-22 10:09:14 +00:00
///
/// default: ["matrix.org"]
2023-08-10 17:45:58 +02:00
#[ serde(default = " default_trusted_servers " ) ]
2024-05-09 15:59:08 -07:00
pub trusted_servers : Vec < OwnedServerName > ,
2024-10-05 19:39:27 +00:00
2024-10-21 22:00:39 +00:00
/// Whether to query the servers listed in trusted_servers first or query
/// the origin server first. For best security, querying the origin server
/// first is advised to minimize the exposure to a compromised trusted
2024-11-10 20:16:38 -05:00
/// server. For maximum federation/join performance this can be set to true,
/// however other options exist to query trusted servers first under
/// specific high-load circumstances and should be evaluated before setting
/// this to true.
2024-10-21 22:00:39 +00:00
#[ serde(default) ]
pub query_trusted_key_servers_first : bool ,
/// Whether to query the servers listed in trusted_servers first
/// specifically on room joins. This option limits the exposure to a
/// compromised trusted server to room joins only. The join operation
/// requires gathering keys from many origin servers which can cause
/// significant delays. Therefor this defaults to true to mitigate
/// unexpected delays out-of-the-box. The security-paranoid or those
/// willing to tolerate delays are advised to set this to false. Note that
/// setting query_trusted_key_servers_first to true causes this option to
/// be ignored.
#[ serde(default = " true_fn " ) ]
pub query_trusted_key_servers_first_on_join : bool ,
/// Only query trusted servers for keys and never the origin server. This is
/// intended for clusters or custom deployments using their trusted_servers
/// as forwarding-agents to cache and deduplicate requests. Notary servers
/// do not act as forwarding-agents by default, therefor do not enable this
/// unless you know exactly what you are doing.
#[ serde(default) ]
pub only_query_trusted_key_servers : bool ,
2024-11-10 20:16:38 -05:00
/// Maximum number of keys to request in each trusted server batch query.
2024-11-09 01:09:09 +00:00
///
/// default: 1024
#[ serde(default = " default_trusted_server_batch_size " ) ]
pub trusted_server_batch_size : usize ,
2024-10-05 19:39:27 +00:00
/// max log level for conduwuit. allows debug, info, warn, or error
/// see also: https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html#directives
2024-11-10 20:16:38 -05:00
///
2024-10-05 19:39:27 +00:00
/// **Caveat**:
/// For release builds, the tracing crate is configured to only implement
/// levels higher than error to avoid unnecessary overhead in the compiled
/// binary from trace macros. For debug builds, this restriction is not
/// applied.
///
2024-10-22 10:09:14 +00:00
/// default: "info"
2022-02-03 13:30:04 +01:00
#[ serde(default = " default_log " ) ]
2024-05-09 15:59:08 -07:00
pub log : String ,
2024-10-05 19:39:27 +00:00
/// controls whether logs will be outputted with ANSI colours
2024-09-29 12:27:42 -04:00
#[ serde(default = " true_fn " , alias = " log_colours " ) ]
pub log_colors : bool ,
2024-10-05 19:39:27 +00:00
2024-11-11 20:49:25 +00:00
/// configures the span events which will be outputted with the log
///
/// default: "none"
#[ serde(default = " default_log_span_events " ) ]
pub log_span_events : String ,
2024-10-05 19:39:27 +00:00
/// OpenID token expiration/TTL in seconds
///
/// These are the OpenID tokens that are primarily used for Matrix account
2024-11-10 20:16:38 -05:00
/// integrations (e.g. Vector Integrations in Element), *not* OIDC/OpenID
/// Connect/etc
2024-10-05 19:39:27 +00:00
///
2024-10-22 10:09:14 +00:00
/// default: 3600
2024-07-02 21:51:11 -04:00
#[ serde(default = " default_openid_token_ttl " ) ]
pub openid_token_ttl : u64 ,
2024-10-05 19:39:27 +00:00
2024-11-10 20:16:38 -05:00
/// static TURN username to provide the client if not using a shared secret
/// ("turn_secret"), It is recommended to use a shared secret over static
/// credentials.
2022-02-03 13:30:04 +01:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub turn_username : String ,
2024-10-05 19:39:27 +00:00
2024-11-10 20:16:38 -05:00
/// static TURN password to provide the client if not using a shared secret
/// ("turn_secret"). It is recommended to use a shared secret over static
/// credentials.
2022-02-03 13:30:04 +01:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub turn_password : String ,
2024-10-05 19:39:27 +00:00
/// vector list of TURN URIs/servers to use
///
/// replace "example.turn.uri" with your TURN domain, such as the coturn
2024-11-10 20:16:38 -05:00
/// "realm" config option. if using TURN over TLS, replace the URI prefix
/// "turn:" with "turns:"
2024-10-05 19:39:27 +00:00
///
2024-11-10 20:16:38 -05:00
/// example: ["turn:example.turn.uri?transport=udp",
/// "turn:example.turn.uri?transport=tcp"]
///
/// default: []
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub turn_uris : Vec < String > ,
2024-10-05 19:39:27 +00:00
/// TURN secret to use for generating the HMAC-SHA1 hash apart of username
/// and password generation
///
/// this is more secure, but if needed you can use traditional
2024-11-10 20:16:38 -05:00
/// static username/password credentials.
2022-02-03 13:30:04 +01:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub turn_secret : String ,
2024-10-05 19:39:27 +00:00
/// TURN secret to use that's read from the file path specified
///
/// this takes priority over "turn_secret" first, and falls back to
/// "turn_secret" if invalid or failed to open.
///
2024-11-10 20:16:38 -05:00
/// example: "/etc/conduwuit/.turn_secret"
2024-09-20 22:57:04 -04:00
pub turn_secret_file : Option < PathBuf > ,
2024-10-05 19:39:27 +00:00
2024-10-22 10:09:14 +00:00
/// TURN TTL in seconds
2024-10-05 19:39:27 +00:00
///
2024-10-22 10:09:14 +00:00
/// default: 86400
2022-02-03 13:30:04 +01:00
#[ serde(default = " default_turn_ttl " ) ]
2024-05-09 15:59:08 -07:00
pub turn_ttl : u64 ,
2024-03-05 19:48:54 -05:00
2024-11-02 20:55:40 -04:00
/// List/vector of room IDs or room aliases that conduwuit will make newly
/// registered users join. The rooms specified must be rooms that you
/// have joined at least once on the server, and must be public.
2024-10-05 19:39:27 +00:00
///
2024-11-10 20:16:38 -05:00
/// example: ["#conduwuit:puppygock.gay",
/// "!eoIzvAvVwY23LPDay8:puppygock.gay"]
///
/// default: []
2024-03-20 11:19:41 -04:00
#[ serde(default = " Vec::new " ) ]
2024-11-02 20:55:40 -04:00
pub auto_join_rooms : Vec < OwnedRoomOrAliasId > ,
2024-10-05 19:39:27 +00:00
/// Config option to automatically deactivate the account of any user who
/// attempts to join a:
/// - banned room
/// - forbidden room alias
/// - room alias or ID with a forbidden server name
///
/// This may be useful if all your banned lists consist of toxic rooms or
/// servers that no good faith user would ever attempt to join, and
/// to automatically remediate the problem without any admin user
/// intervention.
///
/// This will also make the user leave all rooms. Federation (e.g. remote
/// room invites) are ignored here.
///
/// Defaults to false as rooms can be banned for non-moderation-related
/// reasons
2024-05-07 22:39:55 -04:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub auto_deactivate_banned_room_attempts : bool ,
2024-03-20 11:19:41 -04:00
2024-10-05 19:39:27 +00:00
/// RocksDB log level. This is not the same as conduwuit's log level. This
/// is the log level for the RocksDB engine/library which show up in your
2024-11-10 20:16:38 -05:00
/// database folder/path as `LOG` files. conduwuit will log RocksDB errors
/// as normal through tracing.
///
/// default: "error"
2023-12-02 21:30:06 -05:00
#[ serde(default = " default_rocksdb_log_level " ) ]
2024-05-09 15:59:08 -07:00
pub rocksdb_log_level : String ,
2024-10-05 19:39:27 +00:00
2024-04-13 17:58:13 -07:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub rocksdb_log_stderr : bool ,
2024-10-05 19:39:27 +00:00
2024-11-10 20:16:38 -05:00
/// Max RocksDB `LOG` file size before rotating in bytes. Defaults to 4MB in
/// bytes.
2024-10-22 10:09:14 +00:00
///
/// default: 4194304
2023-12-02 21:30:06 -05:00
#[ serde(default = " default_rocksdb_max_log_file_size " ) ]
2024-05-09 15:59:08 -07:00
pub rocksdb_max_log_file_size : usize ,
2024-10-05 19:39:27 +00:00
2024-10-22 10:09:14 +00:00
/// Time in seconds before RocksDB will forcibly rotate logs.
///
/// default: 0
2023-12-02 21:30:06 -05:00
#[ serde(default = " default_rocksdb_log_time_to_roll " ) ]
2024-05-09 15:59:08 -07:00
pub rocksdb_log_time_to_roll : usize ,
2024-10-05 19:39:27 +00:00
/// Set this to true to use RocksDB config options that are tailored to HDDs
/// (slower device storage)
///
/// It is worth noting that by default, conduwuit will use RocksDB with
/// Direct IO enabled. *Generally* speaking this improves performance as it
/// bypasses buffered I/O (system page cache). However there is a potential
/// chance that Direct IO may cause issues with database operations if your
/// setup is uncommon. This has been observed with FUSE filesystems, and
/// possibly ZFS filesystem. RocksDB generally deals/corrects these issues
/// but it cannot account for all setups. If you experience any weird
/// RocksDB issues, try enabling this option as it turns off Direct IO and
/// feel free to report in the conduwuit Matrix room if this option fixes
2024-11-10 20:16:38 -05:00
/// your DB issues.
///
/// See https://github.com/facebook/rocksdb/wiki/Direct-IO for more information.
2023-12-24 00:37:23 -05:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub rocksdb_optimize_for_spinning_disks : bool ,
2024-10-05 19:39:27 +00:00
2024-11-10 20:16:38 -05:00
/// Enables direct-io to increase database performance via unbuffered I/O.
///
/// See https://github.com/facebook/rocksdb/wiki/Direct-IO for more details about Direct IO and RocksDB.
///
/// Set this option to false if the database resides on a filesystem which
/// does not support direct-io like FUSE, or any form of complex filesystem
/// setup such as possibly ZFS.
2024-04-28 13:09:26 -07:00
#[ serde(default = " true_fn " ) ]
2024-05-09 15:59:08 -07:00
pub rocksdb_direct_io : bool ,
2024-10-05 19:39:27 +00:00
/// Amount of threads that RocksDB will use for parallelism on database
/// operatons such as cleanup, sync, flush, compaction, etc. Set to 0 to use
2024-10-22 10:09:14 +00:00
/// all your logical threads. Defaults to your CPU logical thread count.
2024-10-05 19:39:27 +00:00
///
2024-10-22 10:09:14 +00:00
/// default: 0
2024-03-04 20:42:09 -05:00
#[ serde(default = " default_rocksdb_parallelism_threads " ) ]
2024-05-09 15:59:08 -07:00
pub rocksdb_parallelism_threads : usize ,
2024-10-05 19:39:27 +00:00
/// Maximum number of LOG files RocksDB will keep. This must *not* be set to
2024-11-10 20:16:38 -05:00
/// 0. It must be at least 1. Defaults to 3 as these are not very useful
/// unless troubleshooting/debugging a RocksDB bug.
2024-10-22 10:09:14 +00:00
///
/// default: 3
2024-03-06 18:20:02 -05:00
#[ serde(default = " default_rocksdb_max_log_files " ) ]
2024-05-09 15:59:08 -07:00
pub rocksdb_max_log_files : usize ,
2024-10-05 19:39:27 +00:00
/// Type of RocksDB database compression to use.
2024-11-10 20:16:38 -05:00
///
2024-10-05 19:39:27 +00:00
/// Available options are "zstd", "zlib", "bz2", "lz4", or "none"
2024-11-10 20:16:38 -05:00
///
2024-10-05 19:39:27 +00:00
/// It is best to use ZSTD as an overall good balance between
/// speed/performance, storage, IO amplification, and CPU usage.
/// For more performance but less compression (more storage used) and less
/// CPU usage, use LZ4. See https://github.com/facebook/rocksdb/wiki/Compression for more details.
///
/// "none" will disable compression.
///
2024-10-22 10:09:14 +00:00
/// default: "zstd"
2024-03-13 12:31:13 -04:00
#[ serde(default = " default_rocksdb_compression_algo " ) ]
2024-05-09 15:59:08 -07:00
pub rocksdb_compression_algo : String ,
2024-10-05 19:39:27 +00:00
/// Level of compression the specified compression algorithm for RocksDB to
2024-11-10 20:16:38 -05:00
/// use.
///
/// Default is 32767, which is internally read by RocksDB as the
2024-10-05 19:39:27 +00:00
/// default magic number and translated to the library's default
/// compression level as they all differ.
/// See their `kDefaultCompressionLevel`.
2024-11-10 20:16:38 -05:00
///
/// default: 32767
2024-03-13 22:22:07 -04:00
#[ serde(default = " default_rocksdb_compression_level " ) ]
2024-05-09 15:59:08 -07:00
pub rocksdb_compression_level : i32 ,
2024-10-05 19:39:27 +00:00
/// Level of compression the specified compression algorithm for the
/// bottommost level/data for RocksDB to use. Default is 32767, which is
/// internally read by RocksDB as the default magic number and translated
/// to the library's default compression level as they all differ.
/// See their `kDefaultCompressionLevel`.
///
/// Since this is the bottommost level (generally old and least used data),
/// it may be desirable to have a very high compression level here as it's
/// lesss likely for this data to be used. Research your chosen compression
/// algorithm.
2024-11-10 20:16:38 -05:00
///
/// default: 32767
2024-03-13 22:38:30 -04:00
#[ serde(default = " default_rocksdb_bottommost_compression_level " ) ]
2024-05-09 15:59:08 -07:00
pub rocksdb_bottommost_compression_level : i32 ,
2024-10-05 19:39:27 +00:00
2024-11-10 20:16:38 -05:00
/// Whether to enable RocksDB's "bottommost_compression".
///
2024-10-05 19:39:27 +00:00
/// At the expense of more CPU usage, this will further compress the
/// database to reduce more storage. It is recommended to use ZSTD
2024-11-10 20:16:38 -05:00
/// compression with this for best compression results. This may be useful
/// if you're trying to reduce storage usage from the database.
2024-10-05 19:39:27 +00:00
///
2024-11-10 20:16:38 -05:00
/// See https://github.com/facebook/rocksdb/wiki/Compression for more details.
2024-03-13 22:22:07 -04:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub rocksdb_bottommost_compression : bool ,
2024-10-05 19:39:27 +00:00
/// Database recovery mode (for RocksDB WAL corruption)
///
/// Use this option when the server reports corruption and refuses to start.
/// Set mode 2 (PointInTime) to cleanly recover from this corruption. The
/// server will continue from the last good state, several seconds or
/// minutes prior to the crash. Clients may have to run "clear-cache &
/// reload" to account for the rollback. Upon success, you may reset the
/// mode back to default and restart again. Please note in some cases the
/// corruption error may not be cleared for at least 30 minutes of
/// operation in PointInTime mode.
///
/// As a very last ditch effort, if PointInTime does not fix or resolve
/// anything, you can try mode 3 (SkipAnyCorruptedRecord) but this will
/// leave the server in a potentially inconsistent state.
///
/// The default mode 1 (TolerateCorruptedTailRecords) will automatically
/// drop the last entry in the database if corrupted during shutdown, but
/// nothing more. It is extraordinarily unlikely this will desynchronize
/// clients. To disable any form of silent rollback set mode 0
/// (AbsoluteConsistency).
///
/// The options are:
/// 0 = AbsoluteConsistency
/// 1 = TolerateCorruptedTailRecords (default)
/// 2 = PointInTime (use me if trying to recover)
/// 3 = SkipAnyCorruptedRecord (you now voided your Conduwuit warranty)
///
2024-11-10 20:16:38 -05:00
/// See https://github.com/facebook/rocksdb/wiki/WAL-Recovery-Modes for more information on these modes.
2024-10-05 19:39:27 +00:00
///
2024-11-10 20:16:38 -05:00
/// See https://conduwuit.puppyirl.gay/troubleshooting.html#database-corruption for more details on recovering a corrupt database.
2024-10-22 10:09:14 +00:00
///
/// default: 1
2024-03-22 20:34:24 -07:00
#[ serde(default = " default_rocksdb_recovery_mode " ) ]
2024-05-09 15:59:08 -07:00
pub rocksdb_recovery_mode : u8 ,
2024-10-05 19:39:27 +00:00
/// Database repair mode (for RocksDB SST corruption)
///
/// Use this option when the server reports corruption while running or
/// panics. If the server refuses to start use the recovery mode options
/// first. Corruption errors containing the acronym 'SST' which occur after
/// startup will likely require this option.
///
/// - Backing up your database directory is recommended prior to running the
/// repair.
/// - Disabling repair mode and restarting the server is recommended after
/// running the repair.
2024-11-10 20:16:38 -05:00
///
/// See https://conduwuit.puppyirl.gay/troubleshooting.html#database-corruption for more details on recovering a corrupt database.
2024-03-25 16:51:55 -07:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub rocksdb_repair : bool ,
2024-10-05 19:39:27 +00:00
2024-03-25 16:51:55 -07:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub rocksdb_read_only : bool ,
2024-10-05 19:39:27 +00:00
2024-04-06 17:37:56 -07:00
#[ serde(default) ]
2024-10-01 04:20:31 +00:00
pub rocksdb_secondary : bool ,
2024-10-05 19:39:27 +00:00
/// Enables idle CPU priority for compaction thread. This is not enabled by
/// default to prevent compaction from falling too far behind on busy
/// systems.
2024-10-01 04:20:31 +00:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub rocksdb_compaction_prio_idle : bool ,
2024-10-05 19:39:27 +00:00
/// Enables idle IO priority for compaction thread. This prevents any
/// unexpected lag in the server's operation and is usually a good idea.
/// Enabled by default.
2024-04-24 23:29:09 -07:00
#[ serde(default = " true_fn " ) ]
2024-05-09 15:59:08 -07:00
pub rocksdb_compaction_ioprio_idle : bool ,
2024-10-05 19:39:27 +00:00
2024-11-10 20:16:38 -05:00
/// Config option to disable RocksDB compaction. You should never ever have
/// to disable this. If you for some reason find yourself needing to disable
/// this as part of troubleshooting or a bug, please reach out to us in the
/// conduwuit Matrix room with information and details.
///
/// Disabling compaction will lead to a significantly bloated and
/// explosively large database, gradually poor performance, unnecessarily
/// excessive disk read/writes, and slower shutdowns and startups.
2024-07-24 09:04:16 +00:00
#[ serde(default = " true_fn " ) ]
pub rocksdb_compaction : bool ,
2024-10-05 19:39:27 +00:00
/// Level of statistics collection. Some admin commands to display database
/// statistics may require this option to be set. Database performance may
/// be impacted by higher settings.
///
/// Option is a number ranging from 0 to 6:
/// 0 = No statistics.
/// 1 = No statistics in release mode (default).
/// 2 to 3 = Statistics with no performance impact.
/// 3 to 5 = Statistics with possible performance impact.
/// 6 = All statistics.
///
2024-10-22 10:09:14 +00:00
/// default: 1
2024-08-02 01:21:01 +00:00
#[ serde(default = " default_rocksdb_stats_level " ) ]
pub rocksdb_stats_level : u8 ,
2024-03-05 19:48:54 -05:00
2024-11-10 20:16:38 -05:00
/// This is a password that can be configured that will let you login to the
/// server bot account (currently `@conduit`) for emergency troubleshooting
/// purposes such as recovering/recreating your admin room, or inviting
/// yourself back.
///
/// See https://conduwuit.puppyirl.gay/troubleshooting.html#lost-access-to-admin-room for other ways to get back into your admin room.
///
/// Once this password is unset, all sessions will be logged out for
/// security purposes.
///
/// example: "F670$2CP@Hw8mG7RY1$%!#Ic7YA"
2024-05-09 15:59:08 -07:00
pub emergency_password : Option < String > ,
2024-03-05 19:48:54 -05:00
2024-11-10 20:16:38 -05:00
/// default: "/_matrix/push/v1/notify"
2023-10-28 22:31:11 -04:00
#[ serde(default = " default_notification_push_path " ) ]
2024-05-09 15:59:08 -07:00
pub notification_push_path : String ,
2024-03-05 19:48:54 -05:00
2024-10-05 19:39:27 +00:00
/// Config option to control local (your server only) presence
2024-11-10 20:16:38 -05:00
/// updates/requests. Note that presence on conduwuit is
2024-10-05 19:39:27 +00:00
/// very fast unlike Synapse's. If using outgoing presence, this MUST be
/// enabled.
2024-04-05 00:36:49 -04:00
#[ serde(default = " true_fn " ) ]
2024-05-09 15:59:08 -07:00
pub allow_local_presence : bool ,
2024-10-05 19:39:27 +00:00
/// Config option to control incoming federated presence updates/requests.
2024-11-10 20:16:38 -05:00
///
/// This option receives presence updates from other
2024-10-05 19:39:27 +00:00
/// servers, but does not send any unless `allow_outgoing_presence` is true.
/// Note that presence on conduwuit is very fast unlike Synapse's.
2024-03-30 00:49:14 -04:00
#[ serde(default = " true_fn " ) ]
2024-05-09 15:59:08 -07:00
pub allow_incoming_presence : bool ,
2024-10-05 19:39:27 +00:00
2024-11-10 20:16:38 -05:00
/// Config option to control outgoing presence updates/requests.
///
/// This option sends presence updates to other servers, but does not
2024-10-05 19:39:27 +00:00
/// receive any unless `allow_incoming_presence` is true.
/// Note that presence on conduwuit is very fast unlike Synapse's.
/// If using outgoing presence, you MUST enable `allow_local_presence` as
/// well.
2024-04-05 00:36:49 -04:00
#[ serde(default = " true_fn " ) ]
2024-05-09 15:59:08 -07:00
pub allow_outgoing_presence : bool ,
2024-10-05 19:39:27 +00:00
/// Config option to control how many seconds before presence updates that
/// you are idle. Defaults to 5 minutes.
2024-10-22 10:09:14 +00:00
///
/// default: 300
2023-07-10 16:41:00 +02:00
#[ serde(default = " default_presence_idle_timeout_s " ) ]
2024-05-09 15:59:08 -07:00
pub presence_idle_timeout_s : u64 ,
2024-10-05 19:39:27 +00:00
/// Config option to control how many seconds before presence updates that
/// you are offline. Defaults to 30 minutes.
2024-10-22 10:09:14 +00:00
///
/// default: 1800
2023-07-10 16:41:00 +02:00
#[ serde(default = " default_presence_offline_timeout_s " ) ]
2024-05-09 15:59:08 -07:00
pub presence_offline_timeout_s : u64 ,
2024-10-05 19:39:27 +00:00
/// Config option to enable the presence idle timer for remote users.
/// Disabling is offered as an optimization for servers participating in
/// many large rooms or when resources are limited. Disabling it may cause
/// incorrect presence states (i.e. stuck online) to be seen for some
2024-10-22 10:09:14 +00:00
/// remote users.
2024-04-01 20:48:40 -07:00
#[ serde(default = " true_fn " ) ]
2024-05-09 15:59:08 -07:00
pub presence_timeout_remote_users : bool ,
2024-03-05 19:48:54 -05:00
2024-10-05 19:39:27 +00:00
/// Config option to control whether we should receive remote incoming read
2024-10-22 10:09:14 +00:00
/// receipts.
2024-03-17 12:16:04 -04:00
#[ serde(default = " true_fn " ) ]
2024-05-09 15:59:08 -07:00
pub allow_incoming_read_receipts : bool ,
2024-10-05 19:39:27 +00:00
/// Config option to control whether we should send read receipts to remote
2024-10-22 10:09:14 +00:00
/// servers.
2024-04-10 15:22:50 -07:00
#[ serde(default = " true_fn " ) ]
2024-05-09 15:59:08 -07:00
pub allow_outgoing_read_receipts : bool ,
2024-03-17 12:16:04 -04:00
2024-10-22 10:09:14 +00:00
/// Config option to control outgoing typing updates to federation.
2024-03-29 18:35:02 -07:00
#[ serde(default = " true_fn " ) ]
2024-05-09 15:59:08 -07:00
pub allow_outgoing_typing : bool ,
2024-10-05 19:39:27 +00:00
/// Config option to control incoming typing updates from federation.
2024-03-29 18:35:02 -07:00
#[ serde(default = " true_fn " ) ]
2024-05-09 15:59:08 -07:00
pub allow_incoming_typing : bool ,
2024-10-05 19:39:27 +00:00
/// Config option to control maximum time federation user can indicate
/// typing.
2024-10-22 10:09:14 +00:00
///
/// default: 30
2024-03-29 18:35:02 -07:00
#[ serde(default = " default_typing_federation_timeout_s " ) ]
2024-05-09 15:59:08 -07:00
pub typing_federation_timeout_s : u64 ,
2024-10-05 19:39:27 +00:00
/// Config option to control minimum time local client can indicate typing.
/// This does not override a client's request to stop typing. It only
/// enforces a minimum value in case of no stop request.
2024-10-22 10:09:14 +00:00
///
/// default: 15
2024-03-29 18:35:02 -07:00
#[ serde(default = " default_typing_client_timeout_min_s " ) ]
2024-05-09 15:59:08 -07:00
pub typing_client_timeout_min_s : u64 ,
2024-10-05 19:39:27 +00:00
/// Config option to control maximum time local client can indicate typing.
2024-10-22 10:09:14 +00:00
///
/// default: 45
2024-03-29 18:35:02 -07:00
#[ serde(default = " default_typing_client_timeout_max_s " ) ]
2024-05-09 15:59:08 -07:00
pub typing_client_timeout_max_s : u64 ,
2024-03-29 18:35:02 -07:00
2024-10-05 19:39:27 +00:00
/// Set this to true for conduwuit to compress HTTP response bodies using
/// zstd. This option does nothing if conduwuit was not built with
/// `zstd_compression` feature. Please be aware that enabling HTTP
/// compression may weaken TLS. Most users should not need to enable this.
/// See https://breachattack.com/ and https://wikipedia.org/wiki/BREACH
/// before deciding to enable this.
2023-12-24 00:37:23 -05:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub zstd_compression : bool ,
2024-10-05 19:39:27 +00:00
/// Set this to true for conduwuit to compress HTTP response bodies using
/// gzip. This option does nothing if conduwuit was not built with
/// `gzip_compression` feature. Please be aware that enabling HTTP
/// compression may weaken TLS. Most users should not need to enable this.
/// See https://breachattack.com/ and https://wikipedia.org/wiki/BREACH before
/// deciding to enable this.
2024-11-10 20:16:38 -05:00
///
/// If you are in a large amount of rooms, you may find that enabling this
/// is necessary to reduce the significantly large response bodies.
2024-03-30 00:47:26 -04:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub gzip_compression : bool ,
2024-10-05 19:39:27 +00:00
/// Set this to true for conduwuit to compress HTTP response bodies using
/// brotli. This option does nothing if conduwuit was not built with
/// `brotli_compression` feature. Please be aware that enabling HTTP
/// compression may weaken TLS. Most users should not need to enable this.
/// See https://breachattack.com/ and https://wikipedia.org/wiki/BREACH before
/// deciding to enable this.
2024-03-30 00:47:26 -04:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub brotli_compression : bool ,
2024-03-05 19:48:54 -05:00
2024-11-10 20:16:38 -05:00
/// Set to true to allow user type "guest" registrations. Some clients like
/// Element attempt to register guest users automatically.
2023-12-24 00:37:23 -05:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub allow_guest_registration : bool ,
2024-10-05 19:39:27 +00:00
2024-11-10 20:16:38 -05:00
/// Set to true to log guest registrations in the admin room. Note that
/// these may be noisy or unnecessary if you're a public homeserver.
2024-04-13 20:19:10 -04:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub log_guest_registrations : bool ,
2024-10-05 19:39:27 +00:00
/// Set to true to allow guest registrations/users to auto join any rooms
2024-11-10 20:16:38 -05:00
/// specified in `auto_join_rooms`.
2024-04-13 20:33:24 -04:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub allow_guests_auto_join_rooms : bool ,
2024-03-05 19:48:54 -05:00
2024-10-05 19:39:27 +00:00
/// Config option to control whether the legacy unauthenticated Matrix media
/// repository endpoints will be enabled. These endpoints consist of:
/// - /_matrix/media/*/config
/// - /_matrix/media/*/upload
/// - /_matrix/media/*/preview_url
/// - /_matrix/media/*/download/*
/// - /_matrix/media/*/thumbnail/*
///
/// The authenticated equivalent endpoints are always enabled.
///
/// Defaults to true for now, but this is highly subject to change, likely
/// in the next release.
2024-08-27 03:35:00 +00:00
#[ serde(default = " true_fn " ) ]
pub allow_legacy_media : bool ,
2024-10-05 19:39:27 +00:00
2024-06-23 20:48:40 +00:00
#[ serde(default = " true_fn " ) ]
2024-08-28 09:16:41 +00:00
pub freeze_legacy_media : bool ,
2024-10-05 19:39:27 +00:00
/// Checks consistency of the media directory at startup:
/// 1. When `media_compat_file_link` is enbled, this check will upgrade
2024-11-10 20:16:38 -05:00
/// media when switching back and forth between Conduit and conduwuit.
2024-10-05 19:39:27 +00:00
/// Both options must be enabled to handle this.
/// 2. When media is deleted from the directory, this check will also delete
/// its database entry.
///
/// If none of these checks apply to your use cases, and your media
/// directory is significantly large setting this to false may reduce
/// startup time.
2024-08-28 09:16:41 +00:00
#[ serde(default = " true_fn " ) ]
2024-06-23 20:48:40 +00:00
pub media_startup_check : bool ,
2024-10-05 19:39:27 +00:00
/// Enable backward-compatibility with Conduit's media directory by creating
/// symlinks of media. This option is only necessary if you plan on using
/// Conduit again. Otherwise setting this to false reduces filesystem
/// clutter and overhead for managing these symlinks in the directory. This
/// is now disabled by default. You may still return to upstream Conduit
2024-11-10 20:16:38 -05:00
/// but you have to run conduwuit at least once with this set to true and
2024-10-05 19:39:27 +00:00
/// allow the media_startup_check to take place before shutting
2024-11-10 20:16:38 -05:00
/// down to return to Conduit.
2024-07-30 02:06:15 +00:00
#[ serde(default) ]
2024-06-23 20:48:40 +00:00
pub media_compat_file_link : bool ,
2024-10-05 19:39:27 +00:00
/// Prunes missing media from the database as part of the media startup
/// checks. This means if you delete files from the media directory the
/// corresponding entries will be removed from the database. This is
/// disabled by default because if the media directory is accidentally moved
2024-11-10 20:16:38 -05:00
/// or inaccessible, the metadata entries in the database will be lost with
/// sadness.
2024-08-27 01:46:09 +00:00
#[ serde(default) ]
pub prune_missing_media : bool ,
2024-10-05 19:39:27 +00:00
/// Vector list of servers that conduwuit will refuse to download remote
2024-11-10 20:16:38 -05:00
/// media from.
///
/// default: []
#[ serde(default) ]
2024-10-22 06:21:57 +00:00
pub prevent_media_downloads_from : HashSet < OwnedServerName > ,
2024-06-23 20:48:40 +00:00
2024-10-05 19:39:27 +00:00
/// List of forbidden server names that we will block incoming AND outgoing
/// federation with, and block client room joins / remote user invites.
///
/// This check is applied on the room ID, room alias, sender server name,
/// sender user's server name, inbound federation X-Matrix origin, and
/// outbound federation handler.
///
2024-11-10 20:16:38 -05:00
/// Basically "global" ACLs.
///
/// default: []
#[ serde(default) ]
2024-10-22 06:21:57 +00:00
pub forbidden_remote_server_names : HashSet < OwnedServerName > ,
2024-10-05 19:39:27 +00:00
/// List of forbidden server names that we will block all outgoing federated
/// room directory requests for. Useful for preventing our users from
2024-11-10 20:16:38 -05:00
/// wandering into bad servers or spaces.
///
/// default: []
2024-10-22 06:21:57 +00:00
#[ serde(default = " HashSet::new " ) ]
pub forbidden_remote_room_directory_server_names : HashSet < OwnedServerName > ,
2024-03-05 19:48:54 -05:00
2024-10-05 19:39:27 +00:00
/// Vector list of IPv4 and IPv6 CIDR ranges / subnets *in quotes* that you
/// do not want conduwuit to send outbound requests to. Defaults to
/// RFC1918, unroutable, loopback, multicast, and testnet addresses for
/// security.
///
/// Please be aware that this is *not* a guarantee. You should be using a
/// firewall with zones as doing this on the application layer may have
/// bypasses.
///
/// Currently this does not account for proxies in use like Synapse does.
2024-10-22 10:09:14 +00:00
///
/// To disable, set this to be an empty vector (`[]`).
2024-11-10 20:16:38 -05:00
///
/// default: ["127.0.0.0/8", "10.0.0.0/8", "172.16.0.0/12",
/// "192.168.0.0/16", "100.64.0.0/10", "192.0.0.0/24", "169.254.0.0/16",
/// "192.88.99.0/24", "198.18.0.0/15", "192.0.2.0/24", "198.51.100.0/24",
/// "203.0.113.0/24", "224.0.0.0/4", "::1/128", "fe80::/10", "fc00::/7",
/// "2001:db8::/32", "ff00::/8", "fec0::/10"]
2024-01-21 22:59:06 -05:00
#[ serde(default = " default_ip_range_denylist " ) ]
2024-05-09 15:59:08 -07:00
pub ip_range_denylist : Vec < String > ,
2024-03-05 19:48:54 -05:00
2024-10-05 19:39:27 +00:00
/// Vector list of domains allowed to send requests to for URL previews.
/// Defaults to none. Note: this is a *contains* match, not an explicit
/// match. Putting "google.com" will match "https://google.com" and
/// "http://mymaliciousdomainexamplegoogle.com" Setting this to "*" will
/// allow all URL previews. Please note that this opens up significant
/// attack surface to your server, you are expected to be aware of the
/// risks by doing so.
2024-11-10 20:16:38 -05:00
///
/// default: []
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub url_preview_domain_contains_allowlist : Vec < String > ,
2024-10-05 19:39:27 +00:00
/// Vector list of explicit domains allowed to send requests to for URL
/// previews. Defaults to none. Note: This is an *explicit* match, not a
/// contains match. Putting "google.com" will match "https://google.com",
/// "http://google.com", but not
/// "https://mymaliciousdomainexamplegoogle.com". Setting this to "*" will
/// allow all URL previews. Please note that this opens up significant
/// attack surface to your server, you are expected to be aware of the
/// risks by doing so.
2024-11-10 20:16:38 -05:00
///
/// default: []
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub url_preview_domain_explicit_allowlist : Vec < String > ,
2024-10-05 19:39:27 +00:00
/// Vector list of explicit domains not allowed to send requests to for URL
/// previews. Defaults to none. Note: This is an *explicit* match, not a
/// contains match. Putting "google.com" will match "https://google.com",
/// "http://google.com", but not
/// "https://mymaliciousdomainexamplegoogle.com". The denylist is checked
/// first before allowlist. Setting this to "*" will not do anything.
2024-11-10 20:16:38 -05:00
///
/// default: []
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub url_preview_domain_explicit_denylist : Vec < String > ,
2024-10-05 19:39:27 +00:00
/// Vector list of URLs allowed to send requests to for URL previews.
/// Defaults to none. Note that this is a *contains* match, not an
/// explicit match. Putting "google.com" will match
/// "https://google.com/",
/// "https://google.com/url?q=https://mymaliciousdomainexample.com", and
/// "https://mymaliciousdomainexample.com/hi/google.com" Setting this to
/// "*" will allow all URL previews. Please note that this opens up
/// significant attack surface to your server, you are expected to be
/// aware of the risks by doing so.
2024-11-10 20:16:38 -05:00
///
/// default: []
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub url_preview_url_contains_allowlist : Vec < String > ,
2024-10-05 19:39:27 +00:00
/// Maximum amount of bytes allowed in a URL preview body size when
2024-11-10 20:16:38 -05:00
/// spidering. Defaults to 384KB in bytes.
2024-10-22 10:09:14 +00:00
///
2024-11-10 20:16:38 -05:00
/// default: 384000
2024-02-10 13:29:12 -05:00
#[ serde(default = " default_url_preview_max_spider_size " ) ]
2024-05-09 15:59:08 -07:00
pub url_preview_max_spider_size : usize ,
2024-10-05 19:39:27 +00:00
/// Option to decide whether you would like to run the domain allowlist
/// checks (contains and explicit) on the root domain or not. Does not apply
2024-11-10 20:16:38 -05:00
/// to URL contains allowlist. Defaults to false.
///
/// Example usecase: If this is
2024-10-05 19:39:27 +00:00
/// enabled and you have "wikipedia.org" allowed in the explicit and/or
/// contains domain allowlist, it will allow all subdomains under
/// "wikipedia.org" such as "en.m.wikipedia.org" as the root domain is
/// checked and matched. Useful if the domain contains allowlist is still
/// too broad for you but you still want to allow all the subdomains under a
/// root domain.
2024-02-11 11:42:55 -05:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub url_preview_check_root_domain : bool ,
2024-03-05 19:48:54 -05:00
2024-11-10 20:16:38 -05:00
/// List of forbidden room aliases and room IDs as strings of regex
/// patterns.
///
/// Regex can be used or explicit contains matches can be done by
/// just specifying the words (see example).
///
/// This is checked upon room alias creation, custom room ID creation if
/// used, and startup as warnings if any room aliases in your database have
/// a forbidden room alias/ID.
///
/// example: ["19dollarfortnitecards", "b[4a]droom"]
///
/// default: []
#[ serde(default) ]
2024-02-08 19:11:48 -05:00
#[ serde(with = " serde_regex " ) ]
2024-05-09 15:59:08 -07:00
pub forbidden_alias_names : RegexSet ,
2024-03-05 19:48:54 -05:00
2024-11-10 20:16:38 -05:00
/// List of forbidden username patterns/strings.
///
/// Regex can be used or explicit contains matches can be done by just
/// specifying the words (see example).
///
/// This is checked upon username availability check, registration, and
/// startup as warnings if any local users in your database have a forbidden
/// username.
///
/// example: ["administrator", "b[a4]dusernam[3e]"]
///
/// default: []
#[ serde(default) ]
2024-02-08 19:11:48 -05:00
#[ serde(with = " serde_regex " ) ]
2024-05-09 15:59:08 -07:00
pub forbidden_usernames : RegexSet ,
2024-03-05 19:48:54 -05:00
2024-10-05 19:39:27 +00:00
/// Retry failed and incomplete messages to remote servers immediately upon
/// startup. This is called bursting. If this is disabled, said messages
/// may not be delivered until more messages are queued for that server. Do
/// not change this option unless server resources are extremely limited or
/// the scale of the server's deployment is huge. Do not disable this
/// unless you know what you are doing.
2024-03-29 16:39:48 -04:00
#[ serde(default = " true_fn " ) ]
2024-05-09 15:59:08 -07:00
pub startup_netburst : bool ,
2024-10-05 19:39:27 +00:00
/// messages are dropped and not reattempted. The `startup_netburst` option
/// must be enabled for this value to have any effect. Do not change this
/// value unless you know what you are doing. Set this value to -1 to
/// reattempt every message without trimming the queues; this may consume
/// significant disk. Set this value to 0 to drop all messages without any
/// attempt at redelivery.
2024-10-22 10:09:14 +00:00
///
/// default: 50
2024-03-31 19:01:20 -07:00
#[ serde(default = " default_startup_netburst_keep " ) ]
2024-05-09 15:59:08 -07:00
pub startup_netburst_keep : i64 ,
2024-03-27 14:47:21 -07:00
2024-10-05 19:39:27 +00:00
/// controls whether non-admin local users are forbidden from sending room
/// invites (local and remote), and if non-admin users can receive remote
/// room invites. admins are always allowed to send and receive all room
2024-10-22 10:09:14 +00:00
/// invites.
2024-03-02 21:45:08 -05:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub block_non_admin_invites : bool ,
2024-10-05 19:39:27 +00:00
2024-11-10 20:16:38 -05:00
/// Allows admins to enter commands in rooms other than "#admins" (admin
/// room) by prefixing your message with "\!admin" or "\\!admin" followed
/// up a normal conduwuit admin command. The reply will be publicly visible
/// to the room, originating from the sender.
///
/// example: \\!admin debug ping puppygock.gay
2024-06-13 22:22:21 +00:00
#[ serde(default = " true_fn " ) ]
pub admin_escape_commands : bool ,
2024-10-05 19:39:27 +00:00
/// Controls whether the conduwuit admin room console / CLI will immediately
/// activate on startup. This option can also be enabled with `--console`
2024-10-22 10:09:14 +00:00
/// conduwuit argument.
2024-07-22 21:21:44 +00:00
#[ serde(default) ]
pub admin_console_automatic : bool ,
2024-10-05 19:39:27 +00:00
/// Controls what admin commands will be executed on startup. This is a
/// vector list of strings of admin commands to run.
///
///
/// This option can also be configured with the `--execute` conduwuit
/// argument and can take standard shell commands and environment variables
///
/// Such example could be: `./conduwuit --execute "server admin-notice
/// conduwuit has started up at $(date)"`
///
2024-11-10 20:16:38 -05:00
/// example: admin_execute = ["debug ping puppygock.gay", "debug echo hi"]`
///
2024-10-22 10:09:14 +00:00
/// default: []
2024-08-11 23:07:58 +00:00
#[ serde(default) ]
pub admin_execute : Vec < String > ,
2024-10-05 19:39:27 +00:00
/// Controls whether conduwuit should error and fail to start if an admin
2024-10-22 10:09:14 +00:00
/// execute command (`--execute` / `admin_execute`) fails.
2024-08-28 04:09:46 +00:00
#[ serde(default) ]
pub admin_execute_errors_ignore : bool ,
2024-10-05 19:39:27 +00:00
/// Controls the max log level for admin command log captures (logs
2024-10-22 10:09:14 +00:00
/// generated from running admin commands). Defaults to "info" on release
/// builds, else "debug" on debug builds.
2024-10-05 19:39:27 +00:00
///
2024-10-22 10:09:14 +00:00
/// default: "info"
2024-08-17 03:40:05 +00:00
#[ serde(default = " default_admin_log_capture " ) ]
pub admin_log_capture : String ,
2024-10-05 19:39:27 +00:00
2024-11-10 20:16:38 -05:00
/// The default room tag to apply on the admin room.
///
/// On some clients like Element, the room tag "m.server_notice" is a
/// special pinned room at the very bottom of your room list. The conduwuit
/// admin room can be pinned here so you always have an easy-to-access
/// shortcut dedicated to your admin room.
///
/// default: "m.server_notice"
2024-08-28 07:05:13 +00:00
#[ serde(default = " default_admin_room_tag " ) ]
pub admin_room_tag : String ,
2024-03-05 19:48:54 -05:00
2024-10-05 19:39:27 +00:00
/// Sentry.io crash/panic reporting, performance monitoring/metrics, etc.
/// This is NOT enabled by default. conduwuit's default Sentry reporting
/// endpoint is o4506996327251968.ingest.us.sentry.io
2024-03-29 18:21:17 -04:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub sentry : bool ,
2024-10-05 19:39:27 +00:00
/// Sentry reporting URL if a custom one is desired
///
2024-11-10 20:16:38 -05:00
/// default: "https://fe2eb4536aa04949e28eff3128d64757@o4506996327251968.ingest.us.sentry.io/4506996334657536"
2024-04-24 02:19:50 -04:00
#[ serde(default = " default_sentry_endpoint " ) ]
2024-05-09 15:59:08 -07:00
pub sentry_endpoint : Option < Url > ,
2024-10-05 19:39:27 +00:00
2024-11-10 20:16:38 -05:00
/// Report your conduwuit server_name in Sentry.io crash reports and metrics
2024-03-29 18:21:17 -04:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub sentry_send_server_name : bool ,
2024-10-05 19:39:27 +00:00
/// Performance monitoring/tracing sample rate for Sentry.io
///
/// Note that too high values may impact performance, and can be disabled by
/// setting it to 0.0 (0%) This value is read as a percentage to Sentry,
2024-10-22 10:09:14 +00:00
/// represented as a decimal. Defaults to 15% of traces (0.15)
2024-10-05 19:39:27 +00:00
///
2024-10-22 10:09:14 +00:00
/// default: 0.15
2024-03-29 19:59:02 -04:00
#[ serde(default = " default_sentry_traces_sample_rate " ) ]
2024-05-09 15:59:08 -07:00
pub sentry_traces_sample_rate : f32 ,
2024-10-05 19:39:27 +00:00
/// Whether to attach a stacktrace to Sentry reports.
2024-07-10 20:27:17 +00:00
#[ serde(default) ]
pub sentry_attach_stacktrace : bool ,
2024-10-05 19:39:27 +00:00
/// Send panics to sentry. This is true by default, but sentry has to be
2024-11-10 20:16:38 -05:00
/// enabled. The global "sentry" config option must be enabled to send any
/// data.
2024-07-11 02:04:21 +00:00
#[ serde(default = " true_fn " ) ]
pub sentry_send_panic : bool ,
2024-10-05 19:39:27 +00:00
/// Send errors to sentry. This is true by default, but sentry has to be
/// enabled. This option is only effective in release-mode; forced to false
/// in debug-mode.
2024-07-11 02:04:21 +00:00
#[ serde(default = " true_fn " ) ]
pub sentry_send_error : bool ,
2024-10-05 19:39:27 +00:00
/// Controls the tracing log level for Sentry to send things like
2024-11-10 20:16:38 -05:00
/// breadcrumbs and transactions
///
/// default: "info"
2024-07-11 05:03:41 +00:00
#[ serde(default = " default_sentry_filter " ) ]
pub sentry_filter : String ,
2024-03-29 18:21:17 -04:00
2024-10-05 19:39:27 +00:00
/// Enable the tokio-console. This option is only relevant to developers.
2024-11-10 20:16:38 -05:00
/// See https://conduwuit.puppyirl.gay/development.html#debugging-with-tokio-console for more information.
2024-06-26 23:00:33 +00:00
#[ serde(default) ]
pub tokio_console : bool ,
2024-08-26 21:29:00 +00:00
#[ serde(default) ]
pub test : BTreeSet < String > ,
2024-10-24 22:19:18 -04:00
/// Controls whether admin room notices like account registrations, password
/// changes, account deactivations, room directory publications, etc will
/// be sent to the admin room. Update notices and normal admin command
/// responses will still be sent.
#[ serde(default = " true_fn " ) ]
pub admin_room_notices : bool ,
2024-11-28 06:52:23 +00:00
/// Sets the number of worker threads in the frontend-pool of the database.
/// This number should reflect the I/O capabilities of the system,
/// specifically the queue-depth or the number of simultaneous requests in
2024-12-04 01:23:36 +00:00
/// flight. Defaults to 32 or four times the number of CPU cores, whichever
/// is greater.
2024-11-28 06:52:23 +00:00
/// default: 32
#[ serde(default = " default_db_pool_workers " ) ]
pub db_pool_workers : usize ,
/// Size of the queue feeding the database's frontend-pool. Defaults to 256
/// or eight times the number of CPU cores, whichever is greater.
/// default: 256
#[ serde(default = " default_db_pool_queue_size " ) ]
pub db_pool_queue_size : usize ,
2022-02-03 13:30:04 +01:00
#[ serde(flatten) ]
2024-03-22 23:42:22 -04:00
#[ allow(clippy::zero_sized_map_values) ] // this is a catchall, the map shouldn't be zero at runtime
2024-04-22 23:48:57 -04:00
catchall : BTreeMap < String , IgnoredAny > ,
2022-02-03 13:30:04 +01:00
}
2024-11-24 00:19:55 +00:00
#[ derive(Clone, Debug, Deserialize, Default) ]
2024-10-22 22:16:59 +00:00
#[ config_example_generator(filename = " conduwuit-example.toml " , section = " global.tls " ) ]
2024-05-09 15:59:08 -07:00
pub struct TlsConfig {
2024-11-10 20:16:38 -05:00
/// Path to a valid TLS certificate file.
///
/// example: "/path/to/my/certificate.crt"
2024-11-24 00:19:55 +00:00
pub certs : Option < String > ,
2024-11-10 20:16:38 -05:00
/// Path to a valid TLS certificate private key.
///
/// example: "/path/to/my/certificate.key"
2024-11-24 00:19:55 +00:00
pub key : Option < String > ,
2024-02-24 17:25:43 -05:00
/// Whether to listen and allow for HTTP and HTTPS connections (insecure!)
2024-11-10 20:16:38 -05:00
#[ serde(default) ]
2024-05-09 15:59:08 -07:00
pub dual_protocol : bool ,
2022-01-22 18:38:39 +01:00
}
2024-11-21 23:49:46 -05:00
#[ allow(rustdoc::broken_intra_doc_links, rustdoc::bare_urls) ]
2024-04-11 21:50:40 -04:00
#[ derive(Clone, Debug, Deserialize, Default) ]
2024-10-22 22:16:59 +00:00
#[ config_example_generator(filename = " conduwuit-example.toml " , section = " global.well_known " ) ]
2024-05-09 15:59:08 -07:00
pub struct WellKnownConfig {
2024-11-24 00:19:55 +00:00
/// The server URL that the client well-known file will serve. This should
/// not contain a port, and should just be a valid HTTPS URL.
///
/// example: "https://matrix.example.com"
pub client : Option < Url > ,
2024-11-10 20:16:38 -05:00
/// The server base domain of the URL with a specific port that the server
/// well-known file will serve. This should contain a port at the end, and
/// should not be a URL.
///
/// example: "matrix.example.com:443"
2024-05-09 15:59:08 -07:00
pub server : Option < OwnedServerName > ,
2024-11-24 00:19:55 +00:00
2024-05-09 15:59:08 -07:00
pub support_page : Option < Url > ,
2024-11-24 00:19:55 +00:00
2024-05-09 15:59:08 -07:00
pub support_role : Option < ContactRole > ,
2024-11-24 00:19:55 +00:00
2024-05-09 15:59:08 -07:00
pub support_email : Option < String > ,
2024-11-24 00:19:55 +00:00
2024-05-09 15:59:08 -07:00
pub support_mxid : Option < OwnedUserId > ,
2024-04-11 20:17:30 -04:00
}
2024-07-13 01:24:37 +00:00
#[ derive(Deserialize, Clone, Debug) ]
#[ serde(transparent) ]
struct ListeningPort {
#[ serde(with = " either::serde_untagged " ) ]
ports : Either < u16 , Vec < u16 > > ,
}
#[ derive(Deserialize, Clone, Debug) ]
#[ serde(transparent) ]
struct ListeningAddr {
#[ serde(with = " either::serde_untagged " ) ]
addrs : Either < IpAddr , Vec < IpAddr > > ,
}
2024-07-13 16:46:13 -04:00
const DEPRECATED_KEYS : & [ & str ; 9 ] = & [
2024-04-11 20:17:30 -04:00
" cache_capacity " ,
2024-07-13 16:46:13 -04:00
" conduit_cache_capacity_modifier " ,
2024-05-02 20:55:37 -04:00
" max_concurrent_requests " ,
2024-04-11 20:17:30 -04:00
" well_known_client " ,
" well_known_server " ,
" well_known_support_page " ,
" well_known_support_role " ,
" well_known_support_email " ,
" well_known_support_mxid " ,
] ;
2022-02-03 13:30:04 +01:00
impl Config {
2024-07-25 02:59:54 +00:00
/// Pre-initialize config
2024-10-04 19:10:20 +00:00
pub fn load ( paths : Option < & [ PathBuf ] > ) -> Result < Figment > {
let paths_files = paths . into_iter ( ) . flatten ( ) . map ( Toml ::file ) ;
2024-09-20 16:22:29 -04:00
2024-10-04 19:10:20 +00:00
let envs = [ Env ::var ( " CONDUIT_CONFIG " ) , Env ::var ( " CONDUWUIT_CONFIG " ) ] ;
let envs_files = envs . into_iter ( ) . flatten ( ) . map ( Toml ::file ) ;
2024-04-03 20:33:47 -07:00
2024-10-04 19:10:20 +00:00
let config = envs_files
. chain ( paths_files )
. fold ( Figment ::new ( ) , | config , file | config . merge ( file . nested ( ) ) )
2024-09-20 16:22:29 -04:00
. merge ( Env ::prefixed ( " CONDUIT_ " ) . global ( ) . split ( " __ " ) )
2024-10-04 19:10:20 +00:00
. merge ( Env ::prefixed ( " CONDUWUIT_ " ) . global ( ) . split ( " __ " ) ) ;
Ok ( config )
2024-07-25 02:59:54 +00:00
}
/// Finalize config
pub fn new ( raw_config : & Figment ) -> Result < Self > {
2024-10-04 19:10:20 +00:00
let config = raw_config
. extract ::< Self > ( )
. map_err ( | e | err! ( " There was a problem with your configuration file: {e} " ) ) ? ;
2024-04-03 20:33:47 -07:00
// don't start if we're listening on both UNIX sockets and TCP at same time
2024-07-25 02:59:54 +00:00
check ::is_dual_listening ( raw_config ) ? ;
2024-04-03 20:33:47 -07:00
Ok ( config )
}
#[ must_use ]
2024-05-09 15:59:08 -07:00
pub fn get_bind_addrs ( & self ) -> Vec < SocketAddr > {
2024-09-20 23:34:49 -04:00
let mut addrs = Vec ::with_capacity (
self . get_bind_hosts ( )
. len ( )
. saturating_add ( self . get_bind_ports ( ) . len ( ) ) ,
) ;
2024-06-02 22:36:00 +00:00
for host in & self . get_bind_hosts ( ) {
for port in & self . get_bind_ports ( ) {
addrs . push ( SocketAddr ::new ( * host , * port ) ) ;
}
}
addrs
}
fn get_bind_hosts ( & self ) -> Vec < IpAddr > {
match & self . address . addrs {
Left ( addr ) = > vec! [ * addr ] ,
Right ( addrs ) = > addrs . clone ( ) ,
}
}
fn get_bind_ports ( & self ) -> Vec < u16 > {
2024-04-03 20:33:47 -07:00
match & self . port . ports {
2024-06-02 22:36:00 +00:00
Left ( port ) = > vec! [ * port ] ,
Right ( ports ) = > ports . clone ( ) ,
2024-04-03 20:33:47 -07:00
}
}
2024-04-20 23:01:41 -04:00
2024-05-09 15:59:08 -07:00
pub fn check ( & self ) -> Result < ( ) , Error > { check ( self ) }
2022-02-03 13:30:04 +01:00
}
2022-02-06 20:23:22 +01:00
impl fmt ::Display for Config {
fn fmt ( & self , f : & mut fmt ::Formatter < '_ > ) -> fmt ::Result {
2024-10-27 13:21:16 -04:00
writeln! ( f , " Active config values: \n " ) . expect ( " wrote line to formatter stream " ) ;
2024-07-11 02:22:37 +00:00
let mut line = | key : & str , val : & str | {
writeln! ( f , " {key}: {val} " ) . expect ( " wrote line to formatter stream " ) ;
} ;
2024-03-05 19:48:54 -05:00
2024-07-11 02:22:37 +00:00
line ( " Server name " , self . server_name . host ( ) ) ;
line ( " Database path " , & self . database_path . to_string_lossy ( ) ) ;
line (
" Database backup path " ,
self . database_backup_path
. as_ref ( )
. map_or ( " " , | path | path . to_str ( ) . unwrap_or ( " " ) ) ,
) ;
line ( " Database backups to keep " , & self . database_backups_to_keep . to_string ( ) ) ;
line ( " Database cache capacity (MB) " , & self . db_cache_capacity_mb . to_string ( ) ) ;
2024-07-13 16:46:13 -04:00
line ( " Cache capacity modifier " , & self . cache_capacity_modifier . to_string ( ) ) ;
2024-07-11 02:22:37 +00:00
line ( " PDU cache capacity " , & self . pdu_cache_capacity . to_string ( ) ) ;
line ( " Auth chain cache capacity " , & self . auth_chain_cache_capacity . to_string ( ) ) ;
line ( " Short eventid cache capacity " , & self . shorteventid_cache_capacity . to_string ( ) ) ;
line ( " Eventid short cache capacity " , & self . eventidshort_cache_capacity . to_string ( ) ) ;
line ( " Short statekey cache capacity " , & self . shortstatekey_cache_capacity . to_string ( ) ) ;
line ( " Statekey short cache capacity " , & self . statekeyshort_cache_capacity . to_string ( ) ) ;
line (
" Server visibility cache capacity " ,
& self . server_visibility_cache_capacity . to_string ( ) ,
) ;
line (
" User visibility cache capacity " ,
& self . user_visibility_cache_capacity . to_string ( ) ,
) ;
line ( " Stateinfo cache capacity " , & self . stateinfo_cache_capacity . to_string ( ) ) ;
line (
" Roomid space hierarchy cache capacity " ,
& self . roomid_spacehierarchy_cache_capacity . to_string ( ) ,
) ;
line ( " DNS cache entry limit " , & self . dns_cache_entries . to_string ( ) ) ;
line ( " DNS minimum TTL " , & self . dns_min_ttl . to_string ( ) ) ;
line ( " DNS minimum NXDOMAIN TTL " , & self . dns_min_ttl_nxdomain . to_string ( ) ) ;
line ( " DNS attempts " , & self . dns_attempts . to_string ( ) ) ;
line ( " DNS timeout " , & self . dns_timeout . to_string ( ) ) ;
line ( " DNS fallback to TCP " , & self . dns_tcp_fallback . to_string ( ) ) ;
line ( " DNS query over TCP only " , & self . query_over_tcp_only . to_string ( ) ) ;
line ( " Query all nameservers " , & self . query_all_nameservers . to_string ( ) ) ;
line ( " Maximum request size (bytes) " , & self . max_request_size . to_string ( ) ) ;
line ( " Sender retry backoff limit " , & self . sender_retry_backoff_limit . to_string ( ) ) ;
line ( " Request connect timeout " , & self . request_conn_timeout . to_string ( ) ) ;
line ( " Request timeout " , & self . request_timeout . to_string ( ) ) ;
line ( " Request total timeout " , & self . request_total_timeout . to_string ( ) ) ;
line ( " Idle connections per host " , & self . request_idle_per_host . to_string ( ) ) ;
line ( " Request pool idle timeout " , & self . request_idle_timeout . to_string ( ) ) ;
line ( " Well_known connect timeout " , & self . well_known_conn_timeout . to_string ( ) ) ;
line ( " Well_known timeout " , & self . well_known_timeout . to_string ( ) ) ;
line ( " Federation timeout " , & self . federation_timeout . to_string ( ) ) ;
line ( " Federation pool idle per host " , & self . federation_idle_per_host . to_string ( ) ) ;
line ( " Federation pool idle timeout " , & self . federation_idle_timeout . to_string ( ) ) ;
line ( " Sender timeout " , & self . sender_timeout . to_string ( ) ) ;
line ( " Sender pool idle timeout " , & self . sender_idle_timeout . to_string ( ) ) ;
line ( " Appservice timeout " , & self . appservice_timeout . to_string ( ) ) ;
line ( " Appservice pool idle timeout " , & self . appservice_idle_timeout . to_string ( ) ) ;
line ( " Pusher pool idle timeout " , & self . pusher_idle_timeout . to_string ( ) ) ;
line ( " Allow registration " , & self . allow_registration . to_string ( ) ) ;
line (
" Registration token " ,
2024-09-29 01:54:07 -04:00
if self . registration_token . is_none ( ) & & self . registration_token_file . is_none ( ) & & self . allow_registration {
" not set (⚠️ open registration!) "
} else if self . registration_token . is_none ( ) & & self . registration_token_file . is_none ( ) {
" not set "
2024-07-11 02:22:37 +00:00
} else {
2024-09-29 01:54:07 -04:00
" set "
2024-07-11 02:22:37 +00:00
} ,
) ;
2024-09-29 01:54:07 -04:00
line (
" Registration token file path " ,
self . registration_token_file
. as_ref ( )
. map_or ( " " , | path | path . to_str ( ) . unwrap_or_default ( ) ) ,
) ;
2024-07-11 02:22:37 +00:00
line (
" Allow guest registration (inherently false if allow registration is false) " ,
& self . allow_guest_registration . to_string ( ) ,
) ;
line (
" Log guest registrations in admin room " ,
& self . log_guest_registrations . to_string ( ) ,
) ;
line (
" Allow guests to auto join rooms " ,
& self . allow_guests_auto_join_rooms . to_string ( ) ,
) ;
line ( " New user display name suffix " , & self . new_user_displayname_suffix ) ;
line ( " Allow encryption " , & self . allow_encryption . to_string ( ) ) ;
line ( " Allow federation " , & self . allow_federation . to_string ( ) ) ;
2024-08-17 03:39:09 +00:00
line ( " Federation loopback " , & self . federation_loopback . to_string ( ) ) ;
2024-10-27 12:37:44 -04:00
line (
" Require authentication for profile requests " ,
& self . require_auth_for_profile_requests . to_string ( ) ,
) ;
2024-07-11 02:22:37 +00:00
line (
" Allow incoming federated presence requests (updates) " ,
& self . allow_incoming_presence . to_string ( ) ,
) ;
line (
" Allow outgoing federated presence requests (updates) " ,
& self . allow_outgoing_presence . to_string ( ) ,
) ;
line (
" Allow local presence requests (updates) " ,
& self . allow_local_presence . to_string ( ) ,
) ;
line (
" Allow incoming remote read receipts " ,
& self . allow_incoming_read_receipts . to_string ( ) ,
) ;
line (
" Allow outgoing remote read receipts " ,
& self . allow_outgoing_read_receipts . to_string ( ) ,
) ;
line (
" Block non-admin room invites (local and remote, admins can still send and receive invites) " ,
& self . block_non_admin_invites . to_string ( ) ,
) ;
line ( " Enable admin escape commands " , & self . admin_escape_commands . to_string ( ) ) ;
2024-07-22 21:21:44 +00:00
line (
" Activate admin console after startup " ,
& self . admin_console_automatic . to_string ( ) ,
) ;
2024-08-11 23:07:58 +00:00
line ( " Execute admin commands after startup " , & self . admin_execute . join ( " , " ) ) ;
2024-08-28 04:09:46 +00:00
line (
" Continue startup even if some commands fail " ,
& self . admin_execute_errors_ignore . to_string ( ) ,
) ;
2024-08-17 03:40:05 +00:00
line ( " Filter for admin command log capture " , & self . admin_log_capture ) ;
2024-08-28 07:05:13 +00:00
line ( " Admin room tag " , & self . admin_room_tag ) ;
2024-07-11 02:22:37 +00:00
line ( " Allow outgoing federated typing " , & self . allow_outgoing_typing . to_string ( ) ) ;
line ( " Allow incoming federated typing " , & self . allow_incoming_typing . to_string ( ) ) ;
line (
" Incoming federated typing timeout " ,
& self . typing_federation_timeout_s . to_string ( ) ,
) ;
line ( " Client typing timeout minimum " , & self . typing_client_timeout_min_s . to_string ( ) ) ;
line ( " Client typing timeout maxmimum " , & self . typing_client_timeout_max_s . to_string ( ) ) ;
line ( " Allow device name federation " , & self . allow_device_name_federation . to_string ( ) ) ;
line (
" Allow incoming profile lookup federation requests " ,
2024-10-27 12:37:44 -04:00
& self
. allow_inbound_profile_lookup_federation_requests
. to_string ( ) ,
2024-07-11 02:22:37 +00:00
) ;
line (
" Auto deactivate banned room join attempts " ,
& self . auto_deactivate_banned_room_attempts . to_string ( ) ,
) ;
line ( " Notification push path " , & self . notification_push_path ) ;
line ( " Allow room creation " , & self . allow_room_creation . to_string ( ) ) ;
line (
" Allow public room directory over federation " ,
& self . allow_public_room_directory_over_federation . to_string ( ) ,
) ;
line (
" Allow public room directory without authentication " ,
& self . allow_public_room_directory_without_auth . to_string ( ) ,
) ;
line (
" Lockdown public room directory (only allow admins to publish) " ,
& self . lockdown_public_room_directory . to_string ( ) ,
) ;
line (
" JWT secret " ,
match self . jwt_secret {
Some ( _ ) = > " set " ,
None = > " not set " ,
} ,
) ;
line (
" Trusted key servers " ,
& self
. trusted_servers
. iter ( )
. map ( | server | server . host ( ) )
. join ( " , " ) ,
) ;
line ( " OpenID Token TTL " , & self . openid_token_ttl . to_string ( ) ) ;
line (
" TURN username " ,
if self . turn_username . is_empty ( ) {
" not set "
} else {
& self . turn_username
} ,
) ;
line ( " TURN password " , {
if self . turn_password . is_empty ( ) {
" not set "
} else {
" set "
}
} ) ;
line ( " TURN secret " , {
2024-09-20 22:57:04 -04:00
if self . turn_secret . is_empty ( ) & & self . turn_secret_file . is_none ( ) {
2024-07-11 02:22:37 +00:00
" not set "
} else {
" set "
}
} ) ;
2024-09-20 22:57:04 -04:00
line ( " TURN secret file path " , {
self . turn_secret_file
. as_ref ( )
. map_or ( " " , | path | path . to_str ( ) . unwrap_or_default ( ) )
} ) ;
2024-07-11 02:22:37 +00:00
line ( " Turn TTL " , & self . turn_ttl . to_string ( ) ) ;
line ( " Turn URIs " , {
2024-09-20 23:34:49 -04:00
let mut lst = Vec ::with_capacity ( self . turn_uris . len ( ) ) ;
2024-07-11 02:22:37 +00:00
for item in self . turn_uris . iter ( ) . cloned ( ) . enumerate ( ) {
let ( _ , uri ) : ( usize , String ) = item ;
lst . push ( uri ) ;
}
& lst . join ( " , " )
} ) ;
line ( " Auto Join Rooms " , {
2024-09-20 23:34:49 -04:00
let mut lst = Vec ::with_capacity ( self . auto_join_rooms . len ( ) ) ;
2024-07-11 02:22:37 +00:00
for room in & self . auto_join_rooms {
lst . push ( room ) ;
}
& lst . into_iter ( ) . join ( " , " )
} ) ;
line ( " Zstd HTTP Compression " , & self . zstd_compression . to_string ( ) ) ;
line ( " Gzip HTTP Compression " , & self . gzip_compression . to_string ( ) ) ;
line ( " Brotli HTTP Compression " , & self . brotli_compression . to_string ( ) ) ;
line ( " RocksDB database LOG level " , & self . rocksdb_log_level ) ;
line ( " RocksDB database LOG to stderr " , & self . rocksdb_log_stderr . to_string ( ) ) ;
line ( " RocksDB database LOG time-to-roll " , & self . rocksdb_log_time_to_roll . to_string ( ) ) ;
line ( " RocksDB Max LOG Files " , & self . rocksdb_max_log_files . to_string ( ) ) ;
line (
" RocksDB database max LOG file size " ,
& self . rocksdb_max_log_file_size . to_string ( ) ,
) ;
line (
" RocksDB database optimize for spinning disks " ,
& self . rocksdb_optimize_for_spinning_disks . to_string ( ) ,
) ;
line ( " RocksDB Direct-IO " , & self . rocksdb_direct_io . to_string ( ) ) ;
line ( " RocksDB Parallelism Threads " , & self . rocksdb_parallelism_threads . to_string ( ) ) ;
line ( " RocksDB Compression Algorithm " , & self . rocksdb_compression_algo ) ;
line ( " RocksDB Compression Level " , & self . rocksdb_compression_level . to_string ( ) ) ;
line (
" RocksDB Bottommost Compression Level " ,
& self . rocksdb_bottommost_compression_level . to_string ( ) ,
) ;
line (
" RocksDB Bottommost Level Compression " ,
& self . rocksdb_bottommost_compression . to_string ( ) ,
) ;
line ( " RocksDB Recovery Mode " , & self . rocksdb_recovery_mode . to_string ( ) ) ;
line ( " RocksDB Repair Mode " , & self . rocksdb_repair . to_string ( ) ) ;
line ( " RocksDB Read-only Mode " , & self . rocksdb_read_only . to_string ( ) ) ;
2024-10-01 04:20:31 +00:00
line ( " RocksDB Secondary Mode " , & self . rocksdb_secondary . to_string ( ) ) ;
2024-07-11 02:22:37 +00:00
line (
" RocksDB Compaction Idle Priority " ,
& self . rocksdb_compaction_prio_idle . to_string ( ) ,
) ;
line (
" RocksDB Compaction Idle IOPriority " ,
& self . rocksdb_compaction_ioprio_idle . to_string ( ) ,
) ;
2024-07-24 09:04:16 +00:00
line ( " RocksDB Compaction enabled " , & self . rocksdb_compaction . to_string ( ) ) ;
2024-08-02 01:21:01 +00:00
line ( " RocksDB Statistics level " , & self . rocksdb_stats_level . to_string ( ) ) ;
2024-07-11 02:22:37 +00:00
line ( " Media integrity checks on startup " , & self . media_startup_check . to_string ( ) ) ;
line ( " Media compatibility filesystem links " , & self . media_compat_file_link . to_string ( ) ) ;
2024-08-27 01:46:09 +00:00
line ( " Prune missing media from database " , & self . prune_missing_media . to_string ( ) ) ;
2024-08-27 03:35:00 +00:00
line ( " Allow legacy (unauthenticated) media " , & self . allow_legacy_media . to_string ( ) ) ;
2024-08-28 09:16:41 +00:00
line ( " Freeze legacy (unauthenticated) media " , & self . freeze_legacy_media . to_string ( ) ) ;
2024-07-11 02:22:37 +00:00
line ( " Prevent Media Downloads From " , {
2024-09-20 23:34:49 -04:00
let mut lst = Vec ::with_capacity ( self . prevent_media_downloads_from . len ( ) ) ;
2024-07-11 02:22:37 +00:00
for domain in & self . prevent_media_downloads_from {
lst . push ( domain . host ( ) ) ;
}
& lst . join ( " , " )
} ) ;
line ( " Forbidden Remote Server Names ( \" Global \" ACLs) " , {
2024-09-20 23:34:49 -04:00
let mut lst = Vec ::with_capacity ( self . forbidden_remote_server_names . len ( ) ) ;
2024-07-11 02:22:37 +00:00
for domain in & self . forbidden_remote_server_names {
lst . push ( domain . host ( ) ) ;
}
& lst . join ( " , " )
} ) ;
line ( " Forbidden Remote Room Directory Server Names " , {
2024-09-20 23:34:49 -04:00
let mut lst = Vec ::with_capacity ( self . forbidden_remote_room_directory_server_names . len ( ) ) ;
2024-07-11 02:22:37 +00:00
for domain in & self . forbidden_remote_room_directory_server_names {
lst . push ( domain . host ( ) ) ;
}
& lst . join ( " , " )
} ) ;
2024-09-20 23:34:49 -04:00
line ( " Outbound Request IP Range (CIDR) Denylist " , {
let mut lst = Vec ::with_capacity ( self . ip_range_denylist . len ( ) ) ;
2024-07-11 02:22:37 +00:00
for item in self . ip_range_denylist . iter ( ) . cloned ( ) . enumerate ( ) {
let ( _ , ip ) : ( usize , String ) = item ;
lst . push ( ip ) ;
}
& lst . join ( " , " )
} ) ;
line ( " Forbidden usernames " , {
& self . forbidden_usernames . patterns ( ) . iter ( ) . join ( " , " )
} ) ;
line ( " Forbidden room aliases " , {
& self . forbidden_alias_names . patterns ( ) . iter ( ) . join ( " , " )
} ) ;
line (
" URL preview domain contains allowlist " ,
& self . url_preview_domain_contains_allowlist . join ( " , " ) ,
) ;
line (
" URL preview domain explicit allowlist " ,
& self . url_preview_domain_explicit_allowlist . join ( " , " ) ,
) ;
line (
" URL preview domain explicit denylist " ,
& self . url_preview_domain_explicit_denylist . join ( " , " ) ,
) ;
line (
" URL preview URL contains allowlist " ,
& self . url_preview_url_contains_allowlist . join ( " , " ) ,
) ;
line ( " URL preview maximum spider size " , & self . url_preview_max_spider_size . to_string ( ) ) ;
line ( " URL preview check root domain " , & self . url_preview_check_root_domain . to_string ( ) ) ;
line (
" Allow check for updates / announcements check " ,
& self . allow_check_for_updates . to_string ( ) ,
) ;
line ( " Enable netburst on startup " , & self . startup_netburst . to_string ( ) ) ;
#[ cfg(feature = " sentry_telemetry " ) ]
line ( " Sentry.io reporting and tracing " , & self . sentry . to_string ( ) ) ;
#[ cfg(feature = " sentry_telemetry " ) ]
line ( " Sentry.io send server_name in logs " , & self . sentry_send_server_name . to_string ( ) ) ;
#[ cfg(feature = " sentry_telemetry " ) ]
line ( " Sentry.io tracing sample rate " , & self . sentry_traces_sample_rate . to_string ( ) ) ;
line ( " Sentry.io attach stacktrace " , & self . sentry_attach_stacktrace . to_string ( ) ) ;
line ( " Sentry.io send panics " , & self . sentry_send_panic . to_string ( ) ) ;
line ( " Sentry.io send errors " , & self . sentry_send_error . to_string ( ) ) ;
2024-07-11 05:03:41 +00:00
line ( " Sentry.io tracing filter " , & self . sentry_filter ) ;
2024-07-11 02:22:37 +00:00
line (
" Well-known server name " ,
self . well_known
. server
. as_ref ( )
. map_or ( " " , | server | server . as_str ( ) ) ,
) ;
line (
" Well-known client URL " ,
self . well_known
. client
. as_ref ( )
. map_or ( " " , | url | url . as_str ( ) ) ,
) ;
line (
" Well-known support email " ,
self . well_known
. support_email
. as_ref ( )
. map_or ( " " , | str | str . as_ref ( ) ) ,
) ;
line (
" Well-known support Matrix ID " ,
self . well_known
. support_mxid
. as_ref ( )
. map_or ( " " , | mxid | mxid . as_str ( ) ) ,
) ;
line (
" Well-known support role " ,
self . well_known
. support_role
. as_ref ( )
. map_or ( " " , | role | role . as_str ( ) ) ,
) ;
line (
" Well-known support page/URL " ,
self . well_known
. support_page
. as_ref ( )
. map_or ( " " , | url | url . as_str ( ) ) ,
) ;
line ( " Enable the tokio-console " , & self . tokio_console . to_string ( ) ) ;
2024-10-24 22:19:18 -04:00
line ( " Admin room notices " , & self . admin_room_notices . to_string ( ) ) ;
2024-07-11 02:22:37 +00:00
Ok ( ( ) )
2022-02-06 20:23:22 +01:00
}
}
2022-02-03 13:30:04 +01:00
fn true_fn ( ) -> bool { true }
2024-06-02 22:36:00 +00:00
fn default_address ( ) -> ListeningAddr {
ListeningAddr {
addrs : Right ( vec! [ Ipv4Addr ::LOCALHOST . into ( ) , Ipv6Addr ::LOCALHOST . into ( ) ] ) ,
}
}
2022-01-20 11:51:31 +01:00
2024-02-24 15:34:38 -05:00
fn default_port ( ) -> ListeningPort {
ListeningPort {
2024-04-03 20:33:47 -07:00
ports : Left ( 8008 ) ,
2024-02-24 15:34:38 -05:00
}
2022-01-20 11:51:31 +01:00
}
2023-07-29 21:57:41 +00:00
fn default_unix_socket_perms ( ) -> u32 { 660 }
2024-03-19 04:37:35 -07:00
fn default_database_backups_to_keep ( ) -> i16 { 1 }
2024-10-05 22:54:51 +00:00
fn default_db_cache_capacity_mb ( ) -> f64 { 128.0 + parallelism_scaled_f64 ( 64.0 ) }
2022-02-03 13:30:04 +01:00
2024-10-05 22:54:51 +00:00
fn default_pdu_cache_capacity ( ) -> u32 { parallelism_scaled_u32 ( 10_000 ) . saturating_add ( 100_000 ) }
2024-04-03 17:27:43 -07:00
2024-07-13 16:46:13 -04:00
fn default_cache_capacity_modifier ( ) -> f64 { 1.0 }
2022-02-03 13:30:04 +01:00
2024-10-05 22:54:51 +00:00
fn default_auth_chain_cache_capacity ( ) -> u32 { parallelism_scaled_u32 ( 10_000 ) . saturating_add ( 100_000 ) }
2024-04-03 17:27:43 -07:00
2024-10-05 22:54:51 +00:00
fn default_shorteventid_cache_capacity ( ) -> u32 { parallelism_scaled_u32 ( 50_000 ) . saturating_add ( 100_000 ) }
2024-04-03 17:27:43 -07:00
2024-10-05 22:54:51 +00:00
fn default_eventidshort_cache_capacity ( ) -> u32 { parallelism_scaled_u32 ( 25_000 ) . saturating_add ( 100_000 ) }
2024-04-03 17:27:43 -07:00
2024-11-21 23:45:16 -05:00
fn default_eventid_pdu_cache_capacity ( ) -> u32 { parallelism_scaled_u32 ( 25_000 ) . saturating_add ( 100_000 ) }
2024-10-05 22:54:51 +00:00
fn default_shortstatekey_cache_capacity ( ) -> u32 { parallelism_scaled_u32 ( 10_000 ) . saturating_add ( 100_000 ) }
2024-04-03 17:27:43 -07:00
2024-10-05 22:54:51 +00:00
fn default_statekeyshort_cache_capacity ( ) -> u32 { parallelism_scaled_u32 ( 10_000 ) . saturating_add ( 100_000 ) }
2024-04-03 17:27:43 -07:00
2024-11-25 16:08:30 -05:00
fn default_servernameevent_data_cache_capacity ( ) -> u32 { parallelism_scaled_u32 ( 100_000 ) . saturating_add ( 500_000 ) }
2024-10-05 22:54:51 +00:00
fn default_server_visibility_cache_capacity ( ) -> u32 { parallelism_scaled_u32 ( 500 ) }
2024-04-03 17:27:43 -07:00
2024-10-05 22:54:51 +00:00
fn default_user_visibility_cache_capacity ( ) -> u32 { parallelism_scaled_u32 ( 1000 ) }
2024-04-03 17:27:43 -07:00
2024-11-17 00:13:20 +00:00
fn default_stateinfo_cache_capacity ( ) -> u32 { parallelism_scaled_u32 ( 100 ) }
2024-04-03 17:27:43 -07:00
2024-10-05 22:54:51 +00:00
fn default_roomid_spacehierarchy_cache_capacity ( ) -> u32 { parallelism_scaled_u32 ( 1000 ) }
2022-02-03 13:30:04 +01:00
2024-04-26 16:23:25 -07:00
fn default_dns_cache_entries ( ) -> u32 { 32768 }
2024-03-24 23:59:28 -07:00
2024-04-17 19:49:19 -04:00
fn default_dns_min_ttl ( ) -> u64 { 60 * 180 }
2024-03-24 23:59:28 -07:00
2024-04-26 18:06:35 -04:00
fn default_dns_min_ttl_nxdomain ( ) -> u64 { 60 * 60 * 24 * 3 }
2024-03-24 23:59:28 -07:00
2024-04-17 19:49:19 -04:00
fn default_dns_attempts ( ) -> u16 { 10 }
2024-03-24 23:59:28 -07:00
2024-04-17 19:49:19 -04:00
fn default_dns_timeout ( ) -> u64 { 10 }
2024-03-24 23:59:28 -07:00
2024-04-29 14:25:11 -04:00
fn default_ip_lookup_strategy ( ) -> u8 { 5 }
2024-07-07 19:59:04 +00:00
fn default_max_request_size ( ) -> usize {
2022-02-03 13:30:04 +01:00
20 * 1024 * 1024 // Default to 20 MB
}
2024-03-16 15:54:58 -07:00
fn default_request_conn_timeout ( ) -> u64 { 10 }
fn default_request_timeout ( ) -> u64 { 35 }
2024-04-20 14:10:57 -07:00
fn default_request_total_timeout ( ) -> u64 { 320 }
2024-03-16 15:54:58 -07:00
fn default_request_idle_timeout ( ) -> u64 { 5 }
2024-04-20 14:10:57 -07:00
fn default_request_idle_per_host ( ) -> u16 { 1 }
2024-03-16 15:54:58 -07:00
fn default_well_known_conn_timeout ( ) -> u64 { 6 }
fn default_well_known_timeout ( ) -> u64 { 10 }
2024-10-14 03:58:25 +00:00
fn default_federation_timeout ( ) -> u64 { 25 }
2024-03-16 15:54:58 -07:00
fn default_federation_idle_timeout ( ) -> u64 { 25 }
2024-04-20 14:10:57 -07:00
fn default_federation_idle_per_host ( ) -> u16 { 1 }
2024-03-22 23:50:04 -04:00
fn default_sender_timeout ( ) -> u64 { 180 }
2024-03-16 15:54:58 -07:00
fn default_sender_idle_timeout ( ) -> u64 { 180 }
2024-04-22 10:55:48 -07:00
fn default_sender_retry_backoff_limit ( ) -> u64 { 86400 }
2024-05-02 17:00:54 -04:00
fn default_appservice_timeout ( ) -> u64 { 35 }
2024-03-16 15:54:58 -07:00
fn default_appservice_idle_timeout ( ) -> u64 { 300 }
fn default_pusher_idle_timeout ( ) -> u64 { 15 }
2024-10-22 00:09:55 +00:00
fn default_max_fetch_prev_events ( ) -> u16 { 192_ u16 }
2022-09-09 19:17:29 +02:00
2024-07-14 11:30:10 +00:00
fn default_tracing_flame_filter ( ) -> String {
cfg! ( debug_assertions )
. then_some ( " trace,h2=off " )
. unwrap_or ( " info " )
. to_owned ( )
}
2024-04-26 18:23:02 -07:00
2024-07-11 05:26:43 +00:00
fn default_jaeger_filter ( ) -> String {
cfg! ( debug_assertions )
. then_some ( " trace,h2=off " )
. unwrap_or ( " info " )
. to_owned ( )
}
2024-04-26 18:49:58 -07:00
fn default_tracing_flame_output_path ( ) -> String { " ./tracing.folded " . to_owned ( ) }
2023-08-10 17:45:58 +02:00
fn default_trusted_servers ( ) -> Vec < OwnedServerName > { vec! [ OwnedServerName ::try_from ( " matrix.org " ) . unwrap ( ) ] }
2024-06-25 00:52:56 +00:00
/// do debug logging by default for debug builds
2024-05-31 05:39:51 +00:00
#[ must_use ]
pub fn default_log ( ) -> String {
2024-06-25 00:52:56 +00:00
cfg! ( debug_assertions )
. then_some ( " debug " )
. unwrap_or ( " info " )
. to_owned ( )
2024-04-14 19:12:39 -04:00
}
2022-02-03 13:30:04 +01:00
2024-11-11 20:49:25 +00:00
#[ must_use ]
pub fn default_log_span_events ( ) -> String { " none " . into ( ) }
2023-10-28 22:31:11 -04:00
fn default_notification_push_path ( ) -> String { " /_matrix/push/v1/notify " . to_owned ( ) }
2024-07-02 21:51:11 -04:00
fn default_openid_token_ttl ( ) -> u64 { 60 * 60 }
2022-02-03 13:30:04 +01:00
fn default_turn_ttl ( ) -> u64 { 60 * 60 * 24 }
2021-11-01 01:58:26 +00:00
2024-04-01 20:48:40 -07:00
fn default_presence_idle_timeout_s ( ) -> u64 { 5 * 60 }
2023-07-10 16:41:00 +02:00
2024-04-01 20:48:40 -07:00
fn default_presence_offline_timeout_s ( ) -> u64 { 30 * 60 }
2023-07-10 16:41:00 +02:00
2024-03-29 18:35:02 -07:00
fn default_typing_federation_timeout_s ( ) -> u64 { 30 }
fn default_typing_client_timeout_min_s ( ) -> u64 { 15 }
fn default_typing_client_timeout_max_s ( ) -> u64 { 45 }
2024-03-23 00:27:33 -04:00
fn default_rocksdb_recovery_mode ( ) -> u8 { 1 }
2024-03-22 20:34:24 -07:00
2024-03-06 18:17:03 -05:00
fn default_rocksdb_log_level ( ) -> String { " error " . to_owned ( ) }
2023-12-02 21:30:06 -05:00
fn default_rocksdb_log_time_to_roll ( ) -> usize { 0 }
2024-03-06 18:20:02 -05:00
fn default_rocksdb_max_log_files ( ) -> usize { 3 }
2024-03-13 22:41:12 -04:00
fn default_rocksdb_max_log_file_size ( ) -> usize {
// 4 megabytes
4 * 1024 * 1024
}
2024-03-14 12:36:56 -07:00
fn default_rocksdb_parallelism_threads ( ) -> usize { 0 }
2024-03-04 20:42:09 -05:00
2024-03-13 12:31:13 -04:00
fn default_rocksdb_compression_algo ( ) -> String { " zstd " . to_owned ( ) }
2024-03-13 22:22:07 -04:00
/// Default RocksDB compression level is 32767, which is internally read by
/// RocksDB as the default magic number and translated to the library's default
/// compression level as they all differ. See their `kDefaultCompressionLevel`.
2024-03-22 22:44:31 -04:00
#[ allow(clippy::doc_markdown) ]
2024-03-13 22:22:07 -04:00
fn default_rocksdb_compression_level ( ) -> i32 { 32767 }
2024-03-13 22:38:30 -04:00
/// Default RocksDB compression level is 32767, which is internally read by
/// RocksDB as the default magic number and translated to the library's default
/// compression level as they all differ. See their `kDefaultCompressionLevel`.
2024-03-22 22:44:31 -04:00
#[ allow(clippy::doc_markdown) ]
2024-03-13 22:38:30 -04:00
fn default_rocksdb_bottommost_compression_level ( ) -> i32 { 32767 }
2024-08-02 01:21:01 +00:00
fn default_rocksdb_stats_level ( ) -> u8 { 1 }
2021-11-01 01:58:26 +00:00
// I know, it's a great name
2024-05-09 15:59:08 -07:00
#[ must_use ]
2024-11-03 12:42:43 +00:00
#[ inline ]
2024-05-09 15:59:08 -07:00
pub fn default_default_room_version ( ) -> RoomVersionId { RoomVersionId ::V10 }
2023-12-02 21:30:06 -05:00
2024-01-21 22:59:06 -05:00
fn default_ip_range_denylist ( ) -> Vec < String > {
vec! [
" 127.0.0.0/8 " . to_owned ( ) ,
" 10.0.0.0/8 " . to_owned ( ) ,
" 172.16.0.0/12 " . to_owned ( ) ,
" 192.168.0.0/16 " . to_owned ( ) ,
" 100.64.0.0/10 " . to_owned ( ) ,
" 192.0.0.0/24 " . to_owned ( ) ,
" 169.254.0.0/16 " . to_owned ( ) ,
" 192.88.99.0/24 " . to_owned ( ) ,
" 198.18.0.0/15 " . to_owned ( ) ,
" 192.0.2.0/24 " . to_owned ( ) ,
" 198.51.100.0/24 " . to_owned ( ) ,
" 203.0.113.0/24 " . to_owned ( ) ,
" 224.0.0.0/4 " . to_owned ( ) ,
" ::1/128 " . to_owned ( ) ,
" fe80::/10 " . to_owned ( ) ,
" fc00::/7 " . to_owned ( ) ,
" 2001:db8::/32 " . to_owned ( ) ,
" ff00::/8 " . to_owned ( ) ,
" fec0::/10 " . to_owned ( ) ,
]
}
2024-02-10 13:29:12 -05:00
fn default_url_preview_max_spider_size ( ) -> usize {
2024-03-30 15:29:56 -04:00
384_000 // 384KB
2024-02-10 13:29:12 -05:00
}
2024-02-20 23:08:53 -05:00
fn default_new_user_displayname_suffix ( ) -> String { " 🏳️⚧️ " . to_owned ( ) }
2024-03-29 19:59:02 -04:00
2024-04-24 02:19:50 -04:00
fn default_sentry_endpoint ( ) -> Option < Url > {
2024-06-25 00:52:56 +00:00
Url ::parse ( " https://fe2eb4536aa04949e28eff3128d64757@o4506996327251968.ingest.us.sentry.io/4506996334657536 " ) . ok ( )
2024-04-24 02:19:50 -04:00
}
2024-03-29 19:59:02 -04:00
fn default_sentry_traces_sample_rate ( ) -> f32 { 0.15 }
2024-03-31 19:01:20 -07:00
2024-07-11 05:03:41 +00:00
fn default_sentry_filter ( ) -> String { " info " . to_owned ( ) }
2024-03-31 19:01:20 -07:00
fn default_startup_netburst_keep ( ) -> i64 { 50 }
2024-08-17 03:40:05 +00:00
2024-08-31 11:45:36 +00:00
fn default_admin_log_capture ( ) -> String {
cfg! ( debug_assertions )
. then_some ( " debug " )
. unwrap_or ( " info " )
. to_owned ( )
}
2024-08-28 07:05:13 +00:00
fn default_admin_room_tag ( ) -> String { " m.server_notice " . to_owned ( ) }
2024-10-05 22:54:51 +00:00
#[ allow(clippy::as_conversions, clippy::cast_precision_loss) ]
fn parallelism_scaled_f64 ( val : f64 ) -> f64 { val * ( sys ::available_parallelism ( ) as f64 ) }
fn parallelism_scaled_u32 ( val : u32 ) -> u32 {
let val = val . try_into ( ) . expect ( " failed to cast u32 to usize " ) ;
parallelism_scaled ( val ) . try_into ( ) . unwrap_or ( u32 ::MAX )
}
fn parallelism_scaled ( val : usize ) -> usize { val . saturating_mul ( sys ::available_parallelism ( ) ) }
2024-11-09 01:09:09 +00:00
fn default_trusted_server_batch_size ( ) -> usize { 256 }
2024-11-28 06:52:23 +00:00
2024-12-04 01:23:36 +00:00
fn default_db_pool_workers ( ) -> usize { sys ::available_parallelism ( ) . saturating_mul ( 4 ) . max ( 32 ) }
2024-11-28 06:52:23 +00:00
fn default_db_pool_queue_size ( ) -> usize { sys ::available_parallelism ( ) . saturating_mul ( 8 ) . max ( 256 ) }