16 lines
450 B
JavaScript
16 lines
450 B
JavaScript
const { getServerIPs } = require('./services/ipFetcher.js');
|
|
|
|
let ipPattern = null;
|
|
|
|
const buildPattern = () => {
|
|
const ips = getServerIPs();
|
|
if (!ips.length) return null;
|
|
|
|
const escaped = ips.map(i => i.replace(/[.:\\[\](){}^$*+?|]/g, '\\$&'));
|
|
return new RegExp(escaped.join('|'), 'g');
|
|
};
|
|
|
|
module.exports = str => {
|
|
if (ipPattern === null) ipPattern = buildPattern() || false;
|
|
return ipPattern ? str.replace(ipPattern, '[SOME-IP]') : str;
|
|
}; |