Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 99027 invoked from network); 5 Apr 2009 18:33:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 5 Apr 2009 18:33:48 -0000 Received: (qmail 66309 invoked by uid 500); 5 Apr 2009 18:33:44 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 66220 invoked by uid 500); 5 Apr 2009 18:33:44 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 66209 invoked by uid 99); 5 Apr 2009 18:33:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Apr 2009 18:33:44 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of aw@ice-sa.com designates 212.85.38.228 as permitted sender) Received: from [212.85.38.228] (HELO tor.combios.es) (212.85.38.228) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Apr 2009 18:33:36 +0000 Received: from localhost (localhost [127.0.0.1]) by tor.combios.es (Postfix) with ESMTP id 131F4226070 for ; Sun, 5 Apr 2009 20:31:30 +0200 (CEST) Received: from tor.combios.es ([127.0.0.1]) by localhost (tor.combios.es [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8Phlb7yhBXxx for ; Sun, 5 Apr 2009 20:31:30 +0200 (CEST) Received: from [192.168.245.129] (p549E8FB8.dip0.t-ipconnect.de [84.158.143.184]) by tor.combios.es (Postfix) with ESMTPA id B21A822606E for ; Sun, 5 Apr 2009 20:31:29 +0200 (CEST) Message-ID: <49D8F965.40102@ice-sa.com> Date: Sun, 05 Apr 2009 20:33:09 +0200 From: =?ISO-8859-1?Q?Andr=E9_Warnier?= Reply-To: aw@ice-sa.com User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) MIME-Version: 1.0 To: Tomcat Users List Subject: Re: RemoteAddrValve syntax References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Jonathan Mast wrote: > How do I specify wildcards in the RemoteAddrValue declaration? > > The Tomcat docs says it uses the java.util.regex package, so i wrote a test > case like this: > > String patternStr = "192.168.*.*"; > String searchStr = "192.168.1.2"; > > Pattern p = Pattern.compile(patternStr); > Matcher m = p.matcher(searchStr); > System.out.println("Does " + patternStr); > System.out.println("Match " + searchStr); > boolean b = m.matches(); > System.out.println("Result: " + b); > > Which returns true, however when I placed patternStr into my server.xml file > (following the conventions in the Tomcat docs of escaping the "." with \ ): > allow="192\.168\.*\.*"/> This is not a "Tomcat convention", it is how regular expressions work. In a regular expression, a "." means 'any character' "\." mean 'the character "."' the expression "\.*" means "a ".", 0 or n times" The expression "192.168.1.2", as a regexp, matches "192.168.1.2", but also matches "192A168+1C2" and "19201689152" (and a lot more strings), since an unescaped "." matches any character. The regexp "192.168.*.*" does not make much sense, since the first ".*" will match anything that follows (or nothing), leaving nothing to match for the second ".*". To match any address starting with "192.168.", use or (if you want to be really finicky about it) --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org