mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 01:02:30 +01:00
Made the server save a hash of their ip with the data.
This commit is contained in:
parent
16b2b22bc0
commit
05da836384
1 changed files with 11 additions and 1 deletions
12
index.js
12
index.js
|
@ -7,6 +7,10 @@ var app = express();
|
|||
//uuid service
|
||||
var uuidv1 = require('uuid/v1');
|
||||
|
||||
//hashing service
|
||||
var crypto = require('crypto');
|
||||
var hash = crypto.createHash('sha256');
|
||||
|
||||
//load database
|
||||
var sqlite3 = require('sqlite3').verbose();
|
||||
var db = new sqlite3.Database('./databases/sponsorTimes.db');
|
||||
|
@ -55,6 +59,12 @@ app.get('/api/postVideoSponsorTimes', function (req, res) {
|
|||
let endTime = req.query.endTime;
|
||||
let userID = req.query.userID;
|
||||
|
||||
//x-forwarded-for if this server is behind a proxy
|
||||
let ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
|
||||
|
||||
//hash the ip so no one can get it from the database
|
||||
let hashedIP = hash.update(ip).digest('hex');
|
||||
|
||||
if (typeof videoID != 'string' || startTime == undefined || endTime == undefined || userID == undefined) {
|
||||
//invalid request
|
||||
res.sendStatus(400);
|
||||
|
@ -66,7 +76,7 @@ app.get('/api/postVideoSponsorTimes', function (req, res) {
|
|||
|
||||
let UUID = uuidv1();
|
||||
|
||||
db.prepare("INSERT INTO sponsorTimes VALUES(?, ?, ?, ?, ?)").run(videoID, startTime, endTime, UUID, userID);
|
||||
db.prepare("INSERT INTO sponsorTimes VALUES(?, ?, ?, ?, ?, ?)").run(videoID, startTime, endTime, UUID, userID, hashedIP);
|
||||
|
||||
res.sendStatus(200);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue