🔥 添加自定义后缀
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { defineEventHandler } from 'h3';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
interface AddSuffixBody {
|
||||
suffix: string;
|
||||
server: string;
|
||||
}
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const body: AddSuffixBody = await readBody(event);
|
||||
const filePath = path.join('server/whois/json', 'whois-servers.json');
|
||||
|
||||
const fileContent = fs.readFileSync(filePath, { encoding: 'utf8' });
|
||||
const data: Record<string, string> = JSON.parse(fileContent);
|
||||
|
||||
// 添加或更新域名后缀
|
||||
data[body.suffix] = body.server;
|
||||
|
||||
// 写入更新
|
||||
fs.writeFileSync(filePath, JSON.stringify(data, null, 2), { encoding: 'utf8' });
|
||||
|
||||
return { message: 'ok' };
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
import { defineEventHandler } from 'h3';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
interface RemoveSuffixBody {
|
||||
suffix: string;
|
||||
}
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const body: RemoveSuffixBody = await readBody(event);
|
||||
const filePath = path.join('server/whois/json', 'whois-servers.json');
|
||||
|
||||
const fileContent = fs.readFileSync(filePath, { encoding: 'utf8' });
|
||||
const data: Record<string, string> = JSON.parse(fileContent);
|
||||
|
||||
// 删除域名后缀
|
||||
delete data[body.suffix];
|
||||
|
||||
// 写入更新
|
||||
fs.writeFileSync(filePath, JSON.stringify(data, null, 2), { encoding: 'utf8' });
|
||||
|
||||
return { message: 'ok' };
|
||||
});
|
||||
@@ -1533,7 +1533,6 @@
|
||||
"net.cn": "whois.cnnic.net.cn",
|
||||
"org.cn": "whois.cnnic.net.cn",
|
||||
"gov.cn": "whois.cnnic.net.cn",
|
||||
"net.cn": "whois.cnnic.net.cn",
|
||||
"ac.cn": "whois.cnnic.net.cn",
|
||||
"bj.cn": "whois.cnnic.net.cn",
|
||||
"sh.cn": "whois.cnnic.net.cn",
|
||||
@@ -1569,5 +1568,4 @@
|
||||
"gz.cn": "whois.cnnic.net.cn",
|
||||
"sn.cn": "whois.cnnic.net.cn",
|
||||
"xj.cn": "whois.cnnic.net.cn"
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import parametersData from '~/server/whois/json/parameters.json';
|
||||
|
||||
const IANA_CHK_URL = 'https://www.iana.org/whois?q=';
|
||||
|
||||
|
||||
interface IServers {
|
||||
[key: string]: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user