james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pgoldst...@apache.org
Subject cvs commit: jakarta-james/src/java/org/apache/james/transport/matchers RemoteAddrInNetwork.java RemoteAddrNotInNetwork.java
Date Tue, 06 Aug 2002 03:01:57 GMT
pgoldstein    2002/08/05 20:01:57

  Modified:    src/java/org/apache/james/transport/matchers
                        RemoteAddrInNetwork.java
                        RemoteAddrNotInNetwork.java
  Log:
  An enhancement to the RemoteAddrNotInNetwork and RemoteAddrInNetwork matchers
  that allows them to take host names as well as IP addresses as parameter.
  
  Thanks to Noel Bergman for this submission.
  
  Revision  Changes    Path
  1.3       +13 -5     jakarta-james/src/java/org/apache/james/transport/matchers/RemoteAddrInNetwork.java
  
  Index: RemoteAddrInNetwork.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/transport/matchers/RemoteAddrInNetwork.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RemoteAddrInNetwork.java	18 Jan 2002 02:48:38 -0000	1.2
  +++ RemoteAddrInNetwork.java	6 Aug 2002 03:01:57 -0000	1.3
  @@ -20,13 +20,13 @@
   
   /**
    * Checks the IP address of the sending server against a comma-
  - * delimited list of  IP addresses.
  + * delimited list of IP addresses or domain names.
    * <P>Networks should be indicated with a wildcard *, e.g. 192.168.* 
    * <br>Note: The wildcard can go at any level, the matcher will match if the
    * sending host's IP address (as a String based on the octet representation)
    * starts with the String indicated in the configuration file, excluding the
    * wildcard.
  - * <p>Multiple addresses can be indicated, e.g: '127.0.0.1,192.168.*'
  + * <p>Multiple addresses can be indicated, e.g: '127.0.0.1,192.168.*,domain.tld'
    *
    * @author  Serge Knystautas <sergek@lokitech.com>
    */
  @@ -46,10 +46,18 @@
                   } catch (UnknownHostException uhe) {
                   }
               }
  -            if (addr.endsWith("*")) {
  -                addr = addr.substring(0, addr.length() - 1);
  +
  +            try {
  +                if (addr.endsWith("*")) {
  +                    addr = addr.substring(0, addr.length() - 1);
  +                }
  +                else {
  +                    addr = InetAddress.getByName(addr).getHostAddress();
  +                }
  +                networks.add(addr);
  +            } catch (UnknownHostException uhe) {
  +                log("Cannot match against invalid domain: " + uhe.getMessage());
               }
  -            networks.add(addr);
           }
       }
   
  
  
  
  1.3       +11 -3     jakarta-james/src/java/org/apache/james/transport/matchers/RemoteAddrNotInNetwork.java
  
  Index: RemoteAddrNotInNetwork.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/transport/matchers/RemoteAddrNotInNetwork.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RemoteAddrNotInNetwork.java	18 Jan 2002 02:48:38 -0000	1.2
  +++ RemoteAddrNotInNetwork.java	6 Aug 2002 03:01:57 -0000	1.3
  @@ -46,10 +46,18 @@
                   } catch (UnknownHostException uhe) {
                   }
               }
  -            if (addr.endsWith("*")) {
  -                addr = addr.substring(0, addr.length() - 1);
  +
  +            try {
  +                if (addr.endsWith("*")) {
  +                    addr = addr.substring(0, addr.length() - 1);
  +                }
  +                else {
  +                    addr = InetAddress.getByName(addr).getHostAddress();
  +                }
  +                networks.add(addr);
  +            } catch (UnknownHostException uhe) {
  +                log("Cannot match against invalid domain: " + uhe.getMessage());
               }
  -            networks.add(addr);
           }
       }
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:james-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:james-dev-help@jakarta.apache.org>


Mime
View raw message