PID of commands run with `CommandProtocol` are now tracked in memory and stopped/killed on
exit. A `pid_file` argument can be use to track the file on disk, which is useful to
detect stalled processes after a crash/unclean ending of the backend.
Add helper methods to stop and kill those processes.
Add the `li backup` commands with `export`, `import` and `verify`:
- data types selection (`-i`/`-e`) and profile selection (`-p`), `--no-db` on export, `--use-db` on
import
- GPG symmetric encryption of the archive (`--encrypt`)
- progression is shown, with ETA
- the commands can run without a backend connection (import from DB MUST be run without
backend)
- cli (base): `BRIDGELESS_COMMANDS` holds the name of the few commands which can be run
without backend.
rel 480
Add an offline backup/restore engine in `tools.backup`:
- format based on XEP-0227 (pie), extended with Libervia sections
- handle several data types (params, private, roster, pep , gpg, files and db)
- per profile export/import and global handlers
- a manifest is used to have metadata and checksums
- full database snapshot/restore with the `db` type
- sqla: add `get_db_url`
- tools.common.utils: add `is_safe_relpath` and `is_process_running`
rel 480
As PEP bookmarks are nowadays used to sync joined state across devices, trigger points
have been added to XEP-0045 so XEP-0402 can automatically update the `autojoin` status on
MUC joining or leaving.
A check has been added to ignore already joined or left room when XEP-0402 plugin updates
the MUC status on bookmark update.
- Keep the destination resource when resending the correction (e.g. `room/nick`).
- Match the corrected message by id (fallback: last message from the sender).
- Ignore corrections that can't be matched, or whose content is already applied (e.g.
own corrections redelivered by MAM).
- `RATIO_CUTOFF` has been adapted to avoid returning approximate matches.
- In case of duplicate entries (e.g., rooms returned by the local search are also returned
by the external one), we keep only the item with the most metadata.
- Exclude `None` values in `jid_search` bridge method.
Use Pydantic models for data used with bridge.
Also update `backend.models.core.DiscoIdentity` to have `None` as possible and default
value for `name`.
If a room was not joined (e.g., due to failure), `is_room` was wrongly returning `False`.
Disco identity is now used as fallback to detect correctly is an entity is a room or not.
This changes makes `is_room` async, and by extension `get_bare_or_full` too.
If empty string is used for nick in `join` (e.g., due to a bridge call), take use part of
the JID. This fix the use of empty resource, which was resulting in rejection by the
server.
5s timeout is too short, if the server is overloaded or connection is slow, it makes the
identity retrieval fail. 15s is more reasonable and matches timeout used for disco.
We now use `client.is_message_printable` to check if message is printable. If it's not, we
block storage in DB and sending to bridge. The previous code could let message pass if
metadata were stored in `extra`.
Podman can be used as a drop-in replacement for Docker, and it doesn't need root
permissions. The plugin now has a settings to use Podman, and use `auto` by default which
will choose the first found on the device (Podman is tested first).
New `serverless` commands. For now only `discover` and `info` are implemented:
- `discover` find other peers on LAN
- `info` get various infos on serverless status (for now, our own device ID,
advertised service name, and the number of found peers)
rel 479
Implement peer discovery on LAN using mDNS (via `zeroconf`).
A Peer ID is generated (via `libP2P`) per instance, and announced on backend startup.
Meanwhile, other peers are discovered on LAN. A signal is send on peer found and another
on peer lost.
There a bridge methods to find already discovered peers, and to get infos on serverless
(our own ID, adverised service name, and number of peers found).
`Zeroconf` runs in background in its own thread.
rel 479
Cleaning methods per-profile (`profile_disconnected`) and per-plugin (`unload`) were not
called correctly. They are now called on shutdown with the `before/shutdown` Twisted
event.
With this event, it's still possible to call Deferred and do cleaning requiring async
calls.
rel 479
Due to the yielding, `_node_cb` could be modified during node event management, resulting
in an exception. The items are now shallow copied to avoid issue.
`libp2p` will used for implementing serverless features, `zeroconf` for LAN discovery.
Lock file has been updated.
Note: `libp2p` is currently not compatible with Python 3.14 (cf.
https://github.com/libp2p/py-libp2p/issues/1100 )
rel 479
Normally the backend is made to have a singleton instance, and handle all profiles.
However, it may be useful to run instances independently (e.g., for development, to run
components in independent processes, for testing, etc).
This was previously possible by using a specific configuration files at backend's root.
This patch introduce a cleaner way by using an isolation mode.
Isolation mode is activated by settings the `LIBERVIA_ISOLATION` environment variable to
the name of the isolated instance. `LIBERVIA_ISOLATION_MODE` can be used to specify one of
the following mode:
- normal (default): config and shared files are in XDG in a `isolated/<name>` subdirectory
(usually `~/.local/share/libervia/isolated/<name>` and
`~/.config/libervia/isolated/<name>`). Runtime files and other instance specific data
(such as D-Bus name) are also isolated. Config uses cascade as usual.
- full: same as above, but config isn't cascading, it's using only its own isolated config
file.
- tmp: same as normal but the local directory is put in a temporary directory, and deleted
on backend startup. It stays on termination, so data can be checked if necessary (this mode is
usually used for development).
This feature will notably be useful to test severless mode on a single machine.
rel 479
- Hash (SHA-256) is now automacally computed when a file is uploaded via XEP-0363, and
used if no hash has been specified by frontend already.
- Use named tuples (`UploadTracking` and `UploadResult`) to handle callback values.
- upload: fix a bug (missing variable) in `unregister` (which is not used yet anyway).
- usual docstring/type hints improvements
XEP-0447 allow to send sources after the original message. Dino is doing that, and thus we
can't display attachment immediately with only the original message.
This patch handle that by updating the original message once the sources are received, and
emitting a `message_update` signal to notify frontends.
- Fix the wrong encoding of the hash hex string value instead of the binary value.
- Use a `StrEnum` for model, use models specified in XEP-0414.
- Minor typing hint/docstring improvments.