From 2de0e13ec58402d63b71ce26fd9e8b437c6cc575 Mon Sep 17 00:00:00 2001 From: Reed Rosenbluth Date: Mon, 20 Jul 2015 17:28:25 -0700 Subject: [PATCH 1/3] proxy support --- package.json | 1 + src/core/server.js | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 4bb6edc6..a0ed196b 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "babel-runtime": "^5.5.4", "bignumber.js": "^2.0.3", "extend": "~1.2.1", + "https-proxy-agent": "^1.0.0", "is-my-json-valid": "^2.12.0", "lodash": "^3.1.0", "lru-cache": "~2.5.0", diff --git a/src/core/server.js b/src/core/server.js index fff5842e..604ae39c 100644 --- a/src/core/server.js +++ b/src/core/server.js @@ -3,6 +3,7 @@ const _ = require('lodash'); const util = require('util'); const url = require('url'); +const HttpsProxyAgent = require('https-proxy-agent'); const LRU = require('lru-cache'); const EventEmitter = require('events').EventEmitter; const RippleError = require('./').RippleError; @@ -436,7 +437,18 @@ Server.prototype.connect = function() { 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; From a71dc28523a8bb9aafef35ae1746aa4d271806e0 Mon Sep 17 00:00:00 2001 From: Reed Rosenbluth Date: Mon, 20 Jul 2015 18:02:42 -0700 Subject: [PATCH 2/3] updated shrinkwrap --- npm-shrinkwrap.json | 50 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index e14f45c0..f36712ec 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -9,12 +9,12 @@ "resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz" }, "babel-runtime": { - "version": "5.4.7", - "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-5.4.7.tgz", + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-5.7.0.tgz", "dependencies": { "core-js": { - "version": "0.9.13", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-0.9.13.tgz" + "version": "0.9.18", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-0.9.18.tgz" } } }, @@ -26,6 +26,36 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/extend/-/extend-1.2.1.tgz" }, + "https-proxy-agent": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-1.0.0.tgz", + "dependencies": { + "agent-base": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-2.0.0.tgz", + "dependencies": { + "semver": { + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-4.3.6.tgz" + } + } + }, + "debug": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", + "dependencies": { + "ms": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz" + } + } + }, + "extend": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.0.tgz" + } + } + }, "is-my-json-valid": { "version": "2.12.0", "resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.12.0.tgz", @@ -55,8 +85,8 @@ } }, "lodash": { - "version": "3.9.3", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.9.3.tgz" + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.0.tgz" }, "lru-cache": { "version": "2.5.2", @@ -82,12 +112,10 @@ }, "sjcl-extended": { "version": "1.0.3", - "from": "ripple/sjcl-extended#1.0.3", - "resolved": "git://github.com/ripple/sjcl-extended.git#908218e0db4fccd08c4e3f1f7269b72f8d93c270", + "resolved": "git://github.com/ripple/sjcl-extended.git#d8cf8b22e7d97193c54e1f65113e3edcf200ca17", "dependencies": { "sjcl": { "version": "1.0.3", - "from": "sjcl@>=1.0.3 <2.0.0", "resolved": "https://registry.npmjs.org/sjcl/-/sjcl-1.0.3.tgz" } } @@ -115,8 +143,8 @@ "resolved": "https://registry.npmjs.org/options/-/options-0.0.6.tgz" }, "ultron": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.0.1.tgz" + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.0.2.tgz" }, "utf-8-validate": { "version": "1.1.0", From b23d588747638420670618c28870f22c69a9565d Mon Sep 17 00:00:00 2001 From: Reed Rosenbluth Date: Mon, 20 Jul 2015 18:18:45 -0700 Subject: [PATCH 3/3] disable eslint for lines 538 - 548 --- src/core/server.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core/server.js b/src/core/server.js index 604ae39c..a3c4cc99 100644 --- a/src/core/server.js +++ b/src/core/server.js @@ -533,6 +533,8 @@ Server.prototype._retryConnect = function() { this._retry += 1; + /*eslint-disable */ + const retryTimeout = (this._retry < 40) // First, for 2 seconds: 20 times per second ? (1000 / 20) @@ -545,6 +547,8 @@ Server.prototype._retryConnect = function() { // Then: once every 30 seconds : (30 * 1000); + /*eslint-enable */ + function connectionRetry() { if (self._shouldConnect) { if (self._remote.trace) {