DMARC: simplification

pull/214/head
M66B 10 months ago
parent 89a4d3ea6d
commit 9c09ce442f

@ -500,17 +500,12 @@ public class ActivityDmarc extends ActivityBase {
if (ip.startsWith("ip4:") || ip.startsWith("ip6:")) { if (ip.startsWith("ip4:") || ip.startsWith("ip6:")) {
String[] net = ip.substring(4).split("/"); String[] net = ip.substring(4).split("/");
Integer prefix = (net.length > 1 ? Helper.parseInt(net[1]) : null); Integer prefix = (net.length > 1 ? Helper.parseInt(net[1]) : null);
if (prefix == null) { if (prefix == null
if (text.equals(net[0])) { ? text.equals(net[0])
valid = allow; : ConnectionHelper.inSubnet(text, net[0], prefix)) {
because = (allow ? '+' : '-') + ip + " in " + p.first; valid = allow;
break; because = (allow ? '+' : '-') + ip + " in " + p.first;
} break;
} else {
if (ConnectionHelper.inSubnet(text, net[0], prefix)) {
valid = allow;
because = (allow ? '+' : '-') + ip + " in " + p.first + "/" + prefix;
}
} }
} else if ("a".equals(ip) || ip.startsWith("a:")) { } else if ("a".equals(ip) || ip.startsWith("a:")) {
String domain = (ip.startsWith("a:") ? ip.substring(2) : p.first); String domain = (ip.startsWith("a:") ? ip.substring(2) : p.first);
@ -526,18 +521,13 @@ public class ActivityDmarc extends ActivityBase {
} catch (UnknownHostException ignored) { } catch (UnknownHostException ignored) {
} }
for (DnsHelper.DnsRecord a : as) for (DnsHelper.DnsRecord a : as)
if (prefix == null) { if (prefix == null
if (text.equals(a.response)) { ? text.equals(a.response)
valid = allow; : ConnectionHelper.inSubnet(text, a.response, prefix)) {
because = (allow ? '+' : '-') + ip + " in " + domain; valid = allow;
break; because = (allow ? '+' : '-') + ip +
} " in " + domain + (prefix == null ? "" : "/" + prefix);
} else { break;
if (ConnectionHelper.inSubnet(text, a.response, prefix)) {
valid = allow;
because = (allow ? '+' : '-') + ip + " in " + domain + "/" + prefix;
break;
}
} }
} else if ("mx".equals(ip) || ip.startsWith("mx:")) { } else if ("mx".equals(ip) || ip.startsWith("mx:")) {
try { try {
@ -556,18 +546,13 @@ public class ActivityDmarc extends ActivityBase {
} catch (UnknownHostException ignored) { } catch (UnknownHostException ignored) {
} }
for (DnsHelper.DnsRecord a : as) { for (DnsHelper.DnsRecord a : as) {
if (prefix == null) { if (prefix == null
if (text.equals(a.response)) { ? text.equals(a.response)
valid = allow; : ConnectionHelper.inSubnet(text, a.response, prefix)) {
because = (allow ? '+' : '-') + ip + " in " + domain; valid = allow;
break; because = (allow ? '+' : '-') + ip +
} " in " + domain + (prefix == null ? "" : "/" + prefix);
} else { break;
if (ConnectionHelper.inSubnet(text, a.response, prefix)) {
valid = allow;
because = (allow ? '+' : '-') + ip + " in " + domain + "/" + prefix;
break;
}
} }
} }
if (valid != null) if (valid != null)

Loading…
Cancel
Save