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
This commit is contained in:
Goffi 2025-12-15 11:35:19 +01:00
commit c5396f0acf
18 changed files with 484 additions and 43 deletions

View file

@ -24,6 +24,7 @@ from twisted.words.protocols.jabber import jid
from libervia.backend import G
from wokkel.data_form import NS_X_DATA
from libervia.backend.core.main import LiberviaBackend
from libervia.backend.models.tor import TorMode
from libervia.backend.tools import async_trigger as trigger
from libervia.backend.core import xmpp
@ -101,4 +102,6 @@ def client():
client.server_jid = jid.JID("test.example")
client.pubsub_service = jid.JID("pubsub.test.example")
client.pubsub_client = AsyncMock()
client.tor = None
client.tor_mode = TorMode.DISABLED
return client