Added auth result

pull/214/head
M66B 1 year ago
parent 5a72eaf6f5
commit 3aa13a30ba

File diff suppressed because it is too large Load Diff

@ -1276,6 +1276,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
!((Boolean.FALSE.equals(message.dkim) && check_authentication) || !((Boolean.FALSE.equals(message.dkim) && check_authentication) ||
(Boolean.FALSE.equals(message.spf) && check_authentication) || (Boolean.FALSE.equals(message.spf) && check_authentication) ||
(Boolean.FALSE.equals(message.dmarc) && check_authentication) || (Boolean.FALSE.equals(message.dmarc) && check_authentication) ||
(Boolean.FALSE.equals(message.auth) && check_authentication) ||
(Boolean.FALSE.equals(message.reply_domain) && check_reply_domain) || (Boolean.FALSE.equals(message.reply_domain) && check_reply_domain) ||
(Boolean.FALSE.equals(message.mx) && check_mx) || (Boolean.FALSE.equals(message.mx) && check_mx) ||
(Boolean.TRUE.equals(message.blocklist) && check_blocklist)); (Boolean.TRUE.equals(message.blocklist) && check_blocklist));
@ -1377,9 +1378,13 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
!Boolean.FALSE.equals(message.dmarc)) !Boolean.FALSE.equals(message.dmarc))
auths = 3; auths = 3;
if (Boolean.TRUE.equals(message.auth))
auths = 3;
boolean verified = (auths == 3 && (!check_tls || Boolean.TRUE.equals(message.tls))); boolean verified = (auths == 3 && (!check_tls || Boolean.TRUE.equals(message.tls)));
if (message.dkim == null && message.spf == null && message.dmarc == null) if (!Boolean.TRUE.equals(message.auth) &&
message.dkim == null && message.spf == null && message.dmarc == null)
ibAuth.setImageLevel(1); ibAuth.setImageLevel(1);
else else
ibAuth.setImageLevel(auths + 2); ibAuth.setImageLevel(auths + 2);
@ -2020,9 +2025,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibAvatar.setVisibility(main == null || !main.hasPhoto() ? View.GONE : View.VISIBLE); ibAvatar.setVisibility(main == null || !main.hasPhoto() ? View.GONE : View.VISIBLE);
if (main != null && "vmc".equals(main.getType()) && if (main != null && "vmc".equals(main.getType()) &&
Boolean.TRUE.equals(message.dkim) && (Boolean.TRUE.equals(message.auth) ||
Boolean.TRUE.equals(message.spf) && (Boolean.TRUE.equals(message.dkim) &&
Boolean.TRUE.equals(message.dmarc)) { Boolean.TRUE.equals(message.spf) &&
Boolean.TRUE.equals(message.dmarc)))) {
ibVerified.setImageLevel(main.isVerified() ? 1 : 0); ibVerified.setImageLevel(main.isVerified() ? 1 : 0);
ibVerified.setImageTintList(ColorStateList.valueOf(main.isVerified() ibVerified.setImageTintList(ColorStateList.valueOf(main.isVerified()
? colorVerified : colorControlNormal)); ? colorVerified : colorControlNormal));
@ -2765,6 +2771,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
.append(" DKIM=").append(message.dkim == null ? "-" : (message.dkim ? "✓" : "✗")) .append(" DKIM=").append(message.dkim == null ? "-" : (message.dkim ? "✓" : "✗"))
.append(" SPF=").append(message.spf == null ? "-" : (message.spf ? "✓" : "✗")) .append(" SPF=").append(message.spf == null ? "-" : (message.spf ? "✓" : "✗"))
.append(" DMARC=").append(message.dmarc == null ? "-" : (message.dmarc ? "✓" : "✗")) .append(" DMARC=").append(message.dmarc == null ? "-" : (message.dmarc ? "✓" : "✗"))
.append(" AUTH=").append(message.auth == null ? "-" : (message.auth ? "✓" : "✗"))
.append(" BL=").append(message.blocklist == null ? "-" : (message.blocklist ? "✓" : "✗")) .append(" BL=").append(message.blocklist == null ? "-" : (message.blocklist ? "✓" : "✗"))
.append('\n'); .append('\n');
} }
@ -4858,6 +4865,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
result.add("SPF"); result.add("SPF");
if (Boolean.FALSE.equals(message.dmarc)) if (Boolean.FALSE.equals(message.dmarc))
result.add("DMARC"); result.add("DMARC");
if (Boolean.FALSE.equals(message.auth))
result.add("AUTH");
if (Boolean.FALSE.equals(message.mx)) if (Boolean.FALSE.equals(message.mx))
result.add("MX"); result.add("MX");
@ -4875,7 +4884,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
.append(message.spf == null ? "-" : (message.spf ? "✓" : "✗")) .append(message.spf == null ? "-" : (message.spf ? "✓" : "✗"))
.append('\n'); .append('\n');
sb.append("DMARC: ") sb.append("DMARC: ")
.append(message.dmarc == null ? "-" : (message.dmarc ? "✓" : "✗")); .append(message.dmarc == null ? "-" : (message.dmarc ? "✓" : "✗"))
.append('\n');
sb.append("AUTH: ")
.append(message.auth == null ? "-" : (message.auth ? "✓" : "✗"));
} }
if (native_dkim && !TextUtils.isEmpty(message.signedby)) { if (native_dkim && !TextUtils.isEmpty(message.signedby)) {
@ -8142,6 +8154,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
same = false; same = false;
log("dmarc changed", next.id); log("dmarc changed", next.id);
} }
if (!Objects.equals(prev.auth, next.auth)) {
same = false;
log("auth changed", next.id);
}
if (!Objects.equals(prev.mx, next.mx)) { if (!Objects.equals(prev.mx, next.mx)) {
same = false; same = false;
log("mx changed", next.id); log("mx changed", next.id);

@ -3437,6 +3437,7 @@ class Core {
if (message.spf == null && helper.getSPF()) if (message.spf == null && helper.getSPF())
message.spf = true; message.spf = true;
message.dmarc = MessageHelper.getAuthentication("dmarc", authentication); message.dmarc = MessageHelper.getAuthentication("dmarc", authentication);
message.auth = MessageHelper.getAuthentication("auth", authentication);
message.smtp_from = helper.getMailFrom(authentication); message.smtp_from = helper.getMailFrom(authentication);
message.return_path = helper.getReturnPath(); message.return_path = helper.getReturnPath();
message.submitter = helper.getSubmitter(); message.submitter = helper.getSubmitter();
@ -4585,6 +4586,7 @@ class Core {
if (message.spf == null && helper.getSPF()) if (message.spf == null && helper.getSPF())
message.spf = true; message.spf = true;
message.dmarc = MessageHelper.getAuthentication("dmarc", authentication); message.dmarc = MessageHelper.getAuthentication("dmarc", authentication);
message.auth = MessageHelper.getAuthentication("auth", authentication);
message.smtp_from = helper.getMailFrom(authentication); message.smtp_from = helper.getMailFrom(authentication);
message.return_path = helper.getReturnPath(); message.return_path = helper.getReturnPath();
message.submitter = helper.getSubmitter(); message.submitter = helper.getSubmitter();

@ -67,7 +67,7 @@ import javax.mail.internet.InternetAddress;
// https://developer.android.com/topic/libraries/architecture/room.html // https://developer.android.com/topic/libraries/architecture/room.html
@Database( @Database(
version = 286, version = 287,
entities = { entities = {
EntityIdentity.class, EntityIdentity.class,
EntityAccount.class, EntityAccount.class,
@ -2883,6 +2883,12 @@ public abstract class DB extends RoomDatabase {
db.execSQL("UPDATE `attachment` SET available = 0"); db.execSQL("UPDATE `attachment` SET available = 0");
prefs.edit().remove("external_storage").apply(); prefs.edit().remove("external_storage").apply();
} }
}).addMigrations(new Migration(286, 287) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
logMigration(startVersion, endVersion);
db.execSQL("ALTER TABLE `message` ADD COLUMN `auth` INTEGER");
}
}).addMigrations(new Migration(998, 999) { }).addMigrations(new Migration(998, 999) {
@Override @Override
public void migrate(@NonNull SupportSQLiteDatabase db) { public void migrate(@NonNull SupportSQLiteDatabase db) {

@ -163,6 +163,7 @@ public class EntityMessage implements Serializable {
public Boolean dkim; public Boolean dkim;
public Boolean spf; public Boolean spf;
public Boolean dmarc; public Boolean dmarc;
public Boolean auth; // SMTP
public Boolean mx; public Boolean mx;
public Boolean blocklist; public Boolean blocklist;
public Boolean from_domain; // spf/smtp.mailfrom <> from public Boolean from_domain; // spf/smtp.mailfrom <> from
@ -757,6 +758,7 @@ public class EntityMessage implements Serializable {
Objects.equals(this.dkim, other.dkim) && Objects.equals(this.dkim, other.dkim) &&
Objects.equals(this.spf, other.spf) && Objects.equals(this.spf, other.spf) &&
Objects.equals(this.dmarc, other.dmarc) && Objects.equals(this.dmarc, other.dmarc) &&
Objects.equals(this.auth, other.auth) &&
Objects.equals(this.mx, other.mx) && Objects.equals(this.mx, other.mx) &&
Objects.equals(this.blocklist, other.blocklist) && Objects.equals(this.blocklist, other.blocklist) &&
Objects.equals(this.from_domain, other.from_domain) && Objects.equals(this.from_domain, other.from_domain) &&

@ -387,6 +387,9 @@ public class EntityRule {
} else if ("$dmarc".equals(keyword)) { } else if ("$dmarc".equals(keyword)) {
if (!Boolean.TRUE.equals(message.dmarc)) if (!Boolean.TRUE.equals(message.dmarc))
return false; return false;
} else if ("$auth".equals(keyword)) {
if (!Boolean.TRUE.equals(message.auth))
return false;
} else if ("$mx".equals(keyword)) { } else if ("$mx".equals(keyword)) {
if (!Boolean.TRUE.equals(message.mx)) if (!Boolean.TRUE.equals(message.mx))
return false; return false;

@ -2146,6 +2146,7 @@ public class MessageHelper {
List<String> all = new ArrayList<>(); List<String> all = new ArrayList<>();
// https://datatracker.ietf.org/doc/html/rfc8601
String[] results = imessage.getHeader("Authentication-Results"); String[] results = imessage.getHeader("Authentication-Results");
if (results != null) if (results != null)
all.addAll(Arrays.asList(results)); all.addAll(Arrays.asList(results));

Loading…
Cancel
Save