From 7c5f9f72afe72c906ef50281f99addc628e38de3 Mon Sep 17 00:00:00 2001 From: OttoMao Date: Thu, 13 Nov 2014 10:05:56 +0800 Subject: [PATCH 1/2] update doc, bugfix for certMgr --- README.md | 4 +++- lib/certMgr.js | 11 ++++++++--- package.json | 2 +- proxy.js | 4 ++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a78182a..a60b76c 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,12 @@ anyproxy ========== 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与众不同的结构与功能。 ![](https://i.alipayobjects.com/i/ecmng/png/201409/3NKRCRk2Uf.png_250x.png) +(Chinese in this doc is nothing but translation of some key points. Be relax if you dont understand.) + Feature ------------ * work as http or https proxy diff --git a/lib/certMgr.js b/lib/certMgr.js index 1c2b159..c115be3 100644 --- a/lib/certMgr.js +++ b/lib/certMgr.js @@ -14,12 +14,17 @@ var certDir = path.join(util.getUserHome(),"/.anyproxy_certs/"), cmd_genCert = path.join(cmdDir,"./gen-cer"), asyncTaskMgr = new asyncTask(); - 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){ var keyFile = path.join(certDir , "__hostname.key".replace(/__hostname/,hostname) ), crtFile = path.join(certDir , "__hostname.crt".replace(/__hostname/,hostname) ); diff --git a/package.json b/package.json index 6d0840a..dde3930 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "anyproxy", - "version": "2.8.3", + "version": "2.8.7", "description": "A fully configurable proxy in NodeJS, which can handle HTTPS requests perfectly.", "main": "proxy.js", "bin": { diff --git a/proxy.js b/proxy.js index 1e7ae92..3a17bb5 100644 --- a/proxy.js +++ b/proxy.js @@ -55,8 +55,8 @@ if(!fs.existsSync(anyproxyHome)){ if(fs.existsSync(path.join(anyproxyHome,"rule_default.js"))){ default_rule = require(path.join(anyproxyHome,"rule_default")); } -if(fs.existsSync(process.cwd() + '/rule.js')){ - default_rule = require(process.cwd() + '/rule'); +if(fs.existsSync(path.join(process.cwd(),'rule.js'))){ + default_rule = require(path.join(process.cwd(),'rule')); } //option From bc24d9dc5466eab2880395b61e3cf3b1f9327e33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8A=A0=E9=87=8C?= Date: Thu, 13 Nov 2014 10:44:52 +0800 Subject: [PATCH 2/2] update doc --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a60b76c..e415642 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,8 @@ Usage ### step 1 - install * 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 @@ -211,6 +212,7 @@ Using https features * 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 clear all the temperary certificates ``anyproxy --clear`` +* https features may be unstable in windows Others -----------------