mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-08-04 21:39:04 +00:00
add CA download page
This commit is contained in:
@@ -12,7 +12,8 @@ const express = require('express'),
|
||||
wsServer = require('./wsServer'),
|
||||
juicer = require('juicer'),
|
||||
ip = require('ip'),
|
||||
compress = require('compression');
|
||||
compress = require('compression'),
|
||||
pug = require('pug');
|
||||
|
||||
const DEFAULT_WEB_PORT = 8002; // port for web interface
|
||||
|
||||
@@ -202,6 +203,11 @@ class webInterface extends events.EventEmitter {
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/downloadCrt', (req, res) => {
|
||||
const pageFn = pug.compileFile(path.join(__dirname, '../resource/cert_download.pug'));
|
||||
res.end(pageFn({ ua: req.get('user-agent') }));
|
||||
});
|
||||
|
||||
app.get('/fetchCrtFile', (req, res) => {
|
||||
res.setHeader('Access-Control-Allow-Origin', '*');
|
||||
const _crtFilePath = certMgr.getRootCAFilePath();
|
||||
@@ -219,9 +225,8 @@ class webInterface extends events.EventEmitter {
|
||||
app.get('/api/getQrCode', (req, res) => {
|
||||
res.setHeader('Access-Control-Allow-Origin', '*');
|
||||
|
||||
const fileType = certFileTypes.indexOf(req.query.type) !== -1 ? req.query.type : 'crt';
|
||||
const qr = qrCode.qrcode(4, 'M');
|
||||
const targetUrl = req.protocol + '://' + req.get('host') + '/fetchCrtFile?type=' + fileType;
|
||||
const targetUrl = req.protocol + '://' + req.get('host') + '/downloadCrt';
|
||||
const isRootCAFileExists = certMgr.isRootCAFileExists();
|
||||
|
||||
qr.addData(targetUrl);
|
||||
|
||||
Reference in New Issue
Block a user