mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-26 07:05:49 +00:00
proxy support
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
"babel-runtime": "^5.5.4",
|
"babel-runtime": "^5.5.4",
|
||||||
"bignumber.js": "^2.0.3",
|
"bignumber.js": "^2.0.3",
|
||||||
"extend": "~1.2.1",
|
"extend": "~1.2.1",
|
||||||
|
"https-proxy-agent": "^1.0.0",
|
||||||
"is-my-json-valid": "^2.12.0",
|
"is-my-json-valid": "^2.12.0",
|
||||||
"lodash": "^3.1.0",
|
"lodash": "^3.1.0",
|
||||||
"lru-cache": "~2.5.0",
|
"lru-cache": "~2.5.0",
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
const url = require('url');
|
const url = require('url');
|
||||||
|
const HttpsProxyAgent = require('https-proxy-agent');
|
||||||
const LRU = require('lru-cache');
|
const LRU = require('lru-cache');
|
||||||
const EventEmitter = require('events').EventEmitter;
|
const EventEmitter = require('events').EventEmitter;
|
||||||
const RippleError = require('./').RippleError;
|
const RippleError = require('./').RippleError;
|
||||||
@@ -436,7 +437,18 @@ Server.prototype.connect = function() {
|
|||||||
log.info(this.getServerID(), 'connect');
|
log.info(this.getServerID(), 'connect');
|
||||||
}
|
}
|
||||||
|
|
||||||
const ws = this._ws = new WebSocket(this._opts.url);
|
if (this._remote.hasOwnProperty('proxy')) {
|
||||||
|
const parsed = url.parse(this._opts.url);
|
||||||
|
const opts = url.parse(this._remote.proxy);
|
||||||
|
opts.secureEndpoint = parsed.protocol === 'wss:';
|
||||||
|
const agent = new HttpsProxyAgent(opts);
|
||||||
|
|
||||||
|
this._ws = new WebSocket(this._opts.url, {agent: agent});
|
||||||
|
} else {
|
||||||
|
this._ws = new WebSocket(this._opts.url);
|
||||||
|
}
|
||||||
|
|
||||||
|
const ws = this._ws;
|
||||||
|
|
||||||
this._shouldConnect = true;
|
this._shouldConnect = true;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user