hacks for flaky dns
authoradam <adam@megacz.com>
Thu, 5 Jul 2007 01:36:51 +0000 (01:36 +0000)
committeradam <adam@megacz.com>
Thu, 5 Jul 2007 01:36:51 +0000 (01:36 +0000)
darcs-hash:20070705013651-5007d-db4a43d3e714a24d89897f8d01dcb0c9caaddfdf.gz

src/org/ibex/mail/Address.java

index b54dcfa..1197a30 100644 (file)
@@ -54,13 +54,20 @@ public class Address extends JSReflection implements Serializable {
         return desc && description != null && description.length() > 0 ? (description+" <" + toString() + ">") : toString(); }
     public static class Malformed extends Message.Malformed { public Malformed(String s) { super(s); } }
 
         return desc && description != null && description.length() > 0 ? (description+" <" + toString() + ">") : toString(); }
     public static class Malformed extends Message.Malformed { public Malformed(String s) { super(s); } }
 
+    /** in case of flaky DNS */
+    private static HashSet<String> local = new HashSet<String>();
     public boolean isLocal() {
     public boolean isLocal() {
-        InetAddress[] mx = SMTP.getMailExchangerIPs(host);
-        for(int i=0; i<mx.length; i++) {
-            try { if (NetworkInterface.getByInetAddress(mx[i]) != null) { return true; } }
-            catch (Exception e) { /* DELIBERATE */ }
+        synchronized(local) {
+            if (local.contains(host)) return true;
+            InetAddress[] mx = SMTP.getMailExchangerIPs(host);
+            for(int i=0; i<mx.length; i++) {
+                try { if (NetworkInterface.getByInetAddress(mx[i]) != null) {
+                    local.add(host);
+                    return true;
+                } } catch (Exception e) { /* DELIBERATE */ }
+            }
         }
         }
-        Log.warn(this, "returning false");
+        Log.warn(this, "returning false for " + this + ".isLocal()");
         return false;
     }
 
         return false;
     }