add check wxmsg
This commit is contained in:
44
src/modules/off/ban.ts
Normal file
44
src/modules/off/ban.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
// 常备黑的 http://web/ban/
|
||||
// 禁止使用这些用户名注册
|
||||
// 容易被黑客扫描, 也容易被滥用
|
||||
//
|
||||
export const bannedUserNames = [
|
||||
"admin", // 常见管理员名
|
||||
"user", // 常见用户名
|
||||
"guest", // 常见访客名
|
||||
"core", // 常见系统名
|
||||
"config", // 配置相关
|
||||
"system", // 系统相关
|
||||
"setting", // 设置相关
|
||||
"storage", // 存储相关
|
||||
"logs", // 日志相关
|
||||
"log", // 日志相关
|
||||
"backup", // 备份相关
|
||||
"backups", // 备份相关
|
||||
"tmp", // 临时相关
|
||||
]
|
||||
|
||||
/**
|
||||
* 检查用户名是否在禁止列表中
|
||||
* @param username
|
||||
* @returns
|
||||
*/
|
||||
export const userIsBanned = (username: string): boolean => {
|
||||
if (username.startsWith('.')) {
|
||||
return true;
|
||||
}
|
||||
if (username.endsWith('.')) {
|
||||
return true;
|
||||
}
|
||||
return bannedUserNames.includes(username.toLowerCase());
|
||||
}
|
||||
|
||||
export const appIsBanned = (appname: string): boolean => {
|
||||
if (appname.startsWith('.')) {
|
||||
return true;
|
||||
}
|
||||
if (appname.endsWith('.')) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Reference in New Issue
Block a user