From 5995b93cbc5b084a44ab9c6d7a065d9b47b6d7f7 Mon Sep 17 00:00:00 2001
From: dugan <dugan@localhost>
Date: Tue, 19 Sep 2006 19:49:17 +0000
Subject: [PATCH] Add code to support issue #151 client connection disconnect.
---
opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPConnectionHandler.java | 76 +++++++++++++++++--------------------
1 files changed, 35 insertions(+), 41 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPConnectionHandler.java b/opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPConnectionHandler.java
index 92f2a62..870d79a 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPConnectionHandler.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPConnectionHandler.java
@@ -1224,12 +1224,44 @@
ServerSocketChannel serverChannel =
(ServerSocketChannel) key.channel();
SocketChannel clientChannel = serverChannel.accept();
- clientChannel.socket().setKeepAlive(useKeepAlive);
- clientChannel.socket().setTcpNoDelay(useTCPNoDelay);
-
LDAPClientConnection clientConnection =
new LDAPClientConnection(this, clientChannel);
+ InetAddress clientAddr=clientConnection.getRemoteAddress();
+ // Check to see if the client is on the denied list. If so,
+ // then reject it immediately.
+ if((deniedClients != null) && (deniedClients.length > 0) &&
+ AddressMask.maskListContains(clientAddr.getAddress(),
+ clientAddr.getHostName(), deniedClients))
+ {
+ clientConnection.disconnect(
+ DisconnectReason.CONNECTION_REJECTED,
+ sendRejectionNotice,
+ MSGID_LDAP_CONNHANDLER_DENIED_CLIENT,
+ clientConnection.getClientHostPort(),
+ clientConnection.getServerHostPort());
+ iterator.remove();
+ continue;
+ }
+ // Check to see if there is an allowed list and if there is
+ // whether the client is on that list. If not, then reject
+ // the connection.
+ if((allowedClients != null) && (allowedClients.length > 0) &&
+ (!AddressMask.maskListContains(clientAddr.getAddress(),
+ clientAddr.getHostName(), allowedClients)))
+ {
+ clientConnection.disconnect(
+ DisconnectReason.CONNECTION_REJECTED,
+ sendRejectionNotice,
+ MSGID_LDAP_CONNHANDLER_DISALLOWED_CLIENT,
+ clientConnection.getClientHostPort(),
+ clientConnection.getServerHostPort());
+
+ iterator.remove();
+ continue;
+ }
+ clientChannel.socket().setKeepAlive(useKeepAlive);
+ clientChannel.socket().setTcpNoDelay(useTCPNoDelay);
ConnectionSecurityProvider connectionSecurityProvider =
securityProvider.newInstance(clientConnection,
clientChannel);
@@ -1246,44 +1278,6 @@
continue;
}
-
- // Check to see if the client is on the denied list. If so,
- // then reject it immediately.
- if ((deniedClients != null) &&
- AddressMask.maskListContains(clientConnection,
- deniedClients))
- {
- clientConnection.disconnect(
- DisconnectReason.CONNECTION_REJECTED,
- sendRejectionNotice,
- MSGID_LDAP_CONNHANDLER_DENIED_CLIENT,
- clientConnection.getClientHostPort(),
- clientConnection.getServerHostPort());
-
- iterator.remove();
- continue;
- }
-
-
- // Check to see if there is an allowed list and if there is
- // whether the client is on that list. If not, then reject
- // the connection.
- if ((allowedClients != null) && (allowedClients.length > 0) &&
- (! AddressMask.maskListContains(clientConnection,
- allowedClients)))
- {
- clientConnection.disconnect(
- DisconnectReason.CONNECTION_REJECTED,
- sendRejectionNotice,
- MSGID_LDAP_CONNHANDLER_DISALLOWED_CLIENT,
- clientConnection.getClientHostPort(),
- clientConnection.getServerHostPort());
-
- iterator.remove();
- continue;
- }
-
-
// If we've gotten here, then we'll take the connection so
// choose a request handler and register the client with it.
try
--
Gitblit v1.10.0