Commit Graph

298 Commits

Author SHA1 Message Date
Damir Jelić
4e29caf8b2 pantalaimon: Bump version. 2019-12-19 16:55:51 +01:00
Damir Jelić
d9ed67e9bf client: Use a loop sleep time. 2019-12-19 16:35:32 +01:00
Damir Jelić
2853e789d3 client: Use the AsyncClientConfig. 2019-12-19 16:35:11 +01:00
Damir Jelić
e115c6f690 client: Handle more to-device event types from the client sync stream. 2019-12-19 16:01:37 +01:00
Damir Jelić
f3014ec649 client: Refactor out the to device event handling. 2019-12-19 16:00:38 +01:00
Damir Jelić
d38825704d client: Decrypt to-device events from the client sync stream. 2019-12-09 10:43:16 +01:00
Denis Kasak
57e08221de Prepare for prompt-toolkit 3.0 2019-12-05 20:18:13 +01:00
Damir Jelić
a51e93a868 config: Add a DebugEncryption setting to enable the nio crytpo logs. 2019-11-19 16:54:07 +01:00
Damir Jelić
b5ca82976c pantalaimon: Bump the version. 2019-10-18 13:57:48 +02:00
Adam Beckmeyer
ce5372bbfa
Make ui dependencies actually optional 2019-10-14 11:54:37 -04:00
Travis Ralston
6b4f958d53
Merge pull request #22 from matrix-org/travis-docker
Add a simple dockerfile (and other stuff for early bot support)
2019-10-09 12:53:36 +01:00
Travis Ralston
5d43113a26
Merge pull request #24 from matrix-org/travis-fix-alias-lookups
Encode hashes correctly in proxied requests
2019-10-09 12:48:51 +01:00
Travis Ralston
d030863245 Use urllib instead of magic replace 2019-10-09 12:41:03 +01:00
Travis Ralston
cd34b813df Revert "When not using a UI, assume it is safe to send to unverified devices"
This reverts commit 4e993eae59.
2019-10-09 12:29:50 +01:00
Travis Ralston
ba76623433 Revert "Always persist/read the access token when a keyring isn't available"
This reverts commit 48c7f7a17e.
2019-10-09 12:26:23 +01:00
Travis Ralston
a11c9274ef Don't encrypt reaction events for now
Fixes https://github.com/matrix-org/pantalaimon/issues/23
2019-10-09 11:24:07 +01:00
Travis Ralston
fa7255e091 Encode hashes correctly in proxied requests
This is a very disgusting fix, but it works. Fixes https://github.com/matrix-org/pantalaimon/issues/21
2019-10-09 10:42:23 +01:00
Travis Ralston
4e993eae59 When not using a UI, assume it is safe to send to unverified devices
This is also for bot/docker usage. It's arguable that this should be behind a config flag somewhere.
2019-10-02 22:12:35 -06:00
Travis Ralston
48c7f7a17e Always persist/read the access token when a keyring isn't available
Otherwise things just silently fail on restart: the users won't be able to sync, and it'll complain about unknown tokens for devices.
2019-10-02 22:11:57 -06:00
Travis Ralston
70969d43ec Support a data path for Docker usage
Storing somewhere in the Docker container doesn't help anyone - we should use the volume
2019-10-02 22:10:59 -06:00
Damir Jelić
87b37e366e pantalaimon: Fix the formatting. 2019-08-07 13:02:15 +02:00
Damir Jelić
c0cd6a3b98 panctl: Add support to continue or cancel key requests. 2019-08-07 13:01:01 +02:00
Damir Jelić
ddce830d8c daemon: Add support for key request handling. 2019-08-07 13:00:19 +02:00
Damir Jelić
20bfdce167 pacntl: Smyle style fixes. 2019-08-07 12:59:19 +02:00
Damir Jelić
422856b78a ui: Remove the store completely now since it's not used anymore. 2019-08-06 10:06:14 +02:00
Damir Jelić
555c2b5f9e
pantalaimon: Bump version. 2019-07-26 15:10:25 +02:00
Damir Jelić
94fa30a56e daemon: Really disable the experimental db backend. 2019-07-26 13:57:51 +02:00
Damir Jelić
d6827e524c ui: Don't add deleted devices to the devices dict. 2019-07-26 13:16:00 +02:00
Damir Jelić
a339f7be1d client: Catch a KeyboardInterrupt exception in the fetcher loop. 2019-07-26 12:47:20 +02:00
Damir Jelić
87c4958e15 client: Add the room id and token to the fetcher task log line. 2019-07-26 12:46:27 +02:00
Damir Jelić
f570a74b52 client: Disable the SqliteQueue database for now. 2019-07-26 12:46:05 +02:00
Damir Jelić
5c3753a6e1 client: Add support for the Sqlite Queue database from peewee. 2019-07-22 16:21:54 +02:00
Damir Jelić
8cf1968f53 pantalaimon: Formatting fixes. 2019-07-22 12:24:15 +02:00
Damir Jelić
a1c206b8a6 ui: Whitespace fix. 2019-07-22 11:31:38 +02:00
Damir Jelić
1582d7ebf5 client: Log an error if we fail to fetch the room history. 2019-07-22 11:20:29 +02:00
Damir Jelić
872267073b ui: Simplify the ui support detection logic. 2019-07-17 22:53:29 +02:00
Damir Jelić
ea0d35e3e4 ui: Don't disable the UI code unconditionally. 2019-07-12 22:34:42 +02:00
Damir Jelić
9dd3e79bac daemon: Catch a RuntimeError for the keyring.
If the keyring doesn't manage to find a sensible and secure keyring backend it
will raise a RuntimeError.

