From c5b2b64d7fb869ee2fa9cfc0d12a9cec5ce2c511 Mon Sep 17 00:00:00 2001 From: Maxim Shishmarev Date: Wed, 21 Oct 2020 14:07:41 +1100 Subject: [PATCH] Add onions-v2 support for fileserver requests --- config/swarm-testing.json | 3 ++- js/modules/loki_app_dot_net_api.js | 1 + .../AvatarPlaceHolder/AvatarPlaceHolder.tsx | 16 ++++++++-------- ts/session/snode_api/onions.ts | 19 +++++++++---------- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/config/swarm-testing.json b/config/swarm-testing.json index 61594f421..bb68a5d00 100644 --- a/config/swarm-testing.json +++ b/config/swarm-testing.json @@ -6,5 +6,6 @@ } ], "openDevTools": true, - "defaultPublicChatServer": "https://team-chat.lokinet.org/" + "defaultPublicChatServer": "https://team-chat.lokinet.org/", + "defaultFileServer": "https://file-dev.getsession.org" } diff --git a/js/modules/loki_app_dot_net_api.js b/js/modules/loki_app_dot_net_api.js index 923d57daf..1e6329af1 100644 --- a/js/modules/loki_app_dot_net_api.js +++ b/js/modules/loki_app_dot_net_api.js @@ -32,6 +32,7 @@ const LOKIFOUNDATION_APNS_PUBKEY = const urlPubkeyMap = { 'https://file-dev.getsession.org': LOKIFOUNDATION_DEVFILESERVER_PUBKEY, 'https://file-dev.lokinet.org': LOKIFOUNDATION_DEVFILESERVER_PUBKEY, + 'https://file-dev.getsession.org': LOKIFOUNDATION_DEVFILESERVER_PUBKEY, 'https://file.getsession.org': LOKIFOUNDATION_FILESERVER_PUBKEY, 'https://file.lokinet.org': LOKIFOUNDATION_FILESERVER_PUBKEY, 'https://dev.apns.getsession.org': LOKIFOUNDATION_APNS_PUBKEY, diff --git a/ts/components/AvatarPlaceHolder/AvatarPlaceHolder.tsx b/ts/components/AvatarPlaceHolder/AvatarPlaceHolder.tsx index 431065f88..8e7d1e8fd 100644 --- a/ts/components/AvatarPlaceHolder/AvatarPlaceHolder.tsx +++ b/ts/components/AvatarPlaceHolder/AvatarPlaceHolder.tsx @@ -61,9 +61,9 @@ export class AvatarPlaceHolder extends React.PureComponent { cy={r} r={rWithoutBorder} fill="#d2d2d3" - shape-rendering="geometricPrecision" + shapeRendering="geometricPrecision" stroke={borderColor} - stroke-width="1" + strokeWidth="1" /> @@ -88,19 +88,19 @@ export class AvatarPlaceHolder extends React.PureComponent { cy={r} r={rWithoutBorder} fill={bgColor} - shape-rendering="geometricPrecision" + shapeRendering="geometricPrecision" stroke={borderColor} - stroke-width="1" + strokeWidth="1" /> {initial} diff --git a/ts/session/snode_api/onions.ts b/ts/session/snode_api/onions.ts index 05e8c0f19..2fcc2c0ad 100644 --- a/ts/session/snode_api/onions.ts +++ b/ts/session/snode_api/onions.ts @@ -138,9 +138,12 @@ async function buildOnionCtxs( const relayingToFinalDestination = i === firstPos; // if last position if (relayingToFinalDestination && fileServerOptions) { + + const target = useV2 ? '/loki/v2/lsrpc' : '/loki/v1/lsrpc'; + dest = { host: fileServerOptions.host, - target: '/loki/v1/lsrpc', + target, method: 'POST', }; } else { @@ -360,14 +363,6 @@ const sendOnionRequest = async ( ) => { const { log, StringView } = window; - let useV2 = window.lokiFeatureFlags.useOnionRequestsV2; - - if (useV2 && finalRelayOptions) { - useV2 = false; - log.error( - 'TODO: v2 onion protocol for the file server is not yet supported' - ); - } let id = ''; if (lsrpcIdx !== undefined) { @@ -400,9 +395,11 @@ const sendOnionRequest = async ( options.headers = ''; } + const useV2 = window.lokiFeatureFlags.useOnionRequestsV2; + let destCtx; try { - if (useV2) { + if (useV2 && !finalRelayOptions) { const body = options.body || ''; delete options.body; @@ -441,6 +438,8 @@ const sendOnionRequest = async ( id ); + log.debug('Onion payload size: ', payload.length); + const guardFetchOptions = { method: 'POST', body: payload,