mirror of
https://github.com/zoriya/flood.git
synced 2025-12-06 07:16:18 +00:00
14 lines
261 B
TypeScript
14 lines
261 B
TypeScript
import {Reader} from '@maxmind/geoip2-node';
|
|
|
|
import * as data from '../geoip/data';
|
|
|
|
const r = Reader.openBuffer(data.data);
|
|
|
|
export function lookup(s: string): string {
|
|
try {
|
|
return r.country(s)?.country?.isoCode ?? '';
|
|
} catch {
|
|
return '';
|
|
}
|
|
}
|