mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-07 12:07:07 +03:00
Added ability to enable read only mode from the config.
This commit is contained in:
@@ -2,5 +2,9 @@
|
|||||||
"port": 80,
|
"port": 80,
|
||||||
"globalSalt": "[global salt (pepper) that is added to every ip before hashing to make it even harder for someone to decode the ip]",
|
"globalSalt": "[global salt (pepper) that is added to every ip before hashing to make it even harder for someone to decode the ip]",
|
||||||
"adminUserID": "[the hashed id of the user who can perform admin actions]",
|
"adminUserID": "[the hashed id of the user who can perform admin actions]",
|
||||||
"behindProxy": true
|
"behindProxy": true,
|
||||||
|
"db": "./databases/sponsorTimes.db",
|
||||||
|
"privateDB": "./databases/private.db",
|
||||||
|
"mode": "development",
|
||||||
|
"readOnly": false
|
||||||
}
|
}
|
||||||
12
index.js
12
index.js
@@ -9,11 +9,17 @@ var crypto = require('crypto');
|
|||||||
|
|
||||||
let config = JSON.parse(fs.readFileSync('config.json'));
|
let config = JSON.parse(fs.readFileSync('config.json'));
|
||||||
|
|
||||||
//load database
|
|
||||||
var sqlite3 = require('sqlite3').verbose();
|
var sqlite3 = require('sqlite3').verbose();
|
||||||
var db = new sqlite3.Database(config.db);
|
|
||||||
|
let dbMode = sqlite3.OPEN_READWRITE;
|
||||||
|
if (config.readOnly) {
|
||||||
|
dbMode = sqlite3.OPEN_READONLY;
|
||||||
|
}
|
||||||
|
|
||||||
|
//load database
|
||||||
|
var db = new sqlite3.Database(config.db, dbMode);
|
||||||
//where the more sensitive data such as IP addresses are stored
|
//where the more sensitive data such as IP addresses are stored
|
||||||
var privateDB = new sqlite3.Database(config.privateDB);
|
var privateDB = new sqlite3.Database(config.privateDB, dbMode);
|
||||||
|
|
||||||
// Create an HTTP service.
|
// Create an HTTP service.
|
||||||
http.createServer(app).listen(config.port);
|
http.createServer(app).listen(config.port);
|
||||||
|
|||||||
Reference in New Issue
Block a user