Removal of nProtect and NetcoreConfig classes.

This commit is contained in:
MobiusDevelopment
2020-02-19 08:30:13 +00:00
parent 6a213de723
commit faa853de6b
26 changed files with 114 additions and 719 deletions

View File

@@ -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

View File

@@ -1156,6 +1156,26 @@ public class Config
public static long SESSION_TTL; public static long SESSION_TTL;
public static int MAX_LOGINSESSIONS; 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() public static void loadAccessConfig()
{ {
try try

View File

@@ -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();
}
}

View File

@@ -42,5 +42,5 @@ public abstract class MMOClient<T extends MMOConnection<?>>
protected abstract void onDisconnection(); protected abstract void onDisconnection();
protected abstract void onForcedDisconnection(boolean critical); protected abstract void onForcedDisconnection();
} }

View File

@@ -17,7 +17,6 @@
package org.l2jmobius.commons.mmocore; package org.l2jmobius.commons.mmocore;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.Socket; import java.net.Socket;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
@@ -36,8 +35,6 @@ public class MMOConnection<T extends MMOClient<?>>
private final Socket _socket; private final Socket _socket;
private final InputStream _socket_is;
private final InetAddress _address; private final InetAddress _address;
private final ReadableByteChannel _readableByteChannel; private final ReadableByteChannel _readableByteChannel;
@@ -60,16 +57,13 @@ public class MMOConnection<T extends MMOClient<?>>
private T _client; 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; _selectorThread = selectorThread;
_socket = socket; _socket = socket;
_address = socket.getInetAddress(); _address = socket.getInetAddress();
_readableByteChannel = socket.getChannel(); _readableByteChannel = socket.getChannel();
_writableByteChannel = socket.getChannel(); _writableByteChannel = socket.getChannel();
_socket_is = socket.getInputStream();
_port = socket.getPort(); _port = socket.getPort();
_selectionKey = key; _selectionKey = key;
@@ -100,7 +94,7 @@ public class MMOConnection<T extends MMOClient<?>>
_sendQueue.addLast(sp); _sendQueue.addLast(sp);
} }
if (!_sendQueue.isEmpty() && _selectionKey.isValid()) if (!_sendQueue.isEmpty())
{ {
try try
{ {
@@ -163,6 +157,7 @@ public class MMOConnection<T extends MMOClient<?>>
{ {
temp.put(_primaryWriteBuffer); temp.put(_primaryWriteBuffer);
_selectorThread.recycleBuffer(_primaryWriteBuffer); _selectorThread.recycleBuffer(_primaryWriteBuffer);
_primaryWriteBuffer = temp;
} }
else else
{ {
@@ -200,32 +195,6 @@ public class MMOConnection<T extends MMOClient<?>>
return _readBuffer; 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() public boolean isClosed()
{ {
return _pendingClose; return _pendingClose;
@@ -269,16 +238,13 @@ public class MMOConnection<T extends MMOClient<?>>
} }
} }
if (_selectionKey.isValid()) try
{ {
try _selectionKey.interestOps(_selectionKey.interestOps() & ~SelectionKey.OP_WRITE);
{ }
_selectionKey.interestOps(_selectionKey.interestOps() & ~SelectionKey.OP_WRITE); catch (CancelledKeyException e)
} {
catch (CancelledKeyException e) // ignore
{
// not useful LOGGER
}
} }
// _closePacket = sp; // _closePacket = sp;

View File

@@ -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();
}
}

View File

@@ -19,106 +19,41 @@ package org.l2jmobius.commons.mmocore;
/** /**
* @author KenM * @author KenM
*/ */
public class SelectorConfig 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> * 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. * 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> * 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. * 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> * Defines how much time (in milis) should the selector sleep, an higher
* 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> * 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> * <BR>
* Recommended values:<BR> * Recommended values:<BR>
* 1 for minimal latency.<BR> * 1 for minimal latency.<BR>
* 10-30 for an latency/troughput trade-off based on your needs.<BR> * 10-30 for an latency/troughput trade-off based on your needs.<BR>
*/ */
private int sleepTime = 10; public int SLEEP_TIME = 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;
}
} }

View File