Catch this error and log the error message. The keyring can be disabled
in the config if the system cannot provide a sensible keyring backend.
2019-07-12 16:00:18 +02:00
Damir Jelić
b9d518fad8 pantalaimon: Only send UI messages if there is a queue. 2019-07-12 14:47:51 +02:00
Damir Jelić
ad65fbf1a7 pantalaimon: Make the dbus UI optional. 2019-07-12 14:47:20 +02:00
Damir Jelić
dfa5501a6c daemon: Create a method to send messages to the UI thread. 2019-07-12 14:17:22 +02:00
Damir Jelić
ed71fdedb2 client: Don't use the queue attribute directly. 2019-07-12 14:16:14 +02:00
Damir Jelić
48b4baf79c pantalaimon: Update to nio 0.4. 2019-07-12 10:55:20 +02:00
Damir Jelić
fb0bc090c7 client: Formatting fix. 2019-07-04 14:56:16 +02:00
Damir Jelić
1b58d60abc client: Fire out events when the fetcher loop iterates. 2019-07-04 14:55:21 +02:00
Damir Jelić
bf64f4cbae client: Add/delete a continued/old fetcher task atomically. 2019-07-04 14:54:27 +02:00
Damir Jelić
98dfda9496 client: Add missing await. 2019-07-04 14:53:27 +02:00
Damir Jelić
22ee14e7b9 client: Only run sync specific tasks if there's a new sync token. 2019-07-03 17:46:38 +02:00
Damir Jelić
088b0a22d2 ui: Remove a duplicate import. 2019-07-03 17:43:48 +02:00
Damir Jelić
a5e1c59931 panctl: Don't duplicate the commands in a list.
The commands are already stored in a dictionary holding the command and
their respective help message.
2019-07-03 17:42:48 +02:00
Damir Jelić
758ca1fd85 client: Allow the pan client sync loop to have a timeout between iterations. 2019-07-03 17:42:14 +02:00
Damir Jelić
53d1a2945d index: Make the index optional.
This patch disables the message indexer an message store if
tantivy is not installed.

The search API endpoint forwards all search requests to the homeserver.
2019-07-03 17:41:49 +02:00
Damir Jelić
fa1c2bb694 client: Use coroutines for the event callbacks. 2019-07-03 09:50:45 +02:00
Damir Jelić
3e32b9544b daemon: Update the devices in the UI thread after a send and ignore. 2019-07-02 14:12:27 +02:00
Damir Jelić
6510bd7eb9 client: Only send device update messages if there were changed devices. 2019-07-01 18:19:36 +02:00
Damir Jelić
f2415738f3 ui: Don't load the devices from the store.
The device list in the UI thread is replicated so we can show UI clients
the list without the need for a lock.

