update
This commit is contained in:
@ -2,7 +2,7 @@ import * as plugins from '../../plugins.js';
|
||||
import * as paths from '../../paths.js';
|
||||
|
||||
import { Email } from '../core/classes.email.js';
|
||||
import type { MtaService } from '../delivery/classes.mta.js';
|
||||
// MtaService reference removed
|
||||
|
||||
const readFile = plugins.util.promisify(plugins.fs.readFile);
|
||||
const writeFile = plugins.util.promisify(plugins.fs.writeFile);
|
||||
@ -16,7 +16,7 @@ export interface IKeyPaths {
|
||||
export class DKIMCreator {
|
||||
private keysDir: string;
|
||||
|
||||
constructor(private metaRef: MtaService, keysDir = paths.keysDir) {
|
||||
constructor(keysDir = paths.keysDir) {
|
||||
this.keysDir = keysDir;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as plugins from '../../plugins.js';
|
||||
import { MtaService } from '../delivery/classes.mta.js';
|
||||
// MtaService reference removed
|
||||
import { logger } from '../../logger.js';
|
||||
import { SecurityLogger, SecurityLogLevel, SecurityEventType } from '../../security/index.js';
|
||||
|
||||
@ -20,14 +20,13 @@ export interface IDkimVerificationResult {
|
||||
* Enhanced DKIM verifier using smartmail capabilities
|
||||
*/
|
||||
export class DKIMVerifier {
|
||||
public mtaRef: MtaService;
|
||||
// MtaRef reference removed
|
||||
|
||||
// Cache verified results to avoid repeated verification
|
||||
private verificationCache: Map<string, { result: IDkimVerificationResult, timestamp: number }> = new Map();
|
||||
private cacheTtl = 30 * 60 * 1000; // 30 minutes cache
|
||||
|
||||
constructor(mtaRefArg: MtaService) {
|
||||
this.mtaRef = mtaRefArg;
|
||||
constructor() {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,7 +1,7 @@
|
||||
import * as plugins from '../../plugins.js';
|
||||
import { logger } from '../../logger.js';
|
||||
import { SecurityLogger, SecurityLogLevel, SecurityEventType } from '../../security/index.js';
|
||||
import type { MtaService } from '../delivery/classes.mta.js';
|
||||
// MtaService reference removed
|
||||
import type { Email } from '../core/classes.email.js';
|
||||
import type { IDnsVerificationResult } from '../routing/classes.dnsmanager.js';
|
||||
|
||||
@ -63,10 +63,11 @@ export interface DmarcResult {
|
||||
* Class for verifying and enforcing DMARC policies
|
||||
*/
|
||||
export class DmarcVerifier {
|
||||
private mtaRef: MtaService;
|
||||
// DNS Manager reference for verifying records
|
||||
private dnsManager?: any;
|
||||
|
||||
constructor(mtaRefArg: MtaService) {
|
||||
this.mtaRef = mtaRefArg;
|
||||
constructor(dnsManager?: any) {
|
||||
this.dnsManager = dnsManager;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -301,7 +302,9 @@ export class DmarcVerifier {
|
||||
);
|
||||
|
||||
// Lookup DMARC record
|
||||
const dmarcVerificationResult = await this.mtaRef.dnsManager.verifyDmarcRecord(fromDomain);
|
||||
const dmarcVerificationResult = this.dnsManager ?
|
||||
await this.dnsManager.verifyDmarcRecord(fromDomain) :
|
||||
{ found: false, valid: false, error: 'DNS Manager not available' };
|
||||
|
||||
// If DMARC record exists and is valid
|
||||
if (dmarcVerificationResult.found && dmarcVerificationResult.valid) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import * as plugins from '../../plugins.js';
|
||||
import { logger } from '../../logger.js';
|
||||
import { SecurityLogger, SecurityLogLevel, SecurityEventType } from '../../security/index.js';
|
||||
import type { MtaService } from '../delivery/classes.mta.js';
|
||||
// MtaService reference removed
|
||||
import type { Email } from '../core/classes.email.js';
|
||||
import type { IDnsVerificationResult } from '../routing/classes.dnsmanager.js';
|
||||
|
||||
@ -69,11 +69,12 @@ const MAX_SPF_LOOKUPS = 10;
|
||||
* Class for verifying SPF records
|
||||
*/
|
||||
export class SpfVerifier {
|
||||
private mtaRef: MtaService;
|
||||
// DNS Manager reference for verifying records
|
||||
private dnsManager?: any;
|
||||
private lookupCount: number = 0;
|
||||
|
||||
constructor(mtaRefArg: MtaService) {
|
||||
this.mtaRef = mtaRefArg;
|
||||
constructor(dnsManager?: any) {
|
||||
this.dnsManager = dnsManager;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -221,7 +222,9 @@ export class SpfVerifier {
|
||||
|
||||
try {
|
||||
// Look up SPF record
|
||||
const spfVerificationResult = await this.mtaRef.dnsManager.verifySpfRecord(domain);
|
||||
const spfVerificationResult = this.dnsManager ?
|
||||
await this.dnsManager.verifySpfRecord(domain) :
|
||||
{ found: false, valid: false, error: 'DNS Manager not available' };
|
||||
|
||||
if (!spfVerificationResult.found) {
|
||||
return {
|
||||
@ -341,7 +344,9 @@ export class SpfVerifier {
|
||||
|
||||
// Handle redirect
|
||||
const redirectDomain = spfRecord.modifiers.redirect;
|
||||
const redirectResult = await this.mtaRef.dnsManager.verifySpfRecord(redirectDomain);
|
||||
const redirectResult = this.dnsManager ?
|
||||
await this.dnsManager.verifySpfRecord(redirectDomain) :
|
||||
{ found: false, valid: false, error: 'DNS Manager not available' };
|
||||
|
||||
if (!redirectResult.found || !redirectResult.valid) {
|
||||
return {
|
||||
@ -455,7 +460,9 @@ export class SpfVerifier {
|
||||
|
||||
// Check included domain's SPF record
|
||||
const includeDomain = mechanism.value;
|
||||
const includeResult = await this.mtaRef.dnsManager.verifySpfRecord(includeDomain);
|
||||
const includeResult = this.dnsManager ?
|
||||
await this.dnsManager.verifySpfRecord(includeDomain) :
|
||||
{ found: false, valid: false, error: 'DNS Manager not available' };
|
||||
|
||||
if (!includeResult.found || !includeResult.valid) {
|
||||
continue; // Skip this mechanism
|
||||
|
Reference in New Issue
Block a user