mirror of https://gitgud.io/fatchan/jschan.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
491 B
16 lines
491 B
'use strict';
|
|
|
|
const { isIP } = require('net')
|
|
, Permissions = require(__dirname+'/../permission/permissions.js');
|
|
|
|
module.exports = (query, permissions) => {
|
|
if (query && query.ip && typeof query.ip === 'string') {
|
|
const decoded = decodeURIComponent(query.ip);
|
|
//if is IP but no permission, return null
|
|
if (isIP(decoded) && !permissions.get(Permissions.VIEW_RAW_IP)) {
|
|
return null;
|
|
}
|
|
return decoded; //otherwise return ip/cloak query
|
|
}
|
|
return null; //else, no ip filter
|
|
};
|
|
|