fix: path

This commit is contained in:
hamster1963 2024-12-12 00:59:44 +08:00
parent dfef790884
commit d64683a617

View File

@ -1,6 +1,7 @@
"use server";
import fs from "fs";
import path from 'path';
import { AsnResponse, CityResponse, Reader } from "maxmind";
import { GetServerIP } from "./serverFetch";
@ -17,8 +18,12 @@ export default async function GetIPInfo({
}): Promise<IPInfo> {
const ip = await GetServerIP({ server_id: Number(server_id) });
const cityDbBuffer = fs.readFileSync("./lib/GeoLite2-City.mmdb");
const asnDbBuffer = fs.readFileSync("./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 cityDbBuffer = fs.readFileSync(cityDbPath);
const asnDbBuffer = fs.readFileSync(asnDbPath);
const cityLookup = new Reader<CityResponse>(cityDbBuffer);
const asnLookup = new Reader<AsnResponse>(asnDbBuffer);