aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2015-09-07 04:09:21 +0200
committerGuilhem Moulin <guilhem@fripost.org>2015-09-07 04:09:21 +0200
commit0f3cfac7f1961dad77d8fab3abc83f58b3bb20fa (patch)
tree59c2e6004287d3f2c7d1aa7bd8b7bfe0a3c253e7
parent0dbf7b6c4e4e6009ecc38d012997d1d209931f81 (diff)
parent556056abb3004318a3a9c406450bd5315f3d0d6f (diff)
Merge branch 'master' into debian
-rw-r--r--INSTALL7
-rw-r--r--README86
-rw-r--r--lib/Net/IMAP/Sync.pm4
3 files changed, 50 insertions, 47 deletions
diff --git a/INSTALL b/INSTALL
index c9c1389..3c581cb 100644
--- a/INSTALL
+++ b/INSTALL
@@ -18,3 +18,10 @@ On Debian GNU/Linux systems, these modules can be installed with the
following command:
apt-get install libconfig-tiny-perl libdbi-perl libdbd-sqlite3-perl libio-socket-ssl-perl
+
+However Debian GNU/Linux users can also use gbp(1) from git-buildpackage
+to build their own package:
+
+ $ git checkout debian
+ $ git merge master
+ $ AUTO_DEBSIGN=no gbp buildpackage --git-force-create --git-upstream-tree=BRANCH
diff --git a/README b/README
index 5db5b9e..4192812 100644
--- a/README
+++ b/README
@@ -7,53 +7,49 @@ LITERAL+ [RFC2088] and MULTIAPPEND [RFC3502], these extensions greatly
improve performance by reducing the number of required round trips hence
are recommended.
-
-Stateful synchronization is only possible for mailboxes supporting
-persistent message Unique Identifiers (UID) and persistent storage of
-mod-sequences (MODSEQ); any non-compliant mailbox will cause imapsync to
-abort. Furthermore, because UIDs are allocated not by the client but by
-the server, imapsync needs to keep track of associations between local
-and remote UIDs for each mailbox. The synchronization state of a
-mailbox consists of its UIDNEXT and HIGHESTMODSEQ values on each server;
-it is then assumed that each message with UID < $UIDNEXT have been
-replicated to the other server, and that the metadata (such as flags) of
-each message with MODSEQ <= $HIGHESTMODSEQ have been synchronized.
-Conceptually, the synchronization algorithm is derived from [RFC4549]
-with the [RFC7162, section 6] amendments, and works as follows:
-
-
- 1. SELECT (on both servers) a mailbox the current UIDNEXT or
- HIGHESTMODSEQ values of which differ from the values found in the
- database (for either server). Use the QRESYNC SELECT parameter from
- [RFC7162] to list changes (vanished messages and flag updates) since
- $HIGHESTMODSEQ to messages with UID<$UIDNEXT.
-
- 2. Propagate these changes onto the other server: get the corresponding
- UIDs from the database, then a/ issue an UID STORE + UID EXPUNGE
- command to remove messages that have not already been deleted on
- both servers, and b/ issue UID STORE commands to propagate flag
- updates (send a single command for each flag list in order the
- reduce the number of round trips). (Conflicts may occur if the
- metadata of a message has been updated on both servers with
- different flag lists; in that case imapsync issues a warning and
- updates the message on each server with the union of both flag
- lists.) Repeat this step if the server sent some updates in the
- meantime. Otherwise, update the HIGHESTMODSEQ value in the
- database.
-
- 3. Process new messages (if the current UIDNEXT value differ from the
- one found in the database) by issuing an UID FETCH command and for
- each message RFC822 body received, issue an APPEND command to the
- other server on-the-fly. Repeat this step if the server received
- new messages in the meantime. Otherwise, update the UIDNEXT value
- in the database. Go back to step 2 if the server sent some updates
- in the meantime.
-
- 4. Go back to step 1 to proceed with the next unsynchronized mailbox.
-
-
Consult the manual for more information.
imapsync is Copyright© 2015 Guilhem Moulin ⟨guilhem@fripost.org⟩, and
licensed for use under the GNU General Public License version 3 or
later. See ‘COPYING’ for specific terms and distribution information.
+
+#######################################################################
+
+
+IMAP traffic is mostly text (beside message bodies perhaps) hence
+compresses pretty well: enabling compression can save a great amount of
+network resources.
+
+However establishing a SSL/TLS connection (type=imaps, or type=imap and
+STARTTLS=YES) yields a small overhead due to the SSL/TLS handshake.
+
+On the other hand if SSH access is allowed on the remote server, one can
+tunnel the IMAP traffic through SSH and use OpenSSH's ControlPersist
+feature to save most of the cryptographic overhead (at the expense of a
+local 'ssh' process and a remote 'imap' process). Moreover if the IMAP
+user is a valid UNIX user it is possible to use pre-authentication on
+the remote server as well, which saves the extra round trip caused by
+the AUTHENTICATE command. For instance the following configuration
+snippet saves bandwidth and brings a significant speed gain compared to
+type=imaps.
+
+ local: $XDG_CONFIG_HOME/imapsync:
+ [remote]
+ type = tunnel
+ command = /usr/bin/ssh user@imap.example.net
+
+ local: ~/.ssh/config:
+ Host imap.example.net
+ IdentityFile ~/.ssh/id-imapsync
+ IdentitiesOnly yes
+ ControlPath /run/shm/%u@%n
+ ControlMaster auto
+ ControlPersist 10m
+ StrictHostKeyChecking yes
+ ServerAliveCountMax 3
+ ServerAliveInterval 10s
+ RequestTTY no
+ Compression yes
+
+ remote: ~user/.ssh/authorized_keys:
+ command="/usr/lib/dovecot/imap",no-agent-forwarding,no-port-forwarding,no-pty,no-user-rc,no-X11-forwarding ssh-... id-imapsync
diff --git a/lib/Net/IMAP/Sync.pm b/lib/Net/IMAP/Sync.pm
index 785aa54..6561a66 100644
--- a/lib/Net/IMAP/Sync.pm
+++ b/lib/Net/IMAP/Sync.pm
@@ -1287,7 +1287,7 @@ sub _select_or_examine($$$;$$) {
my $self = shift;
my $command = shift;
my $mailbox = shift;
- my ($uids, $seqs) = @_;
+ my ($seqs, $uids) = @_;
my $pcache = $self->{_PCACHE}->{$mailbox} //= {};
my $cache = $self->{_CACHE}->{$mailbox} //= {};
@@ -1298,7 +1298,7 @@ sub _select_or_examine($$$;$$) {
if ($self->_enabled('QRESYNC') and ($pcache->{HIGHESTMODSEQ} // 0) > 0 and ($pcache->{UIDNEXT} // 1) > 1) {
$command .= " (QRESYNC ($pcache->{UIDVALIDITY} $pcache->{HIGHESTMODSEQ} "
."1:".($pcache->{UIDNEXT}-1);
- $command .= " ($uids $seqs)" if defined $uids and defined $seqs;
+ $command .= " ($seqs $uids)" if defined $seqs and defined $uids;
$command .= "))";
}