The previous implementation relied on loading and reloading of the device
list from the store every time an event changed either the devices or their
trust state.

This leads to a couple of ineficiencies leading to timeouts while
waiting on the database lock if a user has a large number of devices.

The new implementation never loads devices in the UI thread from the
database, they get passed through the thread queue by the main thread
which already holds them in memory.
2019-07-01 18:19:30 +02:00
Damir Jelić
62d0e5607e ui: Don't load pan users from the db, pass them over the queue. 2019-06-19 15:54:58 +02:00
Damir Jelić
c9ebfd71ec pantalaimon: Format the source tree using black. 2019-06-19 12:37:44 +02:00
Damir Jelić
531d686d8f pantalaimon: Run isort. 2019-06-19 12:07:56 +02:00
Damir Jelić
773b708f14 daemon: Remove unnecessary pass. 2019-06-19 11:56:32 +02:00
Damir Jelić
2c831de532 config: Set some more default values for the server config. 2019-06-19 11:21:43 +02:00
Damir Jelić
c8d81b9cf4 client: Catch keyboard exceptions for the client tasks. 2019-06-18 16:31:17 +02:00
Damir Jelić
e766b1ae4b config: Make the delay between room history fetching configurable. 2019-06-18 16:30:38 +02:00
Damir Jelić
0ad0da2151 daemon: Add missing await. 2019-06-18 15:35:50 +02:00
Damir Jelić
aafc56b44d daemon: Add CORS headers to the responses.
This add CORS headers to all the responses, they are required for web
based clients (e.g. Riot) to work.
2019-06-18 10:10:25 +02:00
Damir Jelić
f5ffd69a79 config: Make the batch size for room history fetching configurable. 2019-06-17 16:59:54 +02:00
Damir Jelić
0940b67eb8 pantalaimon: Add the ability to index only encrypted rooms.
Since some public rooms can be quite large downloading the room history
for such rooms can be quite resource intensive.

Replicating the whole room history locally for such rooms might be
undesirable. This patch adds the ability to only download room history
and index messages for encrypted rooms.

Do note that the search API supports searching in multiple rooms, thus
if the indexing is restricted to encrypted rooms a search across
multiple rooms will need to make a search request to the server as well
as a local search. This mode is currently unsupported.
2019-06-17 15:23:06 +02:00
Damir Jelić
83f62b0378 config: Make additional Homeserver requests for the search endpoint optional. 2019-06-17 12:26:38 +02:00
Damir Jelić
a6a62434e0 client: Add the context token fetching back for the search. 2019-06-17 10:29:23 +02:00
Damir Jelić
1850ead698 daemon: Sort the imports. 2019-06-14 15:23:41 +02:00
Damir Jelić
fa3e11a1ec index: Catch query parsing errors.
Tantivy's query parser can throw errors if the syntax of the query is
invalid.

There is a more lenient query parser[1] in the works but until then
catch query parser errors and return an error response to the user.

[1] https://github.com/tantivy-search/tantivy/issues/5
2019-06-14 15:15:58 +02:00
Damir Jelić
3a1b001244 index: Rewrite the search logic.
This patch moves all the indexing, event storing and searching into a
separate class.

The index and message store are now represented as a single class and
messages are indexed and stored atomically now which should minimize the
chance of store/index inconsistencies.

Messages are now loaded from the store as a single SQL query and the
context for the messages is as well loaded from the store instead of
fetched from the server.

The room state and start/end tokens for the context aren't currently
loaded.
2019-06-14 14:53:25 +02:00
Damir Jelić
a489031962 client: Fix a style issue. 2019-06-13 13:01:58 +02:00
Damir Jelić
1f5afd75c6 client: Allow per room search.
This is not ideal. We only support a single room or all rooms, which is
good enough for now since riot does that.

The tantivy boolean query logic isn't ideal and didn't work out with
multiple rooms in the query.
2019-06-13 12:32:52 +02:00
Damir Jelić
fe10f54ea9 client: Error out gracefully if we get an invalid limit. 2019-06-13 12:32:21 +02:00
Damir Jelić
ba09f77cb6 client: Simplify the sync logic. 2019-06-12 16:24:03 +02:00
Damir Jelić
6092e27748 client: Pass the sync token to the sync method. 2019-06-12 15:39:43 +02:00
Damir Jelić
b4e60b603a client: Store the history fetcher tasks to the db. 2019-06-12 15:39:08 +02:00
Damir Jelić
1ad2a3af28 daemon: Add access control headers to the search endpoint.
These headers are important for riot to be able to use pan's search
endpoint instead of the default Homeserver endpoint. It fails to search
using pan with CORS errors.
2019-06-12 15:34:08 +02:00
Damir Jelić
a2d6f3cc84 client: Fetch room members before the first encrytped send. 2019-06-12 15:33:27 +02:00
Damir Jelić
383f197e58 client: Store and load sync tokens. 2019-06-11 16:11:53 +02:00
Damir Jelić
2fc738dc20 client: Change the initial sync to contain full state.
Fetching the full state with the initial sync is important because we
don't store any room state locally.

Since we don't store any sync token we are getting the full state
anyways. But once we do this change will be crucial for encryption to
work correctly.
2019-06-11 15:00:35 +02:00
Damir Jelić
8c3cfbc0dd client: Fetch old room messages if there was a limited room timeline.
This patch adds the ability to fetch the whole room history. Note that
this is still incomplete as it not fetch the whole history if it gets
interrupted.

Another deficiency is that it always tries to start fetching room
history after a restart even though we know that it doesn't need to do
so.
2019-06-11 13:59:34 +02:00
Damir Jelić
c7ca5d9851 pantalaimon: Mypy fixes. 2019-06-11 11:24:37 +02:00
Damir Jelić
5b58294a95 pantalaimon: Isort the tree. 2019-06-11 11:24:18 +02:00
Damir Jelić
1e3d891a57 client: Add the ability to order the search by recency. 2019-06-10 16:12:45 +02:00
Damir Jelić
88dbd2000a index: Change the index format.
Tantivy allows search results to be ordered by arbitrary index fields as
long as they are a fast field and have the FastValue trait implemented.
This trait is only for u64 and i64 fields implemented.

To order the the search results by recency we need to add a unsigned
field that stores the server timestamp of the message.
2019-06-10 15:56:05 +02:00
Damir Jelić
818db73a48 daemon: Handle invalid order by fields for the search. 2019-06-10 15:55:37 +02:00
Damir Jelić
8927bb0c90 client: Fix the search response format. 2019-06-10 15:53:19 +02:00
Damir Jelić
71e672a431 client: Make the room messages callback more specific. 2019-06-10 15:52:22 +02:00
Damir Jelić
1db93a731f client: Add the ability to add the context and state to search results. 2019-06-07 11:59:53 +02:00
Damir Jelić
725c043e87 pantalaimon: Initial search support.
This patch adds support for the Matrix search API endpoint.

Events are stored in the pan sqlite database while the indexing is
handled by tanvity.

An tantivy index is created for each pan user. Currently only ordering
by ranking is supported, and all the search options are ignored for now.
2019-06-06 14:25:14 +02:00
Damir Jelić
160fbbaf98 panctl: Add a version option. 2019-05-24 13:48:39 +02:00
Damir Jelić
f8820c0e73 pantalaimon: Add a version option. 2019-05-24 13:48:21 +02:00
Damir Jelić
cc76a8159b panctl: Add a help command. 2019-05-24 11:33:02 +02:00
Damir Jelić
4fe5e7d584 pantalaimon: Isort fixes. 2019-05-23 14:46:29 +02:00
Damir Jelić
ce89b1e407 pantalaimon: Abort the daemon gracefully on keyring errors. 2019-05-23 13:50:02 +02:00
Damir Jelić
e597969a21 config: Make the OS keyring optional. 2019-05-23 13:34:59 +02:00
Damir Jelić
a25ab95f62 config: Allow notifications to be disabled in the config. 2019-05-23 12:00:39 +02:00
Damir Jelić
bfcfdd61ea ui: Add OS notifications. 2019-05-22 16:40:15 +02:00