diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
deleted file mode 100644
index 875759b72a..0000000000
--- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
+++ /dev/null
@@ -1,149 +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 .
- */
-package org.l2jmobius.loginserver.network.util;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.nio.channels.SocketChannel;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.logging.Logger;
-
-import org.l2jmobius.commons.util.Chronos;
-
-/**
- * IPv4 filter.
- * @author Forsaiken
- */
-public class IPv4Filter implements Runnable
-{
- protected final Logger LOGGER = Logger.getLogger(getClass().getName());
-
- private final HashMap _ipFloodMap;
- private static final long SLEEP_TIME = 5000;
-
- public IPv4Filter()
- {
- _ipFloodMap = new HashMap<>();
- final Thread t = new Thread(this, getClass().getSimpleName());
- t.setDaemon(true);
- t.start();
- }
-
- /**
- * @param ip
- * @return
- */
- private static 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 = Chronos.currentTimeMillis();
- trys = 0;
- }
- }
-
- public boolean accept(SocketChannel sc)
- {
- final InetAddress addr = sc.socket().getInetAddress();
- if (!(addr instanceof Inet4Address))
- {
- LOGGER.info("Someone tried to connect from something other than IPv4: " + addr.getHostAddress());
- return false;
- }
-
- final int h = hash(addr.getAddress());
- final long current = Chronos.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)
- {
- final long reference = Chronos.currentTimeMillis() - (1000 * 300);
- synchronized (_ipFloodMap)
- {
- final Iterator> it = _ipFloodMap.entrySet().iterator();
- while (it.hasNext())
- {
- final Flood f = it.next().getValue();
- if (f.lastAccess < reference)
- {
- it.remove();
- }
- }
- }
-
- try
- {
- Thread.sleep(SLEEP_TIME);
- }
- catch (InterruptedException e)
- {
- return;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
deleted file mode 100644
index 875759b72a..0000000000
--- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
+++ /dev/null
@@ -1,149 +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 .
- */
-package org.l2jmobius.loginserver.network.util;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.nio.channels.SocketChannel;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.logging.Logger;
-
-import org.l2jmobius.commons.util.Chronos;
-
-/**
- * IPv4 filter.
- * @author Forsaiken
- */
-public class IPv4Filter implements Runnable
-{
- protected final Logger LOGGER = Logger.getLogger(getClass().getName());
-
- private final HashMap _ipFloodMap;
- private static final long SLEEP_TIME = 5000;
-
- public IPv4Filter()
- {
- _ipFloodMap = new HashMap<>();
- final Thread t = new Thread(this, getClass().getSimpleName());
- t.setDaemon(true);
- t.start();
- }
-
- /**
- * @param ip
- * @return
- */
- private static 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 = Chronos.currentTimeMillis();
- trys = 0;
- }
- }
-
- public boolean accept(SocketChannel sc)
- {
- final InetAddress addr = sc.socket().getInetAddress();
- if (!(addr instanceof Inet4Address))
- {
- LOGGER.info("Someone tried to connect from something other than IPv4: " + addr.getHostAddress());
- return false;
- }
-
- final int h = hash(addr.getAddress());
- final long current = Chronos.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)
- {
- final long reference = Chronos.currentTimeMillis() - (1000 * 300);
- synchronized (_ipFloodMap)
- {
- final Iterator> it = _ipFloodMap.entrySet().iterator();
- while (it.hasNext())
- {
- final Flood f = it.next().getValue();
- if (f.lastAccess < reference)
- {
- it.remove();
- }
- }
- }
-
- try
- {
- Thread.sleep(SLEEP_TIME);
- }
- catch (InterruptedException e)
- {
- return;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
deleted file mode 100644
index 875759b72a..0000000000
--- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
+++ /dev/null
@@ -1,149 +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 .
- */
-package org.l2jmobius.loginserver.network.util;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.nio.channels.SocketChannel;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.logging.Logger;
-
-import org.l2jmobius.commons.util.Chronos;
-
-/**
- * IPv4 filter.
- * @author Forsaiken
- */
-public class IPv4Filter implements Runnable
-{
- protected final Logger LOGGER = Logger.getLogger(getClass().getName());
-
- private final HashMap _ipFloodMap;
- private static final long SLEEP_TIME = 5000;
-
- public IPv4Filter()
- {
- _ipFloodMap = new HashMap<>();
- final Thread t = new Thread(this, getClass().getSimpleName());
- t.setDaemon(true);
- t.start();
- }
-
- /**
- * @param ip
- * @return
- */
- private static 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 = Chronos.currentTimeMillis();
- trys = 0;
- }
- }
-
- public boolean accept(SocketChannel sc)
- {
- final InetAddress addr = sc.socket().getInetAddress();
- if (!(addr instanceof Inet4Address))
- {
- LOGGER.info("Someone tried to connect from something other than IPv4: " + addr.getHostAddress());
- return false;
- }
-
- final int h = hash(addr.getAddress());
- final long current = Chronos.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)
- {
- final long reference = Chronos.currentTimeMillis() - (1000 * 300);
- synchronized (_ipFloodMap)
- {
- final Iterator> it = _ipFloodMap.entrySet().iterator();
- while (it.hasNext())
- {
- final Flood f = it.next().getValue();
- if (f.lastAccess < reference)
- {
- it.remove();
- }
- }
- }
-
- try
- {
- Thread.sleep(SLEEP_TIME);
- }
- catch (InterruptedException e)
- {
- return;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
deleted file mode 100644
index 875759b72a..0000000000
--- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
+++ /dev/null
@@ -1,149 +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 .
- */
-package org.l2jmobius.loginserver.network.util;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.nio.channels.SocketChannel;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.logging.Logger;
-
-import org.l2jmobius.commons.util.Chronos;
-
-/**
- * IPv4 filter.
- * @author Forsaiken
- */
-public class IPv4Filter implements Runnable
-{
- protected final Logger LOGGER = Logger.getLogger(getClass().getName());
-
- private final HashMap _ipFloodMap;
- private static final long SLEEP_TIME = 5000;
-
- public IPv4Filter()
- {
- _ipFloodMap = new HashMap<>();
- final Thread t = new Thread(this, getClass().getSimpleName());
- t.setDaemon(true);
- t.start();
- }
-
- /**
- * @param ip
- * @return
- */
- private static 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 = Chronos.currentTimeMillis();
- trys = 0;
- }
- }
-
- public boolean accept(SocketChannel sc)
- {
- final InetAddress addr = sc.socket().getInetAddress();
- if (!(addr instanceof Inet4Address))
- {
- LOGGER.info("Someone tried to connect from something other than IPv4: " + addr.getHostAddress());
- return false;
- }
-
- final int h = hash(addr.getAddress());
- final long current = Chronos.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)
- {
- final long reference = Chronos.currentTimeMillis() - (1000 * 300);
- synchronized (_ipFloodMap)
- {
- final Iterator> it = _ipFloodMap.entrySet().iterator();
- while (it.hasNext())
- {
- final Flood f = it.next().getValue();
- if (f.lastAccess < reference)
- {
- it.remove();
- }
- }
- }
-
- try
- {
- Thread.sleep(SLEEP_TIME);
- }
- catch (InterruptedException e)
- {
- return;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
deleted file mode 100644
index 875759b72a..0000000000
--- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
+++ /dev/null
@@ -1,149 +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 .
- */
-package org.l2jmobius.loginserver.network.util;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.nio.channels.SocketChannel;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.logging.Logger;
-
-import org.l2jmobius.commons.util.Chronos;
-
-/**
- * IPv4 filter.
- * @author Forsaiken
- */
-public class IPv4Filter implements Runnable
-{
- protected final Logger LOGGER = Logger.getLogger(getClass().getName());
-
- private final HashMap _ipFloodMap;
- private static final long SLEEP_TIME = 5000;
-
- public IPv4Filter()
- {
- _ipFloodMap = new HashMap<>();
- final Thread t = new Thread(this, getClass().getSimpleName());
- t.setDaemon(true);
- t.start();
- }
-
- /**
- * @param ip
- * @return
- */
- private static 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 = Chronos.currentTimeMillis();
- trys = 0;
- }
- }
-
- public boolean accept(SocketChannel sc)
- {
- final InetAddress addr = sc.socket().getInetAddress();
- if (!(addr instanceof Inet4Address))
- {
- LOGGER.info("Someone tried to connect from something other than IPv4: " + addr.getHostAddress());
- return false;
- }
-
- final int h = hash(addr.getAddress());
- final long current = Chronos.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)
- {
- final long reference = Chronos.currentTimeMillis() - (1000 * 300);
- synchronized (_ipFloodMap)
- {
- final Iterator> it = _ipFloodMap.entrySet().iterator();
- while (it.hasNext())
- {
- final Flood f = it.next().getValue();
- if (f.lastAccess < reference)
- {
- it.remove();
- }
- }
- }
-
- try
- {
- Thread.sleep(SLEEP_TIME);
- }
- catch (InterruptedException e)
- {
- return;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
deleted file mode 100644
index 875759b72a..0000000000
--- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
+++ /dev/null
@@ -1,149 +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 .
- */
-package org.l2jmobius.loginserver.network.util;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.nio.channels.SocketChannel;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.logging.Logger;
-
-import org.l2jmobius.commons.util.Chronos;
-
-/**
- * IPv4 filter.
- * @author Forsaiken
- */
-public class IPv4Filter implements Runnable
-{
- protected final Logger LOGGER = Logger.getLogger(getClass().getName());
-
- private final HashMap _ipFloodMap;
- private static final long SLEEP_TIME = 5000;
-
- public IPv4Filter()
- {
- _ipFloodMap = new HashMap<>();
- final Thread t = new Thread(this, getClass().getSimpleName());
- t.setDaemon(true);
- t.start();
- }
-
- /**
- * @param ip
- * @return
- */
- private static 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 = Chronos.currentTimeMillis();
- trys = 0;
- }
- }
-
- public boolean accept(SocketChannel sc)
- {
- final InetAddress addr = sc.socket().getInetAddress();
- if (!(addr instanceof Inet4Address))
- {
- LOGGER.info("Someone tried to connect from something other than IPv4: " + addr.getHostAddress());
- return false;
- }
-
- final int h = hash(addr.getAddress());
- final long current = Chronos.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)
- {
- final long reference = Chronos.currentTimeMillis() - (1000 * 300);
- synchronized (_ipFloodMap)
- {
- final Iterator> it = _ipFloodMap.entrySet().iterator();
- while (it.hasNext())
- {
- final Flood f = it.next().getValue();
- if (f.lastAccess < reference)
- {
- it.remove();
- }
- }
- }
-
- try
- {
- Thread.sleep(SLEEP_TIME);
- }
- catch (InterruptedException e)
- {
- return;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
deleted file mode 100644
index 875759b72a..0000000000
--- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
+++ /dev/null
@@ -1,149 +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 .
- */
-package org.l2jmobius.loginserver.network.util;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.nio.channels.SocketChannel;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.logging.Logger;
-
-import org.l2jmobius.commons.util.Chronos;
-
-/**
- * IPv4 filter.
- * @author Forsaiken
- */
-public class IPv4Filter implements Runnable
-{
- protected final Logger LOGGER = Logger.getLogger(getClass().getName());
-
- private final HashMap _ipFloodMap;
- private static final long SLEEP_TIME = 5000;
-
- public IPv4Filter()
- {
- _ipFloodMap = new HashMap<>();
- final Thread t = new Thread(this, getClass().getSimpleName());
- t.setDaemon(true);
- t.start();
- }
-
- /**
- * @param ip
- * @return
- */
- private static 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 = Chronos.currentTimeMillis();
- trys = 0;
- }
- }
-
- public boolean accept(SocketChannel sc)
- {
- final InetAddress addr = sc.socket().getInetAddress();
- if (!(addr instanceof Inet4Address))
- {
- LOGGER.info("Someone tried to connect from something other than IPv4: " + addr.getHostAddress());
- return false;
- }
-
- final int h = hash(addr.getAddress());
- final long current = Chronos.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)
- {
- final long reference = Chronos.currentTimeMillis() - (1000 * 300);
- synchronized (_ipFloodMap)
- {
- final Iterator> it = _ipFloodMap.entrySet().iterator();
- while (it.hasNext())
- {
- final Flood f = it.next().getValue();
- if (f.lastAccess < reference)
- {
- it.remove();
- }
- }
- }
-
- try
- {
- Thread.sleep(SLEEP_TIME);
- }
- catch (InterruptedException e)
- {
- return;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
deleted file mode 100644
index 875759b72a..0000000000
--- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
+++ /dev/null
@@ -1,149 +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 .
- */
-package org.l2jmobius.loginserver.network.util;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.nio.channels.SocketChannel;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.logging.Logger;
-
-import org.l2jmobius.commons.util.Chronos;
-
-/**
- * IPv4 filter.
- * @author Forsaiken
- */
-public class IPv4Filter implements Runnable
-{
- protected final Logger LOGGER = Logger.getLogger(getClass().getName());
-
- private final HashMap _ipFloodMap;
- private static final long SLEEP_TIME = 5000;
-
- public IPv4Filter()
- {
- _ipFloodMap = new HashMap<>();
- final Thread t = new Thread(this, getClass().getSimpleName());
- t.setDaemon(true);
- t.start();
- }
-
- /**
- * @param ip
- * @return
- */
- private static 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 = Chronos.currentTimeMillis();
- trys = 0;
- }
- }
-
- public boolean accept(SocketChannel sc)
- {
- final InetAddress addr = sc.socket().getInetAddress();
- if (!(addr instanceof Inet4Address))
- {
- LOGGER.info("Someone tried to connect from something other than IPv4: " + addr.getHostAddress());
- return false;
- }
-
- final int h = hash(addr.getAddress());
- final long current = Chronos.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)
- {
- final long reference = Chronos.currentTimeMillis() - (1000 * 300);
- synchronized (_ipFloodMap)
- {
- final Iterator> it = _ipFloodMap.entrySet().iterator();
- while (it.hasNext())
- {
- final Flood f = it.next().getValue();
- if (f.lastAccess < reference)
- {
- it.remove();
- }
- }
- }
-
- try
- {
- Thread.sleep(SLEEP_TIME);
- }
- catch (InterruptedException e)
- {
- return;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
deleted file mode 100644
index 875759b72a..0000000000
--- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
+++ /dev/null
@@ -1,149 +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 .
- */
-package org.l2jmobius.loginserver.network.util;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.nio.channels.SocketChannel;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.logging.Logger;
-
-import org.l2jmobius.commons.util.Chronos;
-
-/**
- * IPv4 filter.
- * @author Forsaiken
- */
-public class IPv4Filter implements Runnable
-{
- protected final Logger LOGGER = Logger.getLogger(getClass().getName());
-
- private final HashMap _ipFloodMap;
- private static final long SLEEP_TIME = 5000;
-
- public IPv4Filter()
- {
- _ipFloodMap = new HashMap<>();
- final Thread t = new Thread(this, getClass().getSimpleName());
- t.setDaemon(true);
- t.start();
- }
-
- /**
- * @param ip
- * @return
- */
- private static 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 = Chronos.currentTimeMillis();
- trys = 0;
- }
- }
-
- public boolean accept(SocketChannel sc)
- {
- final InetAddress addr = sc.socket().getInetAddress();
- if (!(addr instanceof Inet4Address))
- {
- LOGGER.info("Someone tried to connect from something other than IPv4: " + addr.getHostAddress());
- return false;
- }
-
- final int h = hash(addr.getAddress());
- final long current = Chronos.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)
- {
- final long reference = Chronos.currentTimeMillis() - (1000 * 300);
- synchronized (_ipFloodMap)
- {
- final Iterator> it = _ipFloodMap.entrySet().iterator();
- while (it.hasNext())
- {
- final Flood f = it.next().getValue();
- if (f.lastAccess < reference)
- {
- it.remove();
- }
- }
- }
-
- try
- {
- Thread.sleep(SLEEP_TIME);
- }
- catch (InterruptedException e)
- {
- return;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/commons/mmocore/SelectorThread.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/commons/mmocore/SelectorThread.java
index a935406972..55bdf2e9d6 100644
--- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/commons/mmocore/SelectorThread.java
+++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/commons/mmocore/SelectorThread.java
@@ -46,7 +46,6 @@ public class SelectorThread>extends Thread
private final IPacketHandler _packetHandler;
private final IMMOExecutor _executor;
private final IClientFactory _clientFactory;
- private final IAcceptFilter _acceptFilter;
// Configurations
private final int HELPER_BUFFER_SIZE;
private final int HELPER_BUFFER_COUNT;
@@ -66,7 +65,7 @@ public class SelectorThread>extends Thread
private boolean _shutdown;
- public SelectorThread(SelectorConfig sc, IMMOExecutor executor, IPacketHandler packetHandler, IClientFactory clientFactory, IAcceptFilter acceptFilter) throws IOException
+ public SelectorThread(SelectorConfig sc, IMMOExecutor executor, IPacketHandler packetHandler, IClientFactory clientFactory) throws IOException
{
super.setName("SelectorThread-" + super.getId());
@@ -91,7 +90,6 @@ public class SelectorThread>extends Thread
_bufferPool.addLast(ByteBuffer.wrap(new byte[HELPER_BUFFER_SIZE]).order(BYTE_ORDER));
}
- _acceptFilter = acceptFilter;
_packetHandler = packetHandler;
_clientFactory = clientFactory;
_executor = executor;
@@ -116,7 +114,7 @@ public class SelectorThread>extends Thread
selectable.register(_selector, SelectionKey.OP_ACCEPT);
}
- final ByteBuffer getPooledBuffer()
+ protected ByteBuffer getPooledBuffer()
{
if (_bufferPool.isEmpty())
{
@@ -126,7 +124,7 @@ public class SelectorThread>extends Thread
return _bufferPool.removeFirst();
}
- final void recycleBuffer(ByteBuffer buf)
+ protected void recycleBuffer(ByteBuffer buf)
{
if (_bufferPool.size() < HELPER_BUFFER_COUNT)
{
@@ -244,36 +242,29 @@ public class SelectorThread>extends Thread
}
@SuppressWarnings("all")
- private final void acceptConnection(SelectionKey key, MMOConnection con)
+ private void acceptConnection(SelectionKey key, MMOConnection con)
{
final ServerSocketChannel ssc = (ServerSocketChannel) key.channel();
- SocketChannel sc;
+ SocketChannel sc = null;
try
{
while ((sc = ssc.accept()) != null)
{
- if ((_acceptFilter == null) || _acceptFilter.accept(sc))
- {
- sc.configureBlocking(false);
- final SelectionKey clientKey = sc.register(_selector, SelectionKey.OP_READ);
- con = new MMOConnection<>(this, sc.socket(), clientKey);
- con.setClient(_clientFactory.create(con));
- clientKey.attach(con);
- }
- else
- {
- sc.socket().close();
- }
+ sc.configureBlocking(false);
+ final SelectionKey clientKey = sc.register(_selector, SelectionKey.OP_READ);
+ con = new MMOConnection<>(this, sc.socket(), clientKey);
+ con.setClient(_clientFactory.create(con));
+ clientKey.attach(con);
}
}
- catch (IOException e)
+ catch (Exception e)
{
e.printStackTrace();
}
}
- private final void readPacket(SelectionKey key, MMOConnection con)
+ private void readPacket(SelectionKey key, MMOConnection con)
{
if (con.isClosed())
{
@@ -354,7 +345,7 @@ public class SelectorThread>extends Thread
}
}
- private final boolean tryReadPacket(SelectionKey key, T client, ByteBuffer buf, MMOConnection con)
+ private boolean tryReadPacket(SelectionKey key, T client, ByteBuffer buf, MMOConnection con)
{
switch (buf.remaining())
{
@@ -434,7 +425,7 @@ public class SelectorThread>extends Thread
}
}
- private final void allocateReadBuffer(MMOConnection con)
+ private void allocateReadBuffer(MMOConnection con)
{
con.setReadBuffer(getPooledBuffer().put(READ_BUFFER));
READ_BUFFER.clear();
@@ -467,7 +458,7 @@ public class SelectorThread>extends Thread
}
}
- private final void writeClosePacket(MMOConnection con)
+ private void writeClosePacket(MMOConnection con)
{
SendablePacket sp;
synchronized (con.getSendQueue())
@@ -497,7 +488,7 @@ public class SelectorThread>extends Thread
}
}
- protected final void writePacket(SelectionKey key, MMOConnection con)
+ protected void writePacket(SelectionKey key, MMOConnection con)
{
if (!prepareWriteBuffer(con))
{
@@ -548,7 +539,7 @@ public class SelectorThread>extends Thread
}
}
- private final boolean prepareWriteBuffer(MMOConnection con)
+ private boolean prepareWriteBuffer(MMOConnection con)
{
boolean hasPending = false;
DIRECT_WRITE_BUFFER.clear();
@@ -603,7 +594,7 @@ public class SelectorThread>extends Thread
return hasPending;
}
- private final void putPacketIntoWriteBuffer(T client, SendablePacket sp)
+ private void putPacketIntoWriteBuffer(T client, SendablePacket sp)
{
WRITE_BUFFER.clear();
@@ -633,7 +624,7 @@ public class SelectorThread>extends Thread
WRITE_BUFFER.position(dataPos + dataSize);
}
- final void closeConnection(MMOConnection con)
+ protected void closeConnection(MMOConnection con)
{
synchronized (_pendingClose)
{
@@ -641,7 +632,7 @@ public class SelectorThread>extends Thread
}
}
- private final void closeConnectionImpl(SelectionKey key, MMOConnection con)
+ private void closeConnectionImpl(SelectionKey key, MMOConnection con)
{
try
{
diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/commons/util/IPv4Filter.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/commons/util/IPv4Filter.java
deleted file mode 100644
index 8bf0255b21..0000000000
--- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/commons/util/IPv4Filter.java
+++ /dev/null
@@ -1,141 +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 .
- */
-package org.l2jmobius.commons.util;
-
-import java.net.InetAddress;
-import java.nio.channels.SocketChannel;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map.Entry;
-
-import org.l2jmobius.commons.mmocore.IAcceptFilter;
-
-/**
- * Formatted Forsaiken's IPv4 filter [DrHouse]
- * @author Forsaiken
- */
-public class IPv4Filter implements IAcceptFilter, Runnable
-{
- private final HashMap _ipFloodMap;
- private static final long SLEEP_TIME = 5000;
-
- public IPv4Filter()
- {
- _ipFloodMap = new HashMap<>();
- final Thread t = new Thread(this);
- t.setName(getClass().getSimpleName());
- 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 = Chronos.currentTimeMillis();
- trys = 0;
- }
- }
-
- @Override
- public boolean accept(SocketChannel sc)
- {
- final InetAddress addr = sc.socket().getInetAddress();
- final int h = hash(addr.getAddress());
- final long current = Chronos.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)
- {
- final long reference = Chronos.currentTimeMillis() - (1000 * 300);
- synchronized (_ipFloodMap)
- {
- final Iterator> it = _ipFloodMap.entrySet().iterator();
- while (it.hasNext())
- {
- final Flood f = it.next().getValue();
- if (f.lastAccess < reference)
- {
- it.remove();
- }
- }
- }
-
- try
- {
- Thread.sleep(SLEEP_TIME);
- }
- catch (InterruptedException e)
- {
- return;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/GameServer.java
index 3b4947d4a3..647943e42e 100644
--- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/GameServer.java
+++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/GameServer.java
@@ -35,7 +35,6 @@ import org.l2jmobius.commons.mmocore.SelectorConfig;
import org.l2jmobius.commons.mmocore.SelectorThread;
import org.l2jmobius.commons.util.Chronos;
import org.l2jmobius.commons.util.DeadlockDetector;
-import org.l2jmobius.commons.util.IPv4Filter;
import org.l2jmobius.commons.util.Util;
import org.l2jmobius.gameserver.cache.CrestCache;
import org.l2jmobius.gameserver.cache.HtmCache;
@@ -512,7 +511,7 @@ public class GameServer
_gamePacketHandler = new GamePacketHandler();
- _selectorThread = new SelectorThread<>(sc, _gamePacketHandler, _gamePacketHandler, _gamePacketHandler, new IPv4Filter());
+ _selectorThread = new SelectorThread<>(sc, _gamePacketHandler, _gamePacketHandler, _gamePacketHandler);
InetAddress bindAddress = null;
if (!Config.GAMESERVER_HOSTNAME.equals("*"))
diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/loginserver/network/clientpackets/RequestAuthLogin.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/loginserver/network/clientpackets/RequestAuthLogin.java
index 511cf2edd3..ba958f615b 100644
--- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/loginserver/network/clientpackets/RequestAuthLogin.java
+++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/loginserver/network/clientpackets/RequestAuthLogin.java
@@ -76,7 +76,7 @@ public class RequestAuthLogin extends ClientBasePacket
final LoginController login = LoginController.getInstance();
- // ip BANNED due to entering wrong password many times
+ // IP banned due to entering wrong password many times.
if (login.isBannedAddress(getClient().getSocket().getInetAddress().getHostAddress()))
{
getClient().sendPacket(new AccountKicked(AccountKicked.REASON_ILLEGAL_USE));
@@ -90,7 +90,6 @@ public class RequestAuthLogin extends ClientBasePacket
}
// Account BANNED (must always be checked after isLoginValid)
-
if (getClient().getAccessLevel() < 0)
{
getClient().sendPacket(new AccountKicked(AccountKicked.REASON_ILLEGAL_USE));
diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/commons/mmocore/SelectorThread.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/commons/mmocore/SelectorThread.java
index a935406972..55bdf2e9d6 100644
--- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/commons/mmocore/SelectorThread.java
+++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/commons/mmocore/SelectorThread.java
@@ -46,7 +46,6 @@ public class SelectorThread>extends Thread
private final IPacketHandler _packetHandler;
private final IMMOExecutor _executor;
private final IClientFactory _clientFactory;
- private final IAcceptFilter _acceptFilter;
// Configurations
private final int HELPER_BUFFER_SIZE;
private final int HELPER_BUFFER_COUNT;
@@ -66,7 +65,7 @@ public class SelectorThread>extends Thread
private boolean _shutdown;
- public SelectorThread(SelectorConfig sc, IMMOExecutor executor, IPacketHandler packetHandler, IClientFactory clientFactory, IAcceptFilter acceptFilter) throws IOException
+ public SelectorThread(SelectorConfig sc, IMMOExecutor executor, IPacketHandler packetHandler, IClientFactory clientFactory) throws IOException
{
super.setName("SelectorThread-" + super.getId());
@@ -91,7 +90,6 @@ public class SelectorThread>extends Thread
_bufferPool.addLast(ByteBuffer.wrap(new byte[HELPER_BUFFER_SIZE]).order(BYTE_ORDER));
}
- _acceptFilter = acceptFilter;
_packetHandler = packetHandler;
_clientFactory = clientFactory;
_executor = executor;
@@ -116,7 +114,7 @@ public class SelectorThread>extends Thread
selectable.register(_selector, SelectionKey.OP_ACCEPT);
}
- final ByteBuffer getPooledBuffer()
+ protected ByteBuffer getPooledBuffer()
{
if (_bufferPool.isEmpty())
{
@@ -126,7 +124,7 @@ public class SelectorThread>extends Thread
return _bufferPool.removeFirst();
}
- final void recycleBuffer(ByteBuffer buf)
+ protected void recycleBuffer(ByteBuffer buf)
{
if (_bufferPool.size() < HELPER_BUFFER_COUNT)
{
@@ -244,36 +242,29 @@ public class SelectorThread>extends Thread
}
@SuppressWarnings("all")
- private final void acceptConnection(SelectionKey key, MMOConnection con)
+ private void acceptConnection(SelectionKey key, MMOConnection con)
{
final ServerSocketChannel ssc = (ServerSocketChannel) key.channel();
- SocketChannel sc;
+ SocketChannel sc = null;
try
{
while ((sc = ssc.accept()) != null)
{
- if ((_acceptFilter == null) || _acceptFilter.accept(sc))
- {
- sc.configureBlocking(false);
- final SelectionKey clientKey = sc.register(_selector, SelectionKey.OP_READ);
- con = new MMOConnection<>(this, sc.socket(), clientKey);
- con.setClient(_clientFactory.create(con));
- clientKey.attach(con);
- }
- else
- {
- sc.socket().close();
- }
+ sc.configureBlocking(false);
+ final SelectionKey clientKey = sc.register(_selector, SelectionKey.OP_READ);
+ con = new MMOConnection<>(this, sc.socket(), clientKey);
+ con.setClient(_clientFactory.create(con));
+ clientKey.attach(con);
}
}
- catch (IOException e)
+ catch (Exception e)
{
e.printStackTrace();
}
}
- private final void readPacket(SelectionKey key, MMOConnection con)
+ private void readPacket(SelectionKey key, MMOConnection con)
{
if (con.isClosed())
{
@@ -354,7 +345,7 @@ public class SelectorThread>extends Thread
}
}
- private final boolean tryReadPacket(SelectionKey key, T client, ByteBuffer buf, MMOConnection con)
+ private boolean tryReadPacket(SelectionKey key, T client, ByteBuffer buf, MMOConnection con)
{
switch (buf.remaining())
{
@@ -434,7 +425,7 @@ public class SelectorThread>extends Thread
}
}
- private final void allocateReadBuffer(MMOConnection con)
+ private void allocateReadBuffer(MMOConnection con)
{
con.setReadBuffer(getPooledBuffer().put(READ_BUFFER));
READ_BUFFER.clear();
@@ -467,7 +458,7 @@ public class SelectorThread>extends Thread
}
}
- private final void writeClosePacket(MMOConnection con)
+ private void writeClosePacket(MMOConnection con)
{
SendablePacket sp;
synchronized (con.getSendQueue())
@@ -497,7 +488,7 @@ public class SelectorThread>extends Thread
}
}
- protected final void writePacket(SelectionKey key, MMOConnection con)
+ protected void writePacket(SelectionKey key, MMOConnection con)
{
if (!prepareWriteBuffer(con))
{
@@ -548,7 +539,7 @@ public class SelectorThread>extends Thread
}
}
- private final boolean prepareWriteBuffer(MMOConnection con)
+ private boolean prepareWriteBuffer(MMOConnection con)
{
boolean hasPending = false;
DIRECT_WRITE_BUFFER.clear();
@@ -603,7 +594,7 @@ public class SelectorThread>extends Thread
return hasPending;
}
- private final void putPacketIntoWriteBuffer(T client, SendablePacket sp)
+ private void putPacketIntoWriteBuffer(T client, SendablePacket sp)
{
WRITE_BUFFER.clear();
@@ -633,7 +624,7 @@ public class SelectorThread>extends Thread
WRITE_BUFFER.position(dataPos + dataSize);
}
- final void closeConnection(MMOConnection con)
+ protected void closeConnection(MMOConnection con)
{
synchronized (_pendingClose)
{
@@ -641,7 +632,7 @@ public class SelectorThread>extends Thread
}
}
- private final void closeConnectionImpl(SelectionKey key, MMOConnection con)
+ private void closeConnectionImpl(SelectionKey key, MMOConnection con)
{
try
{
diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/commons/util/IPv4Filter.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/commons/util/IPv4Filter.java
deleted file mode 100644
index 8bf0255b21..0000000000
--- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/commons/util/IPv4Filter.java
+++ /dev/null
@@ -1,141 +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 .
- */
-package org.l2jmobius.commons.util;
-
-import java.net.InetAddress;
-import java.nio.channels.SocketChannel;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map.Entry;
-
-import org.l2jmobius.commons.mmocore.IAcceptFilter;
-
-/**
- * Formatted Forsaiken's IPv4 filter [DrHouse]
- * @author Forsaiken
- */
-public class IPv4Filter implements IAcceptFilter, Runnable
-{
- private final HashMap _ipFloodMap;
- private static final long SLEEP_TIME = 5000;
-
- public IPv4Filter()
- {
- _ipFloodMap = new HashMap<>();
- final Thread t = new Thread(this);
- t.setName(getClass().getSimpleName());
- 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 = Chronos.currentTimeMillis();
- trys = 0;
- }
- }
-
- @Override
- public boolean accept(SocketChannel sc)
- {
- final InetAddress addr = sc.socket().getInetAddress();
- final int h = hash(addr.getAddress());
- final long current = Chronos.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)
- {
- final long reference = Chronos.currentTimeMillis() - (1000 * 300);
- synchronized (_ipFloodMap)
- {
- final Iterator> it = _ipFloodMap.entrySet().iterator();
- while (it.hasNext())
- {
- final Flood f = it.next().getValue();
- if (f.lastAccess < reference)
- {
- it.remove();
- }
- }
- }
-
- try
- {
- Thread.sleep(SLEEP_TIME);
- }
- catch (InterruptedException e)
- {
- return;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/GameServer.java
index 4afbf98288..8e471b9e37 100644
--- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/GameServer.java
+++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/GameServer.java
@@ -35,7 +35,6 @@ import org.l2jmobius.commons.mmocore.SelectorConfig;
import org.l2jmobius.commons.mmocore.SelectorThread;
import org.l2jmobius.commons.util.Chronos;
import org.l2jmobius.commons.util.DeadlockDetector;
-import org.l2jmobius.commons.util.IPv4Filter;
import org.l2jmobius.commons.util.Util;
import org.l2jmobius.gameserver.cache.CrestCache;
import org.l2jmobius.gameserver.cache.HtmCache;
@@ -524,7 +523,7 @@ public class GameServer
_gamePacketHandler = new GamePacketHandler();
- _selectorThread = new SelectorThread<>(sc, _gamePacketHandler, _gamePacketHandler, _gamePacketHandler, new IPv4Filter());
+ _selectorThread = new SelectorThread<>(sc, _gamePacketHandler, _gamePacketHandler, _gamePacketHandler);
InetAddress bindAddress = null;
if (!Config.GAMESERVER_HOSTNAME.equals("*"))
diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/loginserver/LoginServer.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/loginserver/LoginServer.java
index aca8e57993..8729acb26d 100644
--- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/loginserver/LoginServer.java
+++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/loginserver/LoginServer.java
@@ -139,7 +139,7 @@ public class LoginServer
final SelectorHelper sh = new SelectorHelper();
try
{
- _selectorThread = new SelectorThread<>(sc, sh, lph, sh, sh);
+ _selectorThread = new SelectorThread<>(sc, sh, lph, sh);
}
catch (IOException e)
{
diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/loginserver/SelectorHelper.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/loginserver/SelectorHelper.java
index 7dcf7e943e..a4d07a46c9 100644
--- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/loginserver/SelectorHelper.java
+++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/loginserver/SelectorHelper.java
@@ -26,7 +26,6 @@ import org.l2jmobius.commons.mmocore.IClientFactory;
import org.l2jmobius.commons.mmocore.IMMOExecutor;
import org.l2jmobius.commons.mmocore.MMOConnection;
import org.l2jmobius.commons.mmocore.ReceivablePacket;
-import org.l2jmobius.commons.util.IPv4Filter;
import org.l2jmobius.loginserver.network.serverpackets.Init;
/**
@@ -35,12 +34,10 @@ import org.l2jmobius.loginserver.network.serverpackets.Init;
public class SelectorHelper implements IMMOExecutor, IClientFactory, IAcceptFilter
{
private final ThreadPoolExecutor _generalPacketsThreadPool;
- private final IPv4Filter _ipv4filter;
public SelectorHelper()
{
_generalPacketsThreadPool = new ThreadPoolExecutor(4, 6, 15L, TimeUnit.SECONDS, new LinkedBlockingQueue());
- _ipv4filter = new IPv4Filter();
}
@Override
@@ -60,7 +57,6 @@ public class SelectorHelper implements IMMOExecutor, IClientFactory
@Override
public boolean accept(SocketChannel sc)
{
- // return !LoginController.getInstance().isBannedAddress(sc.socket().getInetAddress());
- return _ipv4filter.accept(sc) && !LoginController.getInstance().isBannedAddress(sc.socket().getInetAddress());
+ return !LoginController.getInstance().isBannedAddress(sc.socket().getInetAddress());
}
}
diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/loginserver/network/clientpackets/RequestAuthLogin.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/loginserver/network/clientpackets/RequestAuthLogin.java
index ee25a4d0b0..c60980bb17 100644
--- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/loginserver/network/clientpackets/RequestAuthLogin.java
+++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/loginserver/network/clientpackets/RequestAuthLogin.java
@@ -105,14 +105,23 @@ public class RequestAuthLogin extends LoginClientPacket
final LoginController lc = LoginController.getInstance();
final LoginClient client = getClient();
- final InetAddress address = getClient().getConnection().getInetAddress();
+
+ final InetAddress address = client.getConnection().getInetAddress();
if (address == null)
{
LOGGER.warning("Socket is not connected: " + client.getAccount());
client.close(LoginFailReason.REASON_SYSTEM_ERROR);
return;
}
- final AuthLoginResult result = lc.tryAuthLogin(_user, _password, getClient());
+
+ // IP banned or entering wrong password many times.
+ if (lc.isBannedAddress(address))
+ {
+ client.close(new AccountKicked(AccountKickedReason.REASON_PERMANENTLY_BANNED));
+ return;
+ }
+
+ final AuthLoginResult result = lc.tryAuthLogin(_user, _password, client);
switch (result)
{
@@ -123,11 +132,11 @@ public class RequestAuthLogin extends LoginClientPacket
client.setSessionKey(lc.assignSessionKeyToClient(_user, client));
if (Config.SHOW_LICENCE)
{
- client.sendPacket(new LoginOk(getClient().getSessionKey()));
+ client.sendPacket(new LoginOk(client.getSessionKey()));
}
else
{
- getClient().sendPacket(new ServerList(getClient()));
+ client.sendPacket(new ServerList(client));
}
break;
}
diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
deleted file mode 100644
index 875759b72a..0000000000
--- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
+++ /dev/null
@@ -1,149 +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 .
- */
-package org.l2jmobius.loginserver.network.util;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.nio.channels.SocketChannel;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.logging.Logger;
-
-import org.l2jmobius.commons.util.Chronos;
-
-/**
- * IPv4 filter.
- * @author Forsaiken
- */
-public class IPv4Filter implements Runnable
-{
- protected final Logger LOGGER = Logger.getLogger(getClass().getName());
-
- private final HashMap _ipFloodMap;
- private static final long SLEEP_TIME = 5000;
-
- public IPv4Filter()
- {
- _ipFloodMap = new HashMap<>();
- final Thread t = new Thread(this, getClass().getSimpleName());
- t.setDaemon(true);
- t.start();
- }
-
- /**
- * @param ip
- * @return
- */
- private static 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 = Chronos.currentTimeMillis();
- trys = 0;
- }
- }
-
- public boolean accept(SocketChannel sc)
- {
- final InetAddress addr = sc.socket().getInetAddress();
- if (!(addr instanceof Inet4Address))
- {
- LOGGER.info("Someone tried to connect from something other than IPv4: " + addr.getHostAddress());
- return false;
- }
-
- final int h = hash(addr.getAddress());
- final long current = Chronos.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)
- {
- final long reference = Chronos.currentTimeMillis() - (1000 * 300);
- synchronized (_ipFloodMap)
- {
- final Iterator> it = _ipFloodMap.entrySet().iterator();
- while (it.hasNext())
- {
- final Flood f = it.next().getValue();
- if (f.lastAccess < reference)
- {
- it.remove();
- }
- }
- }
-
- try
- {
- Thread.sleep(SLEEP_TIME);
- }
- catch (InterruptedException e)
- {
- return;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
deleted file mode 100644
index 875759b72a..0000000000
--- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
+++ /dev/null
@@ -1,149 +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 .
- */
-package org.l2jmobius.loginserver.network.util;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.nio.channels.SocketChannel;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.logging.Logger;
-
-import org.l2jmobius.commons.util.Chronos;
-
-/**
- * IPv4 filter.
- * @author Forsaiken
- */
-public class IPv4Filter implements Runnable
-{
- protected final Logger LOGGER = Logger.getLogger(getClass().getName());
-
- private final HashMap _ipFloodMap;
- private static final long SLEEP_TIME = 5000;
-
- public IPv4Filter()
- {
- _ipFloodMap = new HashMap<>();
- final Thread t = new Thread(this, getClass().getSimpleName());
- t.setDaemon(true);
- t.start();
- }
-
- /**
- * @param ip
- * @return
- */
- private static 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 = Chronos.currentTimeMillis();
- trys = 0;
- }
- }
-
- public boolean accept(SocketChannel sc)
- {
- final InetAddress addr = sc.socket().getInetAddress();
- if (!(addr instanceof Inet4Address))
- {
- LOGGER.info("Someone tried to connect from something other than IPv4: " + addr.getHostAddress());
- return false;
- }
-
- final int h = hash(addr.getAddress());
- final long current = Chronos.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)
- {
- final long reference = Chronos.currentTimeMillis() - (1000 * 300);
- synchronized (_ipFloodMap)
- {
- final Iterator> it = _ipFloodMap.entrySet().iterator();
- while (it.hasNext())
- {
- final Flood f = it.next().getValue();
- if (f.lastAccess < reference)
- {
- it.remove();
- }
- }
- }
-
- try
- {
- Thread.sleep(SLEEP_TIME);
- }
- catch (InterruptedException e)
- {
- return;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
deleted file mode 100644
index 875759b72a..0000000000
--- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
+++ /dev/null
@@ -1,149 +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 .
- */
-package org.l2jmobius.loginserver.network.util;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.nio.channels.SocketChannel;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.logging.Logger;
-
-import org.l2jmobius.commons.util.Chronos;
-
-/**
- * IPv4 filter.
- * @author Forsaiken
- */
-public class IPv4Filter implements Runnable
-{
- protected final Logger LOGGER = Logger.getLogger(getClass().getName());
-
- private final HashMap _ipFloodMap;
- private static final long SLEEP_TIME = 5000;
-
- public IPv4Filter()
- {
- _ipFloodMap = new HashMap<>();
- final Thread t = new Thread(this, getClass().getSimpleName());
- t.setDaemon(true);
- t.start();
- }
-
- /**
- * @param ip
- * @return
- */
- private static 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 = Chronos.currentTimeMillis();
- trys = 0;
- }
- }
-
- public boolean accept(SocketChannel sc)
- {
- final InetAddress addr = sc.socket().getInetAddress();
- if (!(addr instanceof Inet4Address))
- {
- LOGGER.info("Someone tried to connect from something other than IPv4: " + addr.getHostAddress());
- return false;
- }
-
- final int h = hash(addr.getAddress());
- final long current = Chronos.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)
- {
- final long reference = Chronos.currentTimeMillis() - (1000 * 300);
- synchronized (_ipFloodMap)
- {
- final Iterator> it = _ipFloodMap.entrySet().iterator();
- while (it.hasNext())
- {
- final Flood f = it.next().getValue();
- if (f.lastAccess < reference)
- {
- it.remove();
- }
- }
- }
-
- try
- {
- Thread.sleep(SLEEP_TIME);
- }
- catch (InterruptedException e)
- {
- return;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
deleted file mode 100644
index 875759b72a..0000000000
--- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
+++ /dev/null
@@ -1,149 +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 .
- */
-package org.l2jmobius.loginserver.network.util;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.nio.channels.SocketChannel;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.logging.Logger;
-
-import org.l2jmobius.commons.util.Chronos;
-
-/**
- * IPv4 filter.
- * @author Forsaiken
- */
-public class IPv4Filter implements Runnable
-{
- protected final Logger LOGGER = Logger.getLogger(getClass().getName());
-
- private final HashMap _ipFloodMap;
- private static final long SLEEP_TIME = 5000;
-
- public IPv4Filter()
- {
- _ipFloodMap = new HashMap<>();
- final Thread t = new Thread(this, getClass().getSimpleName());
- t.setDaemon(true);
- t.start();
- }
-
- /**
- * @param ip
- * @return
- */
- private static 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 = Chronos.currentTimeMillis();
- trys = 0;
- }
- }
-
- public boolean accept(SocketChannel sc)
- {
- final InetAddress addr = sc.socket().getInetAddress();
- if (!(addr instanceof Inet4Address))
- {
- LOGGER.info("Someone tried to connect from something other than IPv4: " + addr.getHostAddress());
- return false;
- }
-
- final int h = hash(addr.getAddress());
- final long current = Chronos.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)
- {
- final long reference = Chronos.currentTimeMillis() - (1000 * 300);
- synchronized (_ipFloodMap)
- {
- final Iterator> it = _ipFloodMap.entrySet().iterator();
- while (it.hasNext())
- {
- final Flood f = it.next().getValue();
- if (f.lastAccess < reference)
- {
- it.remove();
- }
- }
- }
-
- try
- {
- Thread.sleep(SLEEP_TIME);
- }
- catch (InterruptedException e)
- {
- return;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
deleted file mode 100644
index 875759b72a..0000000000
--- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
+++ /dev/null
@@ -1,149 +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 .
- */
-package org.l2jmobius.loginserver.network.util;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.nio.channels.SocketChannel;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.logging.Logger;
-
-import org.l2jmobius.commons.util.Chronos;
-
-/**
- * IPv4 filter.
- * @author Forsaiken
- */
-public class IPv4Filter implements Runnable
-{
- protected final Logger LOGGER = Logger.getLogger(getClass().getName());
-
- private final HashMap _ipFloodMap;
- private static final long SLEEP_TIME = 5000;
-
- public IPv4Filter()
- {
- _ipFloodMap = new HashMap<>();
- final Thread t = new Thread(this, getClass().getSimpleName());
- t.setDaemon(true);
- t.start();
- }
-
- /**
- * @param ip
- * @return
- */
- private static 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 = Chronos.currentTimeMillis();
- trys = 0;
- }
- }
-
- public boolean accept(SocketChannel sc)
- {
- final InetAddress addr = sc.socket().getInetAddress();
- if (!(addr instanceof Inet4Address))
- {
- LOGGER.info("Someone tried to connect from something other than IPv4: " + addr.getHostAddress());
- return false;
- }
-
- final int h = hash(addr.getAddress());
- final long current = Chronos.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)
- {
- final long reference = Chronos.currentTimeMillis() - (1000 * 300);
- synchronized (_ipFloodMap)
- {
- final Iterator> it = _ipFloodMap.entrySet().iterator();
- while (it.hasNext())
- {
- final Flood f = it.next().getValue();
- if (f.lastAccess < reference)
- {
- it.remove();
- }
- }
- }
-
- try
- {
- Thread.sleep(SLEEP_TIME);
- }
- catch (InterruptedException e)
- {
- return;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
deleted file mode 100644
index 875759b72a..0000000000
--- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
+++ /dev/null
@@ -1,149 +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 .
- */
-package org.l2jmobius.loginserver.network.util;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.nio.channels.SocketChannel;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.logging.Logger;
-
-import org.l2jmobius.commons.util.Chronos;
-
-/**
- * IPv4 filter.
- * @author Forsaiken
- */
-public class IPv4Filter implements Runnable
-{
- protected final Logger LOGGER = Logger.getLogger(getClass().getName());
-
- private final HashMap _ipFloodMap;
- private static final long SLEEP_TIME = 5000;
-
- public IPv4Filter()
- {
- _ipFloodMap = new HashMap<>();
- final Thread t = new Thread(this, getClass().getSimpleName());
- t.setDaemon(true);
- t.start();
- }
-
- /**
- * @param ip
- * @return
- */
- private static 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 = Chronos.currentTimeMillis();
- trys = 0;
- }
- }
-
- public boolean accept(SocketChannel sc)
- {
- final InetAddress addr = sc.socket().getInetAddress();
- if (!(addr instanceof Inet4Address))
- {
- LOGGER.info("Someone tried to connect from something other than IPv4: " + addr.getHostAddress());
- return false;
- }
-
- final int h = hash(addr.getAddress());
- final long current = Chronos.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)
- {
- final long reference = Chronos.currentTimeMillis() - (1000 * 300);
- synchronized (_ipFloodMap)
- {
- final Iterator> it = _ipFloodMap.entrySet().iterator();
- while (it.hasNext())
- {
- final Flood f = it.next().getValue();
- if (f.lastAccess < reference)
- {
- it.remove();
- }
- }
- }
-
- try
- {
- Thread.sleep(SLEEP_TIME);
- }
- catch (InterruptedException e)
- {
- return;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
deleted file mode 100644
index 875759b72a..0000000000
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
+++ /dev/null
@@ -1,149 +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 .
- */
-package org.l2jmobius.loginserver.network.util;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.nio.channels.SocketChannel;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.logging.Logger;
-
-import org.l2jmobius.commons.util.Chronos;
-
-/**
- * IPv4 filter.
- * @author Forsaiken
- */
-public class IPv4Filter implements Runnable
-{
- protected final Logger LOGGER = Logger.getLogger(getClass().getName());
-
- private final HashMap _ipFloodMap;
- private static final long SLEEP_TIME = 5000;
-
- public IPv4Filter()
- {
- _ipFloodMap = new HashMap<>();
- final Thread t = new Thread(this, getClass().getSimpleName());
- t.setDaemon(true);
- t.start();
- }
-
- /**
- * @param ip
- * @return
- */
- private static 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 = Chronos.currentTimeMillis();
- trys = 0;
- }
- }
-
- public boolean accept(SocketChannel sc)
- {
- final InetAddress addr = sc.socket().getInetAddress();
- if (!(addr instanceof Inet4Address))
- {
- LOGGER.info("Someone tried to connect from something other than IPv4: " + addr.getHostAddress());
- return false;
- }
-
- final int h = hash(addr.getAddress());
- final long current = Chronos.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)
- {
- final long reference = Chronos.currentTimeMillis() - (1000 * 300);
- synchronized (_ipFloodMap)
- {
- final Iterator> it = _ipFloodMap.entrySet().iterator();
- while (it.hasNext())
- {
- final Flood f = it.next().getValue();
- if (f.lastAccess < reference)
- {
- it.remove();
- }
- }
- }
-
- try
- {
- Thread.sleep(SLEEP_TIME);
- }
- catch (InterruptedException e)
- {
- return;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
deleted file mode 100644
index 875759b72a..0000000000
--- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
+++ /dev/null
@@ -1,149 +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 .
- */
-package org.l2jmobius.loginserver.network.util;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.nio.channels.SocketChannel;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.logging.Logger;
-
-import org.l2jmobius.commons.util.Chronos;
-
-/**
- * IPv4 filter.
- * @author Forsaiken
- */
-public class IPv4Filter implements Runnable
-{
- protected final Logger LOGGER = Logger.getLogger(getClass().getName());
-
- private final HashMap _ipFloodMap;
- private static final long SLEEP_TIME = 5000;
-
- public IPv4Filter()
- {
- _ipFloodMap = new HashMap<>();
- final Thread t = new Thread(this, getClass().getSimpleName());
- t.setDaemon(true);
- t.start();
- }
-
- /**
- * @param ip
- * @return
- */
- private static 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 = Chronos.currentTimeMillis();
- trys = 0;
- }
- }
-
- public boolean accept(SocketChannel sc)
- {
- final InetAddress addr = sc.socket().getInetAddress();
- if (!(addr instanceof Inet4Address))
- {
- LOGGER.info("Someone tried to connect from something other than IPv4: " + addr.getHostAddress());
- return false;
- }
-
- final int h = hash(addr.getAddress());
- final long current = Chronos.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)
- {
- final long reference = Chronos.currentTimeMillis() - (1000 * 300);
- synchronized (_ipFloodMap)
- {
- final Iterator> it = _ipFloodMap.entrySet().iterator();
- while (it.hasNext())
- {
- final Flood f = it.next().getValue();
- if (f.lastAccess < reference)
- {
- it.remove();
- }
- }
- }
-
- try
- {
- Thread.sleep(SLEEP_TIME);
- }
- catch (InterruptedException e)
- {
- return;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
deleted file mode 100644
index 875759b72a..0000000000
--- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
+++ /dev/null
@@ -1,149 +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 .
- */
-package org.l2jmobius.loginserver.network.util;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.nio.channels.SocketChannel;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.logging.Logger;
-
-import org.l2jmobius.commons.util.Chronos;
-
-/**
- * IPv4 filter.
- * @author Forsaiken
- */
-public class IPv4Filter implements Runnable
-{
- protected final Logger LOGGER = Logger.getLogger(getClass().getName());
-
- private final HashMap _ipFloodMap;
- private static final long SLEEP_TIME = 5000;
-
- public IPv4Filter()
- {
- _ipFloodMap = new HashMap<>();
- final Thread t = new Thread(this, getClass().getSimpleName());
- t.setDaemon(true);
- t.start();
- }
-
- /**
- * @param ip
- * @return
- */
- private static 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 = Chronos.currentTimeMillis();
- trys = 0;
- }
- }
-
- public boolean accept(SocketChannel sc)
- {
- final InetAddress addr = sc.socket().getInetAddress();
- if (!(addr instanceof Inet4Address))
- {
- LOGGER.info("Someone tried to connect from something other than IPv4: " + addr.getHostAddress());
- return false;
- }
-
- final int h = hash(addr.getAddress());
- final long current = Chronos.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)
- {
- final long reference = Chronos.currentTimeMillis() - (1000 * 300);
- synchronized (_ipFloodMap)
- {
- final Iterator> it = _ipFloodMap.entrySet().iterator();
- while (it.hasNext())
- {
- final Flood f = it.next().getValue();
- if (f.lastAccess < reference)
- {
- it.remove();
- }
- }
- }
-
- try
- {
- Thread.sleep(SLEEP_TIME);
- }
- catch (InterruptedException e)
- {
- return;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
deleted file mode 100644
index 875759b72a..0000000000
--- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/loginserver/network/util/IPv4Filter.java
+++ /dev/null
@@ -1,149 +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 .
- */
-package org.l2jmobius.loginserver.network.util;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.nio.channels.SocketChannel;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.logging.Logger;
-
-import org.l2jmobius.commons.util.Chronos;
-
-/**
- * IPv4 filter.
- * @author Forsaiken
- */
-public class IPv4Filter implements Runnable
-{
- protected final Logger LOGGER = Logger.getLogger(getClass().getName());
-
- private final HashMap _ipFloodMap;
- private static final long SLEEP_TIME = 5000;
-
- public IPv4Filter()
- {
- _ipFloodMap = new HashMap<>();
- final Thread t = new Thread(this, getClass().getSimpleName());
- t.setDaemon(true);
- t.start();
- }
-
- /**
- * @param ip
- * @return
- */
- private static 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 = Chronos.currentTimeMillis();
- trys = 0;
- }
- }
-
- public boolean accept(SocketChannel sc)
- {
- final InetAddress addr = sc.socket().getInetAddress();
- if (!(addr instanceof Inet4Address))
- {
- LOGGER.info("Someone tried to connect from something other than IPv4: " + addr.getHostAddress());
- return false;
- }
-
- final int h = hash(addr.getAddress());
- final long current = Chronos.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)
- {
- final long reference = Chronos.currentTimeMillis() - (1000 * 300);
- synchronized (_ipFloodMap)
- {
- final Iterator> it = _ipFloodMap.entrySet().iterator();
- while (it.hasNext())
- {
- final Flood f = it.next().getValue();
- if (f.lastAccess < reference)
- {
- it.remove();
- }
- }
- }
-
- try
- {
- Thread.sleep(SLEEP_TIME);
- }
- catch (InterruptedException e)
- {
- return;
- }
- }
- }
-}
\ No newline at end of file