Page 4 of 4

Re: L2j Killer - Attacker Gracia Final

Posted: Wed Feb 17, 2010 5:56 am
by janiii
moooo wrote:janiii, I tried this last night, but my server ended up deadlocking overnight. Unfortunately, I hastily closed the server without copying the errors. They're no longer in the logs also... If you happen to know out of miracle mind/server reading what might of happened, please do let me know :)
what did you tried last night? i dont understand..

Re: L2j Killer - Attacker Gracia Final

Posted: Wed Feb 17, 2010 6:22 am
by moooo
janiii wrote:
moooo wrote:janiii, I tried this last night, but my server ended up deadlocking overnight. Unfortunately, I hastily closed the server without copying the errors. They're no longer in the logs also... If you happen to know out of miracle mind/server reading what might of happened, please do let me know :)
what did you tried last night? i dont understand..
Adding this filter patch.

Re: L2j Killer - Attacker Gracia Final

Posted: Wed Feb 17, 2010 10:37 am
by JustLikeMe
Thanks Janii i will try it as soon as i get my pc back im upgrading it. I will try the .jar file first, otherwise i will try to get the Gracia Final sources by changing the svn repository location.

Re: L2j Killer - Attacker Gracia Final

Posted: Thu Feb 18, 2010 2:40 am
by badboy29
Janiii, i have this patch for gracia final:

Code: Select all

