Websocket: only activate on Prosody if the feature is available.
This commit is contained in:
parent
f4daae6ed9
commit
9e06e32351
@ -2,7 +2,7 @@ import type { RegisterServerOptions } from '@peertube/peertube-types'
|
|||||||
import type { ProsodyLogLevel } from './config/content'
|
import type { ProsodyLogLevel } from './config/content'
|
||||||
import * as fs from 'fs'
|
import * as fs from 'fs'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import { getBaseRouterRoute } from '../helpers'
|
import { getBaseRouterRoute, RegisterServerOptionsV5 } from '../helpers'
|
||||||
import { ProsodyFilePaths } from './config/paths'
|
import { ProsodyFilePaths } from './config/paths'
|
||||||
import { ConfigLogExpiration, ProsodyConfigContent } from './config/content'
|
import { ConfigLogExpiration, ProsodyConfigContent } from './config/content'
|
||||||
import { getProsodyDomain } from './config/domain'
|
import { getProsodyDomain } from './config/domain'
|
||||||
@ -77,7 +77,7 @@ interface ProsodyConfig {
|
|||||||
logExpiration: ConfigLogExpiration
|
logExpiration: ConfigLogExpiration
|
||||||
valuesToHideInDiagnostic: Map<string, string>
|
valuesToHideInDiagnostic: Map<string, string>
|
||||||
}
|
}
|
||||||
async function getProsodyConfig (options: RegisterServerOptions): Promise<ProsodyConfig> {
|
async function getProsodyConfig (options: RegisterServerOptionsV5): Promise<ProsodyConfig> {
|
||||||
const logger = options.peertubeHelpers.logger
|
const logger = options.peertubeHelpers.logger
|
||||||
logger.debug('Calling getProsodyConfig')
|
logger.debug('Calling getProsodyConfig')
|
||||||
|
|
||||||
@ -130,7 +130,8 @@ async function getProsodyConfig (options: RegisterServerOptions): Promise<Prosod
|
|||||||
config.useAnonymous()
|
config.useAnonymous()
|
||||||
}
|
}
|
||||||
config.useHttpAuthentication(authApiUrl)
|
config.useHttpAuthentication(authApiUrl)
|
||||||
config.usePeertubeBoshAndWebsocket(prosodyDomain, port, options.peertubeHelpers.config.getWebserverUrl())
|
const useWS = !!options.registerWebSocketRoute // this comes with Peertube >=5.0.0, and is a prerequisite to websocket
|
||||||
|
config.usePeertubeBoshAndWebsocket(prosodyDomain, port, options.peertubeHelpers.config.getWebserverUrl(), useWS)
|
||||||
config.useMucHttpDefault(roomApiUrl)
|
config.useMucHttpDefault(roomApiUrl)
|
||||||
|
|
||||||
if (enableC2s) {
|
if (enableC2s) {
|
||||||
|
@ -201,7 +201,7 @@ class ProsodyConfigContent {
|
|||||||
this.authenticated.set('http_auth_url', url)
|
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('c2s_require_encryption', false)
|
||||||
this.global.set('interfaces', ['127.0.0.1', '::1'])
|
this.global.set('interfaces', ['127.0.0.1', '::1'])
|
||||||
this.global.set('c2s_ports', [])
|
this.global.set('c2s_ports', [])
|
||||||
@ -214,17 +214,21 @@ class ProsodyConfigContent {
|
|||||||
this.global.set('https_interfaces', ['127.0.0.1', '::1'])
|
this.global.set('https_interfaces', ['127.0.0.1', '::1'])
|
||||||
|
|
||||||
this.global.set('consider_bosh_secure', true)
|
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 line seems to be required by Prosody, otherwise it rejects websocket...
|
||||||
this.global.set('cross_domain_websocket', [publicServerUrl])
|
this.global.set('cross_domain_websocket', [publicServerUrl])
|
||||||
|
}
|
||||||
|
|
||||||
if (this.anon) {
|
if (this.anon) {
|
||||||
this.anon.set('trusted_proxies', ['127.0.0.1', '::1'])
|
this.anon.set('trusted_proxies', ['127.0.0.1', '::1'])
|
||||||
this.anon.set('allow_anonymous_s2s', false)
|
this.anon.set('allow_anonymous_s2s', false)
|
||||||
this.anon.add('modules_enabled', 'http')
|
this.anon.add('modules_enabled', 'http')
|
||||||
this.anon.add('modules_enabled', 'bosh')
|
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_host', prosodyDomain)
|
||||||
this.anon.set('http_external_url', 'http://' + prosodyDomain)
|
this.anon.set('http_external_url', 'http://' + prosodyDomain)
|
||||||
}
|
}
|
||||||
@ -238,7 +242,9 @@ class ProsodyConfigContent {
|
|||||||
this.authenticated.set('allow_anonymous_s2s', false)
|
this.authenticated.set('allow_anonymous_s2s', false)
|
||||||
this.authenticated.add('modules_enabled', 'http')
|
this.authenticated.add('modules_enabled', 'http')
|
||||||
this.authenticated.add('modules_enabled', 'bosh')
|
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_host', prosodyDomain)
|
||||||
this.authenticated.set('http_external_url', 'http://' + prosodyDomain)
|
this.authenticated.set('http_external_url', 'http://' + prosodyDomain)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user