Rewriting some c2s code.

This commit is contained in:
John Livingston 2021-07-14 18:46:08 +02:00
parent fbf9ef3eac
commit ed718d7d27
No known key found for this signature in database
GPG Key ID: B17B5640CE66CDBC
2 changed files with 15 additions and 11 deletions

View File

@ -78,10 +78,6 @@ async function getProsodyConfig (options: RegisterServerOptions): Promise<Prosod
throw new Error('Invalid port')
}
const enableC2s = (await options.settingsManager.getSetting('prosody-c2s') as boolean) || false
const c2sPort = (await options.settingsManager.getSetting('prosody-c2s-port') as string) || '52822'
if (!/^\d+$/.test(c2sPort)) {
throw new Error('Invalid c2s port')
}
const prosodyDomain = await getProsodyDomain(options)
const paths = await getProsodyFilePaths(options)
@ -101,9 +97,17 @@ async function getProsodyConfig (options: RegisterServerOptions): Promise<Prosod
const config = new ProsodyConfigContent(paths, prosodyDomain)
config.useHttpAuthentication(authApiUrl)
config.usePeertubeBosh(prosodyDomain, port, enableC2s, c2sPort)
config.usePeertubeBosh(prosodyDomain, port)
config.useMucHttpDefault(roomApiUrl)
if (enableC2s) {
const c2sPort = (await options.settingsManager.getSetting('prosody-c2s-port') as string) || '52822'
if (!/^\d+$/.test(c2sPort)) {
throw new Error('Invalid c2s port')
}
config.useC2S(c2sPort)
}
// TODO: add a settings so that admin can choose? (on/off and duration)
config.useMam('1w') // Remove archived messages after 1 week
// TODO: add a settings to choose?

View File

@ -168,14 +168,10 @@ class ProsodyConfigContent {
this.authenticated.set('http_auth_url', url)
}
usePeertubeBosh (prosodyDomain: string, port: string, enableC2s: boolean, c2sPort: string): void {
usePeertubeBosh (prosodyDomain: string, port: string): void {
this.global.set('c2s_require_encryption', false)
this.global.set('interfaces', ['127.0.0.1', '::1'])
if (enableC2s) {
this.global.set('c2s_ports', [c2sPort])
} else {
this.global.set('c2s_ports', [])
}
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'])
@ -205,6 +201,10 @@ class ProsodyConfigContent {
}
}
useC2S (c2sPort: string): void {
this.global.set('c2s_ports', [c2sPort])
}
useMucHttpDefault (url: string): void {
this.muc.add('modules_enabled', 'muc_http_defaults')
this.muc.add('muc_create_api_url', url)