mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-26 22:29:28 +09:00
22 lines
471 B
TypeScript
22 lines
471 B
TypeScript
|
import * as crypto from 'crypto';
|
||
|
import * as express from 'express';
|
||
|
import * as proxyAddr from 'proxy-addr';
|
||
|
import Xev from 'xev';
|
||
|
|
||
|
const ev = new Xev();
|
||
|
|
||
|
export default function(req: express.Request) {
|
||
|
const ip = proxyAddr(req, () => true);
|
||
|
|
||
|
const md5 = crypto.createHash('md5');
|
||
|
md5.update(ip);
|
||
|
const hashedIp = md5.digest('hex').substr(0, 3);
|
||
|
|
||
|
ev.emit('request', {
|
||
|
ip: hashedIp,
|
||
|
method: req.method,
|
||
|
hostname: req.hostname,
|
||
|
path: req.originalUrl
|
||
|
});
|
||
|
}
|