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.js CHANGED
@@ -17510,7 +17510,7 @@ async function runDnsblChecks(ctx, opts = {}) {
17510
17510
  let listedCount = 0;
17511
17511
  async function processPair(p) {
17512
17512
  const queryName = buildQueryName(p.target, p.targetKind, spamhausQueryHost(p.list.host, cfg.spamhausDqsKey));
17513
- const lookup2 = queryName ? await queryDnsbl(resolver, queryName) : { result: "error", returnCodes: [], errorMessage: "unsupported target format" };
17513
+ const lookup2 = queryName ? await queryDnsbl(resolver, queryName, p.list.host) : { result: "error", returnCodes: [], errorMessage: "unsupported target format" };
17514
17514
  if (lookup2.transient) return;
17515
17515
  if (lookup2.result === "listed") listedCount++;
17516
17516
  await ctx.collections.dnsblChecks.updateOne(
@@ -17571,10 +17571,10 @@ function buildQueryName(target, kind, listHost) {
17571
17571
  return `${domain}.${listHost}`;
17572
17572
  }
17573
17573
  var TRANSIENT_DNS_CODES = /* @__PURE__ */ new Set(["ESERVFAIL", "EREFUSED", "ETIMEOUT", "ETIMEDOUT", "ECONNRESET", "ECONNREFUSED"]);
17574
- async function queryDnsbl(resolver, query) {
17574
+ async function queryDnsbl(resolver, query, listHost) {
17575
17575
  try {
17576
17576
  const records = await resolver.resolve4(query);
17577
- return interpretRecords(records);
17577
+ return interpretRecords(records, listHost);
17578
17578
  } catch (err) {
17579
17579
  const code = err?.code;
17580
17580
  if (code === "ENOTFOUND" || code === "ENODATA") {
@@ -17600,10 +17600,17 @@ var REFUSAL_REASONS = {
17600
17600
  "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",
17601
17601
  "127.255.255.255": "this resolver has exceeded the free query limit"
17602
17602
  };
17603
- function interpretRecords(records) {
17603
+ function interpretRecords(records, listHost) {
17604
17604
  if (!records || records.length === 0) {
17605
17605
  return { result: "clean", returnCodes: [], errorMessage: null };
17606
17606
  }
17607
+ if (listHost && REGISTRABLE_ONLY_LISTS.has(listHost) && records.every((r) => r === "127.0.0.1")) {
17608
+ return {
17609
+ result: "error",
17610
+ returnCodes: records,
17611
+ 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`
17612
+ };
17613
+ }
17607
17614
  const errorish = records.filter((r) => r.startsWith("127.255.255."));
17608
17615
  if (errorish.length === records.length) {
17609
17616
  const reasons = [...new Set(records.map((r) => REFUSAL_REASONS[r] ?? "unrecognised refusal code"))];