forked from XimeraProject/server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbranding.js
More file actions
22 lines (18 loc) · 676 Bytes
/
branding.js
File metadata and controls
22 lines (18 loc) · 676 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
var ip = require('ip');
var _ = require('underscore');
var subnets = [ip.cidrSubnet('164.107.0.0/16'),
ip.cidrSubnet('140.254.0.0/16'),
ip.cidrSubnet('128.146.0.0/16'),
ip.cidrSubnet('192.68.143.0/24'),
ip.cidrSubnet('192.12.205.0/24')];
exports.middleware = function(req, res, next) {
var remoteAddress = req.headers['x-forwarded-for'] ||
req.connection.remoteAddress ||
req.socket.remoteAddress ||
req.connection.socket.remoteAddress;
if (_.some( subnets, function(subnet) { return subnet.contains(remoteAddress); } ))
res.locals.atOhioState = true;
else
res.locals.atOhioState = false;
next();
};