mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-14 21:13:08 +02:00
c05723ca6a
* Fix IP address rate limit * CHANGELOG * Tune getIpHash
9 lines
357 B
TypeScript
9 lines
357 B
TypeScript
import IPCIDR from 'ip-cidr';
|
|
|
|
export function getIpHash(ip: string) {
|
|
// because a single person may control many IPv6 addresses,
|
|
// only a /64 subnet prefix of any IP will be taken into account.
|
|
// (this means for IPv4 the entire address is used)
|
|
const prefix = IPCIDR.createAddress(ip).mask(64);
|
|
return 'ip-' + BigInt('0b' + prefix).toString(36);
|
|
}
|