@@ -70,16 +70,16 @@ public class SelectorThread<T extends MMOClient<?>>extends Thread
{ {
super.setName("SelectorThread-" + super.getId()); super.setName("SelectorThread-" + super.getId());
HELPER_BUFFER_SIZE = sc.getHelperBufferSize(); HELPER_BUFFER_SIZE = sc.HELPER_BUFFER_SIZE;
HELPER_BUFFER_COUNT = sc.getHelperBufferCount(); HELPER_BUFFER_COUNT = sc.HELPER_BUFFER_COUNT;
MAX_SEND_PER_PASS = sc.getMaxSendPerPass(); MAX_SEND_PER_PASS = sc.MAX_SEND_PER_PASS;
MAX_READ_PER_PASS = sc.getMaxReadPerPass(); 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); DIRECT_WRITE_BUFFER = ByteBuffer.allocateDirect(sc.WRITE_BUFFER_SIZE).order(BYTE_ORDER);
WRITE_BUFFER = ByteBuffer.wrap(new byte[sc.getWriteBufferSize()]).order(BYTE_ORDER); WRITE_BUFFER = ByteBuffer.wrap(new byte[sc.WRITE_BUFFER_SIZE]).order(BYTE_ORDER);
READ_BUFFER = ByteBuffer.wrap(new byte[sc.getReadBufferSize()]).order(BYTE_ORDER); READ_BUFFER = ByteBuffer.wrap(new byte[sc.READ_BUFFER_SIZE]).order(BYTE_ORDER);
STRING_BUFFER = new NioNetStringBuffer(64 * 1024); STRING_BUFFER = new NioNetStringBuffer(64 * 1024);
@@ -208,16 +208,9 @@ public class SelectorThread<T extends MMOClient<?>>extends Thread
{ {
while (!_pendingClose.isEmpty()) while (!_pendingClose.isEmpty())
{ {
try con = _pendingClose.removeFirst();
{ writeClosePacket(con);
con = _pendingClose.removeFirst(); closeConnectionImpl(con.getSelectionKey(), con);
writeClosePacket(con);
closeConnectionImpl(con.getSelectionKey(), con);
}
catch (Exception e)
{
e.printStackTrace();
}
} }
} }
@@ -241,7 +234,7 @@ public class SelectorThread<T extends MMOClient<?>>extends Thread
} }
catch (IOException e) catch (IOException e)
{ {
con.getClient().onForcedDisconnection(true); con.getClient().onForcedDisconnection();
closeConnectionImpl(key, con); closeConnectionImpl(key, con);
} }
@@ -288,6 +281,7 @@ public class SelectorThread<T extends MMOClient<?>>extends Thread
{ {
return; return;
} }
ByteBuffer buf = con.getReadBuffer(); ByteBuffer buf = con.getReadBuffer();
if (buf == null) if (buf == null)
{ {
@@ -302,18 +296,13 @@ public class SelectorThread<T extends MMOClient<?>>extends Thread
int result = -2; int result = -2;
boolean critical = true;
try try
{ {
result = con.read(buf); result = con.read(buf);
} }
catch (IOException e) catch (IOException e)
{ {
if (!con.isConnected() || !con.isChannelConnected()) // error handling goes bellow
{
critical = false;
}
} }
if (result > 0) if (result > 0)
@@ -360,7 +349,7 @@ public class SelectorThread<T extends MMOClient<?>>extends Thread
} }
case -2: case -2:
{ {
con.getClient().onForcedDisconnection(critical); con.getClient().onForcedDisconnection();
closeConnectionImpl(key, con); closeConnectionImpl(key, con);
break; break;
} }
@@ -379,7 +368,7 @@ public class SelectorThread<T extends MMOClient<?>>extends Thread
} }
case 1: 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); key.interestOps(key.interestOps() | SelectionKey.OP_READ);
// did we use the READ_BUFFER ? // 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? // do we got enough bytes for the packet?
if (dataPending <= buf.remaining()) if (dataPending <= buf.remaining())
{ {
boolean read = true;
// avoid parsing dummy packets (packets without body) // avoid parsing dummy packets (packets without body)
if (dataPending > 0) if (dataPending > 0)
{ {
final int pos = buf.position(); final int pos = buf.position();
if (!parseClientPacket(pos, buf, dataPending, client)) parseClientPacket(pos, buf, dataPending, client);
{
read = false;
}
buf.position(pos + dataPending); buf.position(pos + dataPending);
} }
// if we are done with this buffer // if we are done with this buffer
if (!buf.hasRemaining()) if (!buf.hasRemaining())
{ {
@@ -426,17 +412,17 @@ public class SelectorThread<T extends MMOClient<?>>extends Thread
{ {
READ_BUFFER.clear(); READ_BUFFER.clear();
} }
read = false; return false;
} }
return read; return true;
} }
// we don`t have enough bytes for the dataPacket so we need // we don't have enough bytes for the dataPacket so we need to read
// to read
key.interestOps(key.interestOps() | SelectionKey.OP_READ); key.interestOps(key.interestOps() | SelectionKey.OP_READ);
// did we use the READ_BUFFER ? // did we use the READ_BUFFER ?
if (buf == READ_BUFFER) if (buf == READ_BUFFER)
{ {
// move it`s position // move it's position
buf.position(buf.position() - HEADER_SIZE); buf.position(buf.position() - HEADER_SIZE);
// move the pending byte to the connections READ_BUFFER // move the pending byte to the connections READ_BUFFER
allocateReadBuffer(con); allocateReadBuffer(con);
@@ -457,7 +443,7 @@ public class SelectorThread<T extends MMOClient<?>>extends Thread
READ_BUFFER.clear(); 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); final boolean ret = client.decrypt(buf, dataSize);
@@ -466,7 +452,6 @@ public class SelectorThread<T extends MMOClient<?>>extends Thread
// apply limit // apply limit
final int limit = buf.limit(); final int limit = buf.limit();
buf.limit(pos + dataSize); buf.limit(pos + dataSize);
final ReceivablePacket<T> cp = _packetHandler.handlePacket(buf, client); final ReceivablePacket<T> cp = _packetHandler.handlePacket(buf, client);
if (cp != null) if (cp != null)
@@ -486,8 +471,6 @@ public class SelectorThread<T extends MMOClient<?>>extends Thread
buf.limit(limit); buf.limit(limit);
} }
return true;
} }
private final void writeClosePacket(MMOConnection<T> con) private final void writeClosePacket(MMOConnection<T> con)
@@ -566,7 +549,7 @@ public class SelectorThread<T extends MMOClient<?>>extends Thread
} }
else else
{ {
con.getClient().onForcedDisconnection(true); con.getClient().onForcedDisconnection();
closeConnectionImpl(key, con); closeConnectionImpl(key, con);
} }
} }
@@ -698,11 +681,6 @@ public class SelectorThread<T extends MMOClient<?>>extends Thread
_shutdown = true; _shutdown = true;
} }
public boolean isShutdown()
{
return _shutdown;
}
protected void closeSelectorThread() protected void closeSelectorThread()
{ {
for (SelectionKey key : _selector.keys()) for (SelectionKey key : _selector.keys())

View File

@@ -29,10 +29,8 @@ import java.util.logging.Logger;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.crypt.nProtect;
import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.commons.enums.ServerMode; import org.l2jmobius.commons.enums.ServerMode;
import org.l2jmobius.commons.mmocore.NetcoreConfig;
import org.l2jmobius.commons.mmocore.SelectorConfig; import org.l2jmobius.commons.mmocore.SelectorConfig;
import org.l2jmobius.commons.mmocore.SelectorThread; import org.l2jmobius.commons.mmocore.SelectorThread;
import org.l2jmobius.commons.util.DeadlockDetector; import org.l2jmobius.commons.util.DeadlockDetector;
@@ -195,12 +193,6 @@ public class GameServer
CrestCache.getInstance(); CrestCache.getInstance();
ScriptEngineManager.getInstance(); ScriptEngineManager.getInstance();
nProtect.getInstance();
if (nProtect.isEnabled())
{
LOGGER.info("nProtect System Enabled");
}
Util.printSection("World"); Util.printSection("World");
World.getInstance(); World.getInstance();
MapRegionData.getInstance(); MapRegionData.getInstance();
@@ -507,10 +499,10 @@ public class GameServer
_loginThread.start(); _loginThread.start();
final SelectorConfig sc = new SelectorConfig(); final SelectorConfig sc = new SelectorConfig();
sc.setMaxReadPerPass(NetcoreConfig.getInstance().MMO_MAX_READ_PER_PASS); sc.MAX_READ_PER_PASS = Config.MMO_MAX_READ_PER_PASS;
sc.setMaxSendPerPass(NetcoreConfig.getInstance().MMO_MAX_SEND_PER_PASS); sc.MAX_SEND_PER_PASS = Config.MMO_MAX_SEND_PER_PASS;
sc.setSleepTime(NetcoreConfig.getInstance().MMO_SELECTOR_SLEEP_TIME); sc.SLEEP_TIME = Config.MMO_SELECTOR_SLEEP_TIME;
sc.setHelperBufferCount(NetcoreConfig.getInstance().MMO_HELPER_BUFFER_COUNT); sc.HELPER_BUFFER_COUNT = Config.MMO_HELPER_BUFFER_COUNT;
_gamePacketHandler = new GamePacketHandler(); _gamePacketHandler = new GamePacketHandler();

View File

@@ -311,18 +311,9 @@ public class LoginServerThread extends Thread
sendPacket(pig); sendPacket(pig);
wcToRemove.gameClient.setState(GameClientState.AUTHED); wcToRemove.gameClient.setState(GameClientState.AUTHED);
wcToRemove.gameClient.setSessionId(wcToRemove.session); wcToRemove.gameClient.setSessionId(wcToRemove.session);
// before the char selection, check shutdown status final CharSelectInfo cl = new CharSelectInfo(wcToRemove.account, wcToRemove.gameClient.getSessionId().playOkID1);
if (GameServer.getSelectorThread().isShutdown()) wcToRemove.gameClient.getConnection().sendPacket(cl);
{ wcToRemove.gameClient.setCharSelection(cl.getCharInfo());
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());
}
} }
else else
{ {

View File

@@ -38,7 +38,6 @@ import java.util.concurrent.locks.ReentrantLock;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.crypt.nProtect;
import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.commons.util.Rnd; import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.GameTimeController; import org.l2jmobius.gameserver.GameTimeController;
@@ -4583,11 +4582,6 @@ public class PlayerInstance extends Playable
*/ */
public void setClient(GameClient client) public void setClient(GameClient client)
{ {
if ((client == null) && (_client != null))
{
_client.stopGuardTask();
nProtect.getInstance().closeSession(_client);
}
_client = client; _client = client;
} }

View File

@@ -25,8 +25,6 @@ import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.l2jmobius.commons.concurrent.ThreadPool; 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.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.datatables.sql.ClanTable; import org.l2jmobius.gameserver.datatables.sql.ClanTable;
import org.l2jmobius.gameserver.datatables.sql.NpcTable; import org.l2jmobius.gameserver.datatables.sql.NpcTable;
@@ -434,11 +432,6 @@ public class FortSiege
// Schedule a task to prepare auto siege end // Schedule a task to prepare auto siege end
_siegeEndDate = Calendar.getInstance(); _siegeEndDate = Calendar.getInstance();
_siegeEndDate.add(Calendar.MINUTE, FortSiegeManager.getInstance().getSiegeLength()); _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 ThreadPool.schedule(new ScheduleEndSiegeTask(getFort()), 1000); // Prepare auto end task
announceToPlayer("The siege of " + getFort().getName() + " has started!", false); announceToPlayer("The siege of " + getFort().getName() + " has started!", false);

View File

@@ -27,8 +27,6 @@ import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.l2jmobius.commons.concurrent.ThreadPool; 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.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.datatables.sql.ClanTable; import org.l2jmobius.gameserver.datatables.sql.ClanTable;
import org.l2jmobius.gameserver.datatables.sql.NpcTable; import org.l2jmobius.gameserver.datatables.sql.NpcTable;
@@ -600,11 +598,7 @@ public class Siege
// Schedule a task to prepare auto siege end // Schedule a task to prepare auto siege end
_siegeEndDate = Calendar.getInstance(); _siegeEndDate = Calendar.getInstance();
_siegeEndDate.add(Calendar.MINUTE, SiegeManager.getInstance().getSiegeLength()); _siegeEndDate.add(Calendar.MINUTE, SiegeManager.getInstance().getSiegeLength());
nProtect.getInstance().checkRestriction(null, RestrictionType.RESTRICT_EVENT, new Object[]
{
Siege.class,
this
});
// Prepare auto end task // Prepare auto end task
ThreadPool.schedule(new ScheduleEndSiegeTask(getCastle()), 1000); ThreadPool.schedule(new ScheduleEndSiegeTask(getCastle()), 1000);

View File

@@ -16,7 +16,7 @@
*/ */
package org.l2jmobius.gameserver.network; package org.l2jmobius.gameserver.network;
import org.l2jmobius.commons.mmocore.NetcoreConfig; import org.l2jmobius.Config;
public class ClientStats public class ClientStats
{ {
@@ -53,13 +53,13 @@ public class ClientStats
public 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]; _packetsInSecond = new int[BUFFER_SIZE];
_head = BUFFER_SIZE - 1; _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() protected final boolean dropPacket()
{ {
@@ -72,9 +72,8 @@ public class ClientStats
} }
/** /**
* Later during flood returns true (and send ActionFailed) once per second.
* @param queueSize * @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) protected final boolean countPacket(int queueSize)
{ {
@@ -93,8 +92,8 @@ public class ClientStats
} }
/** /**
* Counts unknown packets and return true if threshold is reached. * Counts unknown packets.
* @return * @return true if threshold is reached.
*/ */
protected final boolean countUnknownPacket() protected final boolean countUnknownPacket()
{ {
@@ -109,13 +108,13 @@ public class ClientStats
} }
_unknownPacketsInMin++; _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 * @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) protected final boolean countBurst(int count)
{ {
@@ -124,7 +123,7 @@ public class ClientStats
maxBurstSize = count; maxBurstSize = count;
} }
if (count < NetcoreConfig.getInstance().CLIENT_PACKET_QUEUE_MAX_BURST_SIZE) if (count < Config.CLIENT_PACKET_QUEUE_MAX_BURST_SIZE)
{ {
return false; return false;
} }
@@ -134,8 +133,8 @@ public class ClientStats
} }
/** /**
* Counts queue overflows and return true if threshold is reached. * Counts queue overflows.
* @return * @return true if threshold is reached.
*/ */
protected final boolean countQueueOverflow() protected final boolean countQueueOverflow()
{ {
@@ -151,12 +150,12 @@ public class ClientStats
} }
_overflowsInMin++; _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. * Counts underflow exceptions.
* @return * @return true if threshold is reached.
*/ */
protected final boolean countUnderflowException() protected final boolean countUnderflowException()
{ {
@@ -171,26 +170,24 @@ public class ClientStats
} }
_underflowReadsInMin++; _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 true if maximum number of floods per minute is reached.
* @return
*/ */
protected final boolean countFloods() 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() 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 true if flood detected first and ActionFailed packet need to be sent. Later during flood returns true (and send ActionFailed) once per second.
* @return
*/ */
private final synchronized boolean countPacket() private final synchronized boolean countPacket()
{ {
@@ -201,7 +198,7 @@ public class ClientStats
_packetCountStartTick = tick; _packetCountStartTick = tick;
// clear flag if no more flooding during last seconds // 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; _floodDetected = false;
} }
@@ -221,7 +218,7 @@ public class ClientStats
final int count = ++_packetsInSecond[_head]; final int count = ++_packetsInSecond[_head];
if (!_floodDetected) if (!_floodDetected)
{ {
if (count > NetcoreConfig.getInstance().CLIENT_PACKET_QUEUE_MAX_PACKETS_PER_SECOND) if (count > Config.CLIENT_PACKET_QUEUE_MAX_PACKETS_PER_SECOND)
{ {
shortFloods++; shortFloods++;
} }

View File

@@ -32,11 +32,9 @@ import java.util.logging.Logger;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.crypt.nProtect;
import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.commons.mmocore.MMOClient; import org.l2jmobius.commons.mmocore.MMOClient;
import org.l2jmobius.commons.mmocore.MMOConnection; import org.l2jmobius.commons.mmocore.MMOConnection;
import org.l2jmobius.commons.mmocore.NetcoreConfig;
import org.l2jmobius.commons.mmocore.ReceivablePacket; import org.l2jmobius.commons.mmocore.ReceivablePacket;
import org.l2jmobius.gameserver.LoginServerThread; import org.l2jmobius.gameserver.LoginServerThread;
import org.l2jmobius.gameserver.LoginServerThread.SessionKey; 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.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed; import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import org.l2jmobius.gameserver.network.serverpackets.GameServerPacket; 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.network.serverpackets.ServerClose;
import org.l2jmobius.gameserver.util.EventData; import org.l2jmobius.gameserver.util.EventData;
import org.l2jmobius.gameserver.util.FloodProtectors; import org.l2jmobius.gameserver.util.FloodProtectors;
@@ -93,9 +90,6 @@ public class GameClient extends MMOClient<MMOConnection<GameClient>> implements
private final long _connectionStartTime; private final long _connectionStartTime;
private final List<Integer> _charSlotMapping = new ArrayList<>(); private final List<Integer> _charSlotMapping = new ArrayList<>();
// Task
private ScheduledFuture<?> _guardCheckTask = null;
protected ScheduledFuture<?> _cleanupTask = null; protected ScheduledFuture<?> _cleanupTask = null;
private final ClientStats _stats; private final ClientStats _stats;
@@ -103,14 +97,8 @@ public class GameClient extends MMOClient<MMOConnection<GameClient>> implements
// Crypt // Crypt
private final GameCrypt _crypt; private final GameCrypt _crypt;
// Flood protection
public long packetsNextSendTick = 0;
protected boolean _closenow = true;
private boolean _isDetached = false; private boolean _isDetached = false;
protected boolean _forcedToClose = false;
private final ArrayBlockingQueue<ReceivablePacket<GameClient>> _packetQueue; private final ArrayBlockingQueue<ReceivablePacket<GameClient>> _packetQueue;
private final ReentrantLock _queueLock = new ReentrantLock(); private final ReentrantLock _queueLock = new ReentrantLock();
@@ -123,17 +111,7 @@ public class GameClient extends MMOClient<MMOConnection<GameClient>> implements
_connectionStartTime = System.currentTimeMillis(); _connectionStartTime = System.currentTimeMillis();
_crypt = new GameCrypt(); _crypt = new GameCrypt();
_stats = new ClientStats(); _stats = new ClientStats();
_packetQueue = new ArrayBlockingQueue<>(NetcoreConfig.getInstance().CLIENT_PACKET_QUEUE_SIZE); _packetQueue = new ArrayBlockingQueue<>(Config.CLIENT_PACKET_QUEUE_SIZE);
_guardCheckTask = nProtect.getInstance().startTask(this);
ThreadPool.schedule(() ->
{
if (_closenow)
{
close(new LeaveWorld());
}
}, 4000);
} }
public byte[] enableCrypt() public byte[] enableCrypt()
@@ -170,7 +148,6 @@ public class GameClient extends MMOClient<MMOConnection<GameClient>> implements
@Override @Override
public boolean decrypt(ByteBuffer buf, int size) public boolean decrypt(ByteBuffer buf, int size)
{ {
_closenow = false;
_crypt.decrypt(buf.array(), buf.position(), size); _crypt.decrypt(buf.array(), buf.position(), size);
return true; return true;
} }
@@ -538,24 +515,12 @@ public class GameClient extends MMOClient<MMOConnection<GameClient>> implements
} }
@Override @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 // the force operation will allow to not save client position to prevent again criticals and stuck
closeNow(); closeNow();
} }
public void stopGuardTask()
{
if (_guardCheckTask != null)
{
_guardCheckTask.cancel(true);
_guardCheckTask = null;
}
}
@Override @Override
public void onDisconnection() public void onDisconnection()
{ {
@@ -585,7 +550,6 @@ public class GameClient extends MMOClient<MMOConnection<GameClient>> implements
*/ */
public void close(int delay) public void close(int delay)
{ {
close(ServerClose.STATIC_PACKET); close(ServerClose.STATIC_PACKET);
synchronized (this) synchronized (this)
{ {
@@ -595,8 +559,6 @@ public class GameClient extends MMOClient<MMOConnection<GameClient>> implements
} }
_cleanupTask = ThreadPool.schedule(new CleanupTask(), delay); // delayed _cleanupTask = ThreadPool.schedule(new CleanupTask(), delay); // delayed
} }
stopGuardTask();
nProtect.getInstance().closeSession(this);
} }
public String getIpAddress() public String getIpAddress()
@@ -703,16 +665,8 @@ public class GameClient extends MMOClient<MMOConnection<GameClient>> implements
// prevent closing again // prevent closing again
player.setClient(null); player.setClient(null);
player.deleteMe(); player.deleteMe();
player.store(true);
try
{
player.store(_forcedToClose);
}
catch (Exception e2)
{
}
} }
setPlayer(null); setPlayer(null);
@@ -990,11 +944,6 @@ public class GameClient extends MMOClient<MMOConnection<GameClient>> implements
} }
} }
public boolean isForcedToClose()
{
return _forcedToClose;
}
public void setProtocolVersion(int version) public void setProtocolVersion(int version)
{ {
_protocolVersion = version; _protocolVersion = version;

View File

@@ -24,7 +24,6 @@ import org.l2jmobius.commons.mmocore.IClientFactory;
import org.l2jmobius.commons.mmocore.IMMOExecutor; import org.l2jmobius.commons.mmocore.IMMOExecutor;
import org.l2jmobius.commons.mmocore.IPacketHandler; import org.l2jmobius.commons.mmocore.IPacketHandler;
import org.l2jmobius.commons.mmocore.MMOConnection; import org.l2jmobius.commons.mmocore.MMOConnection;
import org.l2jmobius.commons.mmocore.NetcoreConfig;
import org.l2jmobius.commons.mmocore.ReceivablePacket; import org.l2jmobius.commons.mmocore.ReceivablePacket;
import org.l2jmobius.commons.util.Util; import org.l2jmobius.commons.util.Util;
import org.l2jmobius.gameserver.network.GameClient.GameClientState; 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) private void printDebug(int opcode, ByteBuffer buf, GameClientState state, GameClient client)
{ {
if (!NetcoreConfig.getInstance().PACKET_HANDLER_DEBUG) if (!Config.PACKET_HANDLER_DEBUG)
{ {
return; 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) 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; return;
} }

View File

@@ -22,7 +22,6 @@ import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException; import java.util.regex.PatternSyntaxException;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.gameserver.GameServer;
import org.l2jmobius.gameserver.datatables.ItemTable; import org.l2jmobius.gameserver.datatables.ItemTable;
import org.l2jmobius.gameserver.datatables.SkillTable; import org.l2jmobius.gameserver.datatables.SkillTable;
import org.l2jmobius.gameserver.datatables.sql.CharNameTable; import org.l2jmobius.gameserver.datatables.sql.CharNameTable;
@@ -287,13 +286,6 @@ public class CharacterCreate extends GameClientPacket
newChar.store(); newChar.store();
newChar.deleteMe(); // Release the world of this character and it's inventory 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 // Send char list
final CharSelectInfo cl = new CharSelectInfo(client.getAccountName(), client.getSessionId().playOkID1); final CharSelectInfo cl = new CharSelectInfo(client.getAccountName(), client.getSessionId().playOkID1);
client.getConnection().sendPacket(cl); client.getConnection().sendPacket(cl);

View File

@@ -18,7 +18,6 @@ package org.l2jmobius.gameserver.network.clientpackets;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.l2jmobius.gameserver.GameServer;
import org.l2jmobius.gameserver.network.serverpackets.CharDeleteFail; import org.l2jmobius.gameserver.network.serverpackets.CharDeleteFail;
import org.l2jmobius.gameserver.network.serverpackets.CharDeleteOk; import org.l2jmobius.gameserver.network.serverpackets.CharDeleteOk;
import org.l2jmobius.gameserver.network.serverpackets.CharSelectInfo; import org.l2jmobius.gameserver.network.serverpackets.CharSelectInfo;
@@ -77,13 +76,6 @@ public class CharacterDelete extends GameClientPacket
LOGGER.warning("ERROR " + getType() + ": " + e); 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); final CharSelectInfo cl = new CharSelectInfo(getClient().getAccountName(), getClient().getSessionId().playOkID1, 0);
sendPacket(cl); sendPacket(cl);
getClient().setCharSelection(cl.getCharInfo()); getClient().setCharSelection(cl.getCharInfo());

View File

@@ -16,7 +16,6 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.gameserver.GameServer;
import org.l2jmobius.gameserver.network.serverpackets.CharSelectInfo; import org.l2jmobius.gameserver.network.serverpackets.CharSelectInfo;
public class CharacterRestore extends GameClientPacket 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); final CharSelectInfo cl = new CharSelectInfo(getClient().getAccountName(), getClient().getSessionId().playOkID1, 0);
sendPacket(cl); sendPacket(cl);
getClient().setCharSelection(cl.getCharInfo()); getClient().setCharSelection(cl.getCharInfo());

View File

@@ -18,7 +18,6 @@ package org.l2jmobius.gameserver.network.clientpackets;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.l2jmobius.commons.crypt.nProtect;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.GameClient.GameClientState; import org.l2jmobius.gameserver.network.GameClient.GameClientState;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed; import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
@@ -83,7 +82,6 @@ public class CharacterSelected extends GameClientPacket
cha.setClient(getClient()); cha.setClient(getClient());
getClient().setPlayer(cha); getClient().setPlayer(cha);
nProtect.getInstance().sendRequest(getClient());
getClient().setState(GameClientState.ENTERING); getClient().setState(GameClientState.ENTERING);
sendPacket(new CharSelected(cha, getClient().getSessionId().playOkID1)); sendPacket(new CharSelected(cha, getClient().getSessionId().playOkID1));
} }

View File

@@ -26,9 +26,6 @@ import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException; import java.util.regex.PatternSyntaxException;
import org.l2jmobius.Config; 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.GameTimeController;
import org.l2jmobius.gameserver.communitybbs.Manager.MailBBSManager; import org.l2jmobius.gameserver.communitybbs.Manager.MailBBSManager;
import org.l2jmobius.gameserver.datatables.SkillTable; 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.Quest;
import org.l2jmobius.gameserver.model.quest.QuestState; import org.l2jmobius.gameserver.model.quest.QuestState;
import org.l2jmobius.gameserver.model.zone.ZoneId; 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.GameClient.GameClientState;
import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ClientSetTime; 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 // Elrokian Trap like L2OFF
final ItemInstance rhand = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND); final ItemInstance rhand = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
if ((rhand != null) && (rhand.getItemId() == 8763)) if ((rhand != null) && (rhand.getItemId() == 8763))

View File

@@ -16,8 +16,6 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; 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.......... * @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 @Override
protected void runImpl() protected void runImpl()
{ {
// TODO: clean nProtect System
if (!nProtect.getInstance().checkGameGuardRepy(getClient(), _reply))
{
return;
}
getClient().setGameGuardOk(true); getClient().setGameGuardOk(true);
} }
} }

View File

@@ -19,7 +19,6 @@ package org.l2jmobius.gameserver.network.clientpackets;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.gameserver.GameServer;
import org.l2jmobius.gameserver.datatables.SkillTable; import org.l2jmobius.gameserver.datatables.SkillTable;
import org.l2jmobius.gameserver.model.Inventory; import org.l2jmobius.gameserver.model.Inventory;
import org.l2jmobius.gameserver.model.Party; import org.l2jmobius.gameserver.model.Party;
@@ -183,13 +182,6 @@ public class RequestRestart extends GameClientPacket
// return the client to the authed status // return the client to the authed status
client.setState(GameClientState.AUTHED); client.setState(GameClientState.AUTHED);
// before the char selection, check shutdown status
if (GameServer.getSelectorThread().isShutdown())
{
getClient().closeNow();
return;
}
// Restart true // Restart true
sendPacket(RestartResponse.valueOf(true)); sendPacket(RestartResponse.valueOf(true));

View File

@@ -16,8 +16,6 @@
*/ */
package org.l2jmobius.gameserver.network.serverpackets; package org.l2jmobius.gameserver.network.serverpackets;
import org.l2jmobius.commons.crypt.nProtect;
/** /**
* @author zabbix Lets drink to code! * @author zabbix Lets drink to code!
*/ */
@@ -35,6 +33,5 @@ public class GameGuardQuery extends GameServerPacket
public void writeImpl() public void writeImpl()
{ {
writeC(0xf9); writeC(0xf9);
nProtect.getInstance().sendGameGuardQuery(this);
} }
} }

View File

@@ -283,7 +283,7 @@ public class LoginClient extends MMOClient<MMOConnection<LoginClient>>
} }
@Override @Override
protected void onForcedDisconnection(boolean critical) protected void onForcedDisconnection()
{ {
// Empty // Empty
} }

View File

@@ -31,7 +31,6 @@ import org.l2jmobius.Config;
import org.l2jmobius.commons.database.DatabaseBackup; import org.l2jmobius.commons.database.DatabaseBackup;
import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.commons.enums.ServerMode; import org.l2jmobius.commons.enums.ServerMode;
import org.l2jmobius.commons.mmocore.NetcoreConfig;
import org.l2jmobius.commons.mmocore.SelectorConfig; import org.l2jmobius.commons.mmocore.SelectorConfig;
import org.l2jmobius.commons.mmocore.SelectorThread; import org.l2jmobius.commons.mmocore.SelectorThread;
import org.l2jmobius.loginserver.network.gameserverpackets.ServerStatus; import org.l2jmobius.loginserver.network.gameserverpackets.ServerStatus;
@@ -129,10 +128,10 @@ public class LoginServer
} }
final SelectorConfig sc = new SelectorConfig(); final SelectorConfig sc = new SelectorConfig();
sc.setMaxReadPerPass(NetcoreConfig.getInstance().MMO_MAX_READ_PER_PASS); sc.MAX_READ_PER_PASS = Config.MMO_MAX_READ_PER_PASS;
sc.setMaxSendPerPass(NetcoreConfig.getInstance().MMO_MAX_SEND_PER_PASS); sc.MAX_SEND_PER_PASS = Config.MMO_MAX_SEND_PER_PASS;
sc.setSleepTime(NetcoreConfig.getInstance().MMO_SELECTOR_SLEEP_TIME); sc.SLEEP_TIME = Config.MMO_SELECTOR_SLEEP_TIME;
sc.setHelperBufferCount(NetcoreConfig.getInstance().MMO_HELPER_BUFFER_COUNT); sc.HELPER_BUFFER_COUNT = Config.MMO_HELPER_BUFFER_COUNT;
final LoginPacketHandler lph = new LoginPacketHandler(); final LoginPacketHandler lph = new LoginPacketHandler();
final SelectorHelper sh = new SelectorHelper(); final SelectorHelper sh = new SelectorHelper();