Chat Federation (and a lot more) WIP:

Note: websocket s2s is not working yet, still WIP.

New Features

* Chat Federation:
  * You can now connect to a remote chat with your local account.
  * This remote connection is done using a custom implementation of [XEP-0468: WebSocket S2S](https://xmpp.org/extensions/xep-0468.html), using some specific discovering method (so that it will work without any DNS configuration).

Minor changes and fixes

* Possibility to debug Prosody in development environments.
* Using process.spawn instead of process.exec to launch Prosody (safer, and more optimal).
* Prosody AppImage: fix path mapping: we only map necessary /etc/ subdir, so that the AppImage can access to /etc/resolv.conf, /etc/hosts, ...
* Prosody AppImage: hidden debug mode to disable lua-unbound, that seems broken in some docker dev environments.
This commit is contained in:
John Livingston
2023-05-19 12:52:52 +02:00
parent 1174f661be
commit 9a2da60b7d
27 changed files with 1592 additions and 106 deletions

View File

@ -78,6 +78,53 @@ To enable this mode, you juste have to create the
The simple existence of this file is sufficient to trigger the debug mode.
To make sure it's taken into account, you can restart your Peertube instance.
This file can contain some JSON to enable more advances options.
{{% notice warning %}}
Don't enable this mode on a production server, neither on a public server.
This could cause security issues.
{{% /notice %}}
### Restart Prosody
When debug mode is enabled, you can restart Prosody using this API call:
`http://your_instance.tld/plugins/livechat/router/api/restart_prosody`.
This call don't need any authentificaiton.
It can be done from a command line, for example using
`curl http://your_instance.tld/plugins/livechat/router/api/restart_prosody`.
### Prosody debugger
It is possible to connect the Prosody AppImage to a remote debugger using [MobDebug](https://luarocks.org/modules/paulclinger/mobdebug).
To do so, you have to setup MobDebug in a folder that can be accessed by the `peertube` user.
Then, add this in the `debub_mode` file:
```json
{
"debug_prosody": {
"debugger_path": "/the_path_to_mobdebug/src",
"host": "localhost",
"port": "8172"
}
}
```
`host` and `port` are optional. `debugger_path` must point to the folder where the `MobDebug` `.lua` file is.
Restart Peertube.
Start your debugger server.
For Prosody to connect to the debugger, call the API
`http://your_instance.tld/plugins/livechat/router/api/restart_prosody?debugger=true`.
This call does not need any authentication.
It can be done from a command line, for example with
`curl http://your_instance.tld/plugins/livechat/router/api/restart_prosody?debugger=true`.
You can even configure your debug server to launch this request automatically.
Prosody will then restart, connecting to the debugger.
## Quick dev environment using Docker
There is a tutorial, in french, on the

View File

@ -80,6 +80,53 @@ To enable this mode, you juste have to create the
The simple existence of this file is sufficient to trigger the debug mode.
To make sure it's taken into account, you can restart your Peertube instance.
This file can contain some JSON to enable more advances options.
{{% notice warning %}}
Don't enable this mode on a production server, neither on a public server.
This could cause security issues.
{{% /notice %}}
### Restart Prosody
When debug mode is enabled, you can restart Prosody using this API call:
`http://your_instance.tld/plugins/livechat/router/api/restart_prosody`.
This call don't need any authentificaiton.
It can be done from a command line, for example using
`curl http://your_instance.tld/plugins/livechat/router/api/restart_prosody`.
### Prosody debugger
It is possible to connect the Prosody AppImage to a remote debugger using [MobDebug](https://luarocks.org/modules/paulclinger/mobdebug).
To do so, you have to setup MobDebug in a folder that can be accessed by the `peertube` user.
Then, add this in the `debub_mode` file:
```json
{
"debug_prosody": {
"debugger_path": "/the_path_to_mobdebug/src",
"host": "localhost",
"port": "8172"
}
}
```
`host` and `port` are optional. `debugger_path` must point to the folder where the `MobDebug` `.lua` file is.
Restart Peertube.
Start your debugger server.
For Prosody to connect to the debugger, call the API
`http://your_instance.tld/plugins/livechat/router/api/restart_prosody?debugger=true`.
This call does not need any authentication.
It can be done from a command line, for example with
`curl http://your_instance.tld/plugins/livechat/router/api/restart_prosody?debugger=true`.
You can even configure your debug server to launch this request automatically.
Prosody will then restart, connecting to the debugger.
## Quick dev environment using Docker
There is a tutorial, in french, on the
@ -87,3 +134,8 @@ There is a tutorial, in french, on the
that explains how to quickly build a dev env using Docker.
A repo was made out of it, check out https://codeberg.org/mose/pt-plugin-dev
Note: for an unknown reason, Prosody can't resolve containers DNS address when using the lua-unbound library.
There is a dirty hack in the plugin: just create a
`/data/plugins/data/peertube-plugin-livechat/no_lua_unbound` file in your docker-volumes,
then restart containers.

View File

@ -79,9 +79,63 @@ Pour activer ce mode, il suffit de créer un fichier
La simple existance de ce fichier suffit à déclencher le mode debug.
Pour être sûr qu'il est pris en compte, vous pouvez redémarrer votre instance Peertube.
Ce fichier peut également contenir du JSON qui pourra activer d'autres options.
{{% notice warning %}}
N'activer jamais ce mode sur un serveur de production, ni même sur un serveur public.
Cela pourrait poser des problèmes de sécurité.
{{% /notice %}}
### Redémarrer Prosody
Pour redémarrer Prosody quand le mode debug est activé, vous pouvez appeler l'API
`http://votre_instance.tld/plugins/livechat/router/api/restart_prosody`.
Cet appel n'a pas besoin d'authentification.
Il peut se faire depuis une ligne de commande, par exemple avec
`curl http://votre_instance.tld/plugins/livechat/router/api/restart_prosody`.
### Prosody debugger
Il est possible de connecter l'AppImage Prosody à un debugger distant en utilisant
[MobDebug](https://luarocks.org/modules/paulclinger/mobdebug).
Pour cela, placer MobDebug dans un dossier accessible par le user `peertube`.
Ensuite, ajouter cela dans le fichier `debug_mode` du plugin:
```json
{
"debug_prosody": {
"debugger_path": "/the_path_to_mobdebug/src",
"host": "localhost",
"port": "8172"
}
}
```
`host` et `port` sont optionnels. `debugger_path` doit pointer vers le dossier où
se trouve le fichier `.lua` de `MobDebug`.
Redémarrer Peertube.
Lancer votre serveur de debug.
Pour que Prosody se connecte au debugger, appelez l'API
`http://votre_instance.tld/plugins/livechat/router/api/restart_prosody?debugger=true`.
Cet appel n'a pas besoin d'authentification.
Il peut se faire depuis une ligne de commande, par exemple avec
`curl http://votre_instance.tld/plugins/livechat/router/api/restart_prosody?debugger=true`.
Vous pouvez même configurer votre serveur de debuggage pour lancer cette commande
automatiquement.
Prosody va alors redémarrer en se connectant au debugger.
## Environnement de développement rapide via Docker
Un tutoriel est disponible sur [le forum Peertube](https://framacolibri.org/t/tutoriel-creer-un-environnement-de-developpement-de-plugin-peertube-rapidement-en-utilisant-docker-et-qui-permet-de-tester-la-federation/17631)
pour expliquer comment monter rapidement un environnement de développement en utilisant Docker.
Un dépot a été crée sur la base de ce tutoriel: https://codeberg.org/mose/pt-plugin-dev
Note: pour une raison obscure, Prosody n'arrive pas à résoudre les adresses DNS des conteneurs quand la librairie
lua-unbound est utilisée. Pour contourner cela, il y a un «dirty hack»: il suffit de créer une fichier
`/data/plugins/data/peertube-plugin-livechat/no_lua_unbound` dans vos docker-volumes, puis de les redémarrer.