Index: java/net/sf/l2j/gameserver/GameServer.java===================================================================--- java/net/sf/l2j/gameserver/GameServer.java	(revision 1475)+++ java/net/sf/l2j/gameserver/GameServer.java	(working copy)@@ -121,6 +121,7 @@ import net.sf.l2j.gameserver.util.DynamicExtension; import net.sf.l2j.status.Status; import net.sf.l2j.util.DeadLockDetector;+import net.sf.l2j.util.IPv4Filter;  import org.mmocore.network.SelectorConfig; import org.mmocore.network.SelectorThread;@@ -439,7 +440,7 @@ 		sc.SLEEP_TIME = Config.MMO_SELECTOR_SLEEP_TIME; 		sc.HELPER_BUFFER_COUNT = Config.MMO_HELPER_BUFFER_COUNT; 		final L2GamePacketHandler gph = new L2GamePacketHandler();-		_selectorThread = new SelectorThread<L2GameClient>(sc, gph, gph, gph, null);+		_selectorThread = new SelectorThread<L2GameClient>(sc, gph, gph, gph, new IPv4Filter());  		InetAddress bindAddress = null; 		if (!Config.GAMESERVER_HOSTNAME.equals("*"))Index: java/net/sf/l2j/util/IPv4Filter.java===================================================================--- java/net/sf/l2j/util/IPv4Filter.java	(revision 0)+++ java/net/sf/l2j/util/IPv4Filter.java	(revision 0)@@ -0,0 +1,151 @@+/*+ * 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 net.sf.l2j.util;++import java.net.InetAddress;+import java.nio.channels.SocketChannel;+import java.util.ArrayList;+import java.util.HashMap;+import java.util.Map.Entry;++import org.mmocore.network.IAcceptFilter;++/**+ * Formatted Forsaiken's IPv4 filter [DrHouse]+ * + * @author Forsaiken+ *+ */+public class IPv4Filter implements IAcceptFilter, Runnable+{+	private HashMap<Integer, Flood> _ipFloodMap;+	private static final long SLEEP_TIME = 5000;+	+	public IPv4Filter()+	{+		_ipFloodMap = new HashMap<Integer, Flood>();+		Thread t = new Thread(this);+		t.setDaemon(true);+		t.start();+	}+	/**+	 * +	 * @param ip+	 * @return+	 */+	private static final int hash(byte[] ip)+	{+		return ip[0] & 0xFF | ip[1] << 8 & 0xFF00 | ip[2] << 16 & 0xFF0000 | ip[3] << 24 & 0xFF000000;+	}+	+	protected static final class Flood+	{+		long lastAccess;+		int trys;+		+		Flood()+		{+			lastAccess = System.currentTimeMillis();+			trys = 0;+		}+	}+	+	@Override+	public boolean accept(SocketChannel sc)+	{+		InetAddress addr = sc.socket().getInetAddress();+		int h = hash(addr.getAddress());+		+		long current = System.currentTimeMillis();+		Flood f;+		synchronized (_ipFloodMap)+		{+			f = _ipFloodMap.get(h);+		}+		if (f != null)+		{+			if (f.trys == -1)+			{+				f.lastAccess = current;+				return false;+			}+			+			if (f.lastAccess + 1000 > current)+			{+				f.lastAccess = current;+				+				if (f.trys >= 3)+				{+					f.trys = -1;+					return false;+				}+				+				f.trys++;+			}+			else+			{+				f.lastAccess = current;+			}+		}+		else+		{+			synchronized (_ipFloodMap)+			{+				_ipFloodMap.put(h, new Flood());+			}+		}+		+		return true;+	}++	@Override+	public void run()+	{+		while (true)+		{+			long reference = System.currentTimeMillis() - (1000 * 300);+			ArrayList<Integer> toRemove = new ArrayList<Integer>(50);+			+			synchronized (_ipFloodMap)+			{+				for (Entry<Integer, Flood> e : _ipFloodMap.entrySet())+				{+					Flood f = e.getValue();+					if (f.lastAccess < reference)+						toRemove.add(e.getKey());+				}+			}+			+			synchronized (_ipFloodMap)+			{+				for (Integer i : toRemove)+				{+					_ipFloodMap.remove(i);+				}+			}+			+			try+			{+				Thread.sleep(SLEEP_TIME);+			}+			catch (InterruptedException e)+			{+				+			}+		}+	}+	+}\ No newline at end of fileIndex: java/net/sf/l2j/loginserver/SelectorHelper.java===================================================================--- java/net/sf/l2j/loginserver/SelectorHelper.java	(revision 1475)+++ java/net/sf/l2j/loginserver/SelectorHelper.java	(working copy)@@ -12,16 +12,13 @@  */ package net.sf.l2j.loginserver; -import java.net.InetAddress; import java.nio.channels.SocketChannel;-import java.util.ArrayList;-import java.util.HashMap;-import java.util.Map.Entry; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit;  import net.sf.l2j.loginserver.serverpackets.Init;+import net.sf.l2j.util.IPv4Filter;  import org.mmocore.network.IAcceptFilter; import org.mmocore.network.IClientFactory;@@ -33,18 +30,15 @@  *   * @author KenM  */-public class SelectorHelper extends Thread implements IMMOExecutor<L2LoginClient>,+public class SelectorHelper implements IMMOExecutor<L2LoginClient>,         IClientFactory<L2LoginClient>, IAcceptFilter {-	private HashMap<Integer, Flood> _ipFloodMap; 	private ThreadPoolExecutor _generalPacketsThreadPool;+	private IPv4Filter _ipv4filter;  	public SelectorHelper() 	{-		_generalPacketsThreadPool = new ThreadPoolExecutor(4, 6, 15L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());-		_ipFloodMap = new HashMap<Integer, Flood>();-		super.setDaemon(true);-		super.start();+		_ipv4filter = new IPv4Filter(); 	}  	/**@@ -73,110 +67,6 @@ 	 */ 	public boolean accept(SocketChannel sc) 	{-		InetAddress addr = sc.socket().getInetAddress();-		int h = hash(addr.getAddress());-		-		long current = System.currentTimeMillis();-		Flood f;-		synchronized (_ipFloodMap)-		{-			f = _ipFloodMap.get(h);-		}-		if (f != null)-		{-			if (f.trys == -1)-			{-				f.lastAccess = current;-				return false;-			}-			-			if (f.lastAccess + 1000 > current)-			{-				f.lastAccess = current;-				-				if (f.trys >= 3)-				{-					f.trys = -1;-					return false;-				}-				-				f.trys++;-			}-			else-			{-				f.lastAccess = current;-			}-		}-		else-		{-			synchronized (_ipFloodMap)-			{-				_ipFloodMap.put(h, new Flood());-			}-		}-		return !LoginController.getInstance().isBannedAddress(addr);+		return _ipv4filter.accept(sc) && !LoginController.getInstance().isBannedAddress(sc.socket().getInetAddress()); 	}-	-	/**-	 * -	 * @param ip-	 * @return-	 */-	private int hash(byte[] ip)-	{-		return ip[0] & 0xFF | ip[1] << 8 & 0xFF00 | ip[2] << 16 & 0xFF0000 | ip[3] << 24-		        & 0xFF000000;-	}-	-	private class Flood-	{-		long lastAccess;-		int trys;-		-		Flood()-		{-			lastAccess = System.currentTimeMillis();-			trys = 0;-		}-	}-	-	/**-	 * -	 * @see java.lang.Thread#run()-	 */-	@Override-	public void run()-	{-		while (true)-		{-			long reference = System.currentTimeMillis() - (1000 * 300);-			ArrayList<Integer> toRemove = new ArrayList<Integer>(50);-			synchronized (_ipFloodMap)-			{-				for (Entry<Integer, Flood> e : _ipFloodMap.entrySet())-				{-					Flood f = e.getValue();-					if (f.lastAccess < reference)-						toRemove.add(e.getKey());-				}-			}-			-			synchronized (_ipFloodMap)-			{-				for (Integer i : toRemove)-				{-					_ipFloodMap.remove(i);-				}-			}-			-			try-			{-				Thread.sleep(5000);-			}-			catch (InterruptedException e)-			{-				-			}-		}-	} }
Compiled without any error, i started the server also normally, but when I try to log it, I get this error:
Loading LoginController...
Cached 10 KeyPairs for RSA communication
Stored 20 keys for Blowfish communication
Loaded 127 server names
Loaded 1 registered Game Servers
Cached 10 RSA keys for Game Server communication.
Loaded 9 IP Bans.
Listening for GameServers on 127.0.0.1:9014
Telnet server is currently disabled.
Login Server ready on 127.0.0.1:2106
Exception in thread "SelectorThread-15" java.lang.NullPointerException
at net.sf.l2j.loginserver.SelectorHelper.execute(SelectorHelper.java:50)

