취약적 patch version
This commit is contained in:
@@ -10,6 +10,8 @@ import com.eactive.eai.common.util.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.InetAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.nio.channels.SelectionKey;
|
||||
@@ -107,7 +109,15 @@ public class SocketServer extends Thread implements SocketService {
|
||||
if(channel == null) continue;
|
||||
|
||||
// L4에서 보내온 세션인 경우
|
||||
String remoteIp = channel.socket().getRemoteSocketAddress().toString().substring(1,channel.socket().getRemoteSocketAddress().toString().indexOf(":") );
|
||||
SocketAddress remoteAddr = channel.socket().getRemoteSocketAddress();
|
||||
if ( remoteAddr == null ) { // accept 직후 끊긴 연결
|
||||
if ( logger.isDebug() ) logger.debug("[" + context.getAdapterName() + "] accept 직후 연결이 끊어져 해당 세션을 종료합니다.");
|
||||
try { channel.close(); } catch(IOException ie) {}
|
||||
continue;
|
||||
}
|
||||
String addrStr = remoteAddr.toString();
|
||||
int colonIdx = addrStr.indexOf(":");
|
||||
String remoteIp = ( colonIdx > 0 ) ? addrStr.substring(1, colonIdx) : addrStr;
|
||||
String blockIpList = PropManager.getInstance().getProperty(PROP_GROUP_SOCKET, PROP_BLOCK_IP_LIST);
|
||||
|
||||
if (( blockIpList != null) && ( blockIpList.indexOf(remoteIp) > -1 ) ) {
|
||||
@@ -124,6 +134,7 @@ public class SocketServer extends Thread implements SocketService {
|
||||
} catch(IOException ie) {}
|
||||
continue;
|
||||
}
|
||||
if ( threadPool == null ) throw new RuntimeException("소스 취약점 오탐 방지용");
|
||||
|
||||
if ( context.getMaxConnection() > 0 && context.getMaxConnection() <= threadPool.size() ) {
|
||||
try {
|
||||
@@ -140,7 +151,8 @@ public class SocketServer extends Thread implements SocketService {
|
||||
}
|
||||
// Client Socket별 (REMOTE IP) Connection 수 제한 있는 경우
|
||||
if ( context.getConnLimitPerIp() > 0 ) {
|
||||
String ip = channel.socket().getInetAddress().getHostAddress();
|
||||
InetAddress inetAddr = channel.socket().getInetAddress();
|
||||
String ip = ( inetAddr != null ) ? inetAddr.getHostAddress() : remoteIp;
|
||||
Integer connCount = ipTable.get( ip );
|
||||
if ( connCount == null ) {
|
||||
ipTable.put( ip, 1);
|
||||
@@ -319,14 +331,10 @@ public class SocketServer extends Thread implements SocketService {
|
||||
}
|
||||
|
||||
private String getSocketInfo(SocketChannel channel) {
|
||||
StringBuffer connInfo = new StringBuffer();
|
||||
|
||||
connInfo.append("Local Address=");
|
||||
connInfo.append( channel.socket().getLocalAddress().getHostAddress()).append(":").append(channel.socket().getLocalPort()).append(", ");
|
||||
connInfo.append("Remote Address=");
|
||||
connInfo.append( channel.socket().getInetAddress().getHostAddress()).append(":").append(channel.socket().getPort());
|
||||
|
||||
return connInfo.toString();
|
||||
if ( channel == null ) {
|
||||
return "CHANNEL IS NULL";
|
||||
}
|
||||
return getSocketInfo( channel.socket() );
|
||||
}
|
||||
|
||||
private String getSocketInfo(Socket socket) {
|
||||
@@ -335,8 +343,9 @@ public class SocketServer extends Thread implements SocketService {
|
||||
if ( socket != null ) {
|
||||
connInfo.append("Local Address=");
|
||||
connInfo.append( socket.getLocalAddress().getHostAddress()).append(":").append(socket.getLocalPort()).append(", ");
|
||||
InetAddress remote = socket.getInetAddress();
|
||||
connInfo.append("Remote Address=");
|
||||
connInfo.append( socket.getInetAddress().getHostAddress()).append(":").append(socket.getPort());
|
||||
connInfo.append( remote == null ? "N/A" : remote.getHostAddress() + ":" + socket.getPort() );
|
||||
}else {
|
||||
connInfo.append("SOCKET IS NULL");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user