Websocket: only activate on Prosody if the feature is available.

This commit is contained in:
John Livingston
2022-10-13 18:56:00 +02:00
parent f4daae6ed9
commit 9e06e32351
2 changed files with 16 additions and 9 deletions

View File

@ -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)
}