mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-04-23 16:01:26 +00:00
add request
This commit is contained in:
commit
be4c86eb86
@ -2,10 +2,12 @@ anyproxy
|
|||||||
==========
|
==========
|
||||||
A fully configurable proxy in NodeJS, which can handle HTTPS requests perfectly.
|
A fully configurable proxy in NodeJS, which can handle HTTPS requests perfectly.
|
||||||
|
|
||||||
(Chinese in this doc is nothing but translation of some key points. Be relax if you dont understand.)
|
[wiki - 代理服务器的新轮子](https://github.com/alibaba/anyproxy/wiki/%E4%BB%A3%E7%90%86%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%9A%84%E6%96%B0%E8%BD%AE%E5%AD%90%EF%BC%9Aanyproxy) ,介绍我们为什么要再造一个代理服务器,anyproxy与众不同的结构与功能。
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
(Chinese in this doc is nothing but translation of some key points. Be relax if you dont understand.)
|
||||||
|
|
||||||
Feature
|
Feature
|
||||||
------------
|
------------
|
||||||
* work as http or https proxy
|
* work as http or https proxy
|
||||||
@ -22,7 +24,8 @@ Usage
|
|||||||
### step 1 - install
|
### step 1 - install
|
||||||
|
|
||||||
* install [NodeJS](http://nodejs.org/)
|
* install [NodeJS](http://nodejs.org/)
|
||||||
* ``tnpm install -g anyproxy`` , may require ``sudo``
|
* ``npm install -g anyproxy`` , may require ``sudo``
|
||||||
|
* python is optional, it will be OK if you get some error about it during installing.
|
||||||
|
|
||||||
### step 2 - start server
|
### step 2 - start server
|
||||||
|
|
||||||
@ -209,6 +212,7 @@ Using https features
|
|||||||
* root certs and temperary certs are stored at ``path.join(util.getUserHome(),"/.anyproxy_certs/")``
|
* root certs and temperary certs are stored at ``path.join(util.getUserHome(),"/.anyproxy_certs/")``
|
||||||
* to get the rootCA.crt file , you may either find it in local dir or download it via anyproxy web interface
|
* to get the rootCA.crt file , you may either find it in local dir or download it via anyproxy web interface
|
||||||
* to clear all the temperary certificates ``anyproxy --clear``
|
* to clear all the temperary certificates ``anyproxy --clear``
|
||||||
|
* https features may be unstable in windows
|
||||||
|
|
||||||
Others
|
Others
|
||||||
-----------------
|
-----------------
|
||||||
|
@ -14,12 +14,17 @@ var certDir = path.join(util.getUserHome(),"/.anyproxy_certs/"),
|
|||||||
cmd_genCert = path.join(cmdDir,"./gen-cer"),
|
cmd_genCert = path.join(cmdDir,"./gen-cer"),
|
||||||
asyncTaskMgr = new asyncTask();
|
asyncTaskMgr = new asyncTask();
|
||||||
|
|
||||||
|
|
||||||
if(!fs.existsSync(certDir)){
|
if(!fs.existsSync(certDir)){
|
||||||
fs.mkdirSync(certDir,0777);
|
try{
|
||||||
|
fs.mkdirSync(certDir,0777); //may fail in windows
|
||||||
|
}catch(e){
|
||||||
|
console.log("===========");
|
||||||
|
console.log("failed to create cert dir ,please create one by yourself - " + certDir);
|
||||||
|
console.log("this error will not block main thread unless you use https-related features in anyproxy");
|
||||||
|
console.log("===========");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getCertificate(hostname,cb){
|
function getCertificate(hostname,cb){
|
||||||
var keyFile = path.join(certDir , "__hostname.key".replace(/__hostname/,hostname) ),
|
var keyFile = path.join(certDir , "__hostname.key".replace(/__hostname/,hostname) ),
|
||||||
crtFile = path.join(certDir , "__hostname.crt".replace(/__hostname/,hostname) );
|
crtFile = path.join(certDir , "__hostname.crt".replace(/__hostname/,hostname) );
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "anyproxy",
|
"name": "anyproxy",
|
||||||
"version": "2.8.7",
|
"version": "2.8.9",
|
||||||
"description": "A fully configurable proxy in NodeJS, which can handle HTTPS requests perfectly.",
|
"description": "A fully configurable proxy in NodeJS, which can handle HTTPS requests perfectly.",
|
||||||
"main": "proxy.js",
|
"main": "proxy.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
4
proxy.js
4
proxy.js
@ -56,8 +56,8 @@ if(!fs.existsSync(anyproxyHome)){
|
|||||||
if(fs.existsSync(path.join(anyproxyHome,"rule_default.js"))){
|
if(fs.existsSync(path.join(anyproxyHome,"rule_default.js"))){
|
||||||
default_rule = require(path.join(anyproxyHome,"rule_default"));
|
default_rule = require(path.join(anyproxyHome,"rule_default"));
|
||||||
}
|
}
|
||||||
if(fs.existsSync(process.cwd() + '/rule.js')){
|
if(fs.existsSync(path.join(process.cwd(),'rule.js'))){
|
||||||
default_rule = require(process.cwd() + '/rule');
|
default_rule = require(path.join(process.cwd(),'rule'));
|
||||||
}
|
}
|
||||||
|
|
||||||
//option
|
//option
|
||||||
|
Loading…
x
Reference in New Issue
Block a user