Node.js API

If you are willing to help hiproxy to write documentation, please contact zdying@live.com, thank you!

ProxyServer ⇐ EventEmitter

Kind: global class
Extends: EventEmitter

new ProxyServer(options)

Hiproxy’s proxy server.

| Param | Type | Description | | — | — | — | | options | Object | options | | options.httpPort | Number | The HTTP proxy service port. If 0/null/undefined is passed, an available port number will be automatically assigned. | | options.httpsPort | Number | HTTPS proxy service port number. If 0 is passed, an available port will be automatically assigned. If pass null or undefined, the HTTPS service will not be started. | | [options.dir] | String | The hiproxy workspace defaults to the current working directory of the Node.js process(process.cwd()) |

proxyServer.start([config]) ⇒ Promise

Start proxy server.

Kind: instance method of ProxyServer
Access: public

| Param | Type | Description | | — | — | — | | config | Object | configuration fields |

proxyServer.stop() ⇒ ProxyServer

Stop proxy server.

Kind: instance method of ProxyServer
Access: public

proxyServer.restart() ⇒ ProxyServer

Restart proxy server.

Kind: instance method of ProxyServer
Access: public

proxyServer.addHostsFile(filePath) ⇒ ProxyServer

Add a hosts file.

Kind: instance method of ProxyServer
Access: public

| Param | Type | Description | | — | — | — | | filePath | String \| Array | hosts file path(s) (absolute) |

proxyServer.addRewriteFile(filePath) ⇒ ProxyServer

Add a rewrite file.

Kind: instance method of ProxyServer
Access: public

| Param | Type | Description | | — | — | — | | filePath | String \| Array | rewrite file path(s) (absolute) |

proxyServer.openBrowser(browserName, url, [usePacProxy]) ⇒ ProxyServer

Open a browser.

Kind: instance method of ProxyServer
Access: public

| Param | Type | Default | Description | | — | — | — | — | | browserName | String | | browser name | | url | String | | the URL should be opened | | [usePacProxy] | Boolean | false | whether use PAC proxy |

proxyServer.enableConfFile(confFileType, filePath) ⇒ ProxyServer

Enable specified configuration file.

Kind: instance method of ProxyServer
Access: public

| Param | Type | Default | Description | | — | — | — | — | | confFileType | String | | file type (host/rewrite) | | filePath | String \| Array | | modified file path(s) |

proxyServer.disableConfFile(confFileType, filePath) ⇒ ProxyServer

Disable specified configuration file.

Kind: instance method of ProxyServer
Access: public

| Param | Type | Default | Description | | — | — | — | — | | confFileType | String | | file type (host/rewrite) | | filePath | String \| Array | | modified file path(s) |