mirror of
https://github.com/zadam/trilium.git
synced 2025-11-17 10:40:41 +01:00
#98 proxy support for sync setup
This commit is contained in:
@@ -29,7 +29,7 @@ async function initSyncedOptions(username, password) {
|
||||
await passwordEncryptionService.setDataKey(password, utils.randomSecureToken(16));
|
||||
}
|
||||
|
||||
async function initNotSyncedOptions(initialized, startNotePath = '', syncServerHost = '') {
|
||||
async function initNotSyncedOptions(initialized, startNotePath = '', syncServerHost = '', syncProxy = '') {
|
||||
await optionService.createOption('startNotePath', startNotePath, false);
|
||||
await optionService.createOption('lastBackupDate', dateUtils.nowDate(), false);
|
||||
await optionService.createOption('dbVersion', appInfo.dbVersion, false);
|
||||
@@ -42,7 +42,7 @@ async function initNotSyncedOptions(initialized, startNotePath = '', syncServerH
|
||||
|
||||
await optionService.createOption('syncServerHost', syncServerHost, false);
|
||||
await optionService.createOption('syncServerTimeout', 5000, false);
|
||||
await optionService.createOption('syncProxy', '', false);
|
||||
await optionService.createOption('syncProxy', syncProxy, false);
|
||||
|
||||
await optionService.createOption('initialized', initialized ? 'true' : 'false', false);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ function triggerSync() {
|
||||
});
|
||||
}
|
||||
|
||||
async function setupSyncFromSyncServer(serverAddress, username, password) {
|
||||
async function setupSyncFromSyncServer(syncServerHost, syncProxy, username, password) {
|
||||
if (await sqlInit.isDbInitialized()) {
|
||||
return {
|
||||
result: 'failure',
|
||||
@@ -27,7 +27,7 @@ async function setupSyncFromSyncServer(serverAddress, username, password) {
|
||||
|
||||
// response is expected to contain documentId and documentSecret options
|
||||
const options = await rp.get({
|
||||
uri: serverAddress + '/api/sync/document',
|
||||
uri: syncServerHost + '/api/sync/document',
|
||||
auth: {
|
||||
'user': username,
|
||||
'pass': password
|
||||
@@ -35,7 +35,11 @@ async function setupSyncFromSyncServer(serverAddress, username, password) {
|
||||
json: true
|
||||
});
|
||||
|
||||
await sqlInit.createDatabaseForSync(options, serverAddress);
|
||||
if (syncProxy) {
|
||||
options.proxy = syncProxy;
|
||||
}
|
||||
|
||||
await sqlInit.createDatabaseForSync(options, syncServerHost, syncProxy);
|
||||
|
||||
triggerSync();
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ async function createInitialDatabase(username, password) {
|
||||
await initDbConnection();
|
||||
}
|
||||
|
||||
async function createDatabaseForSync(options, syncServerHost = '') {
|
||||
async function createDatabaseForSync(options, syncServerHost = '', syncProxy = '') {
|
||||
log.info("Creating database for sync");
|
||||
|
||||
if (await isDbInitialized()) {
|
||||
@@ -111,7 +111,7 @@ async function createDatabaseForSync(options, syncServerHost = '') {
|
||||
await sql.transactional(async () => {
|
||||
await sql.executeScript(schema);
|
||||
|
||||
await require('./options_init').initNotSyncedOptions(false, '', syncServerHost);
|
||||
await require('./options_init').initNotSyncedOptions(false, '', syncServerHost, syncProxy);
|
||||
|
||||
// document options required for sync to kick off
|
||||
for (const opt of options) {
|
||||
|
||||
Reference in New Issue
Block a user