mirror of
https://github.com/hamster1963/nezha-dash.git
synced 2025-04-24 21:10:45 +08:00
fix: get file
This commit is contained in:
parent
b573b62452
commit
8f38cf94d8
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import maxmind, { CityResponse, AsnResponse } from 'maxmind';
|
import maxmind, { CityResponse, AsnResponse } from 'maxmind';
|
||||||
import { GetServerIP } from './serverFetch';
|
import { GetServerIP } from './serverFetch';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
type IPInfo = {
|
type IPInfo = {
|
||||||
city: CityResponse;
|
city: CityResponse;
|
||||||
@ -9,11 +10,14 @@ type IPInfo = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default async function GetIPInfo({ server_id }: { server_id: string }): Promise<IPInfo> {
|
export default async function GetIPInfo({ server_id }: { server_id: string }): Promise<IPInfo> {
|
||||||
|
|
||||||
const ip = await GetServerIP({ server_id: Number(server_id) })
|
const ip = await GetServerIP({ server_id: Number(server_id) })
|
||||||
|
|
||||||
const cityLookup = await maxmind.open<CityResponse>('./lib/GeoLite2-City.mmdb')
|
// 使用 path.join 获取正确的文件路径
|
||||||
const asnLookup = await maxmind.open<AsnResponse>('./lib/GeoLite2-ASN.mmdb')
|
const cityDbPath = path.join(process.cwd(), 'lib', 'GeoLite2-City.mmdb');
|
||||||
|
const asnDbPath = path.join(process.cwd(), 'lib', 'GeoLite2-ASN.mmdb');
|
||||||
|
|
||||||
|
const cityLookup = await maxmind.open<CityResponse>(cityDbPath)
|
||||||
|
const asnLookup = await maxmind.open<AsnResponse>(asnDbPath)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
city: cityLookup.get(ip) as CityResponse,
|
city: cityLookup.get(ip) as CityResponse,
|
||||||
|
Loading…
Reference in New Issue
Block a user