bogus patch
[org.ibex.mail.git] / src / org / ibex / mail / Address.java
index ebf349b..0cbc494 100644 (file)
@@ -26,7 +26,17 @@ public class Address extends JSReflection {
         user = s.substring(0, s.indexOf('@'));
         host = s.substring(s.indexOf('@')+1);
     }
-    public String coerceToString() { return toString(); }
     public String toString() { return description.equals("") ? (user +"@"+ host) : description+" <" + user +"@"+ host + ">"; }
-    public static class Malformed extends RuntimeException { public Malformed(String s) { super(s); } }
+    public String coerceToString() { return toString(); }
+    public static class Malformed extends Message.Malformed { public Malformed(String s) { super(s); } }
+
+    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 */ }
+        }
+        Log.warn(this, "returning false");
+        return false;
+    }
 }