add server data for nauta to provider-db

This commit is contained in:
B. Petersen
2020-01-26 00:05:05 +01:00
parent 4fc6fa9c8a
commit aaa6497659

View File

@@ -1,4 +1,7 @@
use crate::dc_tools::EmailAddress; use crate::dc_tools::EmailAddress;
use crate::provider::Protocol::*;
use crate::provider::Socket::*;
use crate::provider::UsernamePattern::*;
#[derive(Debug, Copy, Clone, PartialEq, ToPrimitive)] #[derive(Debug, Copy, Clone, PartialEq, ToPrimitive)]
#[repr(u8)] #[repr(u8)]
@@ -10,25 +13,35 @@ pub enum Status {
#[derive(Debug)] #[derive(Debug)]
#[repr(u8)] #[repr(u8)]
pub enum ServerType { pub enum Protocol {
SMTP = 1, SMTP = 1,
IMAP = 2, IMAP = 2,
} }
#[derive(Debug)] #[derive(Debug)]
#[repr(u8)] #[repr(u8)]
pub enum ServerSocket { pub enum Socket {
STARTTLS = 1, STARTTLS = 1,
SSL = 2, SSL = 2,
} }
#[derive(Debug, PartialEq)] #[derive(Debug)]
pub struct Server { #[repr(u8)]
pub stype: u16, pub enum UsernamePattern {
// more fields are needed, just to keep the example short EMAIL = 1,
EMAILLOCALPART = 2,
} }
#[derive(Debug, PartialEq)] #[derive(Debug)]
pub struct Server {
pub protocol: Protocol,
pub socket: Socket,
pub server: &'static str,
pub port: u16,
pub username_pattern: UsernamePattern,
}
#[derive(Debug)]
pub struct Provider { pub struct Provider {
pub domains: &'static str, pub domains: &'static str,
pub status: Status, pub status: Status,
@@ -37,17 +50,19 @@ pub struct Provider {
pub server: Vec<Server>, // this seems to be okay pub server: Vec<Server>, // this seems to be okay
} }
// TODO: the database will be auto-generated from the provider-db
lazy_static::lazy_static! { lazy_static::lazy_static! {
// TODO: the database will be auto-generated from the provider-db
static ref DATABASE: Vec<Provider> = vec![ static ref DATABASE: Vec<Provider> = vec![
Provider { Provider {
domains: "nauta.cu", domains: "nauta.cu",
status: Status::OK, status: Status::OK,
before_login_hint: "", before_login_hint: "",
overview_page: "", overview_page: "",
server: vec![Server { stype: 123 }, Server { stype: 456 }], server: vec![
Server { protocol: IMAP, socket: STARTTLS, server: "imap.nauta.cu", port: 143, username_pattern: EMAIL },
Server { protocol: SMTP, socket: STARTTLS, server: "smtp.nauta.cu", port: 25, username_pattern: EMAIL },
],
}, },
/*
Provider { Provider {
domains: "outlook.com hotmail.com live.com", domains: "outlook.com hotmail.com live.com",
status: Status::BROKEN, status: Status::BROKEN,
@@ -57,6 +72,8 @@ lazy_static::lazy_static! {
for now, we suggest to use another e-mail-address \ for now, we suggest to use another e-mail-address \
or try Delta Chat again when the issue is fixed.", or try Delta Chat again when the issue is fixed.",
overview_page: "https://provider.delta.chat/outlook.com", overview_page: "https://provider.delta.chat/outlook.com",
server: vec![
],
}, },
Provider { Provider {
domains: "gmail.com googlemail.com", domains: "gmail.com googlemail.com",
@@ -66,9 +83,10 @@ lazy_static::lazy_static! {
If this setting is not available, \ If this setting is not available, \
you need to enable \"Less secure apps\".", you need to enable \"Less secure apps\".",
overview_page: "https://provider.delta.chat/gmail.com", overview_page: "https://provider.delta.chat/gmail.com",
server: vec![
],
}, },
*/ ];
];
} }
pub fn get_provider_info(addr: &str) -> Option<&Provider> { pub fn get_provider_info(addr: &str) -> Option<&Provider> {