feat: 安全性提升

This commit is contained in:
手瓜一十雪 committed 2025-09-06 10:49:29 +08:00
1 parent 2daebf1afe
commit a0ef738bcf
10 files changed
+27 -24

No files matched your search

+1 -4
View File
@@ -163,14 +163,11 @@ export async function InitWebUi(logger: LogWrapper, pathWrapper: NapCatPathWrapp
server.listen(port, host, async () => {
// 启动后打印出相关地址
let searchParams = { token: token };
if (host !== '' && host !== '0.0.0.0') {
if (host !== '') {
logger.log(
`[NapCat] [WebUi] WebUi User Panel Url: ${createUrl(host, port.toString(), '/webui', searchParams)}`
);
}
logger.log(
`[NapCat] [WebUi] WebUi Local Panel Url: ${createUrl('127.0.0.1', port.toString(), '/webui', searchParams)}`
);
});
// ------------Over!------------
}
+2 -2
View File
@@ -9,12 +9,12 @@ import { deepMerge } from '../utils/object';
import { themeType } from '../types/theme';
// 限制尝试端口的次数,避免死循环
// 定义配置的类型
const WebUiConfigSchema = Type.Object({
host: Type.String({ default: '0.0.0.0' }),
port: Type.Number({ default: 6099 }),
token: Type.String({ default: 'napcat' }),
// napcat+<月份日>,例如 napcat0625
token: Type.String({ default: 'napcat' + (new Date().getMonth() + 1).toString().padStart(2, '0') + new Date().getDate().toString().padStart(2, '0') }),
loginRate: Type.Number({ default: 10 }),
autoLoginAccount: Type.String({ default: '' }),
theme: themeType,
-1
View File
@@ -13,7 +13,6 @@ import { isIP } from 'node:net';
* @example normalizeHost('2001:4860:4801:51::27') => '[2001:4860:4801:51::27]'
*/
export const normalizeHost = (host: string) => {
if (host === '0.0.0.0') return '127.0.0.1';
if (isIP(host) === 6) return `[${host}]`;
return host;
};