1
0
Fork 1
Spiegel von https://github.com/dani-garcia/vaultwarden.git synchronisiert 2024-11-22 05:10:29 +01:00

Added configurable smtp timeout.

- Added config option for smtp timeout
 - Lowered default timeout to 15 seconds instead of default 60.
Dieser Commit ist enthalten in:
BlackDex 2019-11-06 21:39:33 +01:00
Ursprung cbb92bcbc0
Commit c52adef919
3 geänderte Dateien mit 6 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -157,3 +157,4 @@
# SMTP_USERNAME=username # SMTP_USERNAME=username
# SMTP_PASSWORD=password # SMTP_PASSWORD=password
# SMTP_AUTH_MECHANISM="Plain" # SMTP_AUTH_MECHANISM="Plain"
# SMTP_TIMEOUT=15

Datei anzeigen

@ -350,6 +350,8 @@ make_config! {
smtp_password: Pass, true, option; smtp_password: Pass, true, option;
/// Json form auth mechanism |> Defaults for ssl is "Plain" and "Login" and nothing for non-ssl connections. Possible values: ["Plain", "Login", "Xoauth2"] /// Json form auth mechanism |> Defaults for ssl is "Plain" and "Login" and nothing for non-ssl connections. Possible values: ["Plain", "Login", "Xoauth2"]
smtp_auth_mechanism: String, true, option; smtp_auth_mechanism: String, true, option;
/// SMTP connection timeout |> Number of seconds when to stop trying to connect to the SMTP server
smtp_timeout: u64, true, def, 15;
}, },
/// Email 2FA Settings /// Email 2FA Settings

Datei anzeigen

@ -33,6 +33,8 @@ fn mailer() -> SmtpTransport {
ClientSecurity::None ClientSecurity::None
}; };
use std::time::Duration;
let smtp_client = SmtpClient::new((host.as_str(), CONFIG.smtp_port()), client_security).unwrap(); let smtp_client = SmtpClient::new((host.as_str(), CONFIG.smtp_port()), client_security).unwrap();
let smtp_client = match (&CONFIG.smtp_username(), &CONFIG.smtp_password()) { let smtp_client = match (&CONFIG.smtp_username(), &CONFIG.smtp_password()) {
@ -53,6 +55,7 @@ fn mailer() -> SmtpTransport {
smtp_client smtp_client
.smtp_utf8(true) .smtp_utf8(true)
.timeout(Some(Duration::from_secs(CONFIG.smtp_timeout())))
.connection_reuse(ConnectionReuseParameters::NoReuse) .connection_reuse(ConnectionReuseParameters::NoReuse)
.transport() .transport()
} }