mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-04-23 15:51:25 +00:00
update api
This commit is contained in:
parent
a9d56ef859
commit
61e2821fe6
@ -82,7 +82,7 @@ function generateRootCA(){
|
|||||||
process.exit(0);
|
process.exit(0);
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
|
console.log(color.red("fail to generate root CA"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//manage https servers
|
//manage https servers
|
||||||
var getPort = require('./getPort'),
|
var getPort = require('./getPort'),
|
||||||
async = require("async"),
|
async = require("async"),
|
||||||
http = require('http'),
|
http = require('http'),
|
||||||
https = require('https'),
|
https = require('https'),
|
||||||
@ -8,9 +8,7 @@ var getPort = require('./getPort'),
|
|||||||
url = require('url'),
|
url = require('url'),
|
||||||
color = require('colorful'),
|
color = require('colorful'),
|
||||||
certMgr = require("./certMgr"),
|
certMgr = require("./certMgr"),
|
||||||
requestHandler = require("./requestHandler"),
|
asyncTask = require("./asyncTaskMgr");
|
||||||
asyncTask = require("./asyncTaskMgr");
|
|
||||||
|
|
||||||
|
|
||||||
var DEFAULT_RELEASE_TIME = 120*1000;
|
var DEFAULT_RELEASE_TIME = 120*1000;
|
||||||
|
|
||||||
@ -29,7 +27,7 @@ module.exports =function(){
|
|||||||
};
|
};
|
||||||
|
|
||||||
//fetch a port for https server with hostname
|
//fetch a port for https server with hostname
|
||||||
this.fetchPort = function(hostname,userCB){
|
this.fetchPort = function(hostname,userRequesthandler,userCB){
|
||||||
var serverInfo = self.serverList[hostname],
|
var serverInfo = self.serverList[hostname],
|
||||||
port;
|
port;
|
||||||
|
|
||||||
@ -41,7 +39,7 @@ module.exports =function(){
|
|||||||
|
|
||||||
//create server with corresponding CA
|
//create server with corresponding CA
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
asyncTaskMgr.addTask(hostname ,userCB,function(cb){
|
asyncTaskMgr.addTask(hostname ,userCB,function(cb){
|
||||||
createServer(cb);
|
createServer(cb);
|
||||||
});
|
});
|
||||||
@ -60,7 +58,7 @@ module.exports =function(){
|
|||||||
,function(callback){
|
,function(callback){
|
||||||
|
|
||||||
certMgr.getCertificate(hostname,function(err,keyContent,crtContent){
|
certMgr.getCertificate(hostname,function(err,keyContent,crtContent){
|
||||||
var server = createHttpsServer(port,keyContent,crtContent);
|
var server = createHttpsServer(port,keyContent,crtContent,userRequesthandler);
|
||||||
self.serverList[hostname] = {
|
self.serverList[hostname] = {
|
||||||
port : port,
|
port : port,
|
||||||
server : server,
|
server : server,
|
||||||
@ -96,11 +94,11 @@ module.exports =function(){
|
|||||||
},DEFAULT_RELEASE_TIME);
|
},DEFAULT_RELEASE_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
function createHttpsServer(port,keyContent,crtContent){
|
function createHttpsServer(port,keyContent,crtContent,userRequesthandler){
|
||||||
return https.createServer({
|
return https.createServer({
|
||||||
key : keyContent,
|
key : keyContent,
|
||||||
cert: crtContent
|
cert: crtContent
|
||||||
},requestHandler.userRequestHandler).listen(port);
|
},userRequesthandler).listen(port);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ function connectReqHandler(req, socket, head){
|
|||||||
console.log("==>will forward to local https server");
|
console.log("==>will forward to local https server");
|
||||||
|
|
||||||
//forward the https-request to local https server
|
//forward the https-request to local https server
|
||||||
httpsServerMgrInstance.fetchPort(hostname,function(err,port){
|
httpsServerMgrInstance.fetchPort(hostname,userRequestHandler,function(err,port){
|
||||||
if(!err && port){
|
if(!err && port){
|
||||||
try{
|
try{
|
||||||
var conn = net.connect(port, 'localhost', function(){ //TODO : localhost -> server
|
var conn = net.connect(port, 'localhost', function(){ //TODO : localhost -> server
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "anyproxy",
|
"name": "anyproxy",
|
||||||
"version": "0.2.2",
|
"version": "0.2.3",
|
||||||
"description": "https proxy over http",
|
"description": "https proxy over http",
|
||||||
"main": "proxy.js",
|
"main": "proxy.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user