fix(xo-server/backup-ng): throw error if remote's proxy is different than backup's proxy (#4907)

See #4905
This commit is contained in:
badrAZ 2020-04-22 14:39:28 +02:00 committed by GitHub
parent 85428fa72e
commit 561ef00680
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -638,7 +638,14 @@ export default class BackupNg {
const xapis = {}
await waitAll([
asyncMap(remoteIds, async id => {
remotes[id] = await app.getRemoteWithCredentials(id)
const remote = await app.getRemoteWithCredentials(id)
if (remote.proxy !== job.proxy) {
throw new Error(
`The remote ${remote.name} must be linked to the proxy ${job.proxy}`
)
}
remotes[id] = remote
}),
asyncMap([...servers], async id => {
const {
@ -681,10 +688,19 @@ export default class BackupNg {
}
})
const remotes = await Promise.all(
remoteIds.map(async id => ({
id,
handler: await app.getRemoteHandler(id),
}))
remoteIds.map(async id => {
const remote = await app.getRemote(id)
if (remote.proxy !== undefined) {
throw new Error(
`The remote ${remote.name} must not be linked to a proxy`
)
}
return {
id,
handler: await app.getRemoteHandler(remote),
}
})
)
const settings = merge(job.settings, data?.settings)