mailery 0.19.0 → 0.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/testing.cjs CHANGED
@@ -17525,7 +17525,7 @@ async function runDnsblChecks(ctx, opts = {}) {
17525
17525
  let listedCount = 0;
17526
17526
  async function processPair(p) {
17527
17527
  const queryName = buildQueryName(p.target, p.targetKind, spamhausQueryHost(p.list.host, cfg.spamhausDqsKey));
17528
- const lookup2 = queryName ? await queryDnsbl(resolver, queryName) : { result: "error", returnCodes: [], errorMessage: "unsupported target format" };
17528
+ const lookup2 = queryName ? await queryDnsbl(resolver, queryName, p.list.host) : { result: "error", returnCodes: [], errorMessage: "unsupported target format" };
17529
17529
  if (lookup2.transient) return;
17530
17530
  if (lookup2.result === "listed") listedCount++;
17531
17531
  await ctx.collections.dnsblChecks.updateOne(
@@ -17586,10 +17586,10 @@ function buildQueryName(target, kind, listHost) {
17586
17586
  return `${domain}.${listHost}`;
17587
17587
  }
17588
17588
  var TRANSIENT_DNS_CODES = /* @__PURE__ */ new Set(["ESERVFAIL", "EREFUSED", "ETIMEOUT", "ETIMEDOUT", "ECONNRESET", "ECONNREFUSED"]);
17589
- async function queryDnsbl(resolver, query) {
17589
+ async function queryDnsbl(resolver, query, listHost) {
17590
17590
  try {
17591
17591
  const records = await resolver.resolve4(query);
17592
- return interpretRecords(records);
17592
+ return interpretRecords(records, listHost);
17593
17593
  } catch (err) {
17594
17594
  const code = err?.code;
17595
17595
  if (code === "ENOTFOUND" || code === "ENODATA") {
@@ -17615,10 +17615,17 @@ var REFUSAL_REASONS = {
17615
17615
  "127.255.255.254": "queried through a public or shared DNS resolver, which Spamhaus blocks. Set dnsbl.spamhausDqsKey (free Spamhaus DQS key) or use a private resolver",
17616
17616
  "127.255.255.255": "this resolver has exceeded the free query limit"
17617
17617
  };
17618
- function interpretRecords(records) {
17618
+ function interpretRecords(records, listHost) {
17619
17619
  if (!records || records.length === 0) {
17620
17620
  return { result: "clean", returnCodes: [], errorMessage: null };
17621
17621
  }
17622
+ if (listHost && REGISTRABLE_ONLY_LISTS.has(listHost) && records.every((r) => r === "127.0.0.1")) {
17623
+ return {
17624
+ result: "error",
17625
+ returnCodes: records,
17626
+ errorMessage: `${listHost} refused the query (127.0.0.1): queried through a public or shared DNS resolver, or over the free query limit. Use a private resolver`
17627
+ };
17628
+ }
17622
17629
  const errorish = records.filter((r) => r.startsWith("127.255.255."));
17623
17630
  if (errorish.length === records.length) {
17624
17631
  const reasons = [...new Set(records.map((r) => REFUSAL_REASONS[r] ?? "unrecognised refusal code"))];