mirror of
https://github.com/IrosTheBeggar/mStream.git
synced 2025-10-27 07:31:02 +00:00
enable syncthing with config
This commit is contained in:
parent
90f7c19bbf
commit
ef584d5b1f
@ -1 +0,0 @@
|
||||
This is an experimental webapp that can be compiled to desktop app with electron
|
||||
@ -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"] }));
|
||||
|
||||
@ -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) => {
|
||||
|
||||
@ -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}`);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user