diff --git a/proxy16/node/rpc.js b/proxy16/node/rpc.js index 7708f39e3..227a1878c 100644 --- a/proxy16/node/rpc.js +++ b/proxy16/node/rpc.js @@ -274,7 +274,7 @@ function rpc(request, callback, obj) { var reqf = self.transports?.axios || axios config.method = 'post' - + //config.signal = signal try{ @@ -291,6 +291,8 @@ function rpc(request, callback, obj) { return } + + reqf({ url, diff --git a/proxy16/transports.js b/proxy16/transports.js index 37dabe095..0a92925e9 100644 --- a/proxy16/transports.js +++ b/proxy16/transports.js @@ -100,19 +100,31 @@ class WrappedAxios { return axios(preparedArgs) .then(WrappedAxios.handleSuccess) .catch(async (error) => { + const isAgentAttached = WrappedAxios.isAgentAttached(preparedArgs); const isAgentError = this.transports.checkForAgentError(error); if (isAgentAttached && isAgentError) { return WrappedAxios.handleError(error); } + + if (error.code != 'ECONNREFUSED' && error.code != "ETIMEDOUT" && error.code != "ENOTFOUND"){ + return Promise.reject(error) + } + + + var hasDirectAccess = await this.transports.hasDirectAccess(preparedArgs.url); + var isDirectAccessRestricted = (torCtrl.settings.enabled2 === 'always'); + var useDirectAccess = (hasDirectAccess && !isDirectAccessRestricted); + let isTorReady = this.transports.isTorReady(); + + if (isDirectAccessRestricted) { + isTorReady = await this.transports.waitTorReady(); + } + + var isTorEnabledInSettings = (torCtrl.settings.enabled2 !== 'neveruse'); + var useTor = (!useDirectAccess && isTorReady && isTorEnabledInSettings); - const hasDirectAccess = await this.transports.hasDirectAccess(preparedArgs.url); - const isDirectAccessRestricted = (torCtrl.settings.enabled2 === 'always'); - const useDirectAccess = (hasDirectAccess && !isDirectAccessRestricted); - const isTorReady = await this.transports.waitTorReady(); - const isTorEnabledInSettings = (torCtrl.settings.enabled2 !== 'neveruse'); - const useTor = (!useDirectAccess && isTorReady && isTorEnabledInSettings); if (useTor) { const isTorAutoEnabled = (torCtrl.settings.enabled2 === 'auto'); @@ -212,6 +224,7 @@ class WrappedFetch { }); }) .catch(async (error) => { + const isAgentAttached = WrappedFetch.isAgentAttached(preparedArgs); const isAgentError = this.transports.checkForAgentError(error); @@ -219,6 +232,10 @@ class WrappedFetch { return WrappedFetch.handleError(error); } + if (error.code != 'ECONNREFUSED' && error.code != "ETIMEDOUT" && error.code != "ENOTFOUND"){ + return Promise.reject(error) + } + const hasDirectAccess = await this.transports.hasDirectAccess(url); const isDirectAccessRestricted = (torCtrl.settings.enabled2 === 'always'); const useDirectAccess = (hasDirectAccess && !isDirectAccessRestricted); @@ -341,7 +358,13 @@ class WrappedRequest { const hasDirectAccess = await this.transports.hasDirectAccess(url); const isDirectAccessRestricted = (torCtrl.settings.enabled2 === 'always'); const useDirectAccess = (hasDirectAccess && !isDirectAccessRestricted); - const isTorReady = await this.transports.waitTorReady(); + + let isTorReady = this.transports.isTorReady(); + + if (isDirectAccessRestricted) { + isTorReady = await this.transports.waitTorReady(); + } + const isTorEnabledInSettings = (torCtrl.settings.enabled2 !== 'neveruse'); const useTor = (!useDirectAccess && isTorReady && isTorEnabledInSettings);