Commit graph libervia-backend/libervia/backend/core/main.py
Author SHA1 Message Date
Goffi
68da01a043 Dates update. 2026-03-31 12:57:17 +02:00
Goffi
c634204ac7 core (main): log errors during post_init. 2026-03-30 11:37:17 +02:00
Goffi
a9fa2eeed4 core (main, config): Component auto-configuration:
New `jid`, `secret` and `autoconnect` field are used for component settings. When used,
backend will automatically create the profile and set its relevant parameters, or check
that existing profile is in sync (and update it if necessary).

This make component installation easier to Libervia, as it is not
necessary anymore to use the CLI frontend to install a component.

rel 476
2026-03-30 11:37:17 +02:00
Goffi
51776603e0 depdencies, core: update Tx-XMPP to be version >= 10.0:
This version changes the package name, so all `wokkel` imports habe been replaced by
`tx_xmpp`
2026-03-24 16:42:27 +01:00
Goffi
eaa49911a6 core (xmpp): Don't use Tx-XMPP deprecated attributes:
Some deprecated attribute from `Tx-XMPP` (`Wokkel`) were still used.
This patch also remove some legacy `inlineCallbacks`.
2026-03-21 12:24:39 +01:00
Goffi
f4ca8c52cc core (main): ensure that reactor is running during post initialisation:
In background mode, the reactor is run later, this may cause troubles during some
initialisation. This has notably be seen for PB bridge which was not correctly listening
to the socket.
2026-03-13 22:45:04 +01:00
Goffi
b607b962a8 core (main): fix bridge return value of message_send:
`message_send` was returning message data while the method is declared
with no return value, this was causing issues with some bridges (pb
notably).
2026-03-13 11:38:14 +01:00
Goffi
84321be4cc bridge: automatic bridge:
Add a new "auto" bridge which tries D-Bus and fall back to PB in case of problem. This is
the defaut reactor, but can also be explicitely used.
2026-03-13 10:27:51 +01:00
Goffi
82e2c6efac apply black to the whole codebase. 2026-03-09 09:22:04 +01:00
Goffi
fa937e3e67 core(launcher): Force exit on early exception:
The backend was not properly exiting in case of early exception (e.g. configuration
error). It seems to be related to the use of the `@aio` decorator, but couldn't find the
exact issue with loop. The use of `os._exit` is a workaround for now, until the fix is
inspected more deeply and properly fixed.
2026-02-18 17:37:52 +01:00
Goffi
919cafc68c Update use of media_dir following change in Libervia Media:
Libervia Media is now a Python package instead of files to put in a directory to specify
in settings. The discovery is now automatic, removing the need for settings and enabling
easier installation. Furthermore, it should now work even if the package is zipped.
`libervia_media` can now be specified as a dependency for frontends requiring it.
2026-01-13 10:57:19 +01:00
Goffi
c5396f0acf backend: Tor integration:
- Add the `txtorcon` optional dependency, used with `tor` extra.
- Add settings for Tor.
- Use Tor endpoint when an `.onion` XMPP domain is used, of when Tor is explicitely
  enabled in conf.
- Disable WebRTC, for now it's the safer option as WebRTC can leak IP. It should be
  possible to use it over Tor by forcing the use of a .onion relay, but this is to be
  explored later (A/V should be to slow to be usable, but that stay relevant for file
  transfer or other WebRTC powered things).
- A new `treq` instance using Tor WebAgent is used when Tor is enabled. Properties has
  been added to SatXMPPEntity to conveniently get the right instance.
- Another `tor_mode` property has been added with corresponding bridge methods, to see if
  Tor is activated and in which mode for a given profile. For now there are only two modes
  (disabled, and enabled with WebRTC disabled), but in the future it may be possible to
  activate WebRTC over Tor, or to use Tor only to connect to XMPP server, while using
  clearnet for other connections.
- Tor dedicated models have been added, and bridge methods have been added to build and
  get them.
- Fix tests.

rel 473
2025-12-15 11:35:19 +01:00
Goffi
7b3c8d2ba8 black reformatting. 2025-12-03 17:49:34 +01:00
Goffi
6a7b7bc36a core: Replace legacy INI config system with Pydantic-based TOML configuration.
This is a huge configuration refactoring.

The configuration system now uses Pydantic settings, with better validation, better
support for environment variables and other goodies.

The main config files now use TOML instead of INI, this allow for better handling of
complex types, notably dict.

Plugins, components and frontends can declare their config settings in a class which will
be imported dynamically.
2025-11-30 12:27:35 +01:00
Goffi
b882fb53ea plugin XEP-0004: New data form implementation using Pydantic:
This new model is easier to manipulate and serialize, and use the benefits from Pydantic's
data validation mechanisms. It has method to easily convert to/from Wokkel data form or
to/from a domish.Element.

