From f9056c6754293da6dc2803eb7f04e0902f08be6f Mon Sep 17 00:00:00 2001 From: azivner Date: Mon, 13 Nov 2017 19:45:13 -0500 Subject: [PATCH] proxy support --- services/sync.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/services/sync.js b/services/sync.js index 045ecdcf6..d8e7bef77 100644 --- a/services/sync.js +++ b/services/sync.js @@ -14,6 +14,7 @@ const syncUpdate = require('./sync_update'); const SYNC_SERVER = config['Sync']['syncServerHost']; const isSyncSetup = !!SYNC_SERVER; const SYNC_TIMEOUT = config['Sync']['syncServerTimeout'] || 5000; +const SYNC_PROXY = config['Sync']['syncProxy']; let syncInProgress = false; @@ -215,14 +216,20 @@ async function syncRequest(syncContext, method, uri, body) { const fullUri = SYNC_SERVER + uri; try { - return await rp({ + const options = { method: method, uri: fullUri, jar: syncContext.cookieJar, json: true, body: body, timeout: SYNC_TIMEOUT - }); + }; + + if (SYNC_PROXY) { + options.proxy = SYNC_PROXY; + } + + return await rp(options); } catch (e) { throw new Error("Request to " + method + " " + fullUri + " failed, inner exception: " + e.stack);