More eclipse login issue changes.

This commit is contained in:
MobiusDev 2017-09-30 16:31:07 +00:00
parent 5f8301af70
commit bba9f4be4f
20 changed files with 55 additions and 130 deletions

View File

@ -611,16 +611,17 @@ public final class GameServerTable implements IGameXmlReader
* @param addr the addr
* @return the server address
*/
@SuppressWarnings("unlikely-arg-type")
public String getServerAddress(InetAddress addr)
{
for (GameServerAddress a : _addrs)
{
if (a.getAddress().equals(addr.getAddress()))
if (a.equals(addr))
{
return a.getServerAddress();
}
}
return null; // should not happens
return null; // should not happen
}
/**

View File

@ -323,39 +323,21 @@ public class LoginController
_bannedIps.putIfAbsent(address, System.currentTimeMillis() + duration);
}
public boolean isBannedAddress(InetAddress address)
public boolean isBannedAddress(InetAddress address) throws UnknownHostException
{
final String[] parts = address.getHostAddress().split("\\.");
Long bi = _bannedIps.get(address);
if (bi == null)
{
try
{
bi = _bannedIps.get(InetAddress.getByName(parts[0] + "." + parts[1] + "." + parts[2] + ".0"));
}
catch (UnknownHostException e)
{
}
bi = _bannedIps.get(InetAddress.getByName(parts[0] + "." + parts[1] + "." + parts[2] + ".0"));
}
if (bi == null)
{
try
{
bi = _bannedIps.get(InetAddress.getByName(parts[0] + "." + parts[1] + ".0.0"));
}
catch (UnknownHostException e)
{
}
bi = _bannedIps.get(InetAddress.getByName(parts[0] + "." + parts[1] + ".0.0"));
}
if (bi == null)
{
try
{
bi = _bannedIps.get(InetAddress.getByName(parts[0] + ".0.0.0"));
}
catch (UnknownHostException e)
{
}
bi = _bannedIps.get(InetAddress.getByName(parts[0] + ".0.0.0"));
}
if (bi != null)
{

View File

@ -16,6 +16,7 @@
*/
package com.l2jmobius.loginserver;
import java.net.UnknownHostException;
import java.nio.channels.SocketChannel;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
@ -59,7 +60,7 @@ public class SelectorHelper implements IMMOExecutor<L2LoginClient>, IClientFacto
}
@Override
public boolean accept(SocketChannel sc)
public boolean accept(SocketChannel sc) throws UnknownHostException
{
return _ipv4filter.accept(sc) && !LoginController.getInstance().isBannedAddress(sc.socket().getInetAddress());
}

View File

@ -16,6 +16,7 @@
*/
package com.l2jmobius.loginserver.network.mmocore;
import java.net.UnknownHostException;
import java.nio.channels.SocketChannel;
/**
@ -23,5 +24,5 @@ import java.nio.channels.SocketChannel;
*/
public interface IAcceptFilter
{
boolean accept(SocketChannel sc);
boolean accept(SocketChannel sc) throws UnknownHostException;
}

View File

@ -611,16 +611,17 @@ public final class GameServerTable implements IGameXmlReader
* @param addr the addr
* @return the server address
*/
@SuppressWarnings("unlikely-arg-type")
public String getServerAddress(InetAddress addr)
{
for (GameServerAddress a : _addrs)
{
if (a.getAddress().equals(addr.getAddress()))
if (a.equals(addr))
{
return a.getServerAddress();
}
}
return null; // should not happens
return null; // should not happen
}
/**

View File

@ -323,39 +323,21 @@ public class LoginController
_bannedIps.putIfAbsent(address, System.currentTimeMillis() + duration);
}
public boolean isBannedAddress(InetAddress address)
public boolean isBannedAddress(InetAddress address) throws UnknownHostException
{
final String[] parts = address.getHostAddress().split("\\.");
Long bi = _bannedIps.get(address);
if (bi == null)
{
try
{
bi = _bannedIps.get(InetAddress.getByName(parts[0] + "." + parts[1] + "." + parts[2] + ".0"));
}
catch (UnknownHostException e)
{
}
bi = _bannedIps.get(InetAddress.getByName(parts[0] + "." + parts[1] + "." + parts[2] + ".0"));
}
if (bi == null)
{
try
{
bi = _bannedIps.get(InetAddress.getByName(parts[0] + "." + parts[1] + ".0.0"));
}
catch (UnknownHostException e)
{
}
bi = _bannedIps.get(InetAddress.getByName(parts[0] + "." + parts[1] + ".0.0"));
}
if (bi == null)
{
try
{
bi = _bannedIps.get(InetAddress.getByName(parts[0] + ".0.0.0"));
}
catch (UnknownHostException e)
{
}
bi = _bannedIps.get(InetAddress.getByName(parts[0] + ".0.0.0"));
}
if (bi != null)
{

View File

@ -16,6 +16,7 @@
*/
package com.l2jmobius.loginserver;
import java.net.UnknownHostException;
import java.nio.channels.SocketChannel;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
@ -59,7 +60,7 @@ public class SelectorHelper implements IMMOExecutor<L2LoginClient>, IClientFacto
}
@Override
public boolean accept(SocketChannel sc)
public boolean accept(SocketChannel sc) throws UnknownHostException
{
return _ipv4filter.accept(sc) && !LoginController.getInstance().isBannedAddress(sc.socket().getInetAddress());
}

