fix the start issue when webinterface is disabled, andd add test cases

This commit is contained in:
砚然
2018-02-05 21:04:27 +08:00
parent 1405356292
commit 310f84d68f
3 changed files with 21 additions and 12 deletions

View File

@@ -23,10 +23,16 @@ const DEFAULT_OPTIONS = {
*
* @return An instance of proxy, could be closed by calling `instance.close()`
*/
function defaultProxyServer() {
function defaultProxyServer(webinterfaceEnable = true) {
const AnyProxy = util.freshRequire('../proxy.js');
const options = util.merge({}, DEFAULT_OPTIONS);
util.merge(options, {
webInterface: {
enable: webinterfaceEnable,
webPort: 8002
}
})
const instance = new AnyProxy.ProxyServer(options);
instance.on('error', e => {
console.log('server instance error', e);