mirror of
https://github.com/MCSManager/MCSManager.git
synced 2025-02-23 16:09:37 +08:00
Fix: get real ip
This commit is contained in:
parent
4e4631442d
commit
ae206e4438
@ -23,7 +23,7 @@ export function login(
|
||||
): string {
|
||||
// record the number of login requests
|
||||
GlobalVariable.set(LOGIN_COUNT, GlobalVariable.get(LOGIN_COUNT, 0) + 1);
|
||||
const ip = ctx.socket.remoteAddress;
|
||||
const ip = toText(ctx.header["x-forwarded-for"]) || ctx.socket.remoteAddress;
|
||||
// check user information
|
||||
try {
|
||||
userSystem.checkUser({ userName, passWord }, twoFACode);
|
||||
@ -168,7 +168,7 @@ export function checkBanIp(ctx: Koa.ParameterizedContext) {
|
||||
if (!GlobalVariable.map.has(LOGIN_FAILED_KEY)) GlobalVariable.set(LOGIN_FAILED_KEY, {});
|
||||
// This IpMap also needs to be used when logging in
|
||||
const ipMap = GlobalVariable.get(LOGIN_FAILED_KEY);
|
||||
const ip = toText(ctx.socket.remoteAddress) || "";
|
||||
const ip = toText(ctx.header["x-forwarded-for"]) || ctx.socket.remoteAddress || "";
|
||||
if (ipMap[ip] > 10 && systemConfig?.loginCheckIp === true) {
|
||||
if (ipMap[ip] != 999) {
|
||||
// record the number of bans
|
||||
|
Loading…
Reference in New Issue
Block a user