at org.mmocore.network.SelectorThread.parseClientPacket(SelectorThread.j
ava:428)
at org.mmocore.network.SelectorThread.tryReadPacket(SelectorThread.java:
360)
at org.mmocore.network.SelectorThread.readPacket(SelectorThread.java:294
)
at org.mmocore.network.SelectorThread.run(SelectorThread.java:176)
How i solve this ?

OFF:
JustLikeMe wrote:Look i have scripts with packets com.l2jserver.gameserver . . . and they work in GRACIA FINAL so dont tell me crap.
And now? Lord knows everything, understand what I said? -.-"

Re: L2j Killer - Attacker Gracia Final

Posted: Thu Feb 18, 2010 11:54 am
by LasTravel
Don't use my patch have some lines wrong, use this from janii:

http://www.pastebin.cz/32158

Re: L2j Killer - Attacker Gracia Final

Posted: Thu Feb 18, 2010 5:54 pm
by badboy29
Hmm thanks :)

Re: L2j Killer - Attacker Gracia Final

Posted: Sun Feb 21, 2010 1:07 am
by JustLikeMe
Ok i only changed/added the code from http://www.pastebin.cz/32158 and i get errors in eclipse. My svn repositary location is http://l2jserver.com/svn/branches/L2_GameServer_T2.3 .
Error in GameServer.java:
import net.sf.l2j.util.IPv4Filter
eclipse:Syntax error on token "IPv4Filter", ; expected after this token

errors in SelectorHelper.java:
public class SelectorHelper extends Thread implements IMMOExecutor<L2LoginClient>,
IClientFactory<L2LoginClient>, IAcceptFilter
public class SelectorHelper implements IMMOExecutor<L2LoginClient>, IClientFactory<L2LoginClient>, IAcceptFilter

those errors are at start of the code

eclipse:first error:The type SelectorHelper must implement the inherited abstract method
IClientFactory<L2LoginClient>.create(MMOConnection<L2LoginClient>)

second error: Syntax error, insert "ClassBody" to complete ClassDeclaration

third error: The nested type SelectorHelper cannot hide an enclosing type
and in the IPv4Filter i got many many errors.

Re: L2j Killer - Attacker Gracia Final

Posted: Sun Feb 21, 2010 1:15 am
by moooo
JustLikeMe wrote:Ok i only changed/added the code from http://www.pastebin.cz/32158 and i get errors in eclipse. My svn repositary location is http://l2jserver.com/svn/branches/L2_GameServer_T2.3 .
Error in GameServer.java:
import net.sf.l2j.util.IPv4Filter
eclipse:Syntax error on token "IPv4Filter", ; expected after this token

errors in SelectorHelper.java:
public class SelectorHelper extends Thread implements IMMOExecutor<L2LoginClient>,
IClientFactory<L2LoginClient>, IAcceptFilter
public class SelectorHelper implements IMMOExecutor<L2LoginClient>, IClientFactory<L2LoginClient>, IAcceptFilter

those errors are at start of the code

eclipse:first error:The type SelectorHelper must implement the inherited abstract method
IClientFactory<L2LoginClient>.create(MMOConnection<L2LoginClient>)

second error: Syntax error, insert "ClassBody" to complete ClassDeclaration

third error: The nested type SelectorHelper cannot hide an enclosing type
and in the IPv4Filter i got many many errors.
Post a screenshot of these errors.

Re: L2j Killer - Attacker Gracia Final

Posted: Sun Feb 21, 2010 2:01 am
by JustLikeMe
Click on the images to see them fully. The IPv4Filter in the first image is shown as it was correct, but its from gracia epiloque from my previous sources ...
Image

Image

Image

Re: L2j Killer - Attacker Gracia Final

Posted: Sun Feb 21, 2010 5:15 am
by moooo
The first screenshot make sure your imports are correct.

The second, you forgot a ; after the IPv4Filter import.

Code: Select all

import net.sf.l2j.util.IPv4Filter;
The third...was not patched correctly. Make sure you're patching manually...The '<' and '>' are not correct.

Yours looks like this,

Code: Select all

private HashMap<Integer, Flood> _ ipFloodMap;
When it should be,

Code: Select all

private HashMap<Integer, Flood> _ipFloodMap;

Re: L2j Killer - Attacker Gracia Final

Posted: Sun Feb 21, 2010 2:16 pm
by JustLikeMe
Oh . . . when i copy the code from pastebin some + and # appear at start of each line and the spaces are not correct, so i took the code from the source code of the site and its not the same code lol?

Re: L2j Killer - Attacker Gracia Final

Posted: Sun Feb 21, 2010 2:19 pm
by LasTravel
JustLikeMe wrote:I took the IPv4Filter from janiii's link . . . can you post a working copy for Gracia Final?
http://www.pastebin.cz/32158

PD: READ

Re: L2j Killer - Attacker Gracia Final

Posted: Sun Feb 21, 2010 2:21 pm
by JustLikeMe
LasTravel wrote:
JustLikeMe wrote:I took the IPv4Filter from janiii's link . . . can you post a working copy for Gracia Final?
http://www.pastebin.cz/32158

PD: READ
Look my editedpost

Re: L2j Killer - Attacker Gracia Final

Posted: Sun Feb 21, 2010 4:54 pm
by JustLikeMe
I still have the same errors in SlectorHelper.java .

In IPv4Filter i have this error:
Image

In GameServer.java this error:
Image