Add onions-v2 support for fileserver requests

pull/1348/head
Maxim Shishmarev 5 years ago
parent 692a0e8cff
commit c5b2b64d7f

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

@ -32,6 +32,7 @@ const LOKIFOUNDATION_APNS_PUBKEY =
const urlPubkeyMap = { const urlPubkeyMap = {
'https://file-dev.getsession.org': LOKIFOUNDATION_DEVFILESERVER_PUBKEY, 'https://file-dev.getsession.org': LOKIFOUNDATION_DEVFILESERVER_PUBKEY,
'https://file-dev.lokinet.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.getsession.org': LOKIFOUNDATION_FILESERVER_PUBKEY,
'https://file.lokinet.org': LOKIFOUNDATION_FILESERVER_PUBKEY, 'https://file.lokinet.org': LOKIFOUNDATION_FILESERVER_PUBKEY,
'https://dev.apns.getsession.org': LOKIFOUNDATION_APNS_PUBKEY, 'https://dev.apns.getsession.org': LOKIFOUNDATION_APNS_PUBKEY,

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

@ -138,9 +138,12 @@ async function buildOnionCtxs(
const relayingToFinalDestination = i === firstPos; // if last position const relayingToFinalDestination = i === firstPos; // if last position
if (relayingToFinalDestination && fileServerOptions) { if (relayingToFinalDestination && fileServerOptions) {
const target = useV2 ? '/loki/v2/lsrpc' : '/loki/v1/lsrpc';
dest = { dest = {
host: fileServerOptions.host, host: fileServerOptions.host,
target: '/loki/v1/lsrpc', target,
method: 'POST', method: 'POST',
}; };
} else { } else {
@ -360,14 +363,6 @@ const sendOnionRequest = async (
) => { ) => {
const { log, StringView } = window; 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 = ''; let id = '';
if (lsrpcIdx !== undefined) { if (lsrpcIdx !== undefined) {
@ -400,9 +395,11 @@ const sendOnionRequest = async (
options.headers = ''; options.headers = '';
} }
const useV2 = window.lokiFeatureFlags.useOnionRequestsV2;
let destCtx; let destCtx;
try { try {
if (useV2) { if (useV2 && !finalRelayOptions) {
const body = options.body || ''; const body = options.body || '';
delete options.body; delete options.body;
@ -441,6 +438,8 @@ const sendOnionRequest = async (
id id
); );
log.debug('Onion payload size: ', payload.length);
const guardFetchOptions = { const guardFetchOptions = {
method: 'POST', method: 'POST',
body: payload, body: payload,

Loading…
Cancel
Save