Removal of nProtect and NetcoreConfig classes.
This commit is contained in:
@@ -1,48 +0,0 @@
|
||||
#=========================================#
|
||||
# MMOCore Connection Settings #
|
||||
#=========================================#
|
||||
|
||||
PacketHandlerDebug = False
|
||||
|
||||
# --------------------------
|
||||
# Client Queue Configuration
|
||||
# --------------------------
|
||||
# Queue size, do not set it too low !
|
||||
# Default: 14
|
||||
ClientPacketQueueSize = 14
|
||||
# Maximum number of packets in burst.
|
||||
# Execution will be aborted and thread released if more packets executed in raw.
|
||||
# Default: 50
|
||||
ClientPacketQueueMaxBurstSize = 50
|
||||
# Maximum number of packets per second.
|
||||
# Flood detector will be triggered if more packets received.
|
||||
# After triggering all incoming packets will be dropped until flooding stopped.
|
||||
# Default: 80
|
||||
ClientPacketQueueMaxPacketsPerSecond = 80
|
||||
# Average number of packets per second calculated during this interval.
|
||||
# Using larger value decrease number of false kicks, but slower reaction to flood.
|
||||
# Avoid using too low or too high values, recommended between 3 and 10.
|
||||
# Default: 5
|
||||
ClientPacketQueueMeasureInterval = 5
|
||||
# Maximum average number of packets per second during measure interval.
|
||||
# Flood detector will be triggered if more packets received.
|
||||
# After triggering all incoming packets will be dropped until flooding stopped.
|
||||
# Default: 40
|
||||
ClientPacketQueueMaxAveragePacketsPerSecond = 40
|
||||
# Maximum number of flood triggers per minute.
|
||||
# Client will be kicked if more floods detected.
|
||||
# Default: 2
|
||||
ClientPacketQueueMaxFloodPerMin = 6
|
||||
# Maximum number of queue overflows per minute.
|
||||
# After overflow all incoming packets from client are dropped until queue is flushed.
|
||||
# Client will be kicked if more queue overflows detected.
|
||||
# Default: 50
|
||||
ClientPacketQueueOverflowsPerMin = 50
|
||||
# Maximum number of buffer underflows per minute.
|
||||
# Client will be kicked if more underflow exceptions detected.
|
||||
# Default: 1
|
||||
ClientPacketQueueUnderflowsPerMin = 1
|
||||
# Maximum number of unknown packets per minute.
|
||||
# Client will be kicked if more unknown packets received.
|
||||
# Default: 5
|
||||
ClientPacketQueueUnknownPerMin = 5
|
@@ -1156,6 +1156,26 @@ public class Config
|
||||
public static long SESSION_TTL;
|
||||
public static int MAX_LOGINSESSIONS;
|
||||
|
||||
/** MMO settings */
|
||||
public static final int MMO_SELECTOR_SLEEP_TIME = 20; // default 20
|
||||
public static final int MMO_MAX_SEND_PER_PASS = 80; // default 80
|
||||
public static final int MMO_MAX_READ_PER_PASS = 80; // default 80
|
||||
public static final int MMO_HELPER_BUFFER_COUNT = 20; // default 20
|
||||
|
||||
/** Client Packets Queue settings */
|
||||
public static final int CLIENT_PACKET_QUEUE_SIZE = 14; // default MMO_MAX_READ_PER_PASS + 2
|
||||
public static final int CLIENT_PACKET_QUEUE_MAX_BURST_SIZE = 13; // default MMO_MAX_READ_PER_PASS + 1
|
||||
public static final int CLIENT_PACKET_QUEUE_MAX_PACKETS_PER_SECOND = 160; // default 160
|
||||
public static final int CLIENT_PACKET_QUEUE_MEASURE_INTERVAL = 5; // default 5
|
||||
public static final int CLIENT_PACKET_QUEUE_MAX_AVERAGE_PACKETS_PER_SECOND = 80; // default 80
|
||||
public static final int CLIENT_PACKET_QUEUE_MAX_FLOODS_PER_MIN = 2; // default 2
|
||||
public static final int CLIENT_PACKET_QUEUE_MAX_OVERFLOWS_PER_MIN = 1; // default 1
|
||||
public static final int CLIENT_PACKET_QUEUE_MAX_UNDERFLOWS_PER_MIN = 1; // default 1
|
||||
public static final int CLIENT_PACKET_QUEUE_MAX_UNKNOWN_PER_MIN = 5; // default 5
|
||||
|
||||
/** Packet handler settings */
|
||||
public static final boolean PACKET_HANDLER_DEBUG = false;
|
||||
|
||||
public static void loadAccessConfig()
|
||||
{
|
||||
try
|
||||
|
@@ -1,223 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.commons.crypt;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.GameGuardQuery;
|
||||
|
||||
/**
|
||||
* The main "engine" of protection ...
|
||||
* @author Nick
|
||||
*/
|
||||
public class nProtect
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(nProtect.class.getName());
|
||||
|
||||
public enum RestrictionType
|
||||
{
|
||||
RESTRICT_ENTER,
|
||||
RESTRICT_EVENT,
|
||||
RESTRICT_OLYMPIAD,
|
||||
RESTRICT_SIEGE
|
||||
}
|
||||
|
||||
public class nProtectAccessor
|
||||
{
|
||||
public void setCheckGameGuardQuery(Method m)
|
||||
{
|
||||
_checkGameGuardQuery = m;
|
||||
}
|
||||
|
||||
public void setStartTask(Method m)
|
||||
{
|
||||
_startTask = m;
|
||||
}
|
||||
|
||||
public void setCheckRestriction(Method m)
|
||||
{
|
||||
_checkRestriction = m;
|
||||
}
|
||||
|
||||
public void setSendRequest(Method m)
|
||||
{
|
||||
_sendRequest = m;
|
||||
}
|
||||
|
||||
public void setCloseSession(Method m)
|
||||
{
|
||||
_closeSession = m;
|
||||
}
|
||||
|
||||
public void setSendGGQuery(Method m)
|
||||
{
|
||||
_sendGGQuery = m;
|
||||
}
|
||||
}
|
||||
|
||||
protected Method _checkGameGuardQuery = null;
|
||||
protected Method _startTask = null;
|
||||
protected Method _checkRestriction = null;
|
||||
protected Method _sendRequest = null;
|
||||
protected Method _closeSession = null;
|
||||
protected Method _sendGGQuery = null;
|
||||
|
||||
private static boolean enabled = false;
|
||||
|
||||
private nProtect()
|
||||
{
|
||||
Class<?> clazz = null;
|
||||
try
|
||||
{
|
||||
clazz = Class.forName("org.l2jmobius.protection.main");
|
||||
|
||||
if (clazz != null)
|
||||
{
|
||||
final Method m = clazz.getMethod("init", nProtectAccessor.class);
|
||||
if (m != null)
|
||||
{
|
||||
m.invoke(null, new nProtectAccessor());
|
||||
enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
// LOGGER.warning("nProtect System will be not loaded due to ClassNotFoundException of 'org.l2jmobius.protection.main' class");
|
||||
}
|
||||
catch (SecurityException | InvocationTargetException | IllegalAccessException | IllegalArgumentException | NoSuchMethodException e)
|
||||
{
|
||||
LOGGER.warning("Ptoblem with nProtect: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void sendGameGuardQuery(GameGuardQuery pkt)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_sendGGQuery != null)
|
||||
{
|
||||
_sendGGQuery.invoke(pkt);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.warning("Ptoblem with nProtect: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkGameGuardRepy(GameClient cl, int[] reply)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_checkGameGuardQuery != null)
|
||||
{
|
||||
return (Boolean) _checkGameGuardQuery.invoke(null, cl, reply);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.warning("Ptoblem with nProtect: " + e.getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public ScheduledFuture<?> startTask(GameClient client)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_startTask != null)
|
||||
{
|
||||
return (ScheduledFuture<?>) _startTask.invoke(null, client);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.warning("Ptoblem with nProtect: " + e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void sendRequest(GameClient cl)
|
||||
{
|
||||
if (_sendRequest != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
_sendRequest.invoke(null, cl);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.warning("Ptoblem with nProtect: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void closeSession(GameClient cl)
|
||||
{
|
||||
if (_closeSession != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
_closeSession.invoke(null, cl);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkRestriction(PlayerInstance player, RestrictionType type, Object... params)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_checkRestriction != null)
|
||||
{
|
||||
return (Boolean) _checkRestriction.invoke(null, player, type, params);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.warning("Ptoblem with nProtect: " + e.getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the enabled
|
||||
*/
|
||||
public static boolean isEnabled()
|
||||
{
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public static nProtect getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final nProtect INSTANCE = new nProtect();
|
||||
}
|
||||
}
|
@@ -42,5 +42,5 @@ public abstract class MMOClient<T extends MMOConnection<?>>
|
||||
|
||||
protected abstract void onDisconnection();
|
||||
|
||||
protected abstract void onForcedDisconnection(boolean critical);
|
||||
protected abstract void onForcedDisconnection();
|
||||
}
|
@@ -17,7 +17,6 @@
|
||||
package org.l2jmobius.commons.mmocore;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -36,8 +35,6 @@ public class MMOConnection<T extends MMOClient<?>>
|
||||
|
||||
private final Socket _socket;
|
||||
|
||||
private final InputStream _socket_is;
|
||||
|
||||
private final InetAddress _address;
|
||||
|
||||
private final ReadableByteChannel _readableByteChannel;
|
||||
@@ -60,16 +57,13 @@ public class MMOConnection<T extends MMOClient<?>>
|
||||
|
||||
private T _client;
|
||||
|
||||
public MMOConnection(SelectorThread<T> selectorThread, Socket socket, SelectionKey key) throws IOException
|
||||
public MMOConnection(SelectorThread<T> selectorThread, Socket socket, SelectionKey key)
|
||||
{
|
||||
_selectorThread = selectorThread;
|
||||
_socket = socket;
|
||||
_address = socket.getInetAddress();
|
||||
_readableByteChannel = socket.getChannel();
|
||||
_writableByteChannel = socket.getChannel();
|
||||
|
||||
_socket_is = socket.getInputStream();
|
||||
|
||||
_port = socket.getPort();
|
||||
_selectionKey = key;
|
||||
|
||||
@@ -100,7 +94,7 @@ public class MMOConnection<T extends MMOClient<?>>
|
||||
_sendQueue.addLast(sp);
|
||||
}
|
||||
|
||||
if (!_sendQueue.isEmpty() && _selectionKey.isValid())
|
||||
if (!_sendQueue.isEmpty())
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -163,6 +157,7 @@ public class MMOConnection<T extends MMOClient<?>>
|
||||
{
|
||||
temp.put(_primaryWriteBuffer);
|
||||
_selectorThread.recycleBuffer(_primaryWriteBuffer);
|
||||
_primaryWriteBuffer = temp;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -200,32 +195,6 @@ public class MMOConnection<T extends MMOClient<?>>
|
||||
return _readBuffer;
|
||||
}
|
||||
|
||||
public boolean isConnected()
|
||||
{
|
||||
return !_socket.isClosed() && _socket.isConnected();
|
||||
}
|
||||
|
||||
public boolean isChannelConnected()
|
||||
{
|
||||
boolean output = false;
|
||||
|
||||
if (!_socket.isClosed() && (_socket.getChannel() != null) && _socket.getChannel().isConnected() && _socket.getChannel().isOpen() && !_socket.isInputShutdown())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_socket_is.available() > 0)
|
||||
{
|
||||
output = true;
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// not useful LOGGER
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
public boolean isClosed()
|
||||
{
|
||||
return _pendingClose;
|
||||
@@ -269,16 +238,13 @@ public class MMOConnection<T extends MMOClient<?>>
|
||||
}
|
||||
}
|
||||
|
||||
if (_selectionKey.isValid())
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
_selectionKey.interestOps(_selectionKey.interestOps() & ~SelectionKey.OP_WRITE);
|
||||
}
|
||||
catch (CancelledKeyException e)
|
||||
{
|
||||
// not useful LOGGER
|
||||
}
|
||||
_selectionKey.interestOps(_selectionKey.interestOps() & ~SelectionKey.OP_WRITE);
|
||||
}
|
||||
catch (CancelledKeyException e)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
// _closePacket = sp;
|
||||
|
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.commons.mmocore;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
public class NetcoreConfig
|
||||
{
|
||||
public boolean PACKET_HANDLER_DEBUG;
|
||||
|
||||
/** MMO settings */
|
||||
public int MMO_SELECTOR_SLEEP_TIME = 20; // default 20
|
||||
public int MMO_MAX_SEND_PER_PASS = 12; // default 12
|
||||
public int MMO_MAX_READ_PER_PASS = 12; // default 12
|
||||
public int MMO_HELPER_BUFFER_COUNT = 20; // default 20
|
||||
|
||||
/** Client Packets Queue settings */
|
||||
public int CLIENT_PACKET_QUEUE_SIZE; // default MMO_MAX_READ_PER_PASS + 2
|
||||
public int CLIENT_PACKET_QUEUE_MAX_BURST_SIZE; // default MMO_MAX_READ_PER_PASS + 1
|
||||
public int CLIENT_PACKET_QUEUE_MAX_PACKETS_PER_SECOND; // default 80
|
||||
public int CLIENT_PACKET_QUEUE_MEASURE_INTERVAL; // default 5
|
||||
public int CLIENT_PACKET_QUEUE_MAX_AVERAGE_PACKETS_PER_SECOND; // default 40
|
||||
public int CLIENT_PACKET_QUEUE_MAX_FLOODS_PER_MIN; // default 2
|
||||
public int CLIENT_PACKET_QUEUE_MAX_OVERFLOWS_PER_MIN; // default 1
|
||||
public int CLIENT_PACKET_QUEUE_MAX_UNDERFLOWS_PER_MIN; // default 1
|
||||
public int CLIENT_PACKET_QUEUE_MAX_UNKNOWN_PER_MIN; // default 5
|
||||
|
||||
private NetcoreConfig()
|
||||
{
|
||||
final String MMO_CONFIG = "./config/protected/MmoCore.ini";
|
||||
|
||||
try
|
||||
{
|
||||
final Properties mmoSetting = new Properties();
|
||||
final InputStream is = new FileInputStream(new File(MMO_CONFIG));
|
||||
mmoSetting.load(is);
|
||||
is.close();
|
||||
|
||||
PACKET_HANDLER_DEBUG = Boolean.parseBoolean(mmoSetting.getProperty("PacketHandlerDebug", "False"));
|
||||
|
||||
// CLIENT-QUEUE-SETTINGS
|
||||
CLIENT_PACKET_QUEUE_SIZE = Integer.parseInt(mmoSetting.getProperty("ClientPacketQueueSize", "14")); // default MMO_MAX_READ_PER_PASS + 2
|
||||
CLIENT_PACKET_QUEUE_MAX_BURST_SIZE = Integer.parseInt(mmoSetting.getProperty("ClientPacketQueueMaxBurstSize", "13")); // default MMO_MAX_READ_PER_PASS + 1
|
||||
CLIENT_PACKET_QUEUE_MAX_PACKETS_PER_SECOND = Integer.parseInt(mmoSetting.getProperty("ClientPacketQueueMaxPacketsPerSecond", "80")); // default 80
|
||||
CLIENT_PACKET_QUEUE_MEASURE_INTERVAL = Integer.parseInt(mmoSetting.getProperty("ClientPacketQueueMeasureInterval", "5")); // default 5
|
||||
CLIENT_PACKET_QUEUE_MAX_AVERAGE_PACKETS_PER_SECOND = Integer.parseInt(mmoSetting.getProperty("ClientPacketQueueMaxAveragePacketsPerSecond", "40")); // default 40
|
||||
CLIENT_PACKET_QUEUE_MAX_FLOODS_PER_MIN = Integer.parseInt(mmoSetting.getProperty("ClientPacketQueueMaxFloodPerMin", "6")); // default 6
|
||||
CLIENT_PACKET_QUEUE_MAX_OVERFLOWS_PER_MIN = Integer.parseInt(mmoSetting.getProperty("ClientPacketQueueOverflowsPerMin", "3")); // default 3
|
||||
CLIENT_PACKET_QUEUE_MAX_UNDERFLOWS_PER_MIN = Integer.parseInt(mmoSetting.getProperty("ClientPacketQueueUnderflowsPerMin", "3")); // default 3
|
||||
CLIENT_PACKET_QUEUE_MAX_UNKNOWN_PER_MIN = Integer.parseInt(mmoSetting.getProperty("ClientPacketQueueUnknownPerMin", "5")); // default 5
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
throw new Error("Failed to Load " + MMO_CONFIG + " File.");
|
||||
}
|
||||
}
|
||||
|
||||
public static NetcoreConfig getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final NetcoreConfig INSTANCE = new NetcoreConfig();
|
||||
}
|
||||
}
|
@@ -19,106 +19,41 @@ package org.l2jmobius.commons.mmocore;
|
||||
/**
|
||||
* @author KenM
|
||||
*/
|
||||
|
||||
public class SelectorConfig
|
||||
{
|
||||
private int readBufferSize = 64 * 1024;
|
||||
public int READ_BUFFER_SIZE = 64 * 1024;
|
||||
|
||||
private int writeBufferSize = 64 * 1024;
|
||||
public int WRITE_BUFFER_SIZE = 64 * 1024;
|
||||
|
||||
private int helperBufferCount = 20;
|
||||
public int HELPER_BUFFER_COUNT = 20;
|
||||
|
||||
private int helperBufferSize = 64 * 1024;
|
||||
public int HELPER_BUFFER_SIZE = 64 * 1024;
|
||||
|
||||
/**
|
||||
* Server will try to send maxSendPerPass packets per socket write call<br>
|
||||
* however it may send less if the write buffer was filled before achieving this value.
|
||||
* Server will try to send MAX_SEND_PER_PASS packets per socket write call<br>
|
||||
* however it may send less if the write buffer was filled before achieving
|
||||
* this value.
|
||||
*/
|
||||
private int maxSendPerPass = 10;
|
||||
public int MAX_SEND_PER_PASS = 10;
|
||||
|
||||
/**
|
||||
* Server will try to read maxReadPerPass packets per socket read call<br>
|
||||
* however it may read less if the read buffer was empty before achieving this value.
|
||||
* Server will try to read MAX_READ_PER_PASS packets per socket read call<br>
|
||||
* however it may read less if the read buffer was empty before achieving
|
||||
* this value.
|
||||
*/
|
||||
private int maxReadPerPass = 10;
|
||||
public int MAX_READ_PER_PASS = 10;
|
||||
|
||||
/**
|
||||
* Defines how much time (in milis) should the selector sleep, an higher value increases throughput but also increases latency(to a max of the sleep value itself).<BR>
|
||||
* Also an extremely high value(usually > 100) will decrease throughput due to the server not doing enough sends per second (depends on max sends per pass).<BR>
|
||||
* Defines how much time (in milis) should the selector sleep, an higher
|
||||
* value increases throughput but also increases latency(to a max of the
|
||||
* sleep value itself).<BR>
|
||||
* Also an extremely high value(usually > 100) will decrease throughput due
|
||||
* to the server not doing enough sends per second (depends on max sends per
|
||||
* pass).<BR>
|
||||
* <BR>
|
||||
* Recommended values:<BR>
|
||||
* 1 for minimal latency.<BR>
|
||||
* 10-30 for an latency/troughput trade-off based on your needs.<BR>
|
||||
*/
|
||||
private int sleepTime = 10;
|
||||
|
||||
public int getReadBufferSize()
|
||||
{
|
||||
return readBufferSize;
|
||||
}
|
||||
|
||||
public void setReadBufferSize(int readBufferSize)
|
||||
{
|
||||
this.readBufferSize = readBufferSize;
|
||||
}
|
||||
|
||||
public int getWriteBufferSize()
|
||||
{
|
||||
return writeBufferSize;
|
||||
}
|
||||
|
||||
public void setWriteBufferSize(int writeBufferSize)
|
||||
{
|
||||
this.writeBufferSize = writeBufferSize;
|
||||
}
|
||||
|
||||
public int getHelperBufferCount()
|
||||
{
|
||||
return helperBufferCount;
|
||||
}
|
||||
|
||||
public void setHelperBufferCount(int helperBufferCount)
|
||||
{
|
||||
this.helperBufferCount = helperBufferCount;
|
||||
}
|
||||
|
||||
public int getHelperBufferSize()
|
||||
{
|
||||
return helperBufferSize;
|
||||
}
|
||||
|
||||
public void setHelperBufferSize(int helperBufferSize)
|
||||
{
|
||||
this.helperBufferSize = helperBufferSize;
|
||||
}
|
||||
|
||||
public int getMaxSendPerPass()
|
||||
{
|
||||
return maxSendPerPass;
|
||||
}
|
||||
|
||||
public void setMaxSendPerPass(int maxSendPerPass)
|
||||
{
|
||||
this.maxSendPerPass = maxSendPerPass;
|
||||
}
|
||||
|
||||
public int getMaxReadPerPass()
|
||||
{
|
||||
return maxReadPerPass;
|
||||
}
|
||||
|
||||
public void setMaxReadPerPass(int maxReadPerPass)
|
||||
{
|
||||
this.maxReadPerPass = maxReadPerPass;
|
||||
}
|
||||
|
||||
public int getSleepTime()
|
||||
{
|
||||
return sleepTime;
|
||||
}
|
||||
|
||||
public void setSleepTime(int sleepTime)
|
||||
{
|
||||
this.sleepTime = sleepTime;
|
||||
}
|
||||
public int SLEEP_TIME = 10;
|
||||
}
|
||||
|
@@ -70,16 +70,16 @@ public class SelectorThread<T extends MMOClient<?>>extends Thread
|
||||
{
|
||||
super.setName("SelectorThread-" + super.getId());
|
||||
|
||||
HELPER_BUFFER_SIZE = sc.getHelperBufferSize();
|
||||
HELPER_BUFFER_COUNT = sc.getHelperBufferCount();
|
||||
MAX_SEND_PER_PASS = sc.getMaxSendPerPass();
|
||||
MAX_READ_PER_PASS = sc.getMaxReadPerPass();
|
||||
HELPER_BUFFER_SIZE = sc.HELPER_BUFFER_SIZE;
|
||||
HELPER_BUFFER_COUNT = sc.HELPER_BUFFER_COUNT;
|
||||
MAX_SEND_PER_PASS = sc.MAX_SEND_PER_PASS;
|
||||
MAX_READ_PER_PASS = sc.MAX_READ_PER_PASS;
|
||||
|
||||
SLEEP_TIME = sc.getSleepTime();
|
||||
SLEEP_TIME = sc.SLEEP_TIME;
|
||||
|
||||
DIRECT_WRITE_BUFFER = ByteBuffer.allocateDirect(sc.getWriteBufferSize()).order(BYTE_ORDER);
|
||||
WRITE_BUFFER = ByteBuffer.wrap(new byte[sc.getWriteBufferSize()]).order(BYTE_ORDER);
|
||||
READ_BUFFER = ByteBuffer.wrap(new byte[sc.getReadBufferSize()]).order(BYTE_ORDER);
|
||||
DIRECT_WRITE_BUFFER = ByteBuffer.allocateDirect(sc.WRITE_BUFFER_SIZE).order(BYTE_ORDER);
|
||||
WRITE_BUFFER = ByteBuffer.wrap(new byte[sc.WRITE_BUFFER_SIZE]).order(BYTE_ORDER);
|
||||
READ_BUFFER = ByteBuffer.wrap(new byte[sc.READ_BUFFER_SIZE]).order(BYTE_ORDER);
|
||||
|
||||
STRING_BUFFER = new NioNetStringBuffer(64 * 1024);
|
||||
|
||||
@@ -208,16 +208,9 @@ public class SelectorThread<T extends MMOClient<?>>extends Thread
|
||||
{
|
||||
while (!_pendingClose.isEmpty())
|
||||
{
|
||||
try
|
||||
{
|
||||
con = _pendingClose.removeFirst();
|
||||
writeClosePacket(con);
|
||||
closeConnectionImpl(con.getSelectionKey(), con);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
con = _pendingClose.removeFirst();
|
||||
writeClosePacket(con);
|
||||
closeConnectionImpl(con.getSelectionKey(), con);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,7 +234,7 @@ public class SelectorThread<T extends MMOClient<?>>extends Thread
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
con.getClient().onForcedDisconnection(true);
|
||||
con.getClient().onForcedDisconnection();
|
||||
closeConnectionImpl(key, con);
|
||||
}
|
||||
|
||||
@@ -288,6 +281,7 @@ public class SelectorThread<T extends MMOClient<?>>extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ByteBuffer buf = con.getReadBuffer();
|
||||
if (buf == null)
|
||||
{
|
||||
@@ -302,18 +296,13 @@ public class SelectorThread<T extends MMOClient<?>>extends Thread
|
||||
|
||||
int result = -2;
|
||||
|
||||
boolean critical = true;
|
||||
|
||||
try
|
||||
{
|
||||
result = con.read(buf);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
if (!con.isConnected() || !con.isChannelConnected())
|
||||
{
|
||||
critical = false;
|
||||
}
|
||||
// error handling goes bellow
|
||||
}
|
||||
|
||||
if (result > 0)
|
||||
@@ -360,7 +349,7 @@ public class SelectorThread<T extends MMOClient<?>>extends Thread
|
||||
}
|
||||
case -2:
|
||||
{
|
||||
con.getClient().onForcedDisconnection(critical);
|
||||
con.getClient().onForcedDisconnection();
|
||||
closeConnectionImpl(key, con);
|
||||
break;
|
||||
}
|
||||
@@ -379,7 +368,7 @@ public class SelectorThread<T extends MMOClient<?>>extends Thread
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
// we don`t have enough data for header so we need to read
|
||||
// we don't have enough data for header so we need to read
|
||||
key.interestOps(key.interestOps() | SelectionKey.OP_READ);
|
||||
|
||||
// did we use the READ_BUFFER ?
|
||||
@@ -403,17 +392,14 @@ public class SelectorThread<T extends MMOClient<?>>extends Thread
|
||||
// do we got enough bytes for the packet?
|
||||
if (dataPending <= buf.remaining())
|
||||
{
|
||||
boolean read = true;
|
||||
// avoid parsing dummy packets (packets without body)
|
||||
if (dataPending > 0)
|
||||
{
|
||||
final int pos = buf.position();
|
||||
if (!parseClientPacket(pos, buf, dataPending, client))
|
||||
{
|
||||
read = false;
|
||||
}
|
||||
parseClientPacket(pos, buf, dataPending, client);
|
||||
buf.position(pos + dataPending);
|
||||
}
|
||||
|
||||
// if we are done with this buffer
|
||||
if (!buf.hasRemaining())
|
||||
{
|
||||
@@ -426,17 +412,17 @@ public class SelectorThread<T extends MMOClient<?>>extends Thread
|
||||
{
|
||||
READ_BUFFER.clear();
|
||||
}
|
||||
read = false;
|
||||
return false;
|
||||
}
|
||||
return read;
|
||||
return true;
|
||||
}
|
||||
// we don`t have enough bytes for the dataPacket so we need
|
||||
// to read
|
||||
// we don't have enough bytes for the dataPacket so we need to read
|
||||
key.interestOps(key.interestOps() | SelectionKey.OP_READ);
|
||||
|
||||
// did we use the READ_BUFFER ?
|
||||
if (buf == READ_BUFFER)
|
||||
{
|
||||
// move it`s position
|
||||
// move it's position
|
||||
buf.position(buf.position() - HEADER_SIZE);
|
||||
// move the pending byte to the connections READ_BUFFER
|
||||
allocateReadBuffer(con);
|
||||
@@ -457,7 +443,7 @@ public class SelectorThread<T extends MMOClient<?>>extends Thread
|
||||
READ_BUFFER.clear();
|
||||
}
|
||||
|
||||
private final boolean parseClientPacket(int pos, ByteBuffer buf, int dataSize, T client)
|
||||
private final void parseClientPacket(int pos, ByteBuffer buf, int dataSize, T client)
|
||||
{
|
||||
final boolean ret = client.decrypt(buf, dataSize);
|
||||
|
||||
@@ -466,7 +452,6 @@ public class SelectorThread<T extends MMOClient<?>>extends Thread
|
||||
// apply limit
|
||||
final int limit = buf.limit();
|
||||
buf.limit(pos + dataSize);
|
||||
|
||||
final ReceivablePacket<T> cp = _packetHandler.handlePacket(buf, client);
|
||||
|
||||
if (cp != null)
|
||||
@@ -486,8 +471,6 @@ public class SelectorThread<T extends MMOClient<?>>extends Thread
|
||||
|
||||
buf.limit(limit);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private final void writeClosePacket(MMOConnection<T> con)
|
||||
@@ -566,7 +549,7 @@ public class SelectorThread<T extends MMOClient<?>>extends Thread
|
||||
}
|
||||
else
|
||||
{
|
||||
con.getClient().onForcedDisconnection(true);
|
||||
con.getClient().onForcedDisconnection();
|
||||
closeConnectionImpl(key, con);
|
||||
}
|
||||
}
|
||||
@@ -698,11 +681,6 @@ public class SelectorThread<T extends MMOClient<?>>extends Thread
|
||||
_shutdown = true;
|
||||
}
|
||||
|
||||
public boolean isShutdown()
|
||||
{
|
||||
return _shutdown;
|
||||
}
|
||||
|
||||
protected void closeSelectorThread()
|
||||
{
|
||||
for (SelectionKey key : _selector.keys())
|
||||
|
@@ -29,10 +29,8 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.crypt.nProtect;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.commons.enums.ServerMode;
|
||||
import org.l2jmobius.commons.mmocore.NetcoreConfig;
|
||||
import org.l2jmobius.commons.mmocore.SelectorConfig;
|
||||
import org.l2jmobius.commons.mmocore.SelectorThread;
|
||||
import org.l2jmobius.commons.util.DeadlockDetector;
|
||||
@@ -195,12 +193,6 @@ public class GameServer
|
||||
CrestCache.getInstance();
|
||||
ScriptEngineManager.getInstance();
|
||||
|
||||
nProtect.getInstance();
|
||||
if (nProtect.isEnabled())
|
||||
{
|
||||
LOGGER.info("nProtect System Enabled");
|
||||
}
|
||||
|
||||
Util.printSection("World");
|
||||
World.getInstance();
|
||||
MapRegionData.getInstance();
|
||||
@@ -507,10 +499,10 @@ public class GameServer
|
||||
_loginThread.start();
|
||||
|
||||
final SelectorConfig sc = new SelectorConfig();
|
||||
sc.setMaxReadPerPass(NetcoreConfig.getInstance().MMO_MAX_READ_PER_PASS);
|
||||
sc.setMaxSendPerPass(NetcoreConfig.getInstance().MMO_MAX_SEND_PER_PASS);
|
||||
sc.setSleepTime(NetcoreConfig.getInstance().MMO_SELECTOR_SLEEP_TIME);
|
||||
sc.setHelperBufferCount(NetcoreConfig.getInstance().MMO_HELPER_BUFFER_COUNT);
|
||||
sc.MAX_READ_PER_PASS = Config.MMO_MAX_READ_PER_PASS;
|
||||
sc.MAX_SEND_PER_PASS = Config.MMO_MAX_SEND_PER_PASS;
|
||||
sc.SLEEP_TIME = Config.MMO_SELECTOR_SLEEP_TIME;
|
||||
sc.HELPER_BUFFER_COUNT = Config.MMO_HELPER_BUFFER_COUNT;
|
||||
|
||||
_gamePacketHandler = new GamePacketHandler();
|
||||
|
||||
|
@@ -311,18 +311,9 @@ public class LoginServerThread extends Thread
|
||||
sendPacket(pig);
|
||||
wcToRemove.gameClient.setState(GameClientState.AUTHED);
|
||||
wcToRemove.gameClient.setSessionId(wcToRemove.session);
|
||||
// before the char selection, check shutdown status
|
||||
if (GameServer.getSelectorThread().isShutdown())
|
||||
{
|
||||
wcToRemove.gameClient.getConnection().sendPacket(new AuthLoginFail(1));
|
||||
wcToRemove.gameClient.closeNow();
|
||||
}
|
||||
else
|
||||
{
|
||||
final CharSelectInfo cl = new CharSelectInfo(wcToRemove.account, wcToRemove.gameClient.getSessionId().playOkID1);
|
||||
wcToRemove.gameClient.getConnection().sendPacket(cl);
|
||||
wcToRemove.gameClient.setCharSelection(cl.getCharInfo());
|
||||
}
|
||||
final CharSelectInfo cl = new CharSelectInfo(wcToRemove.account, wcToRemove.gameClient.getSessionId().playOkID1);
|
||||
wcToRemove.gameClient.getConnection().sendPacket(cl);
|
||||
wcToRemove.gameClient.setCharSelection(cl.getCharInfo());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -38,7 +38,6 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.crypt.nProtect;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.commons.util.Rnd;
|
||||
import org.l2jmobius.gameserver.GameTimeController;
|
||||
@@ -4583,11 +4582,6 @@ public class PlayerInstance extends Playable
|
||||
*/
|
||||
public void setClient(GameClient client)
|
||||
{
|
||||
if ((client == null) && (_client != null))
|
||||
{
|
||||
_client.stopGuardTask();
|
||||
nProtect.getInstance().closeSession(_client);
|
||||
}
|
||||
_client = client;
|
||||
}
|
||||
|
||||
|
@@ -25,8 +25,6 @@ import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.crypt.nProtect;
|
||||
import org.l2jmobius.commons.crypt.nProtect.RestrictionType;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.gameserver.datatables.sql.ClanTable;
|
||||
import org.l2jmobius.gameserver.datatables.sql.NpcTable;
|
||||
@@ -434,11 +432,6 @@ public class FortSiege
|
||||
// Schedule a task to prepare auto siege end
|
||||
_siegeEndDate = Calendar.getInstance();
|
||||
_siegeEndDate.add(Calendar.MINUTE, FortSiegeManager.getInstance().getSiegeLength());
|
||||
nProtect.getInstance().checkRestriction(null, RestrictionType.RESTRICT_EVENT, new Object[]
|
||||
{
|
||||
FortSiege.class,
|
||||
this
|
||||
});
|
||||
ThreadPool.schedule(new ScheduleEndSiegeTask(getFort()), 1000); // Prepare auto end task
|
||||
|
||||
announceToPlayer("The siege of " + getFort().getName() + " has started!", false);
|
||||
|
@@ -27,8 +27,6 @@ import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.crypt.nProtect;
|
||||
import org.l2jmobius.commons.crypt.nProtect.RestrictionType;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.gameserver.datatables.sql.ClanTable;
|
||||
import org.l2jmobius.gameserver.datatables.sql.NpcTable;
|
||||
@@ -600,11 +598,7 @@ public class Siege
|
||||
// Schedule a task to prepare auto siege end
|
||||
_siegeEndDate = Calendar.getInstance();
|
||||
_siegeEndDate.add(Calendar.MINUTE, SiegeManager.getInstance().getSiegeLength());
|
||||
nProtect.getInstance().checkRestriction(null, RestrictionType.RESTRICT_EVENT, new Object[]
|
||||
{
|
||||
Siege.class,
|
||||
this
|
||||
});
|
||||
|
||||
// Prepare auto end task
|
||||
ThreadPool.schedule(new ScheduleEndSiegeTask(getCastle()), 1000);
|
||||
|
||||
|
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network;
|
||||
|
||||
import org.l2jmobius.commons.mmocore.NetcoreConfig;
|
||||
import org.l2jmobius.Config;
|
||||
|
||||
public class ClientStats
|
||||
{
|
||||
@@ -53,13 +53,13 @@ public class ClientStats
|
||||
|
||||
public ClientStats()
|
||||
{
|
||||
BUFFER_SIZE = NetcoreConfig.getInstance().CLIENT_PACKET_QUEUE_MEASURE_INTERVAL;
|
||||
BUFFER_SIZE = Config.CLIENT_PACKET_QUEUE_MEASURE_INTERVAL;
|
||||
_packetsInSecond = new int[BUFFER_SIZE];
|
||||
_head = BUFFER_SIZE - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if incoming packet need to be dropped
|
||||
* @return true if incoming packet need to be dropped.
|
||||
*/
|
||||
protected final boolean dropPacket()
|
||||
{
|
||||
@@ -72,9 +72,8 @@ public class ClientStats
|
||||
}
|
||||
|
||||
/**
|
||||
* Later during flood returns true (and send ActionFailed) once per second.
|
||||
* @param queueSize
|
||||
* @return true if flood detected first and ActionFailed packet need to be sent.
|
||||
* @return true if flood detected first and ActionFailed packet need to be sent. Later during flood returns true (and send ActionFailed) once per second.
|
||||
*/
|
||||
protected final boolean countPacket(int queueSize)
|
||||
{
|
||||
@@ -93,8 +92,8 @@ public class ClientStats
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts unknown packets and return true if threshold is reached.
|
||||
* @return
|
||||
* Counts unknown packets.
|
||||
* @return true if threshold is reached.
|
||||
*/
|
||||
protected final boolean countUnknownPacket()
|
||||
{
|
||||
@@ -109,13 +108,13 @@ public class ClientStats
|
||||
}
|
||||
|
||||
_unknownPacketsInMin++;
|
||||
return _unknownPacketsInMin > NetcoreConfig.getInstance().CLIENT_PACKET_QUEUE_MAX_UNKNOWN_PER_MIN;
|
||||
return _unknownPacketsInMin > Config.CLIENT_PACKET_QUEUE_MAX_UNKNOWN_PER_MIN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts burst length and return true if execution of the queue need to be aborted.
|
||||
* Counts burst length.
|
||||
* @param count - current number of processed packets in burst
|
||||
* @return
|
||||
* @return true if execution of the queue need to be aborted.
|
||||
*/
|
||||
protected final boolean countBurst(int count)
|
||||
{
|
||||
@@ -124,7 +123,7 @@ public class ClientStats
|
||||
maxBurstSize = count;
|
||||
}
|
||||
|
||||
if (count < NetcoreConfig.getInstance().CLIENT_PACKET_QUEUE_MAX_BURST_SIZE)
|
||||
if (count < Config.CLIENT_PACKET_QUEUE_MAX_BURST_SIZE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -134,8 +133,8 @@ public class ClientStats
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts queue overflows and return true if threshold is reached.
|
||||
* @return
|
||||
* Counts queue overflows.
|
||||
* @return true if threshold is reached.
|
||||
*/
|
||||
protected final boolean countQueueOverflow()
|
||||
{
|
||||
@@ -151,12 +150,12 @@ public class ClientStats
|
||||
}
|
||||
|
||||
_overflowsInMin++;
|
||||
return _overflowsInMin > NetcoreConfig.getInstance().CLIENT_PACKET_QUEUE_MAX_OVERFLOWS_PER_MIN;
|
||||
return _overflowsInMin > Config.CLIENT_PACKET_QUEUE_MAX_OVERFLOWS_PER_MIN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts underflow exceptions and return true if threshold is reached.
|
||||
* @return
|
||||
* Counts underflow exceptions.
|
||||
* @return true if threshold is reached.
|
||||
*/
|
||||
protected final boolean countUnderflowException()
|
||||
{
|
||||
@@ -171,26 +170,24 @@ public class ClientStats
|
||||
}
|
||||
|
||||
_underflowReadsInMin++;
|
||||
return _underflowReadsInMin > NetcoreConfig.getInstance().CLIENT_PACKET_QUEUE_MAX_UNDERFLOWS_PER_MIN;
|
||||
return _underflowReadsInMin > Config.CLIENT_PACKET_QUEUE_MAX_UNDERFLOWS_PER_MIN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if maximum number of floods per minute is reached.
|
||||
* @return
|
||||
* @return true if maximum number of floods per minute is reached.
|
||||
*/
|
||||
protected final boolean countFloods()
|
||||
{
|
||||
return _floodsInMin > NetcoreConfig.getInstance().CLIENT_PACKET_QUEUE_MAX_FLOODS_PER_MIN;
|
||||
return _floodsInMin > Config.CLIENT_PACKET_QUEUE_MAX_FLOODS_PER_MIN;
|
||||
}
|
||||
|
||||
private final boolean longFloodDetected()
|
||||
{
|
||||
return (_totalCount / BUFFER_SIZE) > NetcoreConfig.getInstance().CLIENT_PACKET_QUEUE_MAX_AVERAGE_PACKETS_PER_SECOND;
|
||||
return (_totalCount / BUFFER_SIZE) > Config.CLIENT_PACKET_QUEUE_MAX_AVERAGE_PACKETS_PER_SECOND;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if flood detected first and ActionFailed packet need to be sent. Later during flood returns true (and send ActionFailed) once per second.
|
||||
* @return
|
||||
* @return true if flood detected first and ActionFailed packet need to be sent. Later during flood returns true (and send ActionFailed) once per second.
|
||||
*/
|
||||
private final synchronized boolean countPacket()
|
||||
{
|
||||
@@ -201,7 +198,7 @@ public class ClientStats
|
||||
_packetCountStartTick = tick;
|
||||
|
||||
// clear flag if no more flooding during last seconds
|
||||
if (_floodDetected && !longFloodDetected() && (_packetsInSecond[_head] < (NetcoreConfig.getInstance().CLIENT_PACKET_QUEUE_MAX_PACKETS_PER_SECOND / 2)))
|
||||
if (_floodDetected && !longFloodDetected() && (_packetsInSecond[_head] < (Config.CLIENT_PACKET_QUEUE_MAX_PACKETS_PER_SECOND / 2)))
|
||||
{
|
||||
_floodDetected = false;
|
||||
}
|
||||
@@ -221,7 +218,7 @@ public class ClientStats
|
||||
final int count = ++_packetsInSecond[_head];
|
||||
if (!_floodDetected)
|
||||
{
|
||||
if (count > NetcoreConfig.getInstance().CLIENT_PACKET_QUEUE_MAX_PACKETS_PER_SECOND)
|
||||
if (count > Config.CLIENT_PACKET_QUEUE_MAX_PACKETS_PER_SECOND)
|
||||
{
|
||||
shortFloods++;
|
||||
}
|
||||
|
@@ -32,11 +32,9 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.crypt.nProtect;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.commons.mmocore.MMOClient;
|
||||
import org.l2jmobius.commons.mmocore.MMOConnection;
|
||||
import org.l2jmobius.commons.mmocore.NetcoreConfig;
|
||||
import org.l2jmobius.commons.mmocore.ReceivablePacket;
|
||||
import org.l2jmobius.gameserver.LoginServerThread;
|
||||
import org.l2jmobius.gameserver.LoginServerThread.SessionKey;
|
||||
@@ -57,7 +55,6 @@ import org.l2jmobius.gameserver.model.entity.olympiad.Olympiad;
|
||||
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.GameServerPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.LeaveWorld;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ServerClose;
|
||||
import org.l2jmobius.gameserver.util.EventData;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -93,9 +90,6 @@ public class GameClient extends MMOClient<MMOConnection<GameClient>> implements
|
||||
private final long _connectionStartTime;
|
||||
private final List<Integer> _charSlotMapping = new ArrayList<>();
|
||||
|
||||
// Task
|
||||
private ScheduledFuture<?> _guardCheckTask = null;
|
||||
|
||||
protected ScheduledFuture<?> _cleanupTask = null;
|
||||
|
||||
private final ClientStats _stats;
|
||||
@@ -103,14 +97,8 @@ public class GameClient extends MMOClient<MMOConnection<GameClient>> implements
|
||||
// Crypt
|
||||
private final GameCrypt _crypt;
|
||||
|
||||
// Flood protection
|
||||
public long packetsNextSendTick = 0;
|
||||
|
||||
protected boolean _closenow = true;
|
||||
private boolean _isDetached = false;
|
||||
|
||||
protected boolean _forcedToClose = false;
|
||||
|
||||
private final ArrayBlockingQueue<ReceivablePacket<GameClient>> _packetQueue;
|
||||
private final ReentrantLock _queueLock = new ReentrantLock();
|
||||
|
||||
@@ -123,17 +111,7 @@ public class GameClient extends MMOClient<MMOConnection<GameClient>> implements
|
||||
_connectionStartTime = System.currentTimeMillis();
|
||||
_crypt = new GameCrypt();
|
||||
_stats = new ClientStats();
|
||||
_packetQueue = new ArrayBlockingQueue<>(NetcoreConfig.getInstance().CLIENT_PACKET_QUEUE_SIZE);
|
||||
|
||||
_guardCheckTask = nProtect.getInstance().startTask(this);
|
||||
ThreadPool.schedule(() ->
|
||||
{
|
||||
if (_closenow)
|
||||
{
|
||||
close(new LeaveWorld());
|
||||
}
|
||||
}, 4000);
|
||||
|
||||
_packetQueue = new ArrayBlockingQueue<>(Config.CLIENT_PACKET_QUEUE_SIZE);
|
||||
}
|
||||
|
||||
public byte[] enableCrypt()
|
||||
@@ -170,7 +148,6 @@ public class GameClient extends MMOClient<MMOConnection<GameClient>> implements
|
||||
@Override
|
||||
public boolean decrypt(ByteBuffer buf, int size)
|
||||
{
|
||||
_closenow = false;
|
||||
_crypt.decrypt(buf.array(), buf.position(), size);
|
||||
return true;
|
||||
}
|
||||
@@ -538,24 +515,12 @@ public class GameClient extends MMOClient<MMOConnection<GameClient>> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onForcedDisconnection(boolean critical)
|
||||
public void onForcedDisconnection()
|
||||
{
|
||||
_forcedToClose = true;
|
||||
|
||||
// the force operation will allow to not save client position to prevent again criticals and stuck
|
||||
closeNow();
|
||||
}
|
||||
|
||||
public void stopGuardTask()
|
||||
{
|
||||
if (_guardCheckTask != null)
|
||||
{
|
||||
_guardCheckTask.cancel(true);
|
||||
_guardCheckTask = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisconnection()
|
||||
{
|
||||
@@ -585,7 +550,6 @@ public class GameClient extends MMOClient<MMOConnection<GameClient>> implements
|
||||
*/
|
||||
public void close(int delay)
|
||||
{
|
||||
|
||||
close(ServerClose.STATIC_PACKET);
|
||||
synchronized (this)
|
||||
{
|
||||
@@ -595,8 +559,6 @@ public class GameClient extends MMOClient<MMOConnection<GameClient>> implements
|
||||
}
|
||||
_cleanupTask = ThreadPool.schedule(new CleanupTask(), delay); // delayed
|
||||
}
|
||||
stopGuardTask();
|
||||
nProtect.getInstance().closeSession(this);
|
||||
}
|
||||
|
||||
public String getIpAddress()
|
||||
@@ -703,16 +665,8 @@ public class GameClient extends MMOClient<MMOConnection<GameClient>> implements
|
||||
|
||||
// prevent closing again
|
||||
player.setClient(null);
|
||||
|
||||
player.deleteMe();
|
||||
|
||||
try
|
||||
{
|
||||
player.store(_forcedToClose);
|
||||
}
|
||||
catch (Exception e2)
|
||||
{
|
||||
}
|
||||
player.store(true);
|
||||
}
|
||||
|
||||
setPlayer(null);
|
||||
@@ -990,11 +944,6 @@ public class GameClient extends MMOClient<MMOConnection<GameClient>> implements
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isForcedToClose()
|
||||
{
|
||||
return _forcedToClose;
|
||||
}
|
||||
|
||||
public void setProtocolVersion(int version)
|
||||
{
|
||||
_protocolVersion = version;
|
||||
|
@@ -24,7 +24,6 @@ import org.l2jmobius.commons.mmocore.IClientFactory;
|
||||
import org.l2jmobius.commons.mmocore.IMMOExecutor;
|
||||
import org.l2jmobius.commons.mmocore.IPacketHandler;
|
||||
import org.l2jmobius.commons.mmocore.MMOConnection;
|
||||
import org.l2jmobius.commons.mmocore.NetcoreConfig;
|
||||
import org.l2jmobius.commons.mmocore.ReceivablePacket;
|
||||
import org.l2jmobius.commons.util.Util;
|
||||
import org.l2jmobius.gameserver.network.GameClient.GameClientState;
|
||||
@@ -1318,7 +1317,7 @@ public class GamePacketHandler implements IPacketHandler<GameClient>, IClientFac
|
||||
|
||||
private void printDebug(int opcode, ByteBuffer buf, GameClientState state, GameClient client)
|
||||
{
|
||||
if (!NetcoreConfig.getInstance().PACKET_HANDLER_DEBUG)
|
||||
if (!Config.PACKET_HANDLER_DEBUG)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -1333,7 +1332,7 @@ public class GamePacketHandler implements IPacketHandler<GameClient>, IClientFac
|
||||
|
||||
private void printDebugDoubleOpcode(int opcode, int id2, ByteBuffer buf, GameClientState state, GameClient client)
|
||||
{
|
||||
if (!NetcoreConfig.getInstance().PACKET_HANDLER_DEBUG)
|
||||
if (!Config.PACKET_HANDLER_DEBUG)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@@ -22,7 +22,6 @@ import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.gameserver.GameServer;
|
||||
import org.l2jmobius.gameserver.datatables.ItemTable;
|
||||
import org.l2jmobius.gameserver.datatables.SkillTable;
|
||||
import org.l2jmobius.gameserver.datatables.sql.CharNameTable;
|
||||
@@ -287,13 +286,6 @@ public class CharacterCreate extends GameClientPacket
|
||||
newChar.store();
|
||||
newChar.deleteMe(); // Release the world of this character and it's inventory
|
||||
|
||||
// Before the char selection, check shutdown status
|
||||
if (GameServer.getSelectorThread().isShutdown())
|
||||
{
|
||||
client.closeNow();
|
||||
return;
|
||||
}
|
||||
|
||||
// Send char list
|
||||
final CharSelectInfo cl = new CharSelectInfo(client.getAccountName(), client.getSessionId().playOkID1);
|
||||
client.getConnection().sendPacket(cl);
|
||||
|
@@ -18,7 +18,6 @@ package org.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.gameserver.GameServer;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.CharDeleteFail;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.CharDeleteOk;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.CharSelectInfo;
|
||||
@@ -77,13 +76,6 @@ public class CharacterDelete extends GameClientPacket
|
||||
LOGGER.warning("ERROR " + getType() + ": " + e);
|
||||
}
|
||||
|
||||
// Before the char selection, check shutdown status
|
||||
if (GameServer.getSelectorThread().isShutdown())
|
||||
{
|
||||
getClient().closeNow();
|
||||
return;
|
||||
}
|
||||
|
||||
final CharSelectInfo cl = new CharSelectInfo(getClient().getAccountName(), getClient().getSessionId().playOkID1, 0);
|
||||
sendPacket(cl);
|
||||
getClient().setCharSelection(cl.getCharInfo());
|
||||
|
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import org.l2jmobius.gameserver.GameServer;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.CharSelectInfo;
|
||||
|
||||
public class CharacterRestore extends GameClientPacket
|
||||
@@ -45,13 +44,6 @@ public class CharacterRestore extends GameClientPacket
|
||||
{
|
||||
}
|
||||
|
||||
// Before the char selection, check shutdown status
|
||||
if (GameServer.getSelectorThread().isShutdown())
|
||||
{
|
||||
getClient().closeNow();
|
||||
return;
|
||||
}
|
||||
|
||||
final CharSelectInfo cl = new CharSelectInfo(getClient().getAccountName(), getClient().getSessionId().playOkID1, 0);
|
||||
sendPacket(cl);
|
||||
getClient().setCharSelection(cl.getCharInfo());
|
||||
|
@@ -18,7 +18,6 @@ package org.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.crypt.nProtect;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.network.GameClient.GameClientState;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
@@ -83,7 +82,6 @@ public class CharacterSelected extends GameClientPacket
|
||||
|
||||
cha.setClient(getClient());
|
||||
getClient().setPlayer(cha);
|
||||
nProtect.getInstance().sendRequest(getClient());
|
||||
getClient().setState(GameClientState.ENTERING);
|
||||
sendPacket(new CharSelected(cha, getClient().getSessionId().playOkID1));
|
||||
}
|
||||
|
@@ -26,9 +26,6 @@ import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.crypt.nProtect;
|
||||
import org.l2jmobius.commons.crypt.nProtect.RestrictionType;
|
||||
import org.l2jmobius.gameserver.GameTimeController;
|
||||
import org.l2jmobius.gameserver.communitybbs.Manager.MailBBSManager;
|
||||
import org.l2jmobius.gameserver.datatables.SkillTable;
|
||||
@@ -68,7 +65,6 @@ import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
import org.l2jmobius.gameserver.model.quest.Quest;
|
||||
import org.l2jmobius.gameserver.model.quest.QuestState;
|
||||
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import org.l2jmobius.gameserver.network.Disconnection;
|
||||
import org.l2jmobius.gameserver.network.GameClient.GameClientState;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ClientSetTime;
|
||||
@@ -508,13 +504,6 @@ public class EnterWorld extends GameClientPacket
|
||||
}
|
||||
}
|
||||
|
||||
if (!nProtect.getInstance().checkRestriction(player, RestrictionType.RESTRICT_ENTER))
|
||||
{
|
||||
player.setImmobilized(true);
|
||||
player.disableAllSkills();
|
||||
ThreadPool.schedule(new Disconnection(player), 20000);
|
||||
}
|
||||
|
||||
// Elrokian Trap like L2OFF
|
||||
final ItemInstance rhand = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
|
||||
if ((rhand != null) && (rhand.getItemId() == 8763))
|
||||
|
@@ -16,8 +16,6 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import org.l2jmobius.commons.crypt.nProtect;
|
||||
|
||||
/**
|
||||
* @author zabbix Lets drink to code! Unknown Packet: ca 0000: 45 00 01 00 1e 37 a2 f5 00 00 00 00 00 00 00 00 E....7..........
|
||||
*/
|
||||
@@ -37,12 +35,6 @@ public class GameGuardReply extends GameClientPacket
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
// TODO: clean nProtect System
|
||||
if (!nProtect.getInstance().checkGameGuardRepy(getClient(), _reply))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
getClient().setGameGuardOk(true);
|
||||
}
|
||||
}
|
@@ -19,7 +19,6 @@ package org.l2jmobius.gameserver.network.clientpackets;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.gameserver.GameServer;
|
||||
import org.l2jmobius.gameserver.datatables.SkillTable;
|
||||
import org.l2jmobius.gameserver.model.Inventory;
|
||||
import org.l2jmobius.gameserver.model.Party;
|
||||
@@ -183,13 +182,6 @@ public class RequestRestart extends GameClientPacket
|
||||
// return the client to the authed status
|
||||
client.setState(GameClientState.AUTHED);
|
||||
|
||||
// before the char selection, check shutdown status
|
||||
if (GameServer.getSelectorThread().isShutdown())
|
||||
{
|
||||
getClient().closeNow();
|
||||
return;
|
||||
}
|
||||
|
||||
// Restart true
|
||||
sendPacket(RestartResponse.valueOf(true));
|
||||
|
||||
|
@@ -16,8 +16,6 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.serverpackets;
|
||||
|
||||
import org.l2jmobius.commons.crypt.nProtect;
|
||||
|
||||
/**
|
||||
* @author zabbix Lets drink to code!
|
||||
*/
|
||||
@@ -35,6 +33,5 @@ public class GameGuardQuery extends GameServerPacket
|
||||
public void writeImpl()
|
||||
{
|
||||
writeC(0xf9);
|
||||
nProtect.getInstance().sendGameGuardQuery(this);
|
||||
}
|
||||
}
|
||||
|
@@ -283,7 +283,7 @@ public class LoginClient extends MMOClient<MMOConnection<LoginClient>>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onForcedDisconnection(boolean critical)
|
||||
protected void onForcedDisconnection()
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
|
@@ -31,7 +31,6 @@ import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.database.DatabaseBackup;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.commons.enums.ServerMode;
|
||||
import org.l2jmobius.commons.mmocore.NetcoreConfig;
|
||||
import org.l2jmobius.commons.mmocore.SelectorConfig;
|
||||
import org.l2jmobius.commons.mmocore.SelectorThread;
|
||||
import org.l2jmobius.loginserver.network.gameserverpackets.ServerStatus;
|
||||
@@ -129,10 +128,10 @@ public class LoginServer
|
||||
}
|
||||
|
||||
final SelectorConfig sc = new SelectorConfig();
|
||||
sc.setMaxReadPerPass(NetcoreConfig.getInstance().MMO_MAX_READ_PER_PASS);
|
||||
sc.setMaxSendPerPass(NetcoreConfig.getInstance().MMO_MAX_SEND_PER_PASS);
|
||||
sc.setSleepTime(NetcoreConfig.getInstance().MMO_SELECTOR_SLEEP_TIME);
|
||||
sc.setHelperBufferCount(NetcoreConfig.getInstance().MMO_HELPER_BUFFER_COUNT);
|
||||
sc.MAX_READ_PER_PASS = Config.MMO_MAX_READ_PER_PASS;
|
||||
sc.MAX_SEND_PER_PASS = Config.MMO_MAX_SEND_PER_PASS;
|
||||
sc.SLEEP_TIME = Config.MMO_SELECTOR_SLEEP_TIME;
|
||||
sc.HELPER_BUFFER_COUNT = Config.MMO_HELPER_BUFFER_COUNT;
|
||||
|
||||
final LoginPacketHandler lph = new LoginPacketHandler();
|
||||
final SelectorHelper sh = new SelectorHelper();
|
||||
|
Reference in New Issue
Block a user