diff --git a/hybrid-app/README.md b/hybrid-app/README.md deleted file mode 100644 index 46e1c43..0000000 --- a/hybrid-app/README.md +++ /dev/null @@ -1 +0,0 @@ -This is an experimental webapp that can be compiled to desktop app with electron \ No newline at end of file diff --git a/src/server.js b/src/server.js index 3d288d3..10d421c 100644 --- a/src/server.js +++ b/src/server.js @@ -16,6 +16,7 @@ const config = require('./state/config'); const logger = require('./logger'); const transode = require('./api/transcode'); const dbManager = require('./db/manager'); +const syncthing = require('./state/syncthing'); let mstream; let server; @@ -93,6 +94,7 @@ exports.serveIt = async configFile => { scrobblerApi.setup(mstream); remoteApi.setupAfterAuth(mstream, server); sharedApi.setupAfterSecurity(mstream); + syncthing.setup(); // Versioned APIs mstream.get('/api/', (req, res) => res.json({ "version": "0.1.0", "supportedVersions": ["1"] })); diff --git a/src/state/config.js b/src/state/config.js index a57225d..777d7ac 100644 --- a/src/state/config.js +++ b/src/state/config.js @@ -44,6 +44,11 @@ const lastFMOptions = Joi.object({ apiSecret: Joi.string().default('a9df934fc504174d4cb68853d9feb143') }); +const federationOptions = Joi.object({ + enabled: Joi.boolean().default(false), + folder: Joi.string().optional() +}); + const schema = Joi.object({ address: Joi.string().ip({ cidr: 'forbidden' }).default('0.0.0.0'), port: Joi.number().default(3000), @@ -87,9 +92,7 @@ const schema = Joi.object({ key: Joi.string().allow('').optional(), cert: Joi.string().allow('').optional() }).optional(), - federation: Joi.object({ - folder: Joi.string().allow('').optional() - }).optional() + federation: federationOptions.default(federationOptions.validate({}).value), }); exports.asyncRandom = (numBytes) => { diff --git a/src/state/syncthing.js b/src/state/syncthing.js index 535e0ff..78e7aff 100644 --- a/src/state/syncthing.js +++ b/src/state/syncthing.js @@ -10,7 +10,6 @@ const https = require('https'); const killQueue = require('./kill-list'); const config = require('./config'); -let spawnedProcess; const platform = os.platform(); const osMap = { "win32": "syncthing.exe", @@ -19,6 +18,8 @@ const osMap = { "android": "syncthing-android" }; +let spawnedProcess; + let xmlObj; // Syncthing XML Config let myId; // Syncthing Device ID const cacheObj = {}; @@ -47,6 +48,8 @@ exports.getPathId = (path) => { // TODO: change this for server reboot exports.setup = async () => { + if (config.program.federation.enabled === false) { return; } + try { await initSyncthingConfig(); await getSyncthingId(); @@ -346,7 +349,7 @@ function bootProgram() { } try { - spawnedProcess = spawn(path.join(__dirname, `../../bin/syncthing/${osMap[platform]}`), ['--home', config.program.storage.syncConfigDirectory, '--no-browser'], {}); + spawnedProcess = spawn(path.join(__dirname, `../../bin/syncthing/${osMap[platform]}`), ['--home', config.program.storage.syncConfigDirectory], {}); spawnedProcess.stdout.on('data', (data) => { winston.info(`sync: ${data}`);