+ g = string_append(g, 2, US" smtp.remote-ip=", sender_host_address);
+ }
+ else if (arc_state_reason)
+ g = string_append(g, 3, US" (", arc_state_reason, US")");
+ DEBUG(D_acl) debug_printf("ARC:\tauthres '%.*s'\n",
+ gstring_length(g) - start - 3, g->s + start + 3);
+ }
+else
+ DEBUG(D_acl) debug_printf("ARC:\tno authres\n");
+return g;
+}
+
+
+# ifdef SUPPORT_DMARC
+/* Append a DMARC history record pair for ARC, to the given history set */
+
+gstring *
+arc_dmarc_hist_append(gstring * g)
+{
+if (arc_state)
+ {
+ BOOL first = TRUE;
+ int i = Ustrcmp(arc_state, "pass") == 0 ? ARES_RESULT_PASS
+ : Ustrcmp(arc_state, "fail") == 0 ? ARES_RESULT_FAIL
+ : ARES_RESULT_UNKNOWN;
+ g = string_fmt_append(g, "arc %d\n", i);
+ g = string_fmt_append(g, "arc_policy %d json[",
+ i == ARES_RESULT_PASS ? DMARC_ARC_POLICY_RESULT_PASS
+ : i == ARES_RESULT_FAIL ? DMARC_ARC_POLICY_RESULT_FAIL
+ : DMARC_ARC_POLICY_RESULT_UNUSED);
+ /*XXX would we prefer this backwards? */
+ for (arc_set * as = arc_verify_ctx.arcset_chain; as;
+ as = as->next, first = FALSE)
+ {
+ arc_line * line = as->hdr_as;
+ if (line)
+ {
+ blob * d = &line->d;
+ blob * s = &line->s;
+
+ if (!first)
+ g = string_catn(g, US",", 1);
+
+ g = string_fmt_append(g, " (\"i\":%u," /*)*/
+ " \"d\":\"%.*s\","
+ " \"s\":\"%.*s\"",
+ as->instance,
+ d->data ? (int)d->len : 0, d->data && d->len ? d->data : US"",
+ s->data ? (int)s->len : 0, s->data && s->len ? s->data : US""
+ );
+ if ((line = as->hdr_aar))
+ {
+ blob * ip = &line->ip;
+ if (ip->data && ip->len)
+ g = string_fmt_append(g, ", \"ip\":\"%.*s\"", (int)ip->len, ip->data);
+ }
+
+ g = string_catn(g, US")", 1);
+ }