Various fix and wip
This commit is contained in:
@ -174,8 +174,14 @@ async function getProsodyConfig (options: RegisterServerOptionsV5): Promise<Pros
|
||||
// enableRemoteChatConnections: local users can communicate with external rooms
|
||||
const enableRemoteChatConnections = !(settings['federation-dont-publish-remotely'] as boolean)
|
||||
let certificates: ProsodyConfigCertificates = false
|
||||
const useBots = !settings['disable-channel-configuration']
|
||||
const bots: ProsodyConfig['bots'] = {}
|
||||
|
||||
// Note: for the bots to connect, we must allow multiplexing.
|
||||
// This will be done on the http (BOSH/Websocket) port, as it only listen on localhost.
|
||||
// TODO: to improve performance, try to avoid multiplexing, and find a better way for bots to connect.
|
||||
const useMultiplexing = useBots
|
||||
|
||||
const apikey = await getAPIKey(options)
|
||||
valuesToHideInDiagnostic.set('APIKey', apikey)
|
||||
|
||||
@ -222,7 +228,7 @@ async function getProsodyConfig (options: RegisterServerOptionsV5): Promise<Pros
|
||||
}
|
||||
config.useHttpAuthentication(authApiUrl)
|
||||
const useWS = !!options.registerWebSocketRoute // this comes with Peertube >=5.0.0, and is a prerequisite to websocket
|
||||
config.usePeertubeBoshAndWebsocket(prosodyDomain, port, publicServerUrl, useWS)
|
||||
config.usePeertubeBoshAndWebsocket(prosodyDomain, port, publicServerUrl, useWS, useMultiplexing)
|
||||
config.useMucHttpDefault(roomApiUrl)
|
||||
|
||||
if (enableC2S) {
|
||||
@ -294,10 +300,12 @@ async function getProsodyConfig (options: RegisterServerOptionsV5): Promise<Pros
|
||||
config.usePeertubeVCards(basePeertubeUrl)
|
||||
config.useAnonymousRandomVCards(paths.avatars)
|
||||
|
||||
if (!settings['disable-channel-configuration']) {
|
||||
if (useBots) {
|
||||
config.useBotsVirtualHost()
|
||||
bots.moderation = await BotConfiguration.singleton().getModerationBotGlobalConf()
|
||||
valuesToHideInDiagnostic.set('BotPassword', bots.moderation.connection.password)
|
||||
if (bots.moderation?.connection?.password) {
|
||||
valuesToHideInDiagnostic.set('BotPassword', bots.moderation.connection.password)
|
||||
}
|
||||
}
|
||||
|
||||
config.useTestModule(apikey, testApiUrl)
|
||||
|
@ -1,5 +1,6 @@
|
||||
import type { ProsodyFilePaths } from './paths'
|
||||
import type { ExternalComponent } from './components'
|
||||
import { BotConfiguration } from '../../configuration/bot'
|
||||
import { userInfo } from 'os'
|
||||
|
||||
type ConfigEntryValue = boolean | number | string | ConfigEntryValue[]
|
||||
@ -221,14 +222,39 @@ class ProsodyConfigContent {
|
||||
this.authenticated.set('http_auth_url', url)
|
||||
}
|
||||
|
||||
usePeertubeBoshAndWebsocket (prosodyDomain: string, port: string, publicServerUrl: string, useWS: boolean): void {
|
||||
/**
|
||||
* Activate BOSH (and optionnaly Websocket).
|
||||
* @param prosodyDomain prosody domain
|
||||
* @param port port to use for BOSH and Websocket interfaces
|
||||
* @param publicServerUrl public server url
|
||||
* @param useWS activate Websocket or not
|
||||
* @param multiplexing activate multiplexing on port. Note: it will only listen on localhost interfaces.
|
||||
*/
|
||||
usePeertubeBoshAndWebsocket (
|
||||
prosodyDomain: string,
|
||||
port: string,
|
||||
publicServerUrl: string,
|
||||
useWS: boolean,
|
||||
multiplexing: boolean
|
||||
): void {
|
||||
// Note: don't activate other http_interface or https_interfaces than localhost.
|
||||
// Elsewhere it would be a security issue.
|
||||
this.global.set('c2s_require_encryption', false)
|
||||
this.global.set('interfaces', ['127.0.0.1', '::1'])
|
||||
this.global.set('c2s_ports', [])
|
||||
this.global.set('c2s_interfaces', ['127.0.0.1', '::1'])
|
||||
this.global.set('s2s_ports', [])
|
||||
this.global.set('s2s_interfaces', ['127.0.0.1', '::1'])
|
||||
this.global.set('http_ports', [port])
|
||||
if (!multiplexing) {
|
||||
this.global.set('http_ports', [port])
|
||||
} else {
|
||||
// Note: don't activate other http_interface or https_interfaces than localhost.
|
||||
// Elsewhere it would be a security issue.
|
||||
this.global.add('modules_enabled', 'net_multiplex')
|
||||
this.global.set('ports', [port])
|
||||
// FIXME: this generates Prosody error logs saying that BOSH/Websocket won't work... even if it is not true.
|
||||
this.global.set('http_ports', [])
|
||||
}
|
||||
this.global.set('http_interfaces', ['127.0.0.1', '::1'])
|
||||
this.global.set('https_ports', [])
|
||||
this.global.set('https_interfaces', ['127.0.0.1', '::1'])
|
||||
@ -410,7 +436,12 @@ class ProsodyConfigContent {
|
||||
*/
|
||||
useBotsVirtualHost (): void {
|
||||
this.bot = new ProsodyConfigVirtualHost('bot.' + this.prosodyDomain)
|
||||
this.bot.set('modules_enabled', ['ping'])
|
||||
this.bot.set('modules_enabled', ['ping', 'bot_peertubelivechat'])
|
||||
|
||||
const configurationPaths = BotConfiguration.singleton().configurationPaths()
|
||||
if (configurationPaths.moderation?.globalDir) {
|
||||
this.bot.set('livechat_bot_conf_folder', configurationPaths.moderation.globalDir)
|
||||
}
|
||||
|
||||
// TODO: bot vcards
|
||||
}
|
||||
|
Reference in New Issue
Block a user