diff --git a/customize.md b/customize.md index 1e09f475..3f21a5f0 100644 --- a/customize.md +++ b/customize.md @@ -1,6 +1,6 @@ # Configure your own spee.ch -_note: this guide assumes you have done the [quickstart](https://github.com/lbryio/spee.ch/blob/readme-update/README.md) or [fullstart](https://github.com/lbryio/spee.ch/blob/readme-update/fullstart.md) guide and have a working spee.ch server_ +_note: this guide assumes you have done the [quickstart](https://github.com/lbryio/spee.ch/blob/master/README.md) or [fullstart](https://github.com/lbryio/spee.ch/blob/master/fullstart.md) guide and have a working spee.ch server_ ## Custom Components The components used by spee.ch are taken from the `client/` folder, but you can override those components by defining your own in the `site/custom/` folder. diff --git a/server/middleware/autoblockPublishMiddleware.js b/server/middleware/autoblockPublishMiddleware.js index 5238280b..dcd856fb 100644 --- a/server/middleware/autoblockPublishMiddleware.js +++ b/server/middleware/autoblockPublishMiddleware.js @@ -5,11 +5,13 @@ const { publishing: { publishingChannelWhitelist }, } = require('@config/siteConfig'); const ipBanFile = './site/config/ipBan.txt'; +const ipWhitelist = './site/config/ipWhitelist.txt'; const forbiddenMessage = '

Forbidden

If you are seeing this by mistake, please contact us using https://chat.lbry.com/'; const maxPublishesInTenMinutes = 20; let ipCounts = {}; let blockedAddresses = []; +let whitelistedAddresses = []; if (fs.existsSync(ipBanFile)) { const lineReader = require('readline').createInterface({ @@ -23,9 +25,28 @@ if (fs.existsSync(ipBanFile)) { }); } +// If a file called ipWhitelist.txt exists +// Please comment above each whitelisted IP why/who/when etc +// # Jim because he's awesome - January 2018 +if (fs.existsSync(ipWhitelist)) { + const lineReader = require('readline').createInterface({ + input: require('fs').createReadStream(ipWhitelist), + }); + + lineReader.on('line', line => { + if (line && line !== '' && line[0] !== '#') { + whitelistedAddresses.push(line); + } + }); +} + const autoblockPublishMiddleware = (req, res, next) => { let ip = (req.headers['x-forwarded-for'] || req.connection.remoteAddress).split(/,\s?/)[0]; + if (whitelistedAddresses.indexOf(ip) !== -1) { + next(); + return; + } if (blockedAddresses.indexOf(ip) !== -1) { res.status(403).send(forbiddenMessage); res.end();