Skip to content
Snippets Groups Projects
Commit 29450921 authored by Jellie's avatar Jellie
Browse files

removed

parent fe613ec0
Branches main
No related tags found
No related merge requests found
const express = require('express');
const router = express.Router();
const isLocalIp = (ip) => {
// Remove IPv6 prefix if it exists
if (ip.startsWith('::ffff:')) {
ip = ip.split(':').pop();
}
// Check for localhost and private IP ranges
return (
ip === '127.0.0.1' || // localhost
ip === '::1' || // IPv6 localhost
ip.startsWith('192.168.') || // Private IPv4 range
ip.startsWith('10.') || // Private IPv4 range
(ip.startsWith('172.') && +ip.split('.')[1] >= 16 && +ip.split('.')[1] <= 31) // Private 172.16.0.0/12
);
}
router.get('/', (req, res) => {
res.send('IP Module');
});
router.get('/verify', (req, res) => {
const clientIp = req.headers['x-forwarded-for'] || req.ip || req.connection.remoteAddress;
const isLocal = isLocalIp(clientIp);
return res.json({success: isLocal})
});
module.exports = router;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment