mirror of
https://github.com/zadam/trilium.git
synced 2024-12-25 08:43:03 +08:00
https support (with custom ca) for sync
This commit is contained in:
parent
07070e2222
commit
02e5d20d44
3 changed files with 29 additions and 1 deletions
|
@ -9,4 +9,5 @@ keyPath=
|
|||
[Sync]
|
||||
syncServerHost=
|
||||
syncServerTimeout=10000
|
||||
syncProxy=
|
||||
syncProxy=
|
||||
syncServerCertificate=
|
|
@ -1,3 +1,16 @@
|
|||
#!/bin/bash
|
||||
# Script generates certificate by default into the ~/trilium-data/cert where it is expected by Trilium
|
||||
# If directory is given in argument, certificate will be created there.
|
||||
|
||||
if [ $# -eq 0 ]
|
||||
then
|
||||
DIR=~/trilium-data/cert
|
||||
else
|
||||
DIR=$1
|
||||
fi
|
||||
|
||||
mkdir -p "$DIR"
|
||||
cd "$DIR"
|
||||
|
||||
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 2000 -nodes
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ const notes = require('./notes');
|
|||
const syncUpdate = require('./sync_update');
|
||||
const content_hash = require('./content_hash');
|
||||
const event_log = require('./event_log');
|
||||
const fs = require('fs');
|
||||
|
||||
const SYNC_SERVER = config['Sync']['syncServerHost'];
|
||||
const isSyncSetup = !!SYNC_SERVER;
|
||||
|
@ -20,6 +21,7 @@ const SYNC_PROXY = config['Sync']['syncProxy'];
|
|||
|
||||
let syncInProgress = false;
|
||||
let proxyToggle = true;
|
||||
let syncServerCertificate = null;
|
||||
|
||||
async function sync() {
|
||||
if (syncInProgress) {
|
||||
|
@ -288,6 +290,10 @@ async function syncRequest(syncContext, method, uri, body) {
|
|||
timeout: SYNC_TIMEOUT
|
||||
};
|
||||
|
||||
if (syncServerCertificate) {
|
||||
options.ca = syncServerCertificate;
|
||||
}
|
||||
|
||||
if (SYNC_PROXY && proxyToggle) {
|
||||
options.proxy = SYNC_PROXY;
|
||||
}
|
||||
|
@ -306,6 +312,14 @@ if (isSyncSetup) {
|
|||
log.info("Sync proxy: " + SYNC_PROXY);
|
||||
}
|
||||
|
||||
const syncCertPath = config['Sync']['syncServerCertificate'];
|
||||
|
||||
if (syncCertPath) {
|
||||
log.info('Sync certificate: ' + syncCertPath);
|
||||
|
||||
syncServerCertificate = fs.readFileSync(syncCertPath);
|
||||
}
|
||||
|
||||
setInterval(sync, 60000);
|
||||
|
||||
// kickoff initial sync immediately
|
||||
|
|
Loading…
Reference in a new issue