XMPP clients connections WIP:

* new option to allow external xmpp account s2s connections
* settings to setup the port and network interfaces
* documentation WIP

Related to issue #114
This commit is contained in:
John Livingston 2023-04-07 18:27:15 +02:00 committed by John Livingston
parent c81c2eb9bb
commit 4d9d9d39b0
14 changed files with 212 additions and 2 deletions

View File

@ -2,6 +2,10 @@
## ??? (Not Released Yet)
### New Features
* XMPP clients: you can now allow connection to rooms using external XMPP accounts and XMPP clients. Please note that this feature might require some server configuration to be available. Please refer to the [documentation](https://johnxlivingston.github.io/peertube-plugin-livechat/documentation/admin/advanced/xmpp_clients/) for more informations.
### Minor changes and fixes
* Diagnostic tool: add the result of `prosodyctl check` in the debug section.

View File

@ -203,6 +203,9 @@ function register ({ registerHook, registerSettingsScript, peertubeHelpers }: Re
switch (name) {
case 'prosody-c2s-port':
return options.formValues['prosody-c2s'] !== true
case 'prosody-s2s-port':
case 'prosody-s2s-interfaces':
return options.formValues['prosody-room-allow-s2s'] !== true
case 'prosody-components-port':
case 'prosody-components-list':
return options.formValues['prosody-components'] !== true

View File

@ -140,6 +140,15 @@ prosody_muc_expiration_description: |
<li><b>nie</b>: Der Inhalt läuft nie ab und wird für immer aufbewahrt.</li>
</ul>
prosody_room_allow_s2s_label: ~
prosody_room_allow_s2s_description: ~
prosody_s2s_port_label: ~
prosody_s2s_port_description: ~
prosody_s2s_interfaces_label: ~
prosody_s2s_interfaces_description: ~
prosody_c2s_label: "Aktivieren von Client-Server-Verbindungen"
prosody_c2s_description: |
Ermöglichen Sie XMPP-Clients die Verbindung zum integrierten Prosody-Server.<br>

View File

@ -140,6 +140,36 @@ prosody_muc_expiration_description: |
<li><b>never</b>: the content will never expire, and will be kept forever.</li>
</ul>
prosody_room_allow_s2s_label: "Enable connection to room using external XMPP accounts"
prosody_room_allow_s2s_description: |
By enabling this option, it will be possible to connect to rooms using external XMPP accounts and XMPP clients.<br>
Warning, enabling this option can request extra server and DNS configuration.
Please refer to the documentation:
<a href="https://johnxlivingston.github.io/peertube-plugin-livechat/documentation/admin/advanced/xmpp_clients/" target="_blank">
Enable external XMPP account connections.
</a>
prosody_s2s_port_label: "Prosody server to server port"
prosody_s2s_port_description: |
The port that will be used for XMPP s2s (server to server) connections.<br>
You should use the standard 5269 port.
Otherwise you should <a href="https://prosody.im/doc/s2s">
setup a specific DNS record
</a>.
prosody_s2s_interfaces_label: "Server to server network interfaces"
prosody_s2s_interfaces_description: |
The network interfaces to listen on for server to server connections.<br>
List of IP to listen on, coma separated (spaces will be stripped).<br>
You can use «*» to listen on all IPv4 interfaces, and «::» for all IPv6.<br>
Examples:
<ul>
<li>*, ::</li>
<li>*</li>
<li>127.0.0.1, ::1</li>
<li>172.18.0.42</li>
</ul>
prosody_c2s_label: "Enable client to server connections"
prosody_c2s_description: |
Enable XMPP clients to connect to the built-in Prosody server.<br>

View File

@ -150,6 +150,36 @@ prosody_muc_expiration_description: |
<li><b>never</b>: le contenu ne sera jamais effacé.</li>
</ul>
prosody_room_allow_s2s_label: "Autoriser les connexions aux salons via des comptes XMPP externes"
prosody_room_allow_s2s_description: |
En activant cette option, il sera possible de se connecter aux salons en utilisant des comptes XMPP externes via des clients XMPP.<br>
Attention, activer cette option peut demander une configuration au niveau du serveur et des enregistrements DNS.
Pour en savoir plus, merci de vous référer à la documentation:
<a href="https://johnxlivingston.github.io/peertube-plugin-livechat/fr/documentation/admin/advanced/xmpp_clients/" target="_blank">
Autoriser les connexions avec des comptes XMPP externes.
</a>
prosody_s2s_port_label: "Port Prosody serveur vers serveur"
prosody_s2s_port_description: |
Le port à utiliser pour les connexions XMPP s2s (server to server).<br>
Il est recommandé d'utiliser le port standard 5269.
Sinon vous devrez <a href="https://prosody.im/doc/s2s">
configurer un enregistrement DNS spécifique
</a>.
prosody_s2s_interfaces_label: "Interfaces réseau pour les connexions serveur vers serveur"
prosody_s2s_interfaces_description: |
Les interfaces réseau sur lequelles écouter pour les connexions s2s (server to server).<br>
Une liste d'IP séparées par des virgules (les espaces seront retirés).
On pourra utiliser «*» pour écouter sur toutes les IPv4, et «::» pour toutes les IPv6.<br>
Exemples de configuration possible:
<ul>
<li>*, ::</li>
<li>*</li>
<li>127.0.0.1, ::1</li>
<li>172.18.0.42</li>
</ul>
prosody_c2s_label: "Activer les connexions client vers serveur"
prosody_c2s_description: |
Autoriser les clients XMPP à se connecter au serveur Prosody.<br>

View File

@ -134,6 +134,15 @@ prosody_muc_expiration_description: |
<li><b>never</b>: il contenuto non sarà mai cancellato.</li>
</ul>
prosody_room_allow_s2s_label: ~
prosody_room_allow_s2s_description: ~
prosody_s2s_port_label: ~
prosody_s2s_port_description: ~
prosody_s2s_interfaces_label: ~
prosody_s2s_interfaces_description: ~
prosody_c2s_label: "Abilitare le connessioni dal client al server"
prosody_c2s_description: |
Consenti ai clienti XMPP a connettersi al server Prosody incorporato nel plugin.<br>

View File

@ -102,6 +102,9 @@ async function getProsodyConfig (options: RegisterServerOptionsV5): Promise<Pros
'prosody-muc-expiration',
'prosody-c2s',
'prosody-c2s-port',
'prosody-room-allow-s2s',
'prosody-s2s-port',
'prosody-s2s-interfaces',
'prosody-room-type',
'prosody-peertube-uri',
'prosody-components',
@ -118,7 +121,8 @@ async function getProsodyConfig (options: RegisterServerOptionsV5): Promise<Pros
const logByDefault = (settings['prosody-muc-log-by-default'] as boolean) ?? true
const disableAnon = (settings['chat-no-anonymous'] as boolean) || false
const logExpirationSetting = (settings['prosody-muc-expiration'] as string) ?? DEFAULTLOGEXPIRATION
const enableC2s = (settings['prosody-c2s'] as boolean) || false
const enableC2S = (settings['prosody-c2s'] as boolean) || false
const enableRoomS2S = (settings['prosody-room-allow-s2s'] as boolean) || false
const enableComponents = (settings['prosody-components'] as boolean) || false
const prosodyDomain = await getProsodyDomain(options)
const paths = await getProsodyFilePaths(options)
@ -149,7 +153,7 @@ async function getProsodyConfig (options: RegisterServerOptionsV5): Promise<Pros
config.usePeertubeBoshAndWebsocket(prosodyDomain, port, options.peertubeHelpers.config.getWebserverUrl(), useWS)
config.useMucHttpDefault(roomApiUrl)
if (enableC2s) {
if (enableC2S) {
const c2sPort = (settings['prosody-c2s-port'] as string) || '52822'
if (!/^\d+$/.test(c2sPort)) {
throw new Error('Invalid c2s port')
@ -169,6 +173,25 @@ async function getProsodyConfig (options: RegisterServerOptionsV5): Promise<Pros
config.useExternalComponents(componentsPort, components)
}
if (enableRoomS2S) {
const s2sPort = (settings['prosody-s2s-port'] as string) || '5269'
if (!/^\d+$/.test(s2sPort)) {
throw new Error('Invalid s2s port')
}
const s2sInterfaces = ((settings['prosody-s2s-interfaces'] as string) || '')
.split(',')
.map(s => s.trim())
// Check that there is no invalid values (to avoid injections):
s2sInterfaces.forEach(networkInterface => {
if (networkInterface === '*') return
if (networkInterface === '::') return
if (networkInterface.match(/^\d+\.\d+\.\d+\.\d+$/)) return
if (networkInterface.match(/^[a-f0-9:]+$/)) return
throw new Error('Invalid s2s interfaces')
})
config.useRoomS2S(s2sPort, s2sInterfaces)
}
const logExpiration = readLogExpiration(options, logExpirationSetting)
config.useMam(logByDefault, logExpiration)
// TODO: add a settings to choose?

View File

@ -257,6 +257,12 @@ class ProsodyConfigContent {
this.global.set('c2s_ports', [c2sPort])
}
useRoomS2S (s2sPort: string, s2sInterfaces: string[]): void {
this.global.set('s2s_ports', [s2sPort])
this.global.set('s2s_interfaces', s2sInterfaces)
this.muc.add('modules_enabled', 's2s')
}
useExternalComponents (componentsPort: string, components: ExternalComponent[]): void {
this.global.set('component_ports', [componentsPort])
this.global.set('component_interfaces', ['127.0.0.1', '::1'])

View File

@ -302,6 +302,33 @@ Please read
descriptionHTML: loc('prosody_muc_expiration_description')
})
registerSetting({
name: 'prosody-room-allow-s2s',
label: loc('prosody_room_allow_s2s_label'),
type: 'input-checkbox',
default: false,
private: true,
descriptionHTML: loc('prosody_room_allow_s2s_description')
})
registerSetting({
name: 'prosody-s2s-port',
label: loc('prosody_s2s_port_label'),
type: 'input',
default: '5269',
private: true,
descriptionHTML: loc('prosody_s2s_port_description')
})
registerSetting({
name: 'prosody-s2s-interfaces',
label: loc('prosody_s2s_interfaces_label'),
type: 'input',
default: '*, ::',
private: true,
descriptionHTML: loc('prosody_s2s_interfaces_description')
})
registerSetting({
name: 'prosody-c2s',
label: loc('prosody_c2s_label'),

View File

@ -0,0 +1,10 @@
+++
title="Allow connection using XMPP clients"
description="Allow connections using external XMPP accounts and XMPP clients"
weight=30
chapter=false
+++
{{% notice warning %}}
This page is not yet translated in your language, please refer to the english version. You can switch to it by using the language selector in the left menu.
{{% /notice %}}

View File

@ -0,0 +1,15 @@
+++
title="XMPP clients"
description="Allow connections using external XMPP accounts and XMPP clients"
weight=30
chapter=false
+++
{{% notice warning %}}
This page is not written yet. It should explain how you can connect with XMPP clients.
{{% /notice %}}
{{% notice tip %}}
For now you can't connect to your Peertube chat account using a XMPP client.
This feature could be added one day, depending on the interest about it.
{{% /notice %}}

View File

@ -0,0 +1,10 @@
+++
title="Allow connection using XMPP clients"
description="Allow connections using external XMPP accounts and XMPP clients"
weight=30
chapter=false
+++
{{% notice warning %}}
This page is not yet translated in your language, please refer to the english version. You can switch to it by using the language selector in the left menu.
{{% /notice %}}

View File

@ -0,0 +1,10 @@
+++
title="Allow connection using XMPP clients"
description="Allow connections using external XMPP accounts and XMPP clients"
weight=30
chapter=false
+++
{{% notice warning %}}
This page is not yet translated in your language, please refer to the english version. You can switch to it by using the language selector in the left menu.
{{% /notice %}}

View File

@ -135,6 +135,30 @@ by editing its properties.
You can set here the expiration delay for room logs.
See the online help for accepted values.
### Enable connection to room using external XMPP accounts
By enabling this option, it will be possible to connect to rooms using external XMPP accounts and XMPP clients.<br>
Warning, enabling this option can request extra server and DNS configuration.
Please refer to the documentation: [Enable external XMPP account connections](/peertube-plugin-livechat/documentation/admin/advanced/xmpp_clients/).
### Prosody server to server port
The port that will be used for XMPP s2s (server to server) connections.<br>
You should use the standard 5269 port.
Otherwise you should [setup a specific DNS record](https://prosody.im/doc/s2s).
### Server to server network interfaces
The network interfaces to listen on for server to server connections.<br>
List of IP to listen on, coma separated (spaces will be stripped).<br>
You can use «*» to listen on all IPv4 interfaces, and «::» for all IPv6.<br>
Examples:
- `*, ::`
- `*`
- `127.0.0.1, ::1`
- `172.18.0.42`
### Enable client to server connections
This setting enable XMPP clients to connect to the built-in Prosody server.