mirror of
https://github.com/soywod/himalaya.git
synced 2024-09-28 20:21:13 +00:00
refactor imap and smtp encryption options
This commit is contained in:
parent
eee17f9173
commit
a59d1ca2c6
18
CHANGELOG.md
18
CHANGELOG.md
|
@ -62,11 +62,19 @@ Few major concepts changed:
|
||||||
- Moved `sync` config option to `sync.enable`.
|
- Moved `sync` config option to `sync.enable`.
|
||||||
- Moved `sync-dir` config option to `sync.dir`.
|
- Moved `sync-dir` config option to `sync.dir`.
|
||||||
- Moved `sync-folders-strategy` config option to `sync.strategy`.
|
- Moved `sync-folders-strategy` config option to `sync.strategy`.
|
||||||
- Moved `maildir-*` config option to `maildir.*`.
|
- Moved `maildir-*` config options to `maildir.*`.
|
||||||
- Moved `imap-*` config option to `imap.*`.
|
- Moved `imap-*` config options to `imap.*`.
|
||||||
- Moved `notmuch-*` config option to `notmuch.*`.
|
- Moved `notmuch-*` config options to `notmuch.*`.
|
||||||
- Moved `sendmail-*` config option to `sendmail.*`.
|
- Moved `sendmail-*` config options to `sendmail.*`.
|
||||||
- Moved `smtp-*` config option to `smtp.*`.
|
- Moved `smtp-*` config options to `smtp.*`.
|
||||||
|
- Replaced options `imap-ssl`, `imap-starttls` and `imap-insecure` by `imap.encryption`:
|
||||||
|
- `imap.encryption = "tls" | true`: use required encryption (SSL/TLS)
|
||||||
|
- `imap.encryption = "start-tls"`: use opportunistic encryption (StartTLS)
|
||||||
|
- `imap.encryption = "none" | false`: do not use any encryption
|
||||||
|
- Replaced options `smtp-ssl`, `smtp-starttls` and `smtp-insecure` by `smtp.encryption`:
|
||||||
|
- `smtp.encryption = "tls" | true`: use required encryption (SSL/TLS)
|
||||||
|
- `smtp.encryption = "start-tls"`: use opportunistic encryption (StartTLS)
|
||||||
|
- `smtp.encryption = "none" | false`: do not use any encryption
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
|
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1217,7 +1217,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "email-lib"
|
name = "email-lib"
|
||||||
version = "0.18.5"
|
version = "0.18.5"
|
||||||
source = "git+https://git.sr.ht/~soywod/pimalaya#42b67fa72d4010c8b2ec6b89a8c2498ae7a53637"
|
source = "git+https://git.sr.ht/~soywod/pimalaya#39833ce0d2c4b3a99977419dd0211f62dcb4a0bd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"advisory-lock",
|
"advisory-lock",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
|
|
@ -61,18 +61,20 @@ message.send.save-copy = true
|
||||||
imap.host = "localhost"
|
imap.host = "localhost"
|
||||||
imap.port = 3143
|
imap.port = 3143
|
||||||
imap.login = "example@localhost"
|
imap.login = "example@localhost"
|
||||||
imap.ssl = false
|
|
||||||
imap.starttls = false
|
|
||||||
imap.insecure = true
|
|
||||||
imap.auth = "passwd" # or oauth2
|
|
||||||
|
|
||||||
# Get password from the raw string (not safe)
|
# Encryption can be either "tls" (or true), "start-tls" or "none" (or false).
|
||||||
|
imap.encryption = "none"
|
||||||
|
|
||||||
|
# Authentication can be either "passwd" or "oauth2"
|
||||||
|
imap.auth = "passwd"
|
||||||
|
|
||||||
|
# Get password from a raw string (not safe)
|
||||||
imap.passwd.raw = "password"
|
imap.passwd.raw = "password"
|
||||||
|
|
||||||
# Get password from a shell command
|
# Get password from a shell command
|
||||||
# imap.passwd.cmd = "echo password"
|
# imap.passwd.cmd = "echo password"
|
||||||
|
|
||||||
# Get password from your system keyring using secret service
|
# Get password from your global system keyring using secret service
|
||||||
# Keyring secrets can be (re)set with the command `account configure example`
|
# Keyring secrets can be (re)set with the command `account configure example`
|
||||||
# imap.passwd.keyring = "example-imap-password"
|
# imap.passwd.keyring = "example-imap-password"
|
||||||
|
|
||||||
|
@ -84,9 +86,7 @@ imap.passwd.raw = "password"
|
||||||
smtp.host = "localhost"
|
smtp.host = "localhost"
|
||||||
smtp.port = 3025
|
smtp.port = 3025
|
||||||
smtp.login = "example@localhost"
|
smtp.login = "example@localhost"
|
||||||
smtp.ssl = false
|
smtp.encryption = false
|
||||||
smtp.starttls = false
|
|
||||||
smtp.insecure = true
|
|
||||||
smtp.auth = "passwd"
|
smtp.auth = "passwd"
|
||||||
smtp.passwd.raw = "password"
|
smtp.passwd.raw = "password"
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ use email::{
|
||||||
oauth2::{OAuth2Config, OAuth2Method, OAuth2Scopes},
|
oauth2::{OAuth2Config, OAuth2Method, OAuth2Scopes},
|
||||||
passwd::PasswdConfig,
|
passwd::PasswdConfig,
|
||||||
},
|
},
|
||||||
imap::config::{ImapAuthConfig, ImapConfig},
|
imap::config::{ImapAuthConfig, ImapConfig, ImapEncryptionKind},
|
||||||
};
|
};
|
||||||
use oauth::v2_0::{AuthorizationCodeGrant, Client};
|
use oauth::v2_0::{AuthorizationCodeGrant, Client};
|
||||||
use secret::Secret;
|
use secret::Secret;
|
||||||
|
@ -16,10 +16,11 @@ use crate::{
|
||||||
wizard_log, wizard_prompt,
|
wizard_log, wizard_prompt,
|
||||||
};
|
};
|
||||||
|
|
||||||
const SSL_TLS: &str = "SSL/TLS";
|
const PROTOCOLS: &[ImapEncryptionKind] = &[
|
||||||
const STARTTLS: &str = "STARTTLS";
|
ImapEncryptionKind::Tls,
|
||||||
const NONE: &str = "None";
|
ImapEncryptionKind::StartTls,
|
||||||
const PROTOCOLS: &[&str] = &[SSL_TLS, STARTTLS, NONE];
|
ImapEncryptionKind::None,
|
||||||
|
];
|
||||||
|
|
||||||
const PASSWD: &str = "Password";
|
const PASSWD: &str = "Password";
|
||||||
const OAUTH2: &str = "OAuth 2.0";
|
const OAUTH2: &str = "OAuth 2.0";
|
||||||
|
@ -49,19 +50,16 @@ pub(crate) async fn configure(account_name: &str, email: &str) -> Result<Backend
|
||||||
.interact_opt()?;
|
.interact_opt()?;
|
||||||
|
|
||||||
let default_port = match protocol {
|
let default_port = match protocol {
|
||||||
Some(idx) if PROTOCOLS[idx] == SSL_TLS => {
|
Some(idx) if PROTOCOLS[idx] == ImapEncryptionKind::Tls => {
|
||||||
config.ssl = Some(true);
|
config.encryption = Some(ImapEncryptionKind::Tls);
|
||||||
config.starttls = Some(false);
|
|
||||||
993
|
993
|
||||||
}
|
}
|
||||||
Some(idx) if PROTOCOLS[idx] == STARTTLS => {
|
Some(idx) if PROTOCOLS[idx] == ImapEncryptionKind::StartTls => {
|
||||||
config.ssl = Some(false);
|
config.encryption = Some(ImapEncryptionKind::StartTls);
|
||||||
config.starttls = Some(true);
|
|
||||||
143
|
143
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
config.ssl = Some(false);
|
config.encryption = Some(ImapEncryptionKind::None);
|
||||||
config.starttls = Some(false);
|
|
||||||
143
|
143
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,7 +5,7 @@ use email::{
|
||||||
oauth2::{OAuth2Config, OAuth2Method, OAuth2Scopes},
|
oauth2::{OAuth2Config, OAuth2Method, OAuth2Scopes},
|
||||||
passwd::PasswdConfig,
|
passwd::PasswdConfig,
|
||||||
},
|
},
|
||||||
smtp::config::{SmtpAuthConfig, SmtpConfig},
|
smtp::config::{SmtpAuthConfig, SmtpConfig, SmtpEncryptionKind},
|
||||||
};
|
};
|
||||||
use oauth::v2_0::{AuthorizationCodeGrant, Client};
|
use oauth::v2_0::{AuthorizationCodeGrant, Client};
|
||||||
use secret::Secret;
|
use secret::Secret;
|
||||||
|
@ -16,10 +16,11 @@ use crate::{
|
||||||
wizard_log, wizard_prompt,
|
wizard_log, wizard_prompt,
|
||||||
};
|
};
|
||||||
|
|
||||||
const SSL_TLS: &str = "SSL/TLS";
|
const PROTOCOLS: &[SmtpEncryptionKind] = &[
|
||||||
const STARTTLS: &str = "STARTTLS";
|
SmtpEncryptionKind::Tls,
|
||||||
const NONE: &str = "None";
|
SmtpEncryptionKind::StartTls,
|
||||||
const PROTOCOLS: &[&str] = &[SSL_TLS, STARTTLS, NONE];
|
SmtpEncryptionKind::None,
|
||||||
|
];
|
||||||
|
|
||||||
const PASSWD: &str = "Password";
|
const PASSWD: &str = "Password";
|
||||||
const OAUTH2: &str = "OAuth 2.0";
|
const OAUTH2: &str = "OAuth 2.0";
|
||||||
|
@ -49,19 +50,16 @@ pub(crate) async fn configure(account_name: &str, email: &str) -> Result<Backend
|
||||||
.interact_opt()?;
|
.interact_opt()?;
|
||||||
|
|
||||||
let default_port = match protocol {
|
let default_port = match protocol {
|
||||||
Some(idx) if PROTOCOLS[idx] == SSL_TLS => {
|
Some(idx) if PROTOCOLS[idx] == SmtpEncryptionKind::Tls => {
|
||||||
config.ssl = Some(true);
|
config.encryption = Some(SmtpEncryptionKind::Tls);
|
||||||
config.starttls = Some(false);
|
|
||||||
465
|
465
|
||||||
}
|
}
|
||||||
Some(idx) if PROTOCOLS[idx] == STARTTLS => {
|
Some(idx) if PROTOCOLS[idx] == SmtpEncryptionKind::StartTls => {
|
||||||
config.ssl = Some(false);
|
config.encryption = Some(SmtpEncryptionKind::StartTls);
|
||||||
config.starttls = Some(true);
|
|
||||||
587
|
587
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
config.ssl = Some(false);
|
config.encryption = Some(SmtpEncryptionKind::None);
|
||||||
config.starttls = Some(false);
|
|
||||||
25
|
25
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue