mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-05-10 14:58:27 +00:00
add download link for rootCA.crt, bugfix
This commit is contained in:
parent
f685d82dd9
commit
0db6b1861a
@ -207,6 +207,7 @@ Using https features
|
|||||||
|
|
||||||
#### about certs
|
#### about certs
|
||||||
* root certs and temperary certs are stored at ``path.join(util.getUserHome(),"/.anyproxy_certs/")``
|
* root certs and temperary certs are stored at ``path.join(util.getUserHome(),"/.anyproxy_certs/")``
|
||||||
|
* to get the rootCA.crt file , you may either find it in local dir or download it via anyproxy web interface
|
||||||
* to clear all the temperary certificates ``anyproxy --clear``
|
* to clear all the temperary certificates ``anyproxy --clear``
|
||||||
|
|
||||||
Others
|
Others
|
||||||
|
@ -72,7 +72,7 @@ function checkRootCA(){
|
|||||||
if(!isRootCAFileExists()){
|
if(!isRootCAFileExists()){
|
||||||
console.log(color.red("can not find rootCA.crt or rootCA.key"));
|
console.log(color.red("can not find rootCA.crt or rootCA.key"));
|
||||||
console.log(color.red("you may generate one by the following methods"));
|
console.log(color.red("you may generate one by the following methods"));
|
||||||
console.log(color.red("\twhen using globally : sudo anyproxy --root"));
|
console.log(color.red("\twhen using globally : anyproxy --root"));
|
||||||
console.log(color.red("\twhen using as a module : require(\"anyproxy\").generateRootCA();"));
|
console.log(color.red("\twhen using as a module : require(\"anyproxy\").generateRootCA();"));
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
@ -110,6 +110,7 @@ function generateRootCA(){
|
|||||||
if(code == 0){
|
if(code == 0){
|
||||||
console.log(color.green("rootCA generated"));
|
console.log(color.green("rootCA generated"));
|
||||||
console.log(color.green(color.bold("please trust the rootCA.crt in " + certDir)));
|
console.log(color.green(color.bold("please trust the rootCA.crt in " + certDir)));
|
||||||
|
console.log(color.green(color.bold("or you may get it via anyproxy webinterface")));
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}else{
|
}else{
|
||||||
console.log(color.red("fail to generate root CA"));
|
console.log(color.red("fail to generate root CA"));
|
||||||
@ -120,6 +121,16 @@ function generateRootCA(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getRootCAFilePath(){
|
||||||
|
if(isRootCAFileExists()){
|
||||||
|
return path.join(certDir,"rootCA.crt");
|
||||||
|
}else{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.getRootCAFilePath = getRootCAFilePath;
|
||||||
module.exports.generateRootCA = generateRootCA;
|
module.exports.generateRootCA = generateRootCA;
|
||||||
module.exports.getCertificate = getCertificate;
|
module.exports.getCertificate = getCertificate;
|
||||||
module.exports.createCert = createCert;
|
module.exports.createCert = createCert;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "anyproxy",
|
"name": "anyproxy",
|
||||||
"version": "2.7.6",
|
"version": "2.8.0",
|
||||||
"description": "A fully configurable proxy in NodeJS, which can handle HTTPS requests perfectly.",
|
"description": "A fully configurable proxy in NodeJS, which can handle HTTPS requests perfectly.",
|
||||||
"main": "proxy.js",
|
"main": "proxy.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
4
proxy.js
4
proxy.js
@ -146,10 +146,12 @@ function proxyServer(option){
|
|||||||
|
|
||||||
//TODO : uncaught exception
|
//TODO : uncaught exception
|
||||||
//kill web server when father process exits
|
//kill web server when father process exits
|
||||||
process.on("exit",function(){
|
process.on("exit uncaughtException",function(){
|
||||||
child_webServer.kill();
|
child_webServer.kill();
|
||||||
|
process.exit();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
GLOBAL.recorder.on("update",function(data){
|
GLOBAL.recorder.on("update",function(data){
|
||||||
child_webServer.send({
|
child_webServer.send({
|
||||||
type: "update",
|
type: "update",
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
<a href="#" class="J_clearBtn"><span class="topBtn">Clear Logs(Ctrl+X)</span></a>
|
<a href="#" class="J_clearBtn"><span class="topBtn">Clear Logs(Ctrl+X)</span></a>
|
||||||
<a href="#" class="J_statusBtn"><span class="topBtn">Stop</span></a>
|
<a href="#" class="J_statusBtn"><span class="topBtn">Stop</span></a>
|
||||||
<a href="#" class="J_statusBtn btn_disable"><span class="topBtn">Resume</span></a>
|
<a href="#" class="J_statusBtn btn_disable"><span class="topBtn">Resume</span></a>
|
||||||
|
<a href="/fetchCrtFile" target="_blank"><span class="topBtn">Fetch rootCA.crt</span></a>
|
||||||
<a href="http://localhost:{{proxyConfigPort}}"><span class="topBtn">Config Local Response(beta)</span></a>
|
<a href="http://localhost:{{proxyConfigPort}}"><span class="topBtn">Config Local Response(beta)</span></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="ruleDesc">
|
<div class="ruleDesc">
|
||||||
|
18
webServer.js
18
webServer.js
@ -3,6 +3,7 @@ var express = require("express"),
|
|||||||
url = require('url'),
|
url = require('url'),
|
||||||
fs = require("fs"),
|
fs = require("fs"),
|
||||||
util = require("./lib/util"),
|
util = require("./lib/util"),
|
||||||
|
certMgr = require("./lib/certMgr"),
|
||||||
events = require("events"),
|
events = require("events"),
|
||||||
inherits = require("util").inherits,
|
inherits = require("util").inherits,
|
||||||
entities = require("entities"),
|
entities = require("entities"),
|
||||||
@ -10,8 +11,10 @@ var express = require("express"),
|
|||||||
WebSocketServer = require('ws').Server;
|
WebSocketServer = require('ws').Server;
|
||||||
|
|
||||||
function proxyWebServer(port,webSocketPort,proxyConfigPort,ruleSummary,ipAddress){
|
function proxyWebServer(port,webSocketPort,proxyConfigPort,ruleSummary,ipAddress){
|
||||||
var self = this,
|
|
||||||
myAbsAddress = "http://" + ipAddress + ":" + port +"/";
|
var self = this,
|
||||||
|
myAbsAddress = "http://" + ipAddress + ":" + port +"/",
|
||||||
|
crtFilePath = certMgr.getRootCAFilePath();
|
||||||
|
|
||||||
if(arguments.length < 3){
|
if(arguments.length < 3){
|
||||||
throw new Error("please assign ports");
|
throw new Error("please assign ports");
|
||||||
@ -46,6 +49,17 @@ function proxyWebServer(port,webSocketPort,proxyConfigPort,ruleSummary,ipAddress
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.get("/fetchCrtFile",function(req,res){
|
||||||
|
if(crtFilePath){
|
||||||
|
res.setHeader("Content-Type","application/x-x509-ca-cert");
|
||||||
|
res.setHeader("Content-Disposition",'attachment; filename="rootCA.crt"');
|
||||||
|
res.end(fs.readFileSync(crtFilePath,{encoding:null}));
|
||||||
|
}else{
|
||||||
|
res.setHeader("Content-Type","text/html");
|
||||||
|
res.end("can not file rootCA ,plase use <strong>anyproxy --root</strong> to generate one");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
//make qr code
|
//make qr code
|
||||||
app.get("/qr",function(req,res){
|
app.get("/qr",function(req,res){
|
||||||
var qr = qrCode.qrcode(4, 'M'),
|
var qr = qrCode.qrcode(4, 'M'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user