fix http req over https

This commit is contained in:
加里 2014-08-11 17:48:32 +08:00
parent 022902943f
commit df1bc9911a
5 changed files with 7 additions and 3 deletions

1
.gitignore vendored
View File

@ -6,6 +6,7 @@
.lock-wscript .lock-wscript
.svn .svn
.wafpickle-* .wafpickle-*
tmp.txt
CVS CVS
npm-debug.log npm-debug.log
cert/**/*.srl cert/**/*.srl

1
bin.js
View File

@ -16,4 +16,5 @@ if(program.clear){
}else{ }else{
mainProxy.startServer(program.type,program.port, program.host); mainProxy.startServer(program.type,program.port, program.host);
} }

View File

@ -2,8 +2,9 @@ var http = require("http"),
https = require("https"); https = require("https");
function handler(req,userRes){ function handler(req,userRes){
console.log(req);
var ifHttps = !!req.connection.encrypted; var ifHttps = !!req.connection.encrypted && !/http:/.test(req.url);
var options = { var options = {
hostname : req.headers.host, hostname : req.headers.host,

View File

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

View File

@ -29,7 +29,7 @@ function startServer(type, port, hostname){
//creat server //creat server
function(callback){ function(callback){
if(proxyType == T_TYPE_HTTPS){ if(proxyType == T_TYPE_HTTPS){
httpsServerMgr.getCertificate(proxyHost,function(err,keyContent,crtContent){ certMgr.getCertificate(proxyHost,function(err,keyContent,crtContent){
if(err){ if(err){
callback(err); callback(err);
}else{ }else{
@ -44,6 +44,7 @@ function startServer(type, port, hostname){
}else{ }else{
httpProxyServer = http.createServer(requestHandler); httpProxyServer = http.createServer(requestHandler);
callback(null); callback(null);
} }
}, },