about summary refs log tree commit homepage
path: root/lib
DateCommit message (Collapse)
2021-05-04treewide: update to v3 Tor onions
v2 onions are insecure, deprecated and going away. v3 names are unfortunately longer and more difficult to remember, but should be more resistant to attack than v2 ones.
2021-05-04lei up: fix dedupe with remote externals on Maildir + IMAP
LeiToMail Maildir and IMAP write callbacks need to account for the caller-supplied smsg. We'll also make better use of the user-supplied smsg object by ensuring blob deduplication happens ASAP. Fixes: e76683309ca4f254 ("lei <q|up>: distinguish between mset and l2m counts")
2021-05-03lei <q|up>: writes to Maildirs and IMAP use mail-sync
This will allow keyword updates from other folders to propagate to folders where search results may be duplicated.
2021-05-03net_writer: use "FLAGS.SILENT" to set keywords
Instead of "+FLAGS.SILENT" which merely adds to the keywords. We store all keywords together, so it's unlikely we will rely on the "+FLAGS.SILENT" or "-FLAGS.SILENT".
2021-05-03lei: simplify workers_start API
In most cases, we just name the worker process based on the command. The only change is for LeiMirror vs "lei add-external --mirror", but I doubt it matters.
2021-05-03lei_input: reject --mail-sync if using HTTP(S) for now
I'm not sure how we'll distinguish JMAP vs read-only HTTPS, yet; but we'll focus on currently-supported stuff, first.
2021-05-03lei_input: common net_merge_all_done for lei <import|tag>
I suspect there'll be more lei_input-only things in the future.
2021-05-03lei <q|up>: combine written/results into one line
Having multiple lines of output mean they can be interleaved in daemon mode. Put stats into one line to reduce screen real-estate size and improve readability.
2021-05-01lei_auth: s/net_merge_complete/net_merge_all_done/
We use the "done" term elsewhere for similar things, and my easily-confused mind equates "complete" with shell completion.
2021-05-01lei edit-search: support relocating lei.q.output
The contents of the old lei.q.output will not be removed, but will be converted into the new one.
2021-05-01lei import: fix --mail-sync handling in LeiInput
"lei inspect" also shows "mail-sync" as a field name
2021-05-01lei: rename ls-sync to ls-mail-sync
This allows tab-completion for "ls-search" to work with fewer characters ("ls-s<TAB>" instead of "ls-se<TAB>"), and I expect "ls-search" to be used more frequently than "ls-mail-sync". This also matches the --mail-sync switch of "lei import"
2021-05-01lei_saved_search: fix excess indent for first lei.q entry
This was harmless, but ugly and possibly confusing to users who run "lei edit-search".
2021-05-01lei <q|up>: distinguish between mset and l2m counts
The number of messages we write to --output is usually different than the mset count due to deduplication from combining multiple sources. This change makes the stderr output of "lei up --all=local" way more useful IMHO.
2021-04-30net_reader: support (imap|nntp).proxy in config file
This allows us to use URL-matching config in git and specify proxies on a per-host basis. git 2.26+ users may use wildcards to enable Tor (on 127.0.0.1:9050) for all NNTP and IMAP .onion domains. My ~/.config/lei/config file has the following: [imap "imap://*.onion"] proxy = socks5h://127.0.0.1:9050 [nntp "nntp://*.onion"] proxy = socks5h://127.0.0.1:9050
2021-04-30net_reader: Net::NNTP --proxy=socks5h:// support
Since Net::NNTP doesn't support Socket or RawSocket options/accessors like Mail::IMAPClient does; we must perform localized @ISA manipulation and massage Net::NNTP into using IO::Socket::Socks rather than IO::Socket::IP. This is a bit fragile, but Net::Cmd and Net::NNTP rarely change; and I keep an eye on them, anyways.
2021-04-30lei: IMAP .onion support via --proxy=s switch
Mail::IMAPClient provides the ability to pass a pre-connected Socket to it. We can rely on this functionality to use IO::Socket::Socks in place whatever socket class Mail::IMAPClient chooses to use. The --proxy=s is shared with curl(1), though we only support socks5h:// at the moment. Is there any need for SOCKS4 or SOCKS5 without name resolution? Tor .onions require socks5h:// for name resolution and to prevent data leakage.
2021-04-30net_reader: {nn,mic}_for: use prototypes for internal subs
We don't use these subs elsewhere, so stick prototypes on them to give them a little extra checking.
2021-04-30lei: ensure autoflush(1) is on STDERR
This fixes error reporting for oneshot tests in xt/lei-auth-failure.t
2021-04-30lei: kill old PIDs when dropping
This ensures hitting Ctrl-C on a long-running "lei convert" or similar will stop the WQ worker, even after we've closed the WQ socketpair in the daemon.
2021-04-30lei_curl: improve correctness of LD_PRELOAD check
LD_PRELOAD sent by a client can't affect lei-daemon.
2021-04-30lei sucks: preserve utsname.machine, add "x86" where appropriate
It's helpful for us to distinguish x86 kernels from x86_64 kernels when using an x86 userspace. OSes are dropping i386 support and only support i486 and newer, so "x86" is a more appropriate description for that platform than "i386".
2021-04-30lei_store: fix locking w.r.t epoch creation
Prior to this change, it was possible for oneshot lei processes to race on epoch creation/rollover. lei-daemon normally prevents the problem by funnelling all writes to a single socket, but oneshot lei has no such protection.
2021-04-30lei import: support shell completion of known folders
This also fixes completion of "lei up" for IMAP folders.
2021-04-30lei import: support UIDVALIDITY in IMAP URL
Specifying a UIDVALIDITY value allows the user to enforce a strict match and force failure. This necessitated changes to NetReader to allow die() and make error reporting more suitable for CLI usage rather than daemonized usage of -watch.
2021-04-30lei import: avoid IMAPTracker, use LeiMailSync more
IMAPTracker has a UNIQUE constraint on the `url' column, which may cause compatibility and/or rollback problems in attempting to deal with UIDVALIDITY changes. Having multiple sources of truth leads to confusion and bugs, so relying on LeiMailSync exclusively ought to simplify things. Furthermore, since LeiMailSync is only written to by LeiStore, it is safer in that it won't mark a UID or article as imported until git-fast-import has seen it, and the SQLite commit always happens after "done\n" is sent to fast-import. This mostly reverts recent commits to IMAPTracker to support lei, those are: 1) commit 7632d8f7590daf70c65d4270e750c36552fa9389 ("net_reader: restart on first UID when UIDVALIDITY changes") 2) commit 311a5d37ad275cd75b1e64d87827c4d13fe4bfab ("imap_tracker: prepare for use with lei"). This means public-inbox-watch will not change between 1.6 and 1.7: -watch stops synching a folder when UIDVALIDITY changes.
2021-04-30content_hash: git_sha: allow unblessed SCALAR refs
This will be convenient to avoid the overhead of PublicInbox::Eml for verifying synchronization in lei.
2021-04-28lei: avoid close(STD{IN,OUT,ERR}) in oneshot mode
This seems to fix the occasional "make check-run" failures I've been chasing. Some parts of our code assumes we can close($lei->{1}) and similar, which causes IO::Handle::autoflush to behave badly when STDOUT is the "select"-ed FH of the Perl process. Since oneshot mode is (hopefully) the uncommon case, we'll just accept the cost of extra FDs and minimize differences between lei in oneshot vs daemon mode.
2021-04-28lei (lcat|q): support --no-color and --color
This should be familiar to git users who wish to force color when writing to pipes or disable color.
2021-04-28lei_view_text: translate background colors from git
This seems to work with or without attributes. We'll deal with 256-color terminal colors when/if somebody cares for it, but the usual 16 ought to be more than enough.
2021-04-28lei_view_text: improve attachment display
Support setting a color to distinguish from user-supplied text. We'll also put the $BLOB:$IDX identifier on a separate line and just put the entire corresponding lei command in the form of: "[-- lei blob $BLOB:$IDX --]" to teach users how to access it.
2021-04-28lei: simple WQ workers use {wq1} field
This lets us share more code and reduces cognitive overhead when it comes to picking names (because {lsss} was ridiculous). We'll need to ensure the first error set in lei is the actual error we exit with, otherwise things can get confusing and errors may get lost.
2021-04-28lei: quiet down Eml-related warnings consistently
"lei import" is probably the only place where it users might care about warnings.
2021-04-28lei-daemon: note FD count mismatch to client
This should help in some error diagnostics
2021-04-28lei_p2q: add _lei_wq_eof callback
This may help with some error diagnostics.
2021-04-28view_diff: minor coding style fixes
Prefer "use v5.10", s/base/parent/, rely on "perl -w" for warnings. We also pass a regexp to the split perlop rather than literal SV, since split() will compile a new RE every time.
2021-04-28tests: restore CWD with "lei -C" and run_script
This simplifies test_lei users in t/*.t
2021-04-28view: add [thread overview] anchor next to Date:
The existing Subject: anchor to #r may not be 100% obvious, and we can't stick the phrase "[thread overview]" into the same line as the Subject without introducing ambiguity. Fortunately, we have the Date: header directly under it. Adding "[thread overview]" after the Date: is unambiguous and won't make the line too long for valid emails. This hopefully improves navigation ever-so-slightly thanks to comments by Son Luong Ngoc. Reported-by: Son Luong Ngoc <sluongng@gmail.com> Link: https://public-inbox.org/git/YHhfsqfTJ9NzRwS1@C02YX140LVDN.corpad.adbkng.com/
2021-04-27lei q + lcat: support --format=text output
This is mainly for "lei lcat" where it's the default, but I find it useful anyways compared to the JSON view. Colors are loaded from ~/.config/lei/config, and fall back to using diff colors from a normal git config (e.g. ~/.gitconfig).
2021-04-27lei lcat: extract Message-IDs from URLs and show them
It's a wrapper around "lei q" which extracts Message-IDs from URLs, "<$MSGID>", "id:$MSGID" and attempts to display the local version of the message. Its main purpose is to extract Message-IDs out of commonly-understood URLs to save users bandwidth and time by displaying the message locally. When reading from stdin, it will discard things it doesn't understand, so you can just pipe an entire "Link: $URL" line to it and it'll attempt to pluck the Message-ID out of the URL.
2021-04-27lei: standardize on _lei_wq_eof callback for workers
Simplify our internals a little bit.
2021-04-27lei blob: support retrieving attachments via $OID:$IDX
We'll be supporting some sort of text view for pager or piping to an $EDITOR buffer.
2021-04-27lei: add "ls-sync" command for listing sync folders
This will be useful, later.
2021-04-26URIimap: canonicalize uppercases UIDVALIDITY parameter
And the UID one, too, as well. This simplifies future comparison and matching code once case is no longer taken into account.
2021-04-26lei p2q: exit with failure if format-patch fails
Merely redirecting the failure message from git to our stderr is insufficient.
2021-04-26lei_input: support PublicInbox::WWW mboxrd URLs
This gives "lei import", "lei tag", and similar commands the ability to use URLs recognized by our PSGI frontend directly. This is more convenient than an equivalent shell pipeline since "set -o pipefail" is not portable and errors may be lost.
2021-04-26www: missing /$INBOX/$MSGID/raw returns 404
Don't attempt to return HTTP 300 via Extmsg on it, since whoever uses /raw is likely piping it to some other command.
2021-04-25lei_xsearch: show --output location with match count
This makes "lei up --all=local" output easier-to-understand when it's updating multiple saved searches.
2021-04-24lei_saved_search: avoid reentrancy in ->is_dup
Use a separate git process when calling xoids_for to prevent reentrancy in ->is_dup. Reentrancy happens since LeiToMail will call ->is_dup when inside callbacks when writing mail. This fixes --dedupe=mid test failures in t/lei-q-save.t I could only reproduce this consistently on a uniprocessor VM. "schedtool -a 0x1 -e ..." could not reproduce the problem on 2 and 4-core systems.
2021-04-24test_common: don't attempt to seek on pipes and terminals
This allows proper error reporting on daemon failure when using "check-run".