sftp: prefix the id with app- and volume-

this helps the backend identify the type of mount
This commit is contained in:
Girish Ramakrishnan
2021-09-25 23:27:25 -07:00
parent 8553b57982
commit d4edd771b5
3 changed files with 15 additions and 8 deletions
+1 -1
View File
@@ -22,6 +22,6 @@ exports = module.exports = {
'redis': { repo: 'cloudron/redis', tag: 'cloudron/redis:3.0.4@sha256:5c60de75d078ae609da5565f32dcd91030f45907e945756cc976ff207b8c6199' },
'mail': { repo: 'cloudron/mail', tag: 'cloudron/mail:3.3.3@sha256:b1093e6f38bebf4a9ae903ca385aea3a32e7cccae5ede7f2e01a34681e361a5f' },
'graphite': { repo: 'cloudron/graphite', tag: 'cloudron/graphite:3.0.1@sha256:bed9f6b5d06fe2c5289e895e806cfa5b74ad62993d705be55d4554a67d128029' },
'sftp': { repo: 'cloudron/sftp', tag: 'cloudron/sftp:3.3.1@sha256:fbd6b18351a1a2830265e1198fdfe589d8b208de2105d11ceb84160e3de35724' }
'sftp': { repo: 'cloudron/sftp', tag: 'cloudron/sftp:3.4.0@sha256:2fd5ed1396cc1563422c7d10c9158e0ec7cc4e3ddbe5e1bda63ac04631965a81' }
}
};
+12 -5
View File
@@ -1,7 +1,8 @@
'use strict';
exports = module.exports = {
proxy
proxyAppData,
proxyVolumeData
};
const assert = require('assert'),
@@ -12,10 +13,8 @@ const assert = require('assert'),
services = require('../services.js'),
url = require('url');
async function proxy(req, res, next) {
assert.strictEqual(typeof req.params.id, 'string');
const id = req.params.id; // app id or volume id
async function proxy(id, req, res, next) {
assert.strictEqual(typeof id, 'string');
req.clearTimeout();
@@ -40,3 +39,11 @@ async function proxy(req, res, next) {
next(new HttpError(500, error));
});
}
function proxyAppData(req, res, next) {
proxy(`app-${req.params.id}`, req, res, next);
}
function proxyVolumeData(req, res, next) {
proxy(`volume-${req.params.id}`, req, res, next);
}
+2 -2
View File
@@ -240,7 +240,7 @@ function initializeExpressSync() {
router.post('/api/v1/apps/:id/clone', json, token, routes.apps.load, authorizeAdmin, routes.apps.clone);
router.get ('/api/v1/apps/:id/download', token, routes.apps.load, authorizeOperator, routes.apps.downloadFile);
router.post('/api/v1/apps/:id/upload', json, token, multipart, routes.apps.load, authorizeOperator, routes.apps.uploadFile);
router.use ('/api/v1/apps/:id/files/*', token, routes.apps.load, authorizeOperator, routes.filemanager.proxy);
router.use ('/api/v1/apps/:id/files/*', token, routes.apps.load, authorizeOperator, routes.filemanager.proxyAppData);
router.get ('/api/v1/apps/:id/exec', token, routes.apps.load, authorizeOperator, routes.apps.exec);
// websocket cannot do bearer authentication
@@ -317,7 +317,7 @@ function initializeExpressSync() {
router.get ('/api/v1/volumes/:id', token, authorizeAdmin, routes.volumes.load, routes.volumes.get);
router.del ('/api/v1/volumes/:id', token, authorizeAdmin, routes.volumes.load, routes.volumes.del);
router.get ('/api/v1/volumes/:id/status', token, authorizeAdmin, routes.volumes.load, routes.volumes.getStatus);
router.use ('/api/v1/volumes/:id/files/*', token, authorizeAdmin, routes.filemanager.proxy);
router.use ('/api/v1/volumes/:id/files/*', token, authorizeAdmin, routes.filemanager.proxyVolumeData);
// service routes
router.get ('/api/v1/services', token, authorizeAdmin, routes.services.list);