diff --git a/server/lib/prosody/config.ts b/server/lib/prosody/config.ts index e81125f4..600e9b85 100644 --- a/server/lib/prosody/config.ts +++ b/server/lib/prosody/config.ts @@ -2,7 +2,7 @@ import type { RegisterServerOptions } from '@peertube/peertube-types' import type { ProsodyLogLevel } from './config/content' import * as fs from 'fs' import * as path from 'path' -import { getBaseRouterRoute } from '../helpers' +import { getBaseRouterRoute, RegisterServerOptionsV5 } from '../helpers' import { ProsodyFilePaths } from './config/paths' import { ConfigLogExpiration, ProsodyConfigContent } from './config/content' import { getProsodyDomain } from './config/domain' @@ -77,7 +77,7 @@ interface ProsodyConfig { logExpiration: ConfigLogExpiration valuesToHideInDiagnostic: Map } -async function getProsodyConfig (options: RegisterServerOptions): Promise { +async function getProsodyConfig (options: RegisterServerOptionsV5): Promise { const logger = options.peertubeHelpers.logger logger.debug('Calling getProsodyConfig') @@ -130,7 +130,8 @@ async function getProsodyConfig (options: RegisterServerOptions): Promise=5.0.0, and is a prerequisite to websocket + config.usePeertubeBoshAndWebsocket(prosodyDomain, port, options.peertubeHelpers.config.getWebserverUrl(), useWS) config.useMucHttpDefault(roomApiUrl) if (enableC2s) { diff --git a/server/lib/prosody/config/content.ts b/server/lib/prosody/config/content.ts index 73717309..091268af 100644 --- a/server/lib/prosody/config/content.ts +++ b/server/lib/prosody/config/content.ts @@ -201,7 +201,7 @@ class ProsodyConfigContent { this.authenticated.set('http_auth_url', url) } - usePeertubeBoshAndWebsocket (prosodyDomain: string, port: string, publicServerUrl: string): void { + usePeertubeBoshAndWebsocket (prosodyDomain: string, port: string, publicServerUrl: string, useWS: boolean): void { this.global.set('c2s_require_encryption', false) this.global.set('interfaces', ['127.0.0.1', '::1']) this.global.set('c2s_ports', []) @@ -214,17 +214,21 @@ class ProsodyConfigContent { this.global.set('https_interfaces', ['127.0.0.1', '::1']) this.global.set('consider_bosh_secure', true) - this.global.set('consider_websocket_secure', true) + if (useWS) { + this.global.set('consider_websocket_secure', true) - // This line seems to be required by Prosody, otherwise it rejects websocket... - this.global.set('cross_domain_websocket', [publicServerUrl]) + // This line seems to be required by Prosody, otherwise it rejects websocket... + this.global.set('cross_domain_websocket', [publicServerUrl]) + } if (this.anon) { this.anon.set('trusted_proxies', ['127.0.0.1', '::1']) this.anon.set('allow_anonymous_s2s', false) this.anon.add('modules_enabled', 'http') this.anon.add('modules_enabled', 'bosh') - this.anon.add('modules_enabled', 'websocket') + if (useWS) { + this.anon.add('modules_enabled', 'websocket') + } this.anon.set('http_host', prosodyDomain) this.anon.set('http_external_url', 'http://' + prosodyDomain) } @@ -238,7 +242,9 @@ class ProsodyConfigContent { this.authenticated.set('allow_anonymous_s2s', false) this.authenticated.add('modules_enabled', 'http') this.authenticated.add('modules_enabled', 'bosh') - this.authenticated.add('modules_enabled', 'websocket') + if (useWS) { + this.authenticated.add('modules_enabled', 'websocket') + } this.authenticated.set('http_host', prosodyDomain) this.authenticated.set('http_external_url', 'http://' + prosodyDomain) }