mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
移除一些anyscript特性
This commit is contained in:
1 parent
c3ff5856e4
commit
cc62fd3cd7
7 files changed
+97
-19
No files matched your search
@@ -6,10 +6,18 @@ import { Reader } from 'maxmind';
|
||||
const buffer = fs.readFileSync(path.resolve(__dirname, 'GeoLite2-City.mmdb'));
|
||||
const reader = new Reader(buffer);
|
||||
|
||||
export interface Result {
|
||||
location?: string,
|
||||
continent?: string,
|
||||
country?: string,
|
||||
city?: string,
|
||||
display: string
|
||||
}
|
||||
|
||||
function lookup(ip: string, locale: string) {
|
||||
const res: any = reader.get(ip);
|
||||
if (!res) return {};
|
||||
const ret: any = {};
|
||||
const ret: Result = { display: '' };
|
||||
if (res.location) ret.location = res.location;
|
||||
if (res.continent) ret.continent = res.continent.names[locale] || res.continent.names.en;
|
||||
if (res.country || res.registered_country) {
|
||||
|
||||
Reference in new issue
Block a user