View File

@ -16,6 +16,7 @@
*/
package com.l2jmobius.loginserver.network.mmocore;
import java.net.UnknownHostException;
import java.nio.channels.SocketChannel;
/**
@ -23,5 +24,5 @@ import java.nio.channels.SocketChannel;
*/
public interface IAcceptFilter
{
boolean accept(SocketChannel sc);
boolean accept(SocketChannel sc) throws UnknownHostException;
}

View File

@ -611,16 +611,17 @@ public final class GameServerTable implements IGameXmlReader
* @param addr the addr
* @return the server address
*/
@SuppressWarnings("unlikely-arg-type")
public String getServerAddress(InetAddress addr)
{
for (GameServerAddress a : _addrs)
{
if (a.getAddress().equals(addr.getAddress()))
if (a.equals(addr))
{
return a.getServerAddress();
}
}
return null; // should not happens
return null; // should not happen
}
/**

View File

@ -323,39 +323,21 @@ public class LoginController
_bannedIps.putIfAbsent(address, System.currentTimeMillis() + duration);
}
public boolean isBannedAddress(InetAddress address)
public boolean isBannedAddress(InetAddress address) throws UnknownHostException
{
final String[] parts = address.getHostAddress().split("\\.");
Long bi = _bannedIps.get(address);
if (bi == null)
{
try
{
bi = _bannedIps.get(InetAddress.getByName(parts[0] + "." + parts[1] + "." + parts[2] + ".0"));
}
catch (UnknownHostException e)
{
}
bi = _bannedIps.get(InetAddress.getByName(parts[0] + "." + parts[1] + "." + parts[2] + ".0"));
}
if (bi == null)
{
try
{
bi = _bannedIps.get(InetAddress.getByName(parts[0] + "." + parts[1] + ".0.0"));
}
catch (UnknownHostException e)
{
}
bi = _bannedIps.get(InetAddress.getByName(parts[0] + "." + parts[1] + ".0.0"));
}
if (bi == null)
{
try
{
bi = _bannedIps.get(InetAddress.getByName(parts[0] + ".0.0.0"));
}
catch (UnknownHostException e)
{
}
bi = _bannedIps.get(InetAddress.getByName(parts[0] + ".0.0.0"));
}
if (bi != null)
{

View File

@ -16,6 +16,7 @@
*/
package com.l2jmobius.loginserver;
import java.net.UnknownHostException;
import java.nio.channels.SocketChannel;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
@ -59,7 +60,7 @@ public class SelectorHelper implements IMMOExecutor<L2LoginClient>, IClientFacto
}
@Override
public boolean accept(SocketChannel sc)
public boolean accept(SocketChannel sc) throws UnknownHostException
{
return _ipv4filter.accept(sc) && !LoginController.getInstance().isBannedAddress(sc.socket().getInetAddress());
}

View File

@ -16,6 +16,7 @@
*/
package com.l2jmobius.loginserver.network.mmocore;
import java.net.UnknownHostException;
import java.nio.channels.SocketChannel;
/**
@ -23,5 +24,5 @@ import java.nio.channels.SocketChannel;
*/
public interface IAcceptFilter
{
boolean accept(SocketChannel sc);
boolean accept(SocketChannel sc) throws UnknownHostException;
}

View File

@ -16,6 +16,7 @@
*/
package com.l2jmobius.commons.mmocore;
import java.net.UnknownHostException;
import java.nio.channels.SocketChannel;
/**
@ -23,5 +24,5 @@ import java.nio.channels.SocketChannel;
*/
public interface IAcceptFilter
{
boolean accept(SocketChannel sc);
boolean accept(SocketChannel sc) throws UnknownHostException;
}

View File

