mailserver: add queue routes
This commit is contained in:
@@ -20,7 +20,7 @@ exports = module.exports = {
|
||||
'postgresql': { repo: 'cloudron/postgresql', tag: 'cloudron/postgresql:4.3.1@sha256:b0c564d097b765d4a639330843e2e813d2c87fc8ed34b7df7550bf2c6df0012c' },
|
||||
'mongodb': { repo: 'cloudron/mongodb', tag: 'cloudron/mongodb:4.2.1@sha256:f7f689beea07b1c6a9503a48f6fb38ef66e5b22f59fc585a92842a6578b33d46' },
|
||||
'redis': { repo: 'cloudron/redis', tag: 'cloudron/redis:3.3.0@sha256:89c4e8083631b6d16b5d630d9b27f8ecf301c62f81219d77bd5948a1f4a4375c' },
|
||||
'mail': { repo: 'cloudron/mail', tag: 'cloudron/mail:3.7.0@sha256:29128fd789fbb226d25c1c17ad4d26e35b132227c1dfee73bf137f8b351ddd02' },
|
||||
'mail': { repo: 'cloudron/mail', tag: 'cloudron/mail:3.7.0@sha256:a78fc61c8674c4c9915db47868f5225174c0e2451fad12bd1f24fdfa4322a682' },
|
||||
'graphite': { repo: 'cloudron/graphite', tag: 'cloudron/graphite:3.1.0@sha256:30ec3a01964a1e01396acf265183997c3e17fb07eac1a82b979292cc7719ff4b' },
|
||||
'sftp': { repo: 'cloudron/sftp', tag: 'cloudron/sftp:3.6.1@sha256:ba4b9a1fe274c0ef0a900e5d0deeb8f3da08e118798d1d90fbf995cc0cf6e3a3' }
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
exports = module.exports = {
|
||||
proxy,
|
||||
restart,
|
||||
queueProxy,
|
||||
|
||||
setLocation,
|
||||
getLocation
|
||||
@@ -26,8 +27,8 @@ async function restart(req, res, next) {
|
||||
next();
|
||||
}
|
||||
|
||||
async function proxy(req, res, next) {
|
||||
let parsedUrl = url.parse(req.url, true /* parseQueryString */);
|
||||
async function proxyToMailContainer(port, req, res, next) {
|
||||
const parsedUrl = url.parse(req.url, true /* parseQueryString */);
|
||||
const pathname = req.path.split('/').pop();
|
||||
|
||||
// do not proxy protected values
|
||||
@@ -41,7 +42,7 @@ async function proxy(req, res, next) {
|
||||
parsedUrl.query['access_token'] = addonDetails.token;
|
||||
req.url = url.format({ pathname: pathname, query: parsedUrl.query });
|
||||
|
||||
const proxyOptions = url.parse(`http://${addonDetails.ip}:3000`);
|
||||
const proxyOptions = url.parse(`http://${addonDetails.ip}:${port}`);
|
||||
const mailserverProxy = middleware.proxy(proxyOptions);
|
||||
|
||||
req.clearTimeout(); // TODO: add timeout to mail server proxy logic instead of this
|
||||
@@ -55,6 +56,14 @@ async function proxy(req, res, next) {
|
||||
});
|
||||
}
|
||||
|
||||
async function proxy(req, res, next) {
|
||||
proxyToMailContainer(3000, req, res, next);
|
||||
}
|
||||
|
||||
async function queueProxy(req, res, next) {
|
||||
proxyToMailContainer(6000, req, res, next);
|
||||
}
|
||||
|
||||
async function getLocation(req, res, next) {
|
||||
const [error, result] = await safe(mail.getLocation());
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
@@ -299,6 +299,9 @@ function initializeExpressSync() {
|
||||
router.get ('/api/v1/mailserver/mailbox_sharing', token, authorizeAdmin, routes.mailserver.proxy);
|
||||
router.post('/api/v1/mailserver/mailbox_sharing', token, authorizeAdmin, routes.mailserver.proxy, routes.mailserver.restart);
|
||||
router.get ('/api/v1/mailserver/usage', token, authorizeMailManager, routes.mailserver.proxy);
|
||||
router.get ('/api/v1/mailserver/tempfail_queue', token, authorizeAdmin, routes.mailserver.queueProxy);
|
||||
router.post('/api/v1/mailserver/tempfail_queue', json, token, authorizeAdmin, routes.mailserver.queueProxy);
|
||||
router.del ('/api/v1/mailserver/tempfail_queue', token, authorizeAdmin, routes.mailserver.queueProxy);
|
||||
|
||||
router.get ('/api/v1/mail/:domain', token, authorizeMailManager, routes.mail.getDomain);
|
||||
router.post('/api/v1/mail/:domain/enable', json, token, authorizeAdmin, routes.mail.setMailEnabled);
|
||||
|
||||
Reference in New Issue
Block a user