mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-04-23 15:11:26 +00:00
fix http req over https
This commit is contained in:
parent
022902943f
commit
df1bc9911a
1
.gitignore
vendored
1
.gitignore
vendored
@ -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
1
bin.js
@ -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);
|
||||||
|
|
||||||
}
|
}
|
@ -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,
|
||||||
|
@ -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",
|
||||||
|
3
proxy.js
3
proxy.js
@ -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);
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user