@ -599,16 +599,17 @@ public final class GameServerTable implements IXmlReader
* @param addr the addr
* @return the server address
*/
@SuppressWarnings("unlikely-arg-type")
public String getServerAddress(InetAddress addr)
{
for (GameServerAddress a : _addrs)
{
if (a.getAddress().equals(addr.getAddress()))
if (a.equals(addr))
{
return a.getServerAddress();
}
}
return null; // should not happens
return null; // should not happen
}
/**

View File

@ -321,39 +321,21 @@ public class LoginController
_bannedIps.putIfAbsent(address, System.currentTimeMillis() + duration);
}
public boolean isBannedAddress(InetAddress address)
public boolean isBannedAddress(InetAddress address) throws UnknownHostException
{
final String[] parts = address.getHostAddress().split("\\.");
Long bi = _bannedIps.get(address);
if (bi == null)
{
try
{
bi = _bannedIps.get(InetAddress.getByName(parts[0] + "." + parts[1] + "." + parts[2] + ".0"));
}
catch (UnknownHostException e)
{
}
bi = _bannedIps.get(InetAddress.getByName(parts[0] + "." + parts[1] + "." + parts[2] + ".0"));
}
if (bi == null)
{
try
{
bi = _bannedIps.get(InetAddress.getByName(parts[0] + "." + parts[1] + ".0.0"));
}
catch (UnknownHostException e)
{
}
bi = _bannedIps.get(InetAddress.getByName(parts[0] + "." + parts[1] + ".0.0"));
}
if (bi == null)
{
try
{
bi = _bannedIps.get(InetAddress.getByName(parts[0] + ".0.0.0"));
}
catch (UnknownHostException e)
{
}
bi = _bannedIps.get(InetAddress.getByName(parts[0] + ".0.0.0"));
}
if (bi != null)
{

View File

@ -16,6 +16,7 @@
*/
package com.l2jmobius.loginserver;
import java.net.UnknownHostException;
import java.nio.channels.SocketChannel;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
@ -59,7 +60,7 @@ public class SelectorHelper implements IMMOExecutor<L2LoginClient>, IClientFacto
}
@Override
public boolean accept(SocketChannel sc)
public boolean accept(SocketChannel sc) throws UnknownHostException
{
return _ipv4filter.accept(sc) && !LoginController.getInstance().isBannedAddress(sc.socket().getInetAddress());
}

View File

@ -611,16 +611,17 @@ public final class GameServerTable implements IGameXmlReader
* @param addr the addr
* @return the server address
*/
@SuppressWarnings("unlikely-arg-type")
public String getServerAddress(InetAddress addr)
{
for (GameServerAddress a : _addrs)
{
if (a.getAddress().equals(addr.getAddress()))
if (a.equals(addr))
{
return a.getServerAddress();
}
}
return null; // should not happens
return null; // should not happen
}
/**

View File

@ -323,39 +323,21 @@ public class LoginController
_bannedIps.putIfAbsent(address, System.currentTimeMillis() + duration);
}
public boolean isBannedAddress(InetAddress address)
public boolean isBannedAddress(InetAddress address) throws UnknownHostException
{
final String[] parts = address.getHostAddress().split("\\.");
Long bi = _bannedIps.get(address);
if (bi == null)
{
try
{
bi = _bannedIps.get(InetAddress.getByName(parts[0] + "." + parts[1] + "." + parts[2] + ".0"));
}
catch (UnknownHostException e)
{
}
bi = _bannedIps.get(InetAddress.getByName(parts[0] + "." + parts[1] + "." + parts[2] + ".0"));
}
if (bi == null)
{
try
{
bi = _bannedIps.get(InetAddress.getByName(parts[0] + "." + parts[1] + ".0.0"));
}
catch (UnknownHostException e)
{
}
bi = _bannedIps.get(InetAddress.getByName(parts[0] + "." + parts[1] + ".0.0"));
}
if (bi == null)
{
try
{
bi = _bannedIps.get(InetAddress.getByName(parts[0] + ".0.0.0"));
}
catch (UnknownHostException e)
{
}
bi = _bannedIps.get(InetAddress.getByName(parts[0] + ".0.0.0"));
}
if (bi != null)
{

View File

@ -16,6 +16,7 @@
*/
package com.l2jmobius.loginserver;
import java.net.UnknownHostException;
import java.nio.channels.SocketChannel;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
@ -59,7 +60,7 @@ public class SelectorHelper implements IMMOExecutor<L2LoginClient>, IClientFacto
}
@Override
public boolean accept(SocketChannel sc)
public boolean accept(SocketChannel sc) throws UnknownHostException
{
return _ipv4filter.accept(sc) && !LoginController.getInstance().isBannedAddress(sc.socket().getInetAddress());
}

View File

@ -16,6 +16,7 @@
*/
package com.l2jmobius.loginserver.network.mmocore;
import java.net.UnknownHostException;
import java.nio.channels.SocketChannel;
/**
@ -23,5 +24,5 @@ import java.nio.channels.SocketChannel;
*/
public interface IAcceptFilter
{
boolean accept(SocketChannel sc);
boolean accept(SocketChannel sc) throws UnknownHostException;
}