Add onions-v2 support for fileserver requests

This commit is contained in:
Maxim Shishmarev 2020-10-21 14:07:41 +11:00
parent 692a0e8cff
commit c5b2b64d7f
4 changed files with 20 additions and 19 deletions

View File

@ -6,5 +6,6 @@
}
],
"openDevTools": true,
"defaultPublicChatServer": "https://team-chat.lokinet.org/"
"defaultPublicChatServer": "https://team-chat.lokinet.org/",
"defaultFileServer": "https://file-dev.getsession.org"
}

View File

@ -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,

View File

@ -61,9 +61,9 @@ export class AvatarPlaceHolder extends React.PureComponent<Props, State> {
cy={r}
r={rWithoutBorder}
fill="#d2d2d3"
shape-rendering="geometricPrecision"
shapeRendering="geometricPrecision"
stroke={borderColor}
stroke-width="1"
strokeWidth="1"
/>
</g>
</svg>
@ -88,19 +88,19 @@ export class AvatarPlaceHolder extends React.PureComponent<Props, State> {
cy={r}
r={rWithoutBorder}
fill={bgColor}
shape-rendering="geometricPrecision"
shapeRendering="geometricPrecision"
stroke={borderColor}
stroke-width="1"
strokeWidth="1"
/>
<text
font-size={fontSize}
fontSize={fontSize}
x="50%"
y="50%"
fill="white"
text-anchor="middle"
textAnchor="middle"
stroke="white"
stroke-width={1}
alignment-baseline="central"
strokeWidth={1}
alignmentBaseline="central"
>
{initial}
</text>

View File

@ -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,