Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

anyproxy

Package Overview
Dependencies
Maintainers
1
Versions
174
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

anyproxy - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

11

lib/requestHandler.js

@@ -30,3 +30,3 @@ var http = require("http"),

var host = req.headers.host,
path = url.parse(req.url).path,
path = url.parse(req.url).pathname,
ifLocalruleMatched = false;

@@ -51,6 +51,7 @@

var targetLocalfile = rule.localFile;
if(!targetLocalfile){ //find file in dir //TODO : /a/b/c -> b/c
var basename = pathUtil.basename(path);
basename = basename.slice(0,basename.indexOf("?")); //remove chars after question mark
targetLocalfile = pathUtil.join(rule.localDir,basename);
//localfile not set, map to dir
if(!targetLocalfile){ //find file in dir, /a/b/file.html -> dir + b/file.html
var remotePathWithoutPrefix = path.replace(new RegExp(rule.path),""); //remove prefix
targetLocalfile = pathUtil.join(rule.localDir,remotePathWithoutPrefix);
}

@@ -57,0 +58,0 @@

{
"name": "anyproxy",
"version": "1.1.1",
"version": "1.1.2",
"description": "a charles/fiddle like web proxy for developers which can intercept https requests without browser warning",

@@ -15,3 +15,5 @@ "main": "proxy.js",

},
"devDependencies": {},
"devDependencies": {
"tunnel": "0.0.3"
},
"scripts": {

@@ -18,0 +20,0 @@ "test": "nodeunit test.js"

@@ -1,3 +0,1 @@

//TODO : get free port
var http = require('http'),

@@ -13,2 +11,3 @@ https = require('https'),

certMgr = require("./lib/certMgr"),
getPort = require("./lib/getPort"),
requestHandler = require("./lib/requestHandler");

@@ -29,6 +28,14 @@

self.httpProxyServer = null;
self.close = function(){
self.httpProxyServer && self.httpProxyServer.close();
console.log(color.green("server closed :" + proxyHost + ":" + proxyPort));
}
if(ruleFile){ //TODO : fs.join
if(ruleFile){
if(fs.existsSync(ruleFile)){
requestHandler.setRules(require(ruleFile));
try{ //for abs path
requestHandler.setRules(require(ruleFile)); //todo : require path
}catch(e){ //for relative path
requestHandler.setRules(require("./" + ruleFile));
}
console.log(color.green("rule file loaded"));

@@ -69,3 +76,2 @@ }else{

}
],

@@ -86,3 +92,2 @@

return self.httpProxyServer;
}

@@ -89,0 +94,0 @@

@@ -9,7 +9,13 @@ var rules = {

}
// ,{
// "host" :/./,
// "path" :/\.(png|gif|jpg|jpeg)/,
// "localFile" :"/Users/Stella/tmp/test.png",
// "localDir" :"~/"
// }
,{
"host" :/./,
"path" :/\.(png|gif|jpg|jpeg)/,
"localFile" :"/Users/Stella/tmp/test.png",
"localDir" :"~/"
"path" :/tps/,
"localFile" :"",
"localDir" :"/Users/Stella/tmp/"
}

@@ -16,0 +22,0 @@ ]

@@ -1,20 +0,78 @@

var https = require("https"),
http = require("http");
http = require("http"),
proxy = require("./proxy"),
tunnel= require('tunnel'),
tls = require("tls");
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0';
module.exports.httpOverHttp = function(test){
var testDesc = "httpOverHttp",
proxyServer = new proxy.proxyServer("http","8004");
try{
var test_option_http_over_http = {
host: "localhost",
port: 8004,
path: "/",
headers: {
Host: "www.baidu.com"
}
};
var options = {
host: "localhost",
port: 8001,
path: "/",
headers: {
Host: "www.alipay.com"
http.get(test_option_http_over_http, function(res) {
var data = "";
res.on("data",function(chunk){
data += chunk;
});
res.on("end",function(){
proxyServer.close();
test.ok(data.length > 50, testDesc);
test.done();
});
});
}catch(e){
console.log(e);
test.ok(false,testDesc);
test.done();
}
};
https.get(options, function(res) {
console.log(res);
res.pipe(process.stdout);
});
}
module.exports.testHttpsOverHttp = function(test){
var testDesc = "httpsOverHttp";
var proxyServer = new proxy.proxyServer("http","8004");
try{
var tunnelingAgent = tunnel.httpsOverHttp({
proxy: {
host: 'localhost',
port: 8004
}
});
var req = https.request({
host: 'www.alipay.com',
port: 443,
agent: tunnelingAgent
},function(res){
var data = "";
res.on("data",function(chunk){
data += chunk;
});
res.on("end",function(){
proxyServer.close();
test.ok(data.length > 50, testDesc);
test.done();
});
});
req.end();
}catch(e){
console.log(e);
test.ok(false,testDesc);
test.done();
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc