zabbix登陆限制监测
parent
0c84c3f839
commit
91e53bdf42
|
@ -0,0 +1,27 @@
|
|||
package com.ljsd.jieling.handler;
|
||||
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import rpc.protocols.PlayerInfoProto;
|
||||
|
||||
public class LoginConfirmHandler extends BaseHandler{
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(LoginRequestHandler.class);
|
||||
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.LOGIN_CONFIRM_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
UserManager.loginConfirm();
|
||||
MessageUtil.sendMessage(iSession,1,
|
||||
MessageTypeProto.MessageType.LOGIN_CONFIRM_RESPONSE.getNumber(),null,true);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package com.ljsd.jieling.logic.dao;
|
||||
|
||||
|
||||
import com.ljsd.GameApplication;
|
||||
import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
|
||||
import com.ljsd.jieling.core.GlobalsDef;
|
||||
import com.ljsd.jieling.db.mongo.AreaManager;
|
||||
|
@ -21,6 +22,7 @@ import com.ljsd.jieling.logic.mission.GameEvent;
|
|||
import com.ljsd.jieling.logic.player.PlayerLogic;
|
||||
import com.ljsd.jieling.network.server.SessionManager;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.SysUtil;
|
||||
import config.SGameSetting;
|
||||
import config.SPlayerLevelConfig;
|
||||
import manager.STableManager;
|
||||
|
@ -28,17 +30,22 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class UserManager {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(UserManager.class);
|
||||
private static Map<Integer, User> userMap = new ConcurrentHashMap<>();
|
||||
private static Map<Integer,Long> userMapPutTime = new ConcurrentHashMap<>(); //离线读入
|
||||
private static AtomicInteger login_f_num = new AtomicInteger(0);//登陆计数
|
||||
private static final int LOGIN_F_LIMIT = 100;//报警界限
|
||||
|
||||
public static void addUser(User user) {
|
||||
userMap.put(user.getId(), user);
|
||||
|
@ -198,4 +205,27 @@ public class UserManager {
|
|||
|
||||
return "33521";
|
||||
}
|
||||
|
||||
public static void loginIncrease(){
|
||||
if(login_f_num.incrementAndGet() >= LOGIN_F_LIMIT){
|
||||
String path = SysUtil.getPath("conf/loginerror/loginerror"+ GameApplication.serverId +".txt");
|
||||
File file = new File(path);
|
||||
try{
|
||||
if(!file.getParentFile().exists()){
|
||||
file.getParentFile().mkdirs();
|
||||
}
|
||||
if(!file.exists()){
|
||||
file.createNewFile();
|
||||
LOGGER.info("生成登陆限制文件!"+TimeUtils.getTimeStamp(System.currentTimeMillis()));
|
||||
}
|
||||
}catch(IOException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void loginConfirm(){
|
||||
login_f_num.decrementAndGet();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -98,8 +98,16 @@ public class SessionManager implements INetSession<ISession>, INetReceived<ISess
|
|||
//聊天请求太多了 过滤掉
|
||||
LOGGER.info("request={} commond ={}: ", packetNetData.getUserId(), MessageTypeProto.MessageType.valueOf(packetNetData.getMsgId()));
|
||||
}
|
||||
if (packetNetData.getMsgId() == MessageTypeProto.MessageType.LOGIN_REQUEST_VALUE ||
|
||||
packetNetData.getMsgId() == MessageTypeProto.MessageType.RECONNECT_REQUEST_VALUE) {
|
||||
if (packetNetData.getMsgId() == MessageTypeProto.MessageType.LOGIN_REQUEST_VALUE) {
|
||||
UserManager.loginIncrease();
|
||||
if (!onLoginORReLoginRequest(session, packetNetData)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//在线列表加入session
|
||||
OnlineUserManager.userOnline(session.getUid(), session);
|
||||
}
|
||||
if(packetNetData.getMsgId() == MessageTypeProto.MessageType.RECONNECT_REQUEST_VALUE){
|
||||
if (!onLoginORReLoginRequest(session, packetNetData)) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue