Compare commits

..

28 Commits

Author SHA1 Message Date
holger krekel
6af272230e skip gh actions 2019-11-13 01:15:11 +01:00
holger krekel
9c81ccfd09 avoid clippy on github actions 2019-11-13 00:04:25 +01:00
holger krekel
895b01f537 new clean try to get circle-ci to work 2019-11-13 00:02:41 +01:00
dignifiedquire
58ad14d9c3 better github action 2019-11-12 16:21:49 +01:00
dignifiedquire
e539bddc3b github actions: nightly only 2019-11-12 16:08:44 +01:00
dignifiedquire
2fc1d21959 update github actions 2019-11-12 16:04:37 +01:00
holger krekel
b43d9d2ffe shortcut fetch/idle on mvbox/sentbox if we don't know the folder and prevent busy-looping 2019-11-12 16:03:19 +01:00
holger krekel
5b73951b9b steramline some teardown decision code, and add webpki_roots for cert-checking 2019-11-12 16:03:19 +01:00
holger krekel
8595b92fcf also make smtp respect CertificateChecks setting roughly 2019-11-12 16:03:19 +01:00
holger krekel
6054b90975 rough integration of async-tls CertChecks (strict and automatic but not more finegrained work) 2019-11-12 16:03:19 +01:00
dignifiedquire
b8427ab56e update to released versions 2019-11-12 16:03:19 +01:00
holger krekel
02f72eea61 use AtomicBool for skip_next_idle_wait 2019-11-12 16:03:19 +01:00
holger krekel
a5a20078f0 actually this fixes the double import issue 2019-11-12 16:03:19 +01:00
holger krekel
7383094b33 fix tests for failed logins 2019-11-12 16:03:19 +01:00
holger krekel
e225a6fb17 * fix interrupt_idle by signalling "skip_next_idle_wait" to the potentially concurrently "fn idle" function 2019-11-12 16:03:19 +01:00
holger krekel
6bdc207277 make select_folder return ImapActionResult's and early-return from idle if there is no selected folder 2019-11-12 16:03:19 +01:00
dignifiedquire
101141c67a remove rustup install 2019-11-12 16:03:19 +01:00
dignifiedquire
d07afe5bd6 try use a different rust version 2019-11-12 16:03:19 +01:00
dignifiedquire
00e22d4339 update deps 2019-11-12 16:03:19 +01:00
dignifiedquire
91c8f48c21 bust ci cache 2019-11-12 16:03:19 +01:00
dignifiedquire
3d76d21925 refactor: drop native-tls 2019-11-12 16:03:19 +01:00
dignifiedquire
3349c0e9dc update docker image 2019-11-12 16:03:19 +01:00
dignifiedquire
7b35104b83 cleanup imap impl 2019-11-12 16:03:19 +01:00
dignifiedquire
22b6e8f6e2 update async-imap 2019-11-12 16:03:19 +01:00
dignifiedquire
ad118aa0df implement idle again 2019-11-12 16:03:19 +01:00
dignifiedquire
9044b80b9f remove local dependency 2019-11-12 16:03:19 +01:00
dignifiedquire
b948e973c5 it compiles with async-imap 2019-11-12 16:03:19 +01:00
Friedel Ziegelmayer
d330d890c0 setup minimal github action
Just so we can experiment with it on branches
2019-11-12 14:31:38 +01:00
5 changed files with 139 additions and 37 deletions

View File

@@ -0,0 +1,77 @@
name: CI
on:
pull_request:
push:
env:
RUSTFLAGS: -Dwarnings
jobs:
build_and_test:
name: Build and test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
rust: [nightly]
steps:
- uses: actions/checkout@master
- name: Install ${{ matrix.rust }}
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
override: true
- name: check
uses: actions-rs/cargo@v1
if: matrix.rust == 'nightly'
with:
command: check
args: --all --bins --examples --tests
- name: tests
uses: actions-rs/cargo@v1
with:
command: test
args: --all
- name: tests ignored
uses: actions-rs/cargo@v1
with:
command: test
args: --all --release -- --ignored
check_fmt:
name: Checking fmt and docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: rustfmt
- name: fmt
run: cargo fmt --all -- --check
# clippy_check:
# name: Clippy check
# runs-on: ubuntu-latest
#
# steps:
# - uses: actions/checkout@v1
# - uses: actions-rs/toolchain@v1
# with:
# profile: minimal
# toolchain: nightly
# override: true
# components: clippy
#
# - name: clippy
# run: cargo clippy --all

View File

@@ -32,8 +32,8 @@ if [[ $NORUN == "1" ]]; then
export CARGO_SUBCMD="build"
else
export CARGO_SUBCMD="test --all"
export OPT="${OPT} "
export OPT_RELEASE="${OPT_RELEASE} "
export OPT="-j1 ${OPT} "
export OPT_RELEASE="-j2 ${OPT_RELEASE} "
export OPT_RELEASE_IGNORED="${OPT_RELEASE} -- --ignored"
fi

View File

@@ -312,18 +312,21 @@ impl Imap {
return false;
}
let (teardown, can_idle, has_xlist) = match &mut *self.session.lock().await {
let teardown = match &mut *self.session.lock().await {
Some(ref mut session) => match session.capabilities().await {
Ok(caps) => {
if !context.sql.is_open() {
warn!(context, "IMAP-LOGIN as {} ok but ABORTING", lp.mail_user,);
(true, false, false)
true
} else {
let can_idle = caps.has_str("IDLE");
let has_xlist = caps.has_str("XLIST");
let caps_list = caps
.iter()
.fold(String::new(), |s, c| s + &format!(" {:?}", c));
self.config.write().await.can_idle = can_idle;
self.config.write().await.has_xlist = has_xlist;
*self.connected.lock().await = true;
emit_event!(
context,
Event::ImapConnected(format!(
@@ -331,25 +334,22 @@ impl Imap {
lp.mail_user, caps_list,
))
);
(false, can_idle, has_xlist)
false
}
}
Err(err) => {
info!(context, "CAPABILITY command error: {}", err);
(true, false, false)
true
}
},
None => (true, false, false),
None => true,
};
if teardown {
self.unsetup_handle(context).await;
self.free_connect_params().await;
self.disconnect(context);
false
} else {
self.config.write().await.can_idle = can_idle;
self.config.write().await.has_xlist = has_xlist;
*self.connected.lock().await = true;
true
}
})
@@ -746,10 +746,13 @@ impl Imap {
pub fn idle(&self, context: &Context) {
task::block_on(async move {
if self.config.read().await.selected_folder.is_none() {
// this probably means that we are in teardown
// in any case we can't perform any idling
return;
}
if !self.config.read().await.can_idle {
self.fake_idle(context).await;
self.fake_idle(context, true).await;
return;
}
@@ -765,7 +768,7 @@ impl Imap {
"idle select_folder failed {:?}",
watch_folder.as_ref()
);
self.fake_idle(context).await;
self.fake_idle(context, true).await;
return;
}
}
@@ -836,7 +839,7 @@ impl Imap {
});
}
async fn fake_idle(&self, context: &Context) {
pub(crate) async fn fake_idle(&self, context: &Context, use_network: bool) {
// Idle using timeouts. This is also needed if we're not yet configured -
// in this case, we're waiting for a configure job
let fake_idle_start_time = SystemTime::now();
@@ -846,13 +849,20 @@ impl Imap {
task::block_on(async move {
let interrupt = stop_token::StopSource::new();
// TODO: More flexible interval
let interval = async_std::stream::interval(Duration::from_secs(10));
// we use 1000 minutes if we are told to not try network
// which can happen because the watch_folder is not defined
// but clients are still calling us in a loop.
// if we are to use network, we check every minute if there
// is new mail -- TODO: make this more flexible
let secs = if use_network { 60 } else { 60000 };
let interval = async_std::stream::interval(Duration::from_secs(secs));
let mut interrupt_interval = interrupt.stop_token().stop_stream(interval);
*self.interrupt.lock().await = Some(interrupt);
while let Some(_) = interrupt_interval.next().await {
// check if we want to finish fake-idling.
if !use_network {
continue;
}
if !self.is_connected().await {
// try to connect with proper login params
// (setup_handle_if_needed might not know about them if we
@@ -1154,13 +1164,6 @@ impl Imap {
.list_folders(session, context)
.await
.expect("no folders found");
let delimiter = self.config.read().await.imap_delimiter;
let fallback_folder = format!("INBOX{}DeltaChat", delimiter);
let mut mvbox_folder = folders
.iter()
.find(|folder| folder.name() == "DeltaChat" || folder.name() == fallback_folder)
.map(|n| n.name().to_string());
let sentbox_folder =
folders
@@ -1169,6 +1172,15 @@ impl Imap {
FolderMeaning::SentObjects => true,
_ => false,
});
info!(context, "sentbox folder is {:?}", sentbox_folder);
let delimiter = self.config.read().await.imap_delimiter;
let fallback_folder = format!("INBOX{}DeltaChat", delimiter);
let mut mvbox_folder = folders
.iter()
.find(|folder| folder.name() == "DeltaChat" || folder.name() == fallback_folder)
.map(|n| n.name().to_string());
if mvbox_folder.is_none() && 0 != (flags as usize & DC_CREATE_MVBOX) {
info!(context, "Creating MVBOX-folder \"DeltaChat\"...",);

View File

@@ -110,9 +110,14 @@ impl JobThread {
if async_std::task::block_on(async move { self.imap.is_connected().await }) {
return true;
}
let watch_folder_name = match context.sql.get_raw_config(context, self.folder_config_name) {
Some(name) => name,
None => {
return false;
}
};
let mut ret_connected = dc_connect_to_configured_imap(context, &self.imap) != 0;
let ret_connected = dc_connect_to_configured_imap(context, &self.imap) != 0;
if ret_connected {
if context
.sql
@@ -123,12 +128,7 @@ impl JobThread {
self.imap.configure_folders(context, 0x1);
}
if let Some(mvbox_name) = context.sql.get_raw_config(context, self.folder_config_name) {
self.imap.set_watch_folder(mvbox_name);
} else {
self.imap.disconnect(context);
ret_connected = false;
}
self.imap.set_watch_folder(watch_folder_name);
}
ret_connected
@@ -170,10 +170,18 @@ impl JobThread {
}
}
self.connect_to_imap(context);
info!(context, "{}-IDLE started...", self.name,);
self.imap.idle(context);
info!(context, "{}-IDLE ended.", self.name);
if self.connect_to_imap(context) {
info!(context, "{}-IDLE started...", self.name,);
self.imap.idle(context);
info!(context, "{}-IDLE ended.", self.name);
} else {
// It's probably wrong that the thread even runs
// but let's call fake_idle and tell it to not try network at all.
// (once we move to rust-managed threads this problem goes away)
info!(context, "{}-IDLE not connected, fake-idling", self.name);
async_std::task::block_on(async move { self.imap.fake_idle(context, false).await });
info!(context, "{}-IDLE fake-idling finished", self.name);
}
self.state.0.lock().unwrap().using_handle = false;
}

View File

@@ -6,6 +6,7 @@ use crate::error::Error;
use async_std::sync::Arc;
use rustls;
use webpki;
use webpki_roots;
#[derive(Copy, Clone, Debug, Display, FromPrimitive)]
#[repr(i32)]
@@ -270,6 +271,10 @@ impl rustls::ServerCertVerifier for NoCertificateVerification {
pub fn dc_build_tls_config(certificate_checks: CertificateChecks) -> rustls::ClientConfig {
let mut config = rustls::ClientConfig::new();
config
.root_store
.add_server_trust_anchors(&webpki_roots::TLS_SERVER_ROOTS);
match certificate_checks {
CertificateChecks::Strict => {}
CertificateChecks::Automatic => {