james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r451815 - in /james/jspf/trunk/src: main/java/org/apache/james/jspf/core/SPF1Data.java test/resources/org/apache/james/jspf/tests.yml
Date Sun, 01 Oct 2006 21:32:37 GMT
Author: bago
Date: Sun Oct  1 14:32:36 2006
New Revision: 451815

URL: http://svn.apache.org/viewvc?view=rev&rev=451815
Log:
Few more fixes against official testsuite: we now validate PTR records looking for matching
A records.

Modified:
    james/jspf/trunk/src/main/java/org/apache/james/jspf/core/SPF1Data.java
    james/jspf/trunk/src/test/resources/org/apache/james/jspf/tests.yml

Modified: james/jspf/trunk/src/main/java/org/apache/james/jspf/core/SPF1Data.java
URL: http://svn.apache.org/viewvc/james/jspf/trunk/src/main/java/org/apache/james/jspf/core/SPF1Data.java?view=diff&rev=451815&r1=451814&r2=451815
==============================================================================
--- james/jspf/trunk/src/main/java/org/apache/james/jspf/core/SPF1Data.java (original)
+++ james/jspf/trunk/src/main/java/org/apache/james/jspf/core/SPF1Data.java Sun Oct  1 14:32:36
2006
@@ -21,10 +21,12 @@
 package org.apache.james.jspf.core;
 
 import org.apache.james.jspf.SPF1Utils;
+import org.apache.james.jspf.core.DNSService.TimeoutException;
 import org.apache.james.jspf.exceptions.NoneException;
 import org.apache.james.jspf.exceptions.PermErrorException;
 import org.apache.james.jspf.macro.MacroData;
 
+import java.util.Iterator;
 import java.util.List;
 
 /**
@@ -184,20 +186,33 @@
      */
     public String getClientDomain() {
         if (clientDomain == null) {
+            clientDomain = "unknown";
             try {
                 List records = null;
-                if (IPAddr.isIPV6(ipAddress)) {
+                boolean ip6 = IPAddr.isIPV6(ipAddress);
+                if (ip6) {
                     records = dnsProbe.getRecords(IPAddr.getAddress(ipAddress).getReverseIP()
+ ".ip6.arpa", DNSService.PTR);
                 } else {
                     records = dnsProbe.getRecords(IPAddr.getAddress(ipAddress).getReverseIP()
+ ".in-addr.arpa", DNSService.PTR);
                 }
                 if (records != null && records.size() > 0) {
-                    clientDomain = (String) records.get(0);
-                } else {
-                    clientDomain = ipAddress;
+                    String record = (String) records.get(0);
+                    records = dnsProbe.getRecords(record, ip6 ? DNSService.AAAA : DNSService.A);
+                    if (records != null && records.size() > 0) {
+                        Iterator i = records.iterator();
+                        while (i.hasNext()) {
+                            String next = (String) i.next();
+                            if (IPAddr.getAddress(ipAddress).toString().equals(IPAddr.getAddress(next).toString()))
{
+                                clientDomain = record;
+                                break;
+                            }
+                        }
+                    }
                 }
-            } catch (Exception e) {
-                clientDomain = ipAddress;
+            } catch (TimeoutException e) {
+                // just return the default "unknown".
+            } catch (PermErrorException e) {
+                // just return the default "unknown".
             }
         }
         return clientDomain;

Modified: james/jspf/trunk/src/test/resources/org/apache/james/jspf/tests.yml
URL: http://svn.apache.org/viewvc/james/jspf/trunk/src/test/resources/org/apache/james/jspf/tests.yml?view=diff&rev=451815&r1=451814&r2=451815
==============================================================================
--- james/jspf/trunk/src/test/resources/org/apache/james/jspf/tests.yml (original)
+++ james/jspf/trunk/src/test/resources/org/apache/james/jspf/tests.yml Sun Oct  1 14:32:36
2006
@@ -169,6 +169,8 @@
     - TXT:  Explanation %{r} - %{p} (%{o})
   24.0.0.10.in-addr.arpa:
     - PTR:  my.host.domain.foo.bar
+  my.host.domain.foo.bar:
+    - A:  10.0.0.24
   spf25-test.foo.bar:
     - TXT:  v=spf1 -all exp=exp-spf25-test.foo.bar
   exp-spf25-test.foo.bar:



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message