Implements #123: «disable websocket» settings».

This commit is contained in:
John Livingston
2022-12-08 11:25:57 +01:00
parent 74cf60908e
commit ae5860e537
4 changed files with 2402 additions and 4 deletions

View File

@ -44,11 +44,14 @@ async function initWebchatRouter (options: RegisterServerOptionsV5): Promise<Rou
const roomKey = req.params.roomKey
const settings = await settingsManager.getSettings([
'prosody-room-type',
'disable-websocket',
'converse-theme', 'converse-autocolors'
])
const boshUri = getBaseRouterRoute(options) + 'http-bind'
let wsUri = getBaseWebSocketRoute(options) // can be undefined
let wsUri = settings['disable-websocket']
? undefined
: getBaseWebSocketRoute(options) // can be undefined
wsUri = wsUri !== undefined ? wsUri + 'xmpp-websocket' : ''
let room: string
@ -341,7 +344,7 @@ async function enableProxyRoute (
logger.error(
'The http bind proxy got an error ' +
'(this can be normal if you updated/uninstalled the plugin, or shutdowned peertube while users were chatting): ' +
(err.message as string)
err.message
)
if ('writeHead' in res) {
res.writeHead(500)
@ -363,7 +366,7 @@ async function enableProxyRoute (
logger.error(
'The websocket proxy got an error ' +
'(this can be normal if you updated/uninstalled the plugin, or shutdowned peertube while users were chatting): ' +
(err.message as string)
err.message
)
if ('writeHead' in res) {
res.writeHead(500)

View File

@ -222,6 +222,20 @@ Only use this if you encounter problems with the embedded Prosody.`,
default: false
})
registerSetting({
name: 'disable-websocket',
type: 'input-checkbox',
label: 'Disable Websocket',
descriptionHTML: `With Peertube &gt;= 5.0.0, this plugin try to use Websocket connection for chatting.
If the user's browser or connection is not compatible, the browser will automatically fallback on the BOSH protocol.
<br>
But in rare case, this can fail. For example if you have a reverse proxy in front of Peertube that does not
allow Websocket connection for plugins.
In this case, you can check this settings to disable Websocket connections.`,
private: true,
default: false
})
registerSetting({
name: 'prosody-port',
label: 'Prosody port',