diff --git a/.eslintignore b/.eslintignore
new file mode 100644
index 0000000..497e913
--- /dev/null
+++ b/.eslintignore
@@ -0,0 +1,7 @@
+node_modules
+dist
+web
+web2
+resource
+*.sh
+docs
\ No newline at end of file
diff --git a/.eslintrc b/.eslintrc
new file mode 100644
index 0000000..1b7b3f1
--- /dev/null
+++ b/.eslintrc
@@ -0,0 +1,75 @@
+{
+ "extends": "airbnb",
+ "parser": "babel-eslint",
+ "env": {
+ "browser": true,
+ "node": true,
+ "es6": true,
+ "jasmine": true
+ },
+ "globals": {
+ "React": true,
+ "ReactDOM": true,
+ "Zepto": true,
+ "JsBridgeUtil": true
+ },
+ "rules": {
+ "semi": [0],
+ "comma-dangle": [0],
+ "global-require": [0],
+ "no-alert": [0],
+ "no-console": [0],
+ "no-param-reassign": [0],
+ "max-len": [0],
+ "func-names": [0],
+ "no-underscore-dangle": [0],
+ "no-unused-vars": ["error", { "vars": "all", "args": "none", "ignoreRestSiblings": false }],
+ "object-shorthand": [0],
+ "arrow-body-style": [0],
+ "no-new": [0],
+ "strict": [0],
+ "no-script-url": [0],
+ "spaced-comment": [0],
+ "no-empty": [0],
+ "no-constant-condition": [0],
+ "no-else-return": [0],
+ "no-use-before-define": [0],
+ "no-unused-expressions": [0],
+ "no-class-assign": [0],
+ "new-cap": [0],
+ "array-callback-return": [0],
+ "prefer-template": [0],
+ "no-restricted-syntax": [0],
+ "no-trailing-spaces": [0],
+ "import/no-unresolved": [0],
+ "jsx-a11y/img-has-alt": [0],
+ "camelcase": [0],
+ "consistent-return": [0],
+ "guard-for-in": [0],
+ "one-var": [0],
+ "react/wrap-multilines": [0],
+ "react/no-multi-comp": [0],
+ "react/jsx-no-bind": [0],
+ "react/prop-types": [0],
+ "react/prefer-stateless-function": [0],
+ "react/jsx-first-prop-new-line": [0],
+ "react/sort-comp": [0],
+ "import/no-extraneous-dependencies": [0],
+ "import/extensions": [0],
+ "react/forbid-prop-types": [0],
+ "react/require-default-props": [0],
+ "class-methods-use-this": [0],
+ "jsx-a11y/no-static-element-interactions": [0],
+ "react/no-did-mount-set-state": [0],
+ "jsx-a11y/alt-text": [0],
+ "import/no-dynamic-require": [0],
+ "no-extra-boolean-cast": [0],
+ "no-lonely-if": [0],
+ "no-plusplus": [0],
+ "generator-star-spacing": ["error", {"before": true, "after": false}],
+ "require-yield": [0],
+ "arrow-parens": [0],
+ "no-template-curly-in-string": [0],
+ "no-mixed-operators": [0]
+ }
+}
diff --git a/.eslintrc.js b/.eslintrc.js
deleted file mode 100644
index 5d96e44..0000000
--- a/.eslintrc.js
+++ /dev/null
@@ -1,245 +0,0 @@
-module.exports = {
- // http://eslint.org/docs/rules/
-
- "ecmaFeatures": {
- "arrowFunctions": false, // enable arrow functions
- "binaryLiterals": false, // enable binary literals
- "blockBindings": false, // enable let and const (aka block bindings)
- "classes": false, // enable classes
- "defaultParams": false, // enable default function parameters
- "destructuring": false, // enable destructuring
- "forOf": false, // enable for-of loops
- "generators": false, // enable generators
- "modules": false, // enable modules and global strict mode
- "objectLiteralComputedProperties": false, // enable computed object literal property names
- "objectLiteralDuplicateProperties": false, // enable duplicate object literal properties in strict mode
- "objectLiteralShorthandMethods": false, // enable object literal shorthand methods
- "objectLiteralShorthandProperties": false, // enable object literal shorthand properties
- "octalLiterals": false, // enable octal literals
- "regexUFlag": false, // enable the regular expression u flag
- "regexYFlag": false, // enable the regular expression y flag
- "restParams": false, // enable the rest parameters
- "spread": false, // enable the spread operator
- "superInFunctions": false, // enable super references inside of functions
- "templateStrings": false, // enable template strings
- "unicodeCodePointEscapes": false, // enable code point escapes
- "globalReturn": false, // allow return statements in the global scope
- "jsx": false // enable JSX
- },
- "parser": "babel-eslint",
-
- "env": {
- "browser": true, // browser global variables.
- "node": false, // Node.js global variables and Node.js-specific rules.
- "worker": false, // web workers global variables.
- "amd": true, // defines require() and define() as global variables as per the amd spec.
- "mocha": false, // adds all of the Mocha testing global variables.
- "jasmine": true, // adds all of the Jasmine testing global variables for version 1.3 and 2.0.
- "phantomjs": false, // phantomjs global variables.
- "jquery": false, // jquery global variables.
- "prototypejs": false, // prototypejs global variables.
- "shelljs": false, // shelljs global variables.
- "meteor": false, // meteor global variables.
- "mongo": false, // mongo global variables.
- "applescript": false, // applescript global variables.
- "es6": true, // enable all ECMAScript 6 features except for modules.
- },
-
- "globals": {
- "goog": true,
- "module": true,
- "exports": true,
- "__dirname": true,
- "process": true
- },
-
- "plugins": [
- // e.g. "react" (must run `npm install eslint-plugin-react` first)
- ],
-
- "rules": {
-
- // Possible Errors
- "comma-dangle": 0, // disallow trailing commas in object literals
- "no-cond-assign": 0, // disallow assignment in conditional expressions
- "no-console": 0, // disallow use of console (off by default in the node environment)
- "no-constant-condition": 0, // disallow use of constant expressions in conditions
- "no-control-regex": 0, // disallow control characters in regular expressions
- "no-debugger": 0, // disallow use of debugger
- "no-dupe-args": 0, // disallow duplicate arguments in functions
- "no-dupe-keys": 0, // disallow duplicate keys when creating object literals
- "no-duplicate-case": 0, // disallow a duplicate case label
- "no-empty-character-class": 0, // disallow the use of empty character classes in regular expressions
- "no-empty": 0, // disallow empty statements
- "no-ex-assign": 0, // disallow assigning to the exception in a catch block
- "no-extra-boolean-cast": 0, // disallow double-negation boolean casts in a boolean context
- "no-extra-parens": 0, // disallow unnecessary parentheses (off by default)
- "no-extra-semi": 1, // disallow unnecessary semicolons
- "no-func-assign": 0, // disallow overwriting functions written as function declarations
- "no-inner-declarations": 2, // disallow function or variable declarations in nested blocks
- "no-invalid-regexp": 0, // disallow invalid regular expression strings in the RegExp constructor
- "no-irregular-whitespace": 0, // disallow irregular whitespace outside of strings and comments
- "no-negated-in-lhs": 0, // disallow negation of the left operand of an in expression
- "no-obj-calls": 0, // disallow the use of object properties of the global object (Math and JSON) as functions
- "no-regex-spaces": 0, // disallow multiple spaces in a regular expression literal
- "no-reserved-keys": 0, // disallow reserved words being used as object literal keys (off by default)
- "no-sparse-arrays": 0, // disallow sparse arrays
- "no-unreachable": 0, // disallow unreachable statements after a return, throw, continue, or break statement
- "use-isnan": 0, // disallow comparisons with the value NaN
- "valid-jsdoc": 0, // Ensure JSDoc comments are valid (off by default)
- "valid-typeof": 0, // Ensure that the results of typeof are compared against a valid string
- "no-unexpected-multiline": 0, // Avoid code that looks like two expressions but is actually one (off by default)
-
-
- // Best Practices
- "accessor-pairs": 0, // enforces getter/setter pairs in objects (off by default)
- "block-scoped-var": 0, // treat var statements as if they were block scoped (off by default)
- "complexity": 0, // specify the maximum cyclomatic complexity allowed in a program (off by default)
- "consistent-return": 0, // require return statements to either always or never specify values
- "curly": 2, // specify curly brace conventions for all control statements
- "default-case": 0, // require default case in switch statements (off by default)
- "dot-notation": 0, // encourages use of dot notation whenever possible
- "dot-location": 0, // enforces consistent newlines before or after dots (off by default)
- "eqeqeq": 0, // require the use of === and !==
- "guard-for-in": 0, // make sure for-in loops have an if statement (off by default)
- "no-alert": 0, // disallow the use of alert, confirm, and prompt
- "no-caller": 0, // disallow use of arguments.caller or arguments.callee
- "no-div-regex": 0, // disallow division operators explicitly at beginning of regular expression (off by default)
- "no-else-return": 0, // disallow else after a return in an if (off by default)
- "no-empty-label": 0, // disallow use of labels for anything other then loops and switches
- "no-eq-null": 0, // disallow comparisons to null without a type-checking operator (off by default)
- "no-eval": 2, // disallow use of eval()
- "no-extend-native": 2, // disallow adding to native types
- "no-extra-bind": 0, // disallow unnecessary function binding
- "no-fallthrough": 0, // disallow fallthrough of case statements
- "no-floating-decimal": 0, // disallow the use of leading or trailing decimal points in numeric literals (off by default)
- "no-implied-eval": 0, // disallow use of eval()-like methods
- "no-iterator": 0, // disallow usage of __iterator__ property
- "no-labels": 0, // disallow use of labeled statements
- "no-lone-blocks": 0, // disallow unnecessary nested blocks
- "no-loop-func": 0, // disallow creation of functions within loops
- "no-multi-spaces": 0, // disallow use of multiple spaces
- "no-multi-str": 0, // disallow use of multiline strings
- "no-native-reassign": 0, // disallow reassignments of native objects
- "no-new-func": 0, // disallow use of new operator for Function object
- "no-new-wrappers": 2, // disallows creating new instances of String, Number, and Boolean
- "no-new": 0, // disallow use of new operator when not part of the assignment or comparison
- "no-octal-escape": 0, // disallow use of octal escape sequences in string literals, such as var foo = "Copyright \251";
- "no-octal": 0, // disallow use of octal literals
- "no-param-reassign": 0, // disallow reassignment of function parameters (off by default)
- "no-process-env": 0, // disallow use of process.env (off by default)
- "no-proto": 0, // disallow usage of __proto__ property
- "no-redeclare": 0, // disallow declaring the same variable more then once
- "no-return-assign": 0, // disallow use of assignment in return statement
- "no-script-url": 0, // disallow use of javascript: urls
- "no-self-compare": 0, // disallow comparisons where both sides are exactly the same (off by default)
- "no-sequences": 0, // disallow use of comma operator
- "no-throw-literal": 0, // restrict what can be thrown as an exception (off by default)
- "no-unused-expressions": 0, // disallow usage of expressions in statement position
- "no-void": 0, // disallow use of void operator (off by default)
- "no-warning-comments": 0, // disallow usage of configurable warning terms in comments, e.g. TODO or FIXME (off by default)
- "no-with": 2, // disallow use of the with statement
- "radix": 0, // require use of the second argument for parseInt() (off by default)
- "vars-on-top": 0, // requires to declare all vars on top of their containing scope (off by default)
- "wrap-iife": 0, // require immediate function invocation to be wrapped in parentheses (off by default)
- "yoda": 0, // require or disallow Yoda conditions
-
-
- // Strict Mode
- "strict": 0, // controls location of Use Strict Directives
-
-
- // Variables
- "no-catch-shadow": 0, // disallow the catch clause parameter name being the same as a variable in the outer scope (off by default in the node environment)
- "no-delete-var": 0, // disallow deletion of variables
- "no-label-var": 0, // disallow labels that share a name with a variable
- "no-shadow": 0, // disallow declaration of variables already declared in the outer scope
- "no-shadow-restricted-names": 0, // disallow shadowing of names such as arguments
- "no-undef": 2, // disallow use of undeclared variables unless mentioned in a /*global */ block
- "no-undef-init": 0, // disallow use of undefined when initializing variables
- "no-undefined": 0, // disallow use of undefined variable (off by default)
- "no-unused-vars": 0, // disallow declaration of variables that are not used in the code
- "no-use-before-define": 0, // disallow use of variables before they are defined
-
-
- // Node.js
- "handle-callback-err": 0, // enforces error handling in callbacks (off by default) (on by default in the node environment)
- "no-mixed-requires": 0, // disallow mixing regular variable and require declarations (off by default) (on by default in the node environment)
- "no-new-require": 0, // disallow use of new operator with the require function (off by default) (on by default in the node environment)
- "no-path-concat": 0, // disallow string concatenation with __dirname and __filename (off by default) (on by default in the node environment)
- "no-process-exit": 0, // disallow process.exit() (on by default in the node environment)
- "no-restricted-modules": 0, // restrict usage of specified node modules (off by default)
- "no-sync": 0, // disallow use of synchronous methods (off by default)
-
-
- // Stylistic Issues
- "array-bracket-spacing": [2, "never"], // enforce spacing inside array brackets (off by default)
- "brace-style": 0, // enforce one true brace style (off by default)
- "camelcase": 0, // require camel case names
- "comma-spacing": 0, // enforce spacing before and after comma
- "comma-style": 0, // enforce one true comma style (off by default)
- "computed-property-spacing": 0, // require or disallow padding inside computed properties (off by default)
- "consistent-this": 0, // enforces consistent naming when capturing the current execution context (off by default)
- "eol-last": 0, // enforce newline at the end of file, with no multiple empty lines
- "func-names": 0, // require function expressions to have a name (off by default)
- "func-style": 0, // enforces use of function declarations or expressions (off by default)
- "indent": [2, 4], // this option sets a specific tab width for your code (off by default)
- "key-spacing": 0, // enforces spacing between keys and values in object literal properties
- "lines-around-comment": 0, // enforces empty lines around comments (off by default)
- "linebreak-style": 0, // disallow mixed 'LF' and 'CRLF' as linebreaks (off by default)
- "max-nested-callbacks": 0, // specify the maximum depth callbacks can be nested (off by default)
- "new-cap": 0, // require a capital letter for constructors
- "new-parens": 0, // disallow the omission of parentheses when invoking a constructor with no arguments
- "new-parens": 0, // disallow the omission of parentheses when invoking a constructor with no arguments
- "newline-after-var": 0, // allow/disallow an empty newline after var statement (off by default)
- "no-array-constructor": 2, // disallow use of the Array constructor
- "no-continue": 0, // disallow use of the continue statement (off by default)
- "no-inline-comments": 0, // disallow comments inline after code (off by default)
- "no-lonely-if": 0, // disallow if as the only statement in an else block (off by default)
- "no-mixed-spaces-and-tabs": 2, // disallow mixed spaces and tabs for indentation
- "no-multiple-empty-lines": 0, // disallow multiple empty lines (off by default)
- "no-nested-ternary": 0, // disallow nested ternary expressions (off by default)
- "no-new-object": 2, // disallow use of the Object constructor
- "no-spaced-func": 0, // disallow space between function identifier and application
- "no-ternary": 0, // disallow the use of ternary operators (off by default)
- "no-trailing-spaces": 0, // disallow trailing whitespace at the end of lines
- "no-underscore-dangle": 0, // disallow dangling underscores in identifiers
- "object-curly-spacing": [2, "always"], // require or disallow padding inside curly braces (off by default)
- "one-var": 0, // allow just one var statement per function (off by default)
- "operator-assignment": 0, // require assignment operator shorthand where possible or prohibit it entirely (off by default)
- "operator-linebreak": 0, // enforce operators to be placed before or after line breaks (off by default)
- "padded-blocks": 0, // enforce padding within blocks (off by default)
- "quote-props": 0, // require quotes around object literal property names (off by default)
- "quotes": 0, // specify whether double or single quotes should be used
- "semi-spacing": 0, // enforce spacing before and after semicolons
- "semi": [2, "always"], // require or disallow use of semicolons instead of ASI
- "sort-vars": 0, // sort variables within the same declaration block (off by default)
- "space-after-keywords": 0, // require a space after certain keywords (off by default)
- "space-before-blocks": 0, // require or disallow space before blocks (off by default)
- "space-before-function-paren": 0, // require or disallow space before function opening parenthesis (off by default)
- "space-in-parens": 0, // require or disallow spaces inside parentheses (off by default)
- "space-infix-ops": 0, // require spaces around operators
- "space-return-throw-case": 0, // require a space after return, throw, and case
- "space-unary-ops": 0, // require or disallow spaces before/after unary operators (words on by default, nonwords off by default)
- "spaced-comment": 0, // require or disallow a space immediately following the // or /* in a comment (off by default)
- "wrap-regex": 0, // require regex literals to be wrapped in parentheses (off by default)
-
-
- // ECMAScript 6
- "constructor-super": 0, // verify super() callings in constructors (off by default)
- "generator-star-spacing": 0, // enforce the spacing around the * in generator functions (off by default)
- "no-this-before-super": 0, // disallow to use this/super before super() calling in constructors (off by default)
- "no-var": 0, // require let or const instead of var (off by default)
- "object-shorthand": 0, // require method and property shorthand syntax for object literals (off by default)
- "prefer-const": 0, // suggest using of const declaration for variables that are never modified after declared (off by default)
-
-
- // Legacy
- "max-depth": 0, // specify the maximum depth that blocks can be nested (off by default)
- "max-len": [1, 120, 2], // specify the maximum length of a line in your program (off by default)
- "max-params": 0, // limits the number of parameters that can be used in the function declaration. (off by default)
- "max-statements": 0, // specify the maximum number of statement allowed in a function (off by default)
- "no-bitwise": 0, // disallow use of bitwise operators (off by default)
- "no-plusplus": 0 // disallow use of unary operators, ++ and -- (off by default)
- }
-}
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 2fa5ecd..f751563 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,15 +3,18 @@ cert/**/*.key
cert/**/*.crt
cert/**/*.csr
web/build/.module-cache/
+test/report/*.txt
tmp.txt
.*.swp
._*
.DS_Store
+.vscode
.git
.hg
.lock-wscript
.svn
.wafpickle-*
+.vscode
CVS
npm-debug.log
logs
@@ -25,4 +28,10 @@ coverage
build/Release
node_modules
.lock-wscript
-temp
\ No newline at end of file
+temp
+dist
+test/report
+*.tgz
+doc_compiled.md
+docs-md/cn/doc.md
+docs-md/en/doc.md
\ No newline at end of file
diff --git a/.npmignore b/.npmignore
new file mode 100644
index 0000000..ee4cfdf
--- /dev/null
+++ b/.npmignore
@@ -0,0 +1,31 @@
+cert/**/*.srl
+cert/**/*.key
+cert/**/*.crt
+cert/**/*.csr
+web/build/.module-cache/
+tmp.txt
+.*.swp
+._*
+.DS_Store
+.git
+.hg
+.lock-wscript
+.svn
+.wafpickle-*
+CVS
+npm-debug.log
+logs
+*.log
+pids
+*.pid
+*.seed
+lib-cov
+coverage
+.grunt
+node_modules
+.lock-wscript
+temp
+releases
+rule_sample
+test
+*.tgz
\ No newline at end of file
diff --git a/CHANGELOG b/CHANGELOG
index b0561c6..e33d013 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,8 @@
+22 Dec 2016: AnyProxy 4.0.0-beta:
+
+ * to AnyProxy rules: all the rule interfaces are asynchronous now, you can write them in a Promise way
+ * to the UI, rewrite the code and enhance the user experience
+
26 Feb 2016: AnyProxy 3.10.4:
* let users assign the port for web socket in AnyProxy cli
diff --git a/README.md b/README.md
index 3c57c93..5d98594 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,5 @@
AnyProxy
-==========
-
-> AnyProxy 4.x is in beta release now. Rule interface is simplified and Promise is supported. Welcome to have a try! http://anyproxy.io/4.x/
-
-> AnyProxy 4.x 正在beta中,rule接口大幅简化,同时支持了Promise。文档及试用:http://anyproxy.io/4.x/
+----------------
[![NPM version][npm-image]][npm-url]
[![node version][node-image]][node-url]
@@ -11,134 +7,23 @@ AnyProxy
[npm-image]: https://img.shields.io/npm/v/anyproxy.svg?style=flat-square
[npm-url]: https://npmjs.org/package/anyproxy
-[node-image]: https://img.shields.io/badge/node.js-%3E=_0.10-green.svg?style=flat-square
+[node-image]: https://img.shields.io/badge/node.js-%3E=_5.0.0-green.svg?style=flat-square
[node-url]: http://nodejs.org/download/
[download-image]: https://img.shields.io/npm/dm/anyproxy.svg?style=flat-square
[download-url]: https://npmjs.org/package/anyproxy
-A fully configurable HTTP/HTTPS proxy in NodeJS.
+AnyProxy is A fully configurable HTTP/HTTPS proxy in NodeJS.
Home page : [AnyProxy.io](http://anyproxy.io)
-(Chinese in this doc is nothing but translation of some key points. Be relax if you dont understand.)
+Issue: https://github.com/alibaba/anyproxy/issues
-
+AnyProxy是一个基于NodeJS的,可供插件配置的HTTP/HTTPS代理服务器。
-特性
-------------
-* 支持https明文代理
-* 支持低网速模拟
-* 支持二次开发,可以用javascript控制代理的全部流程,搭建前端个性化调试环境
-* 提供web版界面,观测请求情况
-* 中文文档:
- * [代理服务器的新轮子](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相关教程](https://github.com/alibaba/anyproxy/wiki/HTTPS%E7%9B%B8%E5%85%B3%E6%95%99%E7%A8%8B),讲解如何配置AnyProxy的https特性
-* 中文主页:[http://anyproxy.io](http://anyproxy.io/cn)
+主页:[AnyProxy.io](http://anyproxy.io)
-Feature
-------------
-* work as http or https proxy
-* fully configurable, you could modify a request at any stage with your customized javascript code
-* when working as https proxy, AnyProxy could intercept https requests for any domain without complaint by browser (after you trust its root CA)
-* a web interface for you to watch realtime request details, where html with (almost) any charset could be shown correctly
+
-Quick Start
---------------
-
-### step 1 - install
-
-* install [NodeJS](http://nodejs.org/)
-* ``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 proxy server
-
-* start with default settings : ``anyproxy``
-* ...or start with a specific port: ``anyproxy --port 8001``
-* ...start with a rule file: ``anyproxy --rule ./rule_sample/rule_allow_CORS.js``
-
-### step 3 - set up proxy settings in your browser , or system ,or mobile devices ,etc
-
-* default proxy should be 127.0.0.1:8001 , or you_ip_address:8001 on remote devices
-
-### step 4 - launch web interface
-
-* visit [http://127.0.0.1:8002](http://127.0.0.1:8002) ,you will see realtime requests in your browser
-* be sure to use web interface with modern browsers
-
-
-
-
-
-Rule module
--------------------
-* Rule module is the specialty for AnyProxy. Think it as a middleware, you could write your own code to hack requests at any stage, no matter it is about to response or the proxy just gets the request. In this way, AnyProxy would be flexible to meet your own demands.
-
-* It's highly recommended to read this guide before using: [What is rule file and how to write one ?](https://github.com/alibaba/anyproxy/wiki/What-is-rule-file-and-how-to-write-one)
-
-* An entire scheme of rule file could be found at [./rule_sample/rule__blank.js](https://github.com/alibaba/anyproxy/blob/master/rule_sample/rule__blank.js). Besides, there are some samples at [./rule_sample](https://github.com/alibaba/anyproxy/tree/master/rule_sample). That may help you a lot when writing your own rule files.
-
-
-Https features
----------------
-After configuring rootCA, AnyProxy could help to decrypt https requests, whose approach is also called Man-In-The-Middle(MITM).
-A guide about configuring https features is here : [https://github.com/alibaba/anyproxy/wiki/How-to-config-https-proxy](https://github.com/alibaba/anyproxy/wiki/How-to-config-https-proxy)
-
-HTTPS配置中文教程 : [https://github.com/alibaba/anyproxy/wiki/HTTPS%E7%9B%B8%E5%85%B3%E6%95%99%E7%A8%8B](https://github.com/alibaba/anyproxy/wiki/HTTPS%E7%9B%B8%E5%85%B3%E6%95%99%E7%A8%8B)
-
-
-Others
------------------
-
-#### to save request data
-* to save request data to local file, use ``` anyproxy --file /path/to/file ```
-* anyproxy uses [nedb](https://github.com/louischatriot/nedb) to save request data. Since NeDB's persistence uses an append-only format, you may get some redundant record in local file. For those dupplicated ones with the same id, just use the lastest line of record.
-* [TrafficeRecorder](https://github.com/ottomao/TrafficRecorder) is another tool based on anyproxy to help recording all request data, including header and body. You may have a try.
-
-#### throttling
-* for instance, ``` anyproxy --throttle 10 ``` sets the speed limit to 10kb/s (kbyte/sec)
-* this is just a rough throttling for downstream, not for network simulation
-
-#### work as a module for nodejs
-* use it as a module and develop your own proxy.
-
-```
-npm install anyproxy --save
-```
-
-```javascript
-var proxy = require("anyproxy");
-
-//create cert when you want to use https features
-//please manually trust this rootCA when it is the first time you run it
-!proxy.isRootCAFileExists() && proxy.generateRootCA();
-
-var options = {
- type : "http",
- port : 8001,
- hostname : "localhost",
- rule : require("path/to/my/ruleModule.js"),
- dbFile : null, // optional, save request data to a specified file, will use in-memory db if not specified
- webPort : 8002, // optional, port for web interface
- socketPort : 8003, // optional, internal port for web socket, replace this when it is conflict with your own service
- throttle : 10, // optional, speed limit in kb/s
- disableWebInterface : false, //optional, set it when you don't want to use the web interface
- setAsGlobalProxy : false, //set anyproxy as your system proxy
- silent : false //optional, do not print anything into terminal. do not set it when you are still debugging.
-};
-new proxy.proxyServer(options);
-
-```
-
-Contact
------------------
-
-* Please feel free to [raise issue](https://github.com/alibaba/anyproxy/issues), or give us some advice. :)
-* AnyProxy用户旺旺群已经停止维护,任何疑问可以直接[提issue](https://github.com/alibaba/anyproxy/issues) :)
-
-
-License
------------------
-
-* Apache License, Version 2.0
+Legacy doc of version 3.x : https://github.com/alibaba/anyproxy/wiki/3.x-docs
\ No newline at end of file
diff --git a/bin.js b/bin.js
deleted file mode 100755
index 19e561a..0000000
--- a/bin.js
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/usr/bin/env node
-
-var program = require('commander'),
- color = require('colorful'),
- fs = require("fs"),
- path = require("path"),
- npm = require("npm"),
- packageInfo = require("./package.json"),
- util = require("./lib/util"),
- logUtil = require("./lib/log");
-
-program
- .version(packageInfo.version)
- .option('-u, --host [value]', 'hostname for https proxy, localhost for default')
- .option('-t, --type [value]', 'http|https, http for default')
- .option('-p, --port [value]', 'proxy port, 8001 for default')
- .option('-w, --web [value]' , 'web GUI port, 8002 for default')
- .option('-e, --ws [value]' , 'web socket port, 8003 for default')
- .option('-f, --file [value]', 'save request data to a specified file, will use in-memory db if not specified')
- .option('-r, --rule [value]', 'path for rule file,')
- .option('-g, --root [value]', 'generate root CA')
- .option('-l, --throttle [value]', 'throttle speed in kb/s (kbyte / sec)')
- .option('-i, --intercept', 'intercept(decrypt) https requests when root CA exists')
- .option('-s, --silent', 'do not print anything into terminal')
- .option('-c, --clear', 'clear all the tmp certificates')
- .option('-o, --global', 'set as global proxy for system')
- .option('install', '[alpha] install node modules')
- .parse(process.argv);
-
-if(program.clear){
- require("./lib/certMgr").clearCerts(function(){
- console.log( color.green("all certs cleared") );
- process.exit(0);
- });
-
-}else if(program.root){
- require("./lib/certMgr").generateRootCA(function(){
- process.exit(0);
- });
-
-}else if(program.install){
- npm.load({
- "prefix": process.env.NODE_PATH + '/anyproxy/'
- }, function (er) {
- npm.commands.install(program.args || [], function (er, data) {
- if(er)throw er;
- });
- npm.registry.log.on("log", function (message) {});
- });
-}else{
- var proxy = require("./proxy.js");
- var ruleModule;
-
- if(program.silent){
- logUtil.setPrintStatus(false);
- }
-
- if(program.rule){
- var ruleFilePath = path.resolve(process.cwd(),program.rule);
- try{
- if(fs.existsSync(ruleFilePath)){
- ruleModule = require(ruleFilePath);
- logUtil.printLog("rule file loaded :" + ruleFilePath);
- }else{
- var logText = color.red("can not find rule file at " + ruleFilePath);
- logUtil.printLog(logText, logUtil.T_ERR);
- }
- }catch(e){
- logUtil.printLog("failed to load rule file :" + e.toString(), logUtil.T_ERR);
- }
- }else{
- //a feature for donghua.yan
- //read rule file from a specific position
- (function(){
- try{
- var anyproxyHome = path.join(util.getAnyProxyHome());
- if(fs.existsSync(path.join(anyproxyHome,"rule_default.js"))){
- ruleModule = require(path.join(anyproxyHome,"rule_default"));
- }
- if(fs.existsSync(path.join(process.cwd(),'rule.js'))){
- ruleModule = require(path.join(process.cwd(),'rule'));
- }
- }catch(e){}
- })();
- }
-
- new proxy.proxyServer({
- type : program.type,
- port : program.port,
- hostname : program.host,
- dbFile : program.file,
- throttle : program.throttle,
- webPort : program.web,
- socketPort : program.ws,
- rule : ruleModule,
- disableWebInterface : false,
- setAsGlobalProxy : program.global,
- interceptHttps : program.intercept,
- silent : program.silent
- });
-}
diff --git a/bin/anyproxy b/bin/anyproxy
new file mode 100755
index 0000000..330e083
--- /dev/null
+++ b/bin/anyproxy
@@ -0,0 +1,114 @@
+#!/usr/bin/env node
+
+'use strict'
+const program = require('commander'),
+ color = require('colorful'),
+ packageInfo = require('../package.json'),
+ ruleLoader = require('../lib/ruleLoader'),
+ util = require('../lib/util'),
+ logUtil = require('../lib/log');
+
+program
+ .version(packageInfo.version)
+ .option('-p, --port [value]', 'proxy port, 8001 for default')
+ .option('-w, --web [value]', 'web GUI port, 8002 for default')
+ .option('-r, --rule [value]', 'path for rule file,')
+ .option('-l, --throttle [value]', 'throttle speed in kb/s (kbyte / sec)')
+ .option('-i, --intercept', 'intercept(decrypt) https requests when root CA exists')
+ .option('-s, --silent', 'do not print anything into terminal')
+ .option('-c, --clear', 'clear all the certificates and temp files')
+ .option('--ignore-unauthorized-ssl', 'ignore all ssl error')
+ .parse(process.argv);
+
+if (program.clear) {
+ require('../lib/certMgr').clearCerts(() => {
+ util.deleteFolderContentsRecursive(util.getAnyProxyPath('cache'));
+ console.log(color.green('done !'));
+ process.exit(0);
+ });
+} else if (program.root) {
+ require('../lib/certMgr').generateRootCA(() => {
+ process.exit(0);
+ });
+} else {
+ const AnyProxy = require('../proxy.js');
+ let proxyServer;
+
+ if (program.silent) {
+ logUtil.setPrintStatus(false);
+ }
+
+ // load rule module
+ new Promise((resolve, reject) => {
+ if (program.rule) {
+ resolve(ruleLoader.requireModule(program.rule));
+ } else {
+ resolve(null);
+ }
+ })
+ .catch(e => {
+ logUtil.printLog('Failed to load rule file', logUtil.T_ERR);
+ logUtil.printLog(e, logUtil.T_ERR);
+ process.exit();
+ })
+
+ //start proxy
+ .then(ruleModule => {
+ proxyServer = new AnyProxy.ProxyServer({
+ type: 'http',
+ port: program.port || 8001,
+ throttle: program.throttle,
+ rule: ruleModule,
+ webInterface: {
+ enable: true,
+ webPort: program.web,
+ },
+ forceProxyHttps: program.intercept,
+ dangerouslyIgnoreUnauthorized: !!program.ignoreUnauthorizedSsl,
+ silent: program.silent
+ });
+ // proxyServer.on('ready', () => {});
+ proxyServer.start();
+ })
+ .catch(e => {
+ logUtil.printLog(e, logUtil.T_ERR);
+ if (e && e.code) {
+ logUtil.printLog('code ' + e.code, logUtil.T_ERR);
+ }
+ logUtil.printLog(e.stack, logUtil.T_ERR);
+ });
+
+ process.on('exit', (code) => {
+ if (code > 0) {
+ logUtil.printLog('AnyProxy is about to exit with code: ' + code, logUtil.T_ERR);
+ }
+
+ process.exit();
+ });
+
+ //exit cause ctrl+c
+ process.on('SIGINT', () => {
+ try {
+ proxyServer && proxyServer.close();
+ } catch (e) {
+ console.error(e);
+ }
+ process.exit();
+ });
+
+ process.on('uncaughtException', (err) => {
+ let errorTipText = 'got an uncaught exception, is there anything goes wrong in your rule file ?\n';
+ try {
+ if (err && err.stack) {
+ errorTipText += err.stack;
+ } else {
+ errorTipText += err;
+ }
+ } catch (e) {}
+ logUtil.printLog(errorTipText, logUtil.T_ERR);
+ try {
+ proxyServer && proxyServer.close();
+ } catch (e) {}
+ process.exit();
+ });
+}
diff --git a/bin/anyproxy-ca b/bin/anyproxy-ca
new file mode 100755
index 0000000..f03a60f
--- /dev/null
+++ b/bin/anyproxy-ca
@@ -0,0 +1,102 @@
+#!/usr/bin/env node
+
+'use strict'
+
+// exist-false, trusted-false : create CA
+// exist-true, trusted-false : trust CA
+// exist-true, trusted-true : all things done
+const program = require('commander');
+const color = require('colorful');
+const certMgr = require('../lib/certMgr');
+const AnyProxy = require('../proxy');
+const exec = require('child_process').exec;
+const co = require('co');
+const path = require('path');
+const inquirer = require('inquirer');
+
+program
+ .option('-c, --clear', 'clear all the tmp certificates and root CA')
+ .option('-g, --generate', 'generate a new rootCA')
+ .parse(process.argv);
+
+function openFolderOfFile(filePath) {
+ const isWin = /^win/.test(process.platform);
+ if (isWin) {
+ exec('start .', { cwd: path.dirname(filePath) });
+ } else {
+ exec(`open -R ${filePath}`);
+ }
+}
+
+function guideToGenrateCA() {
+ AnyProxy.utils.certMgr.generateRootCA((error, keyPath, crtPath) => {
+ if (!error) {
+ const certDir = path.dirname(keyPath);
+ console.log(`The cert is generated at ${certDir}. Please trust the ${color.bold('rootCA.crt')}.`);
+ // TODO: console.log('guide to install');
+ openFolderOfFile(crtPath);
+ } else {
+ console.error('failed to generate rootCA', error);
+ }
+ });
+}
+
+function guideToTrustCA() {
+ const certPath = AnyProxy.utils.certMgr.getRootCAFilePath();
+ if (certPath) {
+ // TODO: console.log('guide to install');
+ openFolderOfFile(certPath);
+ } else {
+ console.error('failed to get cert path');
+ }
+}
+
+if (program.clear) {
+ AnyProxy.utils.certMgr.clearCerts(() => {
+ console.log(color.green('done !'));
+ });
+} else if (program.generate) {
+ guideToGenrateCA();
+} else {
+ console.log('detecting CA status...');
+ co(certMgr.getCAStatus)
+ .then(status => {
+ if (!status.exist) {
+ console.log('AnyProxy CA does not exist.');
+ const questions = [{
+ type: 'confirm',
+ name: 'ifCreate',
+ message: 'Would you like to generate one ?',
+ default: true
+ }];
+ inquirer.prompt(questions).then(answers => {
+ if (answers.ifCreate) {
+ guideToGenrateCA();
+ }
+ });
+ } else if (!status.trusted) {
+ if (/^win/.test(process.platform)) {
+ console.log('AnyProxy CA exists, make sure it has been trusted');
+ } else {
+ console.log('AnyProxy CA exists, but not be trusted');
+ const questions = [{
+ type: 'confirm',
+ name: 'ifGotoTrust',
+ message: 'Would you like to open the folder and trust it ?',
+ default: true
+ }];
+ inquirer.prompt(questions).then(answers => {
+ if (answers.ifGotoTrust) {
+ guideToTrustCA();
+ }
+ });
+ }
+ // AnyProxy.utils.certMgr.clearCerts()
+ } else {
+ console.log(color.green('AnyProxy CA has already been trusted'));
+ }
+ })
+ .catch(e => {
+ console.log(e);
+ })
+}
diff --git a/build_scripts/prebuild-doc.js b/build_scripts/prebuild-doc.js
new file mode 100644
index 0000000..58645ff
--- /dev/null
+++ b/build_scripts/prebuild-doc.js
@@ -0,0 +1,77 @@
+const fs = require('fs');
+const path = require('path');
+
+const textTpl = [
+ '```bash',
+ 'anyproxy --rule {{url}}',
+ '```',
+ '```js',
+ '{{content}}',
+ '```'
+].join('\n');
+
+/**
+ *
+ * @param {*} config
+ * @param {string} config.input input markdown path
+ * @param {string} config.ouput output markdown path
+ */
+function mergeMdWithRuleFile(config) {
+ const doc = fs.readFileSync(config.input, { encoding: 'utf8' });
+ const rules = doc.match(/\{\{sample-rule:([\S]+)\}\}/g).map((rawToReplace) => ({
+ raw: rawToReplace,
+ url: rawToReplace.replace(/\{\{sample-rule:([\S]+)\}\}/g, ($0, $1) => {
+ return $1;
+ })
+ }));
+
+ const tasks = rules.map((item) => (
+ new Promise((resolve, reject) => {
+ fs.readFile(item.url, 'utf8', (err, data) => {
+ if (!err) {
+ const result = Object.assign({}, item);
+ result.content = data;
+ resolve(result);
+ } else {
+ reject(err);
+ }
+ });
+ })
+ ));
+
+ // fetch all samples
+ return Promise.all(tasks)
+ .then((results) => {
+ // merge to doc
+ let resultDoc = doc;
+ results.forEach((item) => {
+ const contentToInsert = textTpl.replace('{{url}}', item.url).replace('{{content}}', item.content);
+ resultDoc = resultDoc.replace(item.raw, contentToInsert);
+ });
+ fs.writeFileSync(config.output, resultDoc);
+ }, (fail) => {
+ console.log('failed to load resource');
+ console.log(fail);
+ process.exit();
+ })
+ .catch(e => {
+ console.log(e);
+ process.exit();
+ });
+}
+
+Promise.all([
+ {
+ input: path.join(__dirname, '../docs-src/cn/src_doc.md'),
+ output: path.join(__dirname, '../docs-src/cn/README.md'),
+ },
+ {
+ input: path.join(__dirname, '../docs-src/en/src_doc.md'),
+ output: path.join(__dirname, '../docs-src/en/README.md'),
+ }
+].map(mergeMdWithRuleFile)).then(result => {
+ console.log('done');
+}).catch(e => {
+ console.log('err');
+ console.log(e);
+});
diff --git a/docs-src/CNAME b/docs-src/CNAME
new file mode 100644
index 0000000..edd7608
--- /dev/null
+++ b/docs-src/CNAME
@@ -0,0 +1 @@
+anyproxy.io
\ No newline at end of file
diff --git a/docs-src/LANGS.md b/docs-src/LANGS.md
new file mode 100644
index 0000000..b2beea8
--- /dev/null
+++ b/docs-src/LANGS.md
@@ -0,0 +1,4 @@
+# Languages
+
+* [中文](cn/)
+* [English](en/)
diff --git a/docs-src/README.md b/docs-src/README.md
new file mode 100644
index 0000000..c55bde3
--- /dev/null
+++ b/docs-src/README.md
@@ -0,0 +1,2 @@
+# THIS IS AUTO GENERATED FILE, DO NOT EDIT THE HTML DIRECTLY.
+# YOU CAN EDIT THE SOURCE IN docs-md FOLDER
diff --git a/docs-src/_layouts/layout.html b/docs-src/_layouts/layout.html
new file mode 100644
index 0000000..0c1a708
--- /dev/null
+++ b/docs-src/_layouts/layout.html
@@ -0,0 +1,29 @@
+
+
+
port {number} required, port number of proxy server
+
rule {object} your rule module
+
throttle {number} throttle in kb/s, unlimited for default
+
forceProxyHttps {boolean} in force intercept all https request, false for default
+
silent {boolean} if keep silent in console, false for defaultfalse
+
dangerouslyIgnoreUnauthorized {boolean} if ignore certificate error in request, false for default
+
webInterface {object} config for web interface
+
enable {boolean} if enable web interface, false for default
+
webPort {number} port number for web interface
+
+
+
+
+
Event: ready
+
+
emit when proxy server is ready
+
sample
+
+
proxy.on('ready', function() { })
+
+
+
Event: error
+
+
emit when error happened inside proxy server
+
sample
+
+
proxy.on('error', function() { })
+
+
+
Method: start
+
+
start proxy server
+
sample
+
+
proxy.start();
+
+
+
Method: close
+
+
close proxy server
+
sample
+
+
proxy.close();
+
+
+
+
+
AnyProxy.utils.systemProxyMgr
+
+
manage the system proxy config. sudo password may be required
+
sample
+
+
// set 127.0.0.1:8001 as system http server
+AnyProxy.utils.systemProxyMgr.enableGlobalProxy('127.0.0.1', '8001');
+
+// disable global proxy server
+AnyProxy.utils.systemProxyMgr.disableGlobalProxy();
+
+
+
AnyProxy.utils.certMgr
+
+
Manage certificates of AnyProxy
+
AnyProxy.utils.certMgr.ifRootCAFileExists()
+
detect if AnyProx rootCA exists
+
+
+
AnyProxy.utils.certMgr.generateRootCA(callback)
+
generate a rootCA
+
+
+
Sample
+
+
const AnyProxy = require('AnyProxy');
+ const exec = require('child_process').exec;
+
+ if (!AnyProxy.utils.certMgr.ifRootCAFileExists()) {
+ AnyProxy.utils.certMgr.generateRootCA((error, keyPath) => {
+ // let users to trust this CA before using proxy
+ if (!error) {
+ const certDir = require('path').dirname(keyPath);
+ console.log('The cert is generated at', certDir);
+ const isWin = /^win/.test(process.platform);
+ if (isWin) {
+ exec('start .', { cwd: certDir });
+ } else {
+ exec('open .', { cwd: certDir });
+ }
+ } else {
+ console.error('error when generating rootCA', error);
+ }
+ });
+ }
+
+
+
+
Proxy Https
+
+
AnyProxy does NOT intercept https requests by default. To view decrypted info, you have to config the CA certificate.
+
+
+
Under the hood, AnyProxy decryptes https requests by man-in-the-middle attack. Users have to trust the CA cert in advance. Otherwise, client side will issue errors about unsecure network.
+
+
+
generate certifycates and intercept
+
+
anyproxy-ca #generate root CA. manually trust it after that.
+anyproxy --intercept #launch anyproxy and intercept all https traffic
+
Click Root CA in web ui, and follow the instruction to install
+
+
+
trust root CA in iOS after 10.3
+
+
Besides installing root CA, you have to "turn on" the certificate for web manually in settings - general - about - Certificate Trust Settings. Otherwire, safari will not trust the root CA generated by AnyProxy.
+
+
+
config iOS/Android proxy server
+
+
proxy settings are placed in wifi setting
+
+
iOS
+
+
+
+
+
Android
+
+
+
FAQ
+
Q: can not deal https request in rule module.
+
+
A: Any of these options could be used to change the way AnyProxy deall https requests
+
config --intercept when luanching AnyProxy via cli, or use forceProxyHttps when using as an npm module
+
place a beforeDealHttpsRequest function in your rule file and determine which request to intercept by your own.
+
+
+
+
Q: get an error says function is not yieldable
+
+
A: Rule module is driven by co. The functions inside should be yieldable, i.e. return a promise or be a generator function.
+
+
Q: The connection is not private
+
AnyProxy will propmt this message when the certification of the site you're visiting is not issued by a common known CA. This happens when the certification is self-signed. If you know and trust it, you can ignore the error as below.
+
+
If you run AnyProxy by command line
+Pass in the option --ignore-unauthorized-ssl to ignore the certification errors, please mind that the option will be active for all connections.
+
anyproxy -i --ignore-unauthorized-ssl
+
+
+
If you run AnyProxy by Nodejs
+Pass in the option dangerouslyIgnoreUnauthorized:true, like this:
This is also a global option, all certification errors will be ignored
+
+
With the help of AnyProxy Rule
+You can change the request with rule of course. For this scenario, all you need is to pass in an option to Nodejs Http.rquest, as we do in AnyProxy. A simple demo below:
port {number} required, port number of proxy server
+
rule {object} your rule module
+
throttle {number} throttle in kb/s, unlimited for default
+
forceProxyHttps {boolean} in force intercept all https request, false for default
+
silent {boolean} if keep silent in console, false for defaultfalse
+
dangerouslyIgnoreUnauthorized {boolean} if ignore certificate error in request, false for default
+
webInterface {object} config for web interface
+
enable {boolean} if enable web interface, false for default
+
webPort {number} port number for web interface
+
+
+
+
+
Event: ready
+
+
emit when proxy server is ready
+
sample
+
+
proxy.on('ready', function() { })
+
+
+
Event: error
+
+
emit when error happened inside proxy server
+
sample
+
+
proxy.on('error', function() { })
+
+
+
Method: start
+
+
start proxy server
+
sample
+
+
proxy.start();
+
+
+
Method: close
+
+
close proxy server
+
sample
+
+
proxy.close();
+
+
+
+
+
AnyProxy.utils.systemProxyMgr
+
+
manage the system proxy config. sudo password may be required
+
sample
+
+
// set 127.0.0.1:8001 as system http server
+AnyProxy.utils.systemProxyMgr.enableGlobalProxy('127.0.0.1', '8001');
+
+// disable global proxy server
+AnyProxy.utils.systemProxyMgr.disableGlobalProxy();
+
+
+
AnyProxy.utils.certMgr
+
+
Manage certificates of AnyProxy
+
AnyProxy.utils.certMgr.ifRootCAFileExists()
+
detect if AnyProx rootCA exists
+
+
+
AnyProxy.utils.certMgr.generateRootCA(callback)
+
generate a rootCA
+
+
+
Sample
+
+
const AnyProxy = require('AnyProxy');
+ const exec = require('child_process').exec;
+
+ if (!AnyProxy.utils.certMgr.ifRootCAFileExists()) {
+ AnyProxy.utils.certMgr.generateRootCA((error, keyPath) => {
+ // let users to trust this CA before using proxy
+ if (!error) {
+ const certDir = require('path').dirname(keyPath);
+ console.log('The cert is generated at', certDir);
+ const isWin = /^win/.test(process.platform);
+ if (isWin) {
+ exec('start .', { cwd: certDir });
+ } else {
+ exec('open .', { cwd: certDir });
+ }
+ } else {
+ console.error('error when generating rootCA', error);
+ }
+ });
+ }
+
+
+
+
Proxy Https
+
+
AnyProxy does NOT intercept https requests by default. To view decrypted info, you have to config the CA certificate.
+
+
+
Under the hood, AnyProxy decryptes https requests by man-in-the-middle attack. Users have to trust the CA cert in advance. Otherwise, client side will issue errors about unsecure network.
+
+
+
generate certifycates and intercept
+
+
anyproxy-ca #generate root CA. manually trust it after that.
+anyproxy --intercept #launch anyproxy and intercept all https traffic
+
Click Root CA in web ui, and follow the instruction to install
+
+
+
trust root CA in iOS after 10.3
+
+
Besides installing root CA, you have to "turn on" the certificate for web manually in settings - general - about - Certificate Trust Settings. Otherwire, safari will not trust the root CA generated by AnyProxy.
+
+
+
config iOS/Android proxy server
+
+
proxy settings are placed in wifi setting
+
+
iOS
+
+
+
+
+
Android
+
+
+
FAQ
+
Q: can not deal https request in rule module.
+
+
A: Any of these options could be used to change the way AnyProxy deall https requests
+
config --intercept when luanching AnyProxy via cli, or use forceProxyHttps when using as an npm module
+
place a beforeDealHttpsRequest function in your rule file and determine which request to intercept by your own.
+
+
+
+
Q: get an error says function is not yieldable
+
+
A: Rule module is driven by co. The functions inside should be yieldable, i.e. return a promise or be a generator function.
+
+
Q: The connection is not private
+
AnyProxy will propmt this message when the certification of the site you're visiting is not issued by a common known CA. This happens when the certification is self-signed. If you know and trust it, you can ignore the error as below.
+
+
If you run AnyProxy by command line
+Pass in the option --ignore-unauthorized-ssl to ignore the certification errors, please mind that the option will be active for all connections.
+
anyproxy -i --ignore-unauthorized-ssl
+
+
+
If you run AnyProxy by Nodejs
+Pass in the option dangerouslyIgnoreUnauthorized:true, like this:
This is also a global option, all certification errors will be ignored
+
+
With the help of AnyProxy Rule
+You can change the request with rule of course. For this scenario, all you need is to pass in an option to Nodejs Http.rquest, as we do in AnyProxy. A simple demo below: