Update the user agent for debug log requests
This commit is contained in:
parent
c517e4193b
commit
b159a8d7c7
4 changed files with 14 additions and 22 deletions
|
@ -8,6 +8,7 @@ const config = url.parse(window.location.toString(), true).query;
|
||||||
const { locale } = config;
|
const { locale } = config;
|
||||||
const localeMessages = ipcRenderer.sendSync('locale-data');
|
const localeMessages = ipcRenderer.sendSync('locale-data');
|
||||||
|
|
||||||
|
window.getVersion = () => config.version;
|
||||||
window.theme = config.theme;
|
window.theme = config.theme;
|
||||||
window.i18n = i18n.setup(locale, localeMessages);
|
window.i18n = i18n.setup(locale, localeMessages);
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
/* eslint-env node */
|
/* eslint-env node */
|
||||||
|
/* global window */
|
||||||
|
|
||||||
const FormData = require('form-data');
|
const FormData = require('form-data');
|
||||||
const got = require('got');
|
const got = require('got');
|
||||||
|
|
||||||
const BASE_URL = 'https://debuglogs.org';
|
const BASE_URL = 'https://debuglogs.org';
|
||||||
|
const VERSION = window.getVersion();
|
||||||
|
const USER_AGENT = `Signal Desktop ${VERSION}`;
|
||||||
|
|
||||||
// Workaround: Submitting `FormData` using native `FormData::submit` procedure
|
// Workaround: Submitting `FormData` using native `FormData::submit` procedure
|
||||||
// as integration with `got` results in S3 error saying we haven’t set the
|
// as integration with `got` results in S3 error saying we haven’t set the
|
||||||
|
@ -22,7 +25,12 @@ const submitFormData = (form, url) =>
|
||||||
|
|
||||||
// upload :: String -> Promise URL
|
// upload :: String -> Promise URL
|
||||||
exports.upload = async content => {
|
exports.upload = async content => {
|
||||||
const signedForm = await got.get(BASE_URL, { json: true });
|
const signedForm = await got.get(BASE_URL, {
|
||||||
|
json: true,
|
||||||
|
headers: {
|
||||||
|
'user-agent': USER_AGENT,
|
||||||
|
},
|
||||||
|
});
|
||||||
const { fields, url } = signedForm.body;
|
const { fields, url } = signedForm.body;
|
||||||
|
|
||||||
const form = new FormData();
|
const form = new FormData();
|
||||||
|
@ -36,10 +44,11 @@ exports.upload = async content => {
|
||||||
|
|
||||||
const contentBuffer = Buffer.from(content, 'utf8');
|
const contentBuffer = Buffer.from(content, 'utf8');
|
||||||
const contentType = 'text/plain';
|
const contentType = 'text/plain';
|
||||||
|
form.append('User-Agent', USER_AGENT);
|
||||||
form.append('Content-Type', contentType);
|
form.append('Content-Type', contentType);
|
||||||
form.append('file', contentBuffer, {
|
form.append('file', contentBuffer, {
|
||||||
contentType,
|
contentType,
|
||||||
filename: 'signal-desktop-debug-log.txt',
|
filename: `signal-desktop-debug-log-${VERSION}.txt`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// WORKAROUND: See comment on `submitFormData`:
|
// WORKAROUND: See comment on `submitFormData`:
|
||||||
|
|
|
@ -11,8 +11,6 @@ const localeMessages = ipcRenderer.sendSync('locale-data');
|
||||||
window.theme = config.theme;
|
window.theme = config.theme;
|
||||||
window.i18n = i18n.setup(locale, localeMessages);
|
window.i18n = i18n.setup(locale, localeMessages);
|
||||||
|
|
||||||
require('./js/logging');
|
|
||||||
|
|
||||||
// So far we're only using this for Signal.Types
|
// So far we're only using this for Signal.Types
|
||||||
const Signal = require('./js/modules/signal');
|
const Signal = require('./js/modules/signal');
|
||||||
|
|
||||||
|
@ -80,3 +78,5 @@ function makeSetter(name) {
|
||||||
ipcRenderer.send(`set-${name}`, value);
|
ipcRenderer.send(`set-${name}`, value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
require('./js/logging');
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
const { assert } = require('chai');
|
|
||||||
const got = require('got');
|
|
||||||
|
|
||||||
const debuglogs = require('../../js/modules/debuglogs');
|
|
||||||
|
|
||||||
describe('debuglogs', () => {
|
|
||||||
describe('upload', () => {
|
|
||||||
it('should upload log content', async () => {
|
|
||||||
const nonce = Math.random()
|
|
||||||
.toString()
|
|
||||||
.slice(2);
|
|
||||||
const url = await debuglogs.upload(nonce);
|
|
||||||
|
|
||||||
const { body } = await got.get(url);
|
|
||||||
assert.equal(nonce, body);
|
|
||||||
}).timeout(3000);
|
|
||||||
});
|
|
||||||
});
|
|
Loading…
Add table
Add a link
Reference in a new issue