|
|
|
@ -1,25 +1,26 @@
|
|
|
|
|
import https from 'https';
|
|
|
|
|
// eslint-disable-next-line import/no-named-default
|
|
|
|
|
import { default as insecureNodeFetch, RequestInit, Response } from 'node-fetch';
|
|
|
|
|
import ByteBuffer from 'bytebuffer';
|
|
|
|
|
import pRetry from 'p-retry';
|
|
|
|
|
import { cloneDeep, isEmpty, isString, omit } from 'lodash';
|
|
|
|
|
import { AbortSignal } from 'abort-controller';
|
|
|
|
|
import ByteBuffer from 'bytebuffer';
|
|
|
|
|
import { to_string } from 'libsodium-wrappers-sumo';
|
|
|
|
|
import { cloneDeep, isEmpty, isString, omit } from 'lodash';
|
|
|
|
|
import { RequestInit, Response, default as insecureNodeFetch } from 'node-fetch';
|
|
|
|
|
import pRetry from 'p-retry';
|
|
|
|
|
// eslint-disable-next-line import/no-unresolved
|
|
|
|
|
import { AbortSignal as AbortSignalNode } from 'node-fetch/externals';
|
|
|
|
|
|
|
|
|
|
import { dropSnodeFromSnodePool, dropSnodeFromSwarmIfNeeded, updateSwarmFor } from './snodePool';
|
|
|
|
|
|
|
|
|
|
import { OnionPaths } from '../../onions';
|
|
|
|
|
import { toHex } from '../../utils/String';
|
|
|
|
|
import { ed25519Str, incrementBadPathCountOrDrop } from '../../onions/onionPath';
|
|
|
|
|
import { toHex } from '../../utils/String';
|
|
|
|
|
|
|
|
|
|
import { Snode } from '../../../data/data';
|
|
|
|
|
import { ERROR_CODE_NO_CONNECT } from './SNodeAPI';
|
|
|
|
|
import { hrefPnServerProd } from '../push_notification_api/PnServer';
|
|
|
|
|
import { callUtilsWorker } from '../../../webworker/workers/browser/util_worker_interface';
|
|
|
|
|
import { encodeV4Request } from '../../onions/onionv4';
|
|
|
|
|
import { fileServerHost } from '../file_server_api/FileServerApi';
|
|
|
|
|
import { hrefPnServerProd } from '../push_notification_api/PnServer';
|
|
|
|
|
import { ERROR_CODE_NO_CONNECT } from './SNodeAPI';
|
|
|
|
|
|
|
|
|
|
// hold the ed25519 key of a snode against the time it fails. Used to remove a snode only after a few failures (snodeFailureThreshold failures)
|
|
|
|
|
let snodeFailureCount: Record<string, number> = {};
|
|
|
|
@ -839,6 +840,7 @@ async function sendOnionRequestHandlingSnodeEject({
|
|
|
|
|
response = result.response;
|
|
|
|
|
if (
|
|
|
|
|
!isEmpty(finalRelayOptions) &&
|
|
|
|
|
finalRelayOptions.host !== fileServerHost &&
|
|
|
|
|
response.status === 502 &&
|
|
|
|
|
response.statusText === 'Bad Gateway'
|
|
|
|
|
) {
|
|
|
|
@ -848,6 +850,7 @@ async function sendOnionRequestHandlingSnodeEject({
|
|
|
|
|
decodingSymmetricKey = result.decodingSymmetricKey;
|
|
|
|
|
} catch (e) {
|
|
|
|
|
window?.log?.warn('sendOnionRequestNoRetries error message: ', e.message);
|
|
|
|
|
|
|
|
|
|
if (e.code === 'ENETUNREACH' || e.message === 'ENETUNREACH' || throwErrors) {
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|