update api

This commit is contained in:
加里 2014-08-13 13:27:05 +08:00
parent a9d56ef859
commit 61e2821fe6
4 changed files with 10 additions and 12 deletions

View File

@ -82,7 +82,7 @@ function generateRootCA(){
process.exit(0);
});
}else{
console.log(color.red("fail to generate root CA"));
}
});
}

View File

@ -1,5 +1,5 @@
//manage https servers
var getPort = require('./getPort'),
var getPort = require('./getPort'),
async = require("async"),
http = require('http'),
https = require('https'),
@ -8,9 +8,7 @@ var getPort = require('./getPort'),
url = require('url'),
color = require('colorful'),
certMgr = require("./certMgr"),
requestHandler = require("./requestHandler"),
asyncTask = require("./asyncTaskMgr");
asyncTask = require("./asyncTaskMgr");
var DEFAULT_RELEASE_TIME = 120*1000;
@ -29,7 +27,7 @@ module.exports =function(){
};
//fetch a port for https server with hostname
this.fetchPort = function(hostname,userCB){
this.fetchPort = function(hostname,userRequesthandler,userCB){
var serverInfo = self.serverList[hostname],
port;
@ -41,7 +39,7 @@ module.exports =function(){
//create server with corresponding CA
}else{
asyncTaskMgr.addTask(hostname ,userCB,function(cb){
createServer(cb);
});
@ -60,7 +58,7 @@ module.exports =function(){
,function(callback){
certMgr.getCertificate(hostname,function(err,keyContent,crtContent){
var server = createHttpsServer(port,keyContent,crtContent);
var server = createHttpsServer(port,keyContent,crtContent,userRequesthandler);
self.serverList[hostname] = {
port : port,
server : server,
@ -96,11 +94,11 @@ module.exports =function(){
},DEFAULT_RELEASE_TIME);
}
function createHttpsServer(port,keyContent,crtContent){
function createHttpsServer(port,keyContent,crtContent,userRequesthandler){
return https.createServer({
key : keyContent,
cert: crtContent
},requestHandler.userRequestHandler).listen(port);
},userRequesthandler).listen(port);
}

View File

@ -139,7 +139,7 @@ function connectReqHandler(req, socket, head){
console.log("==>will forward 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){
try{
var conn = net.connect(port, 'localhost', function(){ //TODO : localhost -> server

View File

@ -1,6 +1,6 @@
{
"name": "anyproxy",
"version": "0.2.2",
"version": "0.2.3",
"description": "https proxy over http",
"main": "proxy.js",
"bin": {