rel 465
2025-10-01 17:57:47 +02:00
Goffi
0a42dd3da3 core (main): renamed hasFeature to has_feature to fix inconsistency. 2025-09-05 19:31:50 +02:00
Goffi
c008b65e63 core: Add a "Global" variable with a LiberviaBackend singleton to libervia.backend. 2025-05-06 00:16:15 +02:00
Goffi
1f3c6f0329 core (main): Let plugins have several handlers + various improvements:
`get_handler` can now return several handlers, which is notably useful for component with
several included services.

Various improvements such move to `async` method, docstring/type hints update, and slight
improvment of SatXMPPComponent.

rel 453
2024-12-03 00:11:00 +01:00
Goffi
489eed2540 plugin XEP-0033: code modernisation, improve delivery, data validation:
- Code has been rewritten using Pydantic models and `async` coroutines for data validation
  and cleaner element parsing/generation.
- Delivery has been completely rewritten. It now works even if server doesn't support
  multicast, and send to local multicast service first. Delivering to local multicast
  service first is due to bad support of XEP-0033 in server (notably Prosody which has an
  incomplete implementation), and the current impossibility to detect if a sub-domain
  service handles fully multicast or only for local domains. This is a workaround to have
  a good balance between backward compatilibity and use of bandwith, and to make it work
  with the incoming email gateway implementation (the gateway will only deliver to
  entities of its own domain).
- disco feature checking now uses `async` corountines. `host` implementation still use
  Deferred return values for compatibility with legacy code.

rel 450
2024-09-26 16:12:01 +02:00
Goffi
c9ab0cd9dd black reformatting 2024-07-14 16:47:45 +02:00
Goffi
ae77da43fd core: show warning instead of exception in case of missing dependency when loading plugins 2024-07-12 18:53:00 +02:00
Goffi
53fdaa9d09 Reformatted code base using black. 2024-06-19 18:44:57 +02:00
Goffi
e7d240b7e4 core (main): add a mechanism to have a shared temp directory:
this directory may be used to share files between backend and frontends. Normally, an
os-dependent temporary directory is created for that, but if this option is set, the
directory will be created in <local_dir>/<cache_dir>, which may be useful in some use case
(e.g. containerized frontends and backend).
2024-06-12 22:47:34 +02:00
Goffi
e8fb0a8a28 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Implement XEP-0343: Signaling WebRTC Data Channels in Jingle. The current version of the
XEP (0.3.1) has no implementation and contains some flaws. After discussing this on xsf@,
Daniel (from Conversations) mentioned that they had a sprint with Larma (from Dino) to
work on another version and provided me with this link:
https://gist.github.com/iNPUTmice/6c56f3e948cca517c5fb129016d99e74 . I have used it for my
implementation.

This implementation reuses work done on Jingle A/V call (notably XEP-0176 and XEP-0167
plugins), with adaptations. When used, XEP-0234 will not handle the file itself as it
normally does. This is because WebRTC has several implementations (browser for web
interface, GStreamer for others), and file/data must be handled directly by the frontend.
This is particularly important for web frontends, as the file is not sent from the backend
but from the end-user's browser device.

Among the changes, there are:

- XEP-0343 implementation.
- `file_send` bridge method now use serialised dict as output.
- New `BaseTransportHandler.is_usable` method which get content data and returns a boolean
  (default to `True`) to tell if this transport can actually be used in this context (when
  we are initiator). Used in webRTC case to see if call data are available.
- Support of `application` media type, and everything necessary to handle data channels.
- Better confirmation message, with file name, size and description when available.
- When file is accepted in preflight, it is specified in following `action_new` signal for
  actual file transfer. This way, frontend can avoid the display or 2 confirmation
  messages.
- XEP-0166: when not specified, default `content` name is now its index number instead of
  a UUID. This follows the behaviour of browsers.
- XEP-0353: better handling of events such as call taken by another device.
- various other updates.

rel 441
2024-04-06 12:57:23 +02:00
Goffi
e14dd9da8b core: add new init_script_path option:
`init_script_path` option can be used in `[DEFAULTS]` to run a script at the end of
backend initialisation. A new `init_pre_script` method is used to wait for backend to
reach this stage (designed to be used mostly by CLI frontend), then the usual `ready_get`
method is finished once the script is finished.
2023-12-13 22:00:22 +01:00
Goffi
34fa69661c core: fix path in get_local_path:
`local_dir` was not used in final path, resulting in workind dir used instead or actual
local path.
2023-12-09 14:05:02 +01:00
Goffi
b74f55d73d core: notifications implementation, first draft:
add a new table for notifications, and methods/bridge methods to manipulate them.
2023-10-16 17:29:31 +02:00
Goffi
b7618e12f7 version: use standard Python's dev0 instead of Libervia specific D for dev version 2023-06-06 12:41:53 +02:00
Goffi
91f6b77b3d refactoring: rename core.sat_main to core.main 2023-06-02 12:59:21 +02:00
Renamed from libervia/backend/core/sat_main.py (Browse further)