chatgpt-web-midjourney-proxy
chatgpt-web-midjourney-proxy copied to clipboard
增加访问密码输入三次超时60重试
修改verify.js起不到效果,不知道是变量出去了吗,修改内容如下: `` const attemptStore = {}; module.exports = (req, res) => { const clientIp = req.ip; // 获取客户端IP作为标识 const currentTime = Date.now(); const retryTimeout = 60000; // 60秒重试时间限制 let obj = { "status": "Fail", "message": "密钥无效 | Secret key is invalid", "data": null };
// 检查是否有验证尝试记录
if (!attemptStore[clientIp]) {
attemptStore[clientIp] = { attempts: 0, lastAttempt: currentTime };
}
const clientAttempt = attemptStore[clientIp];
// 检查是否超过重试时间限制
if (currentTime - clientAttempt.lastAttempt < retryTimeout && clientAttempt.attempts >= 3) {
obj.message = '超出尝试次数,请在60秒后重试 | Too many attempts, please retry after 60 seconds.';
} else {
// 如果时间超过60秒,重置尝试次数
if (currentTime - clientAttempt.lastAttempt >= retryTimeout) {
clientAttempt.attempts = 0;
}
// 验证密钥
if (req.body && req.body.token && process.env.AUTH_SECRET_KEY === req.body.token) {
obj = { status: 'Success', message: 'Verify successfully', data: null };
clientAttempt.attempts = 0; // 验证成功,重置尝试次数
} else {
clientAttempt.attempts += 1; // 验证失败,增加尝试次数
obj.message += ` | 当前尝试次数: ${clientAttempt.attempts}`;
}
clientAttempt.lastAttempt = currentTime; // 更新最后尝试时间
}
res.setHeader('Content-type', 'application/json');
res.writeHead(200).end(JSON.stringify(obj));
}; ``
attemptStore 这个变量 这么能寄存么?
attemptStore 这个变量 这么能寄存么?
好像不行