Eric Wong [Thu, 1 Oct 2015 05:57:19 +0000 (05:57 +0000)]
view: correctly pick latest in index anchor links
The last message in a thread _display_ is not necessarily the
latest message in the thread. We must go by the Date: header
on the messages themselves as a best-guess. Of course Date:
headers may lie, but most mail clients trust them by default,
so we will, too.
Eric Wong [Wed, 30 Sep 2015 21:00:25 +0000 (21:00 +0000)]
nntp: implement OVER/XOVER summary in search document
The document data of a search message already contains a good chunk
of the information needed to respond to OVER/XOVER commands quickly.
Expand on that and use the document data to implement OVER/XOVER
quickly.
This adds a dependency on Xapian being available for nntpd usage,
but is probably alright since nntpd is esoteric enough that anybody
willing to run nntpd will also want search functionality offered
by Xapian.
This also speeds up XHDR/HDR with the To: and Cc: headers and
:bytes/:lines article metadata used by some clients for header
displays and marking messages as read/unread.
Eric Wong [Wed, 30 Sep 2015 21:00:20 +0000 (21:00 +0000)]
daemon: always autoflush stdout/stderr
Users may log output to a pipe, so ensure these outputs are
unbuffered in userspace and go to the operating system ASAP
for other processes to pick up.
Eric Wong [Wed, 30 Sep 2015 21:00:19 +0000 (21:00 +0000)]
remove unnecessary fields usage
It doesn't actually give performance improvements unless we
use types with "my", but we don't do that. We'll only continue
using fields with Danga::Socket-derived classes where they're
required.
Eric Wong [Fri, 25 Sep 2015 08:21:43 +0000 (08:21 +0000)]
daemon: fix various permissions + daemon issues
When using user-switching in a single process, we must be
careful to not inadvertantly create new Msgmap sqlite3 files.
We must also ensure we set proper permissions on any files
we create.
Additionally, our refactoring was broken as we failed to
actually daemonize or preserve the parent FD in a worker
process.
Finally, default to one worker process since our code may
be fatally broken and it's nice to be able to scale to multiple
cores via SIGTTIN if needed.
Eric Wong [Fri, 25 Sep 2015 02:27:57 +0000 (02:27 +0000)]
nntp: avoid signals for long responses
Using a signal-based timer can hurt throughput on a machine that's
overloaded. Ensure there's always forward progress and reduce the
number of syscalls we make, too.
Eric Wong [Thu, 24 Sep 2015 21:28:51 +0000 (21:28 +0000)]
nntpd: hoist out daemon management code
We'll probably be supporting read-only IMAP, or maybe
we'll just implement a custom HTTP server so users can
manage/upgrade the same way as the nntpd while being
immune to slow clients.
Eric Wong [Mon, 21 Sep 2015 11:11:11 +0000 (11:11 +0000)]
remove bytes:: for length checks
Apparently, my mental model of Perl internals is still incorrect
after all these years. I am but a simple *nix programmer:
everything is a bag of bytes to me.
This fixes a problem with UTF-8 headers from Xapian (via
"XHDR Subject [range]") triggering partial writes and writing an
extra newline to the outputs.
Eric Wong [Sun, 20 Sep 2015 09:34:52 +0000 (09:34 +0000)]
nntp: add "newsgroup" parameter and sort grouplist
Using non-hierarchical mailing list names for newsgroups
might confuse traditional newsreader software and perhaps
some humans. Allow administrators to configure newsgroups
names and hierarchies to their liking.
Sorting the grouplist alphabetically should probably be
done anyways to improve usability for some clients which
won't sort themselves.
Eric Wong [Sun, 20 Sep 2015 03:36:11 +0000 (03:36 +0000)]
nntp: fix handling of trickled responses
We cannot use the push_back_read functionality of Danga::Socket
since it will trigger event_read on buffered data. This would
allow a malicious (or badly implemented) client to burn CPU
without actually sending us anything.
So we still do buffering ourselves and play some tricks with
timers re-enable readability.
Eric Wong [Sat, 19 Sep 2015 02:03:38 +0000 (02:03 +0000)]
nntp: fix ARTICLE/HEAD/BODY/STAT
Article number is optional, but we need to update the
article number of the client connection if it was specified
(but not if it was given a Message-ID) as stipulated by
RFC 977
Eric Wong [Sat, 19 Sep 2015 02:03:34 +0000 (02:03 +0000)]
nntp: speed up XHDR for the Message-ID case
We can use our msgmap database to implement "XHDR Message-ID [range]"
commands quickly. This helps immensely with slrnpull, which prefers
XHDR to LISTGROUP for some reason...
Eric Wong [Sat, 19 Sep 2015 02:03:30 +0000 (02:03 +0000)]
nntp: introduce long response API for streaming
XOVER, NEWNEWS, XHDR responses may be arbitrarily long and cause
memory usage via buffering. This problem would exist even if we
were to optimize them by caching headers for fast retrieval and
search.
Introduce a generic API to handle all of these commands fairly
without triggering excessive buffering and unfairness of the
existing implementation.
Generating these responses is still expensive for now, but at least
the implementation is fair to other clients and prevents one client
from using one of these commands to monopolize resources away from
other clients.
Eric Wong [Tue, 15 Sep 2015 01:08:03 +0000 (01:08 +0000)]
extmsg: wire up to use msgmap for prefixes
DBI + DBD::SQLite has much better handling of prefix lookups
than Xapian. While we're at it, avoid linking blatantly wrong
Message-IDs to external services.
Eric Wong [Tue, 15 Sep 2015 01:08:02 +0000 (01:08 +0000)]
searchidx: sync Msgmap database along with Xapian
We can avoid duplicating work of extracting messages from git if we
tie this to Xapian. Of course, this ties the two features together,
but it's probably reasonable to expect that anybody who wants to use
public-inbox to serve messages to front-end users will have both.
Eric Wong [Mon, 14 Sep 2015 00:04:30 +0000 (00:04 +0000)]
searchview: do not link Atom feed by relevance
Atom feeds only make sense when sorted by time, not when our
search indexing rules change and affect relevance. So do not
include the relevance option when linking to Atom feeds.
However, we shall still honor the 'r' query parameter in case
somebody wants to manually include that in the URL for
testing/experimental purposes. We simply will not advertise
it.
Eric Wong [Sat, 12 Sep 2015 01:23:32 +0000 (01:23 +0000)]
searchview: support displaying entire threads
This hopefully makes it easy to perform queries to display
an entire thread. Raise the limit in the threaded view to
display more results and hopefully improve the output of
thread display.
Eric Wong [Mon, 7 Sep 2015 07:02:20 +0000 (07:02 +0000)]
view: change References link to expand thread
The expanded thread view is generally more useful. Having links
to more links at the bottom seems to a waste of navigation time.
However, keep the '#r' anchor in case people rely on it for
links.
Eric Wong [Sat, 5 Sep 2015 08:00:12 +0000 (08:00 +0000)]
search: tweak parsing for internal queries
We should not need to use QueryParser for internal queries,
but rather for external ones.
We'll also be exposing searching Message-IDs with the "mid:" prefix
for broken mids on some servers, and enabling partial searching
with 'm' to help with URL truncations.
Since thread IDs may be volatile, they cannot be exposed to the
public, there's no reason to expose them to the query parser,
either.
Also, add 's:' as an alternative probabilistic prefix to 'subject'
as it is shorter.
Eric Wong [Sat, 5 Sep 2015 05:54:26 +0000 (05:54 +0000)]
searchview: improve footer navigation
Aallow navigating backwards and forwards, as some pages will be
bookmarked or some browsers may not have history. Also add a
link back to the index where they presumably came from.
While we're at it, limit the number of results we have to 25
for now to avoid making the page too big and wasting clients
memory for irrelevant results.