directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@apache.org
Subject svn commit: r111303 - /incubator/directory/seda/branches/berin_api_proposal/src/java/org/apache/directory/seda/input/Firewall.java /incubator/directory/seda/branches/berin_api_proposal/src/test/org/apache/directory/seda/input/test/TestFirewall.java
Date Wed, 08 Dec 2004 20:16:46 GMT
Author: bloritsch
Date: Wed Dec  8 12:16:44 2004
New Revision: 111303

URL: http://svn.apache.org/viewcvs?view=rev&rev=111303
Log:
Finish the Firewall.  Apparently my tests were failing due to lingering sockets and timing
issues.  The code was good.
Modified:
   incubator/directory/seda/branches/berin_api_proposal/src/java/org/apache/directory/seda/input/Firewall.java
   incubator/directory/seda/branches/berin_api_proposal/src/test/org/apache/directory/seda/input/test/TestFirewall.java

Modified: incubator/directory/seda/branches/berin_api_proposal/src/java/org/apache/directory/seda/input/Firewall.java
Url: http://svn.apache.org/viewcvs/incubator/directory/seda/branches/berin_api_proposal/src/java/org/apache/directory/seda/input/Firewall.java?view=diff&rev=111303&p1=incubator/directory/seda/branches/berin_api_proposal/src/java/org/apache/directory/seda/input/Firewall.java&r1=111302&p2=incubator/directory/seda/branches/berin_api_proposal/src/java/org/apache/directory/seda/input/Firewall.java&r2=111303
==============================================================================
--- incubator/directory/seda/branches/berin_api_proposal/src/java/org/apache/directory/seda/input/Firewall.java
(original)
+++ incubator/directory/seda/branches/berin_api_proposal/src/java/org/apache/directory/seda/input/Firewall.java
Wed Dec  8 12:16:44 2004
@@ -58,6 +58,8 @@
                 if ( m_deny.contains(client.socket().getLocalSocketAddress()) )
                 {
                     client.configureBlocking( true );
+                    client.socket().setSoLinger( true, 0 );
+                    client.socket().setTcpNoDelay( true );
                     client.socket().shutdownInput();
                     client.socket().shutdownOutput();
                     client.close();
@@ -84,5 +86,10 @@
         {
             m_deny.add( localSocketAddress );
         }
+    }
+
+    public void allow( final SocketAddress localSocketAddress )
+    {
+        m_deny.remove( localSocketAddress );
     }
 }

Modified: incubator/directory/seda/branches/berin_api_proposal/src/test/org/apache/directory/seda/input/test/TestFirewall.java
Url: http://svn.apache.org/viewcvs/incubator/directory/seda/branches/berin_api_proposal/src/test/org/apache/directory/seda/input/test/TestFirewall.java?view=diff&rev=111303&p1=incubator/directory/seda/branches/berin_api_proposal/src/test/org/apache/directory/seda/input/test/TestFirewall.java&r1=111302&p2=incubator/directory/seda/branches/berin_api_proposal/src/test/org/apache/directory/seda/input/test/TestFirewall.java&r2=111303
==============================================================================
--- incubator/directory/seda/branches/berin_api_proposal/src/test/org/apache/directory/seda/input/test/TestFirewall.java
(original)
+++ incubator/directory/seda/branches/berin_api_proposal/src/test/org/apache/directory/seda/input/test/TestFirewall.java
Wed Dec  8 12:16:44 2004
@@ -78,11 +78,12 @@
         assertEquals( "test", firewall.getDefaultPipe().dequeue() );
     }
 
-    public void testAccept()
+    public void testAccept() throws IOException
     {
         final Firewall firewall = new Firewall();
         firewall.handleEvent( m_key );
 
+        m_client.getOutputStream().write( "test".getBytes() );
         assertTrue(m_client.isConnected());
         assertFalse(m_client.isClosed());
     }
@@ -94,11 +95,6 @@
 
         firewall.handleEvent( m_key );
 
-        System.out.println(m_client.isConnected());
-        System.out.println(m_client.isClosed());
-        System.out.println(m_client.isInputShutdown());
-        System.out.println(m_client.isOutputShutdown());
-
         try
         {
             m_client.getOutputStream().write( "test".getBytes() );
@@ -108,5 +104,19 @@
         {
             assertTrue("Threw an exception, but not an IOException: " + ioe, ioe instanceof
IOException);
         }
+    }
+
+    public void testAllow() throws IOException
+    {
+        final Firewall firewall = new Firewall();
+        firewall.deny(m_client.getRemoteSocketAddress());
+        // NOTE: the order here is important
+        firewall.allow(m_client.getRemoteSocketAddress());
+
+        firewall.handleEvent( m_key );
+
+        m_client.getOutputStream().write( "test".getBytes() );
+        assertTrue(m_client.isConnected());
+        assertFalse(m_client.isClosed());
     }
 }

Mime
View raw message