mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-12-21 14:20:06 +08:00
Update default host and token length in config
Changed the default host to '0.0.0.0' and increased the default token length from 8 to 12 characters in WebUiConfigSchema. Also removed unused getDefaultHost import and made minor formatting adjustments.
This commit is contained in:
parent
0e9aa43476
commit
aae676fdc7
@ -7,14 +7,14 @@ import { resolve } from 'node:path';
|
|||||||
|
|
||||||
import { deepMerge } from '../utils/object';
|
import { deepMerge } from '../utils/object';
|
||||||
import { themeType } from '../types/theme';
|
import { themeType } from '../types/theme';
|
||||||
import { getRandomToken, getDefaultHost } from '../utils/url'
|
import { getRandomToken } from '../utils/url'
|
||||||
|
|
||||||
// 限制尝试端口的次数,避免死循环
|
// 限制尝试端口的次数,避免死循环
|
||||||
// 定义配置的类型
|
// 定义配置的类型
|
||||||
const WebUiConfigSchema = Type.Object({
|
const WebUiConfigSchema = Type.Object({
|
||||||
host: Type.String({ default: getDefaultHost() }),
|
host: Type.String({ default: '0.0.0.0' }),
|
||||||
port: Type.Number({ default: 6099 }),
|
port: Type.Number({ default: 6099 }),
|
||||||
token: Type.String({ default: getRandomToken(8) }),
|
token: Type.String({ default: getRandomToken(12) }),
|
||||||
loginRate: Type.Number({ default: 10 }),
|
loginRate: Type.Number({ default: 10 }),
|
||||||
autoLoginAccount: Type.String({ default: '' }),
|
autoLoginAccount: Type.String({ default: '' }),
|
||||||
theme: themeType,
|
theme: themeType,
|
||||||
@ -64,7 +64,7 @@ export class WebUiConfigWrapper {
|
|||||||
|
|
||||||
async GetWebUIConfig(): Promise<WebUiConfigType> {
|
async GetWebUIConfig(): Promise<WebUiConfigType> {
|
||||||
if (this.WebUiConfigData) {
|
if (this.WebUiConfigData) {
|
||||||
return this.WebUiConfigData
|
return this.WebUiConfigData
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -76,7 +76,7 @@ export class WebUiConfigWrapper {
|
|||||||
...parsedConfig,
|
...parsedConfig,
|
||||||
// 首次读取内存中是没有token的,需要进行一层兜底
|
// 首次读取内存中是没有token的,需要进行一层兜底
|
||||||
token: getInitialWebUiToken() || parsedConfig.token,
|
token: getInitialWebUiToken() || parsedConfig.token,
|
||||||
};
|
};
|
||||||
return this.WebUiConfigData;
|
return this.WebUiConfigData;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('读取配置文件失败', e);
|
console.log('读取配置文件失败', e);
|
||||||
@ -123,7 +123,7 @@ export class WebUiConfigWrapper {
|
|||||||
// 使用内存中缓存的token进行验证,确保强兼容性
|
// 使用内存中缓存的token进行验证,确保强兼容性
|
||||||
const cachedToken = getInitialWebUiToken();
|
const cachedToken = getInitialWebUiToken();
|
||||||
const tokenToCheck = cachedToken || (await this.GetWebUIConfig()).token;
|
const tokenToCheck = cachedToken || (await this.GetWebUIConfig()).token;
|
||||||
|
|
||||||
if (tokenToCheck !== oldToken) {
|
if (tokenToCheck !== oldToken) {
|
||||||
throw new Error('旧 token 不匹配');
|
throw new Error('旧 token 不匹配');
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user