fix optional config section related

split api/client well_known

simplify well_known config access

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-11-24 00:19:55 +00:00
parent 5f1cab6850
commit f30b08f015
9 changed files with 144 additions and 138 deletions

View file

@ -87,7 +87,8 @@ pub struct Config {
port: ListeningPort,
// external structure; separate section
pub tls: Option<TlsConfig>,
#[serde(default)]
pub tls: TlsConfig,
/// Uncomment unix_socket_path to listen on a UNIX socket at the specified
/// path. If listening on a UNIX socket, you MUST remove/comment the
@ -1500,17 +1501,19 @@ pub struct Config {
catchall: BTreeMap<String, IgnoredAny>,
}
#[derive(Clone, Debug, Deserialize)]
#[derive(Clone, Debug, Deserialize, Default)]
#[config_example_generator(filename = "conduwuit-example.toml", section = "global.tls")]
pub struct TlsConfig {
/// Path to a valid TLS certificate file.
///
/// example: "/path/to/my/certificate.crt"
pub certs: String,
pub certs: Option<String>,
/// Path to a valid TLS certificate private key.
///
/// example: "/path/to/my/certificate.key"
pub key: String,
pub key: Option<String>,
/// Whether to listen and allow for HTTP and HTTPS connections (insecure!)
#[serde(default)]
pub dual_protocol: bool,
@ -1520,20 +1523,25 @@ pub struct TlsConfig {
#[derive(Clone, Debug, Deserialize, Default)]
#[config_example_generator(filename = "conduwuit-example.toml", section = "global.well_known")]
pub struct WellKnownConfig {
/// 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>,
/// 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"
pub server: Option<OwnedServerName>,
/// 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>,
pub support_page: Option<Url>,
pub support_role: Option<ContactRole>,
pub support_email: Option<String>,
pub support_mxid: Option<OwnedUserId>,
}