黑名单 服务器检查
parent
cc6da29f57
commit
fbe7d1b23d
|
@ -4,18 +4,34 @@ import com.ljsd.jieling.exception.ErrorCode;
|
||||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||||
import com.ljsd.jieling.network.session.ISession;
|
import com.ljsd.jieling.network.session.ISession;
|
||||||
import com.ljsd.jieling.util.MessageUtil;
|
import com.ljsd.jieling.util.MessageUtil;
|
||||||
|
import io.netty.util.internal.ConcurrentSet;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description: 进服前检查
|
* Description: 检查
|
||||||
* Author: zsx
|
* Author: zsx
|
||||||
* CreateDate: 2019/11/5 14:42
|
* CreateDate: 2019/11/5 14:42
|
||||||
*/
|
*/
|
||||||
public class Blocker {
|
public class Blocker {
|
||||||
|
|
||||||
public static final AtomicInteger maxAllowedOnlineAccountCount = new AtomicInteger(5000);
|
public static final AtomicInteger maxAllowedOnlineAccountCount = new AtomicInteger(5000);
|
||||||
|
private static ConcurrentSet<Integer> forbidLogin = new ConcurrentSet<>();
|
||||||
|
|
||||||
|
public static boolean checkForbidUser(ISession iSession){
|
||||||
|
if(forbidLogin.size()<1){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(iSession!=null) {
|
||||||
|
if(forbidLogin.contains(iSession.getUid())){
|
||||||
|
MessageUtil.sendErrorCode(iSession, ErrorCode.reloginCode, "您已被踢下线!");
|
||||||
|
iSession.setOfflineType(ErrorCode.reloginCode);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean checkFlow(ISession iSession){
|
public static boolean checkFlow(ISession iSession){
|
||||||
if(iSession!=null) {
|
if(iSession!=null) {
|
||||||
|
@ -28,6 +44,12 @@ public class Blocker {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Set<Integer> getForbidLogin() {
|
||||||
|
return forbidLogin;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setForbidLogin(Set<Integer> forbidLogin) {
|
||||||
|
Blocker.forbidLogin.clear();
|
||||||
|
Blocker.forbidLogin.addAll(forbidLogin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,6 @@ public class ProtocolsManager implements ProtocolsAbstract {
|
||||||
public static Map<MessageTypeProto.MessageType, String> gameMessageForLogin = new ConcurrentHashMap<>();
|
public static Map<MessageTypeProto.MessageType, String> gameMessageForLogin = new ConcurrentHashMap<>();
|
||||||
private Map<Integer, BaseHandler> handlers = new HashMap<>();
|
private Map<Integer, BaseHandler> handlers = new HashMap<>();
|
||||||
private static ClassLoader classLoader = GameApplication.class.getClassLoader();
|
private static ClassLoader classLoader = GameApplication.class.getClassLoader();
|
||||||
private static Set<Integer> forbidLogin = new HashSet<>();
|
|
||||||
public final int HANDLER_THREAD_NUM = 50;
|
public final int HANDLER_THREAD_NUM = 50;
|
||||||
public HandlerLogicThread[] handlerThreads = new HandlerLogicThread[HANDLER_THREAD_NUM];
|
public HandlerLogicThread[] handlerThreads = new HandlerLogicThread[HANDLER_THREAD_NUM];
|
||||||
|
|
||||||
|
@ -202,7 +201,7 @@ public class ProtocolsManager implements ProtocolsAbstract {
|
||||||
if (checkIndex(session,packetNetData) != 0){
|
if (checkIndex(session,packetNetData) != 0){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boolean b = checkForbidUser(session);
|
boolean b = Blocker.checkForbidUser(session);
|
||||||
if(b){
|
if(b){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -480,31 +479,19 @@ public class ProtocolsManager implements ProtocolsAbstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean checkForbidUser(ISession iSession){
|
|
||||||
if(forbidLogin.size()<1){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(iSession!=null) {
|
|
||||||
if(forbidLogin.contains(iSession.getUid())){
|
|
||||||
MessageUtil.sendErrorCode(iSession, ErrorCode.reloginCode, "您已被踢下线!");
|
|
||||||
iSession.setOfflineType(ErrorCode.reloginCode);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
public void minuteCheckForbidUser(){
|
public void minuteCheckForbidUser(){
|
||||||
RedisUtil redisUtil = RedisUtil.getInstence();
|
RedisUtil redisUtil = RedisUtil.getInstence();
|
||||||
String key = RedisKey.getKey(RedisKey.FORBID_LOGIN, "", false);
|
String key = RedisKey.getKey(RedisKey.FORBID_LOGIN, "", false);
|
||||||
if(!redisUtil.hasKey(key)){
|
if(!redisUtil.hasKey(key)){
|
||||||
forbidLogin.clear();
|
Blocker.getForbidLogin().clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Map<Integer, Integer> forbidMap = redisUtil.getMapValues(RedisKey.FORBID_LOGIN, "", Integer.class, Integer.class);
|
Map<Integer, Integer> forbidMap = redisUtil.getMapValues(RedisKey.FORBID_LOGIN, "", Integer.class, Integer.class);
|
||||||
if(forbidMap==null||forbidMap.size()<1){
|
if(forbidMap==null||forbidMap.size()<1){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
forbidLogin = forbidMap.keySet();
|
Blocker.setForbidLogin(forbidMap.keySet());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue