feat(mailer-smtp): add in-process security pipeline for SMTP delivery (DKIM/SPF/DMARC, content scanning, IP reputation)
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartmta',
|
||||
version: '2.1.0',
|
||||
version: '2.2.1',
|
||||
description: 'A high-performance, enterprise-grade Mail Transfer Agent (MTA) built from scratch in TypeScript with Rust acceleration.'
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSxzQkFBc0I7SUFDNUIsT0FBTyxFQUFFLE9BQU87SUFDaEIsV0FBVyxFQUFFLHlIQUF5SDtDQUN2SSxDQUFBIn0=
|
||||
3
dist_ts/mail/delivery/index.d.ts
vendored
3
dist_ts/mail/delivery/index.d.ts
vendored
@@ -8,5 +8,4 @@ export type { IRateLimitConfig } from './classes.ratelimiter.js';
|
||||
export * from './classes.unified.rate.limiter.js';
|
||||
export * from './classes.mta.config.js';
|
||||
import * as smtpClientMod from './smtpclient/index.js';
|
||||
import * as smtpServerMod from './smtpserver/index.js';
|
||||
export { smtpClientMod, smtpServerMod };
|
||||
export { smtpClientMod };
|
||||
|
||||
@@ -13,6 +13,5 @@ export * from './classes.unified.rate.limiter.js';
|
||||
export * from './classes.mta.config.js';
|
||||
// Import and export SMTP modules as namespaces to avoid conflicts
|
||||
import * as smtpClientMod from './smtpclient/index.js';
|
||||
import * as smtpServerMod from './smtpserver/index.js';
|
||||
export { smtpClientMod, smtpServerMod };
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjoz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0FBdUM7QUFDdkMsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBQ3pELE9BQU8sRUFBRSxjQUFjLEVBQUUsTUFBTSw4QkFBOEIsQ0FBQztBQUU5RCw2Q0FBNkM7QUFDN0MsT0FBTyxFQUFFLFdBQVcsRUFBRSxNQUFNLDBCQUEwQixDQUFDO0FBR3ZELHVCQUF1QjtBQUN2QixjQUFjLG1DQUFtQyxDQUFDO0FBRWxELGdDQUFnQztBQUNoQyxjQUFjLHlCQUF5QixDQUFDO0FBRXhDLGtFQUFrRTtBQUNsRSxPQUFPLEtBQUssYUFBYSxNQUFNLHVCQUF1QixDQUFDO0FBRXZELE9BQU8sRUFBRSxhQUFhLEVBQUUsQ0FBQyJ9
|
||||
@@ -1,45 +0,0 @@
|
||||
/**
|
||||
* Certificate Utilities for SMTP Server
|
||||
* Provides utilities for managing TLS certificates
|
||||
*/
|
||||
import * as tls from 'tls';
|
||||
/**
|
||||
* Certificate data
|
||||
*/
|
||||
export interface ICertificateData {
|
||||
key: Buffer;
|
||||
cert: Buffer;
|
||||
ca?: Buffer;
|
||||
}
|
||||
/**
|
||||
* Load certificates from PEM format strings
|
||||
* @param options - Certificate options
|
||||
* @returns Certificate data with Buffer format
|
||||
*/
|
||||
export declare function loadCertificatesFromString(options: {
|
||||
key: string | Buffer;
|
||||
cert: string | Buffer;
|
||||
ca?: string | Buffer;
|
||||
}): ICertificateData;
|
||||
/**
|
||||
* Load certificates from files
|
||||
* @param options - Certificate file paths
|
||||
* @returns Certificate data with Buffer format
|
||||
*/
|
||||
export declare function loadCertificatesFromFiles(options: {
|
||||
keyPath: string;
|
||||
certPath: string;
|
||||
caPath?: string;
|
||||
}): ICertificateData;
|
||||
/**
|
||||
* Generate self-signed certificates for testing
|
||||
* @returns Certificate data with Buffer format
|
||||
*/
|
||||
export declare function generateSelfSignedCertificates(): ICertificateData;
|
||||
/**
|
||||
* Create TLS options for secure server or STARTTLS
|
||||
* @param certificates - Certificate data
|
||||
* @param isServer - Whether this is for server (true) or client (false)
|
||||
* @returns TLS options
|
||||
*/
|
||||
export declare function createTlsOptions(certificates: ICertificateData, isServer?: boolean): tls.TlsOptions;
|
||||
File diff suppressed because one or more lines are too long
@@ -1,156 +0,0 @@
|
||||
/**
|
||||
* SMTP Command Handler
|
||||
* Responsible for parsing and handling SMTP commands
|
||||
*/
|
||||
import * as plugins from '../../../plugins.js';
|
||||
import type { ISmtpSession } from './interfaces.js';
|
||||
import type { ICommandHandler, ISmtpServer } from './interfaces.js';
|
||||
import { SmtpCommand } from './constants.js';
|
||||
/**
|
||||
* Handles SMTP commands and responses
|
||||
*/
|
||||
export declare class CommandHandler implements ICommandHandler {
|
||||
/**
|
||||
* Reference to the SMTP server instance
|
||||
*/
|
||||
private smtpServer;
|
||||
/**
|
||||
* Creates a new command handler
|
||||
* @param smtpServer - SMTP server instance
|
||||
*/
|
||||
constructor(smtpServer: ISmtpServer);
|
||||
/**
|
||||
* Process a command from the client
|
||||
* @param socket - Client socket
|
||||
* @param commandLine - Command line from client
|
||||
*/
|
||||
processCommand(socket: plugins.net.Socket | plugins.tls.TLSSocket, commandLine: string): Promise<void>;
|
||||
/**
|
||||
* Send a response to the client
|
||||
* @param socket - Client socket
|
||||
* @param response - Response to send
|
||||
*/
|
||||
sendResponse(socket: plugins.net.Socket | plugins.tls.TLSSocket, response: string): void;
|
||||
/**
|
||||
* Check if a socket error is potentially recoverable
|
||||
* @param error - The error that occurred
|
||||
* @returns Whether the error is potentially recoverable
|
||||
*/
|
||||
private isRecoverableSocketError;
|
||||
/**
|
||||
* Handle recoverable socket errors with retry logic
|
||||
* @param socket - Client socket
|
||||
* @param error - The error that occurred
|
||||
* @param response - The response that failed to send
|
||||
*/
|
||||
private handleSocketError;
|
||||
/**
|
||||
* Handle EHLO command
|
||||
* @param socket - Client socket
|
||||
* @param clientHostname - Client hostname from EHLO command
|
||||
*/
|
||||
handleEhlo(socket: plugins.net.Socket | plugins.tls.TLSSocket, clientHostname: string): void;
|
||||
/**
|
||||
* Handle MAIL FROM command
|
||||
* @param socket - Client socket
|
||||
* @param args - Command arguments
|
||||
*/
|
||||
handleMailFrom(socket: plugins.net.Socket | plugins.tls.TLSSocket, args: string): void;
|
||||
/**
|
||||
* Handle RCPT TO command
|
||||
* @param socket - Client socket
|
||||
* @param args - Command arguments
|
||||
*/
|
||||
handleRcptTo(socket: plugins.net.Socket | plugins.tls.TLSSocket, args: string): void;
|
||||
/**
|
||||
* Handle DATA command
|
||||
* @param socket - Client socket
|
||||
*/
|
||||
handleData(socket: plugins.net.Socket | plugins.tls.TLSSocket): void;
|
||||
/**
|
||||
* Handle RSET command
|
||||
* @param socket - Client socket
|
||||
*/
|
||||
handleRset(socket: plugins.net.Socket | plugins.tls.TLSSocket): void;
|
||||
/**
|
||||
* Handle NOOP command
|
||||
* @param socket - Client socket
|
||||
*/
|
||||
handleNoop(socket: plugins.net.Socket | plugins.tls.TLSSocket): void;
|
||||
/**
|
||||
* Handle QUIT command
|
||||
* @param socket - Client socket
|
||||
*/
|
||||
handleQuit(socket: plugins.net.Socket | plugins.tls.TLSSocket, args?: string): void;
|
||||
/**
|
||||
* Handle AUTH command
|
||||
* @param socket - Client socket
|
||||
* @param args - Command arguments
|
||||
*/
|
||||
private handleAuth;
|
||||
/**
|
||||
* Handle AUTH PLAIN authentication
|
||||
* @param socket - Client socket
|
||||
* @param session - Session
|
||||
* @param initialResponse - Optional initial response
|
||||
*/
|
||||
private handleAuthPlain;
|
||||
/**
|
||||
* Handle AUTH LOGIN authentication
|
||||
* @param socket - Client socket
|
||||
* @param session - Session
|
||||
* @param initialResponse - Optional initial response
|
||||
*/
|
||||
private handleAuthLogin;
|
||||
/**
|
||||
* Handle AUTH LOGIN response
|
||||
* @param socket - Client socket
|
||||
* @param session - Session
|
||||
* @param response - Response from client
|
||||
*/
|
||||
private handleAuthLoginResponse;
|
||||
/**
|
||||
* Handle HELP command
|
||||
* @param socket - Client socket
|
||||
* @param args - Command arguments
|
||||
*/
|
||||
private handleHelp;
|
||||
/**
|
||||
* Handle VRFY command (Verify user/mailbox)
|
||||
* RFC 5321 Section 3.5.1: Server MAY respond with 252 to avoid disclosing sensitive information
|
||||
* @param socket - Client socket
|
||||
* @param args - Command arguments (username to verify)
|
||||
*/
|
||||
private handleVrfy;
|
||||
/**
|
||||
* Handle EXPN command (Expand mailing list)
|
||||
* RFC 5321 Section 3.5.2: Server MAY disable this for security
|
||||
* @param socket - Client socket
|
||||
* @param args - Command arguments (mailing list to expand)
|
||||
*/
|
||||
private handleExpn;
|
||||
/**
|
||||
* Reset session to after-EHLO state
|
||||
* @param session - SMTP session to reset
|
||||
*/
|
||||
private resetSession;
|
||||
/**
|
||||
* Validate command sequence based on current state
|
||||
* @param command - Command to validate
|
||||
* @param session - Current session
|
||||
* @returns Whether the command is valid in the current state
|
||||
*/
|
||||
private validateCommandSequence;
|
||||
/**
|
||||
* Handle an SMTP command (interface requirement)
|
||||
*/
|
||||
handleCommand(socket: plugins.net.Socket | plugins.tls.TLSSocket, command: SmtpCommand, args: string, session: ISmtpSession): Promise<void>;
|
||||
/**
|
||||
* Get supported commands for current session state (interface requirement)
|
||||
*/
|
||||
getSupportedCommands(session: ISmtpSession): SmtpCommand[];
|
||||
/**
|
||||
* Clean up resources
|
||||
*/
|
||||
destroy(): void;
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -1,159 +0,0 @@
|
||||
/**
|
||||
* SMTP Connection Manager
|
||||
* Responsible for managing socket connections to the SMTP server
|
||||
*/
|
||||
import * as plugins from '../../../plugins.js';
|
||||
import type { IConnectionManager, ISmtpServer } from './interfaces.js';
|
||||
/**
|
||||
* Manager for SMTP connections
|
||||
* Handles connection setup, event listeners, and lifecycle management
|
||||
* Provides resource management, connection tracking, and monitoring
|
||||
*/
|
||||
export declare class ConnectionManager implements IConnectionManager {
|
||||
/**
|
||||
* Reference to the SMTP server instance
|
||||
*/
|
||||
private smtpServer;
|
||||
/**
|
||||
* Set of active socket connections
|
||||
*/
|
||||
private activeConnections;
|
||||
/**
|
||||
* Connection tracking for resource management
|
||||
*/
|
||||
private connectionStats;
|
||||
/**
|
||||
* Per-IP connection tracking for rate limiting
|
||||
*/
|
||||
private ipConnections;
|
||||
/**
|
||||
* Resource monitoring interval
|
||||
*/
|
||||
private resourceCheckInterval;
|
||||
/**
|
||||
* Track cleanup timers so we can clear them
|
||||
*/
|
||||
private cleanupTimers;
|
||||
/**
|
||||
* SMTP server options with enhanced resource controls
|
||||
*/
|
||||
private options;
|
||||
/**
|
||||
* Creates a new connection manager with enhanced resource management
|
||||
* @param smtpServer - SMTP server instance
|
||||
*/
|
||||
constructor(smtpServer: ISmtpServer);
|
||||
/**
|
||||
* Start resource monitoring interval to check resource usage
|
||||
*/
|
||||
private startResourceMonitoring;
|
||||
/**
|
||||
* Monitor resource usage and log statistics
|
||||
*/
|
||||
private monitorResourceUsage;
|
||||
/**
|
||||
* Clean up expired IP rate limits and perform additional resource monitoring
|
||||
*/
|
||||
private cleanupIpRateLimits;
|
||||
/**
|
||||
* Validate and repair resource tracking to prevent leaks
|
||||
*/
|
||||
private validateResourceTracking;
|
||||
/**
|
||||
* Handle a new connection with resource management
|
||||
* @param socket - Client socket
|
||||
*/
|
||||
handleNewConnection(socket: plugins.net.Socket): Promise<void>;
|
||||
/**
|
||||
* Check if an IP has exceeded the rate limit
|
||||
* @param ip - Client IP address
|
||||
* @returns True if rate limited
|
||||
*/
|
||||
private isIPRateLimited;
|
||||
/**
|
||||
* Track a new connection from an IP
|
||||
* @param ip - Client IP address
|
||||
*/
|
||||
private trackIPConnection;
|
||||
/**
|
||||
* Check if an IP has reached its connection limit
|
||||
* @param ip - Client IP address
|
||||
* @returns True if limit reached
|
||||
*/
|
||||
private hasReachedIPConnectionLimit;
|
||||
/**
|
||||
* Handle a new secure TLS connection with resource management
|
||||
* @param socket - Client TLS socket
|
||||
*/
|
||||
handleNewSecureConnection(socket: plugins.tls.TLSSocket): Promise<void>;
|
||||
/**
|
||||
* Set up event handlers for a socket with enhanced resource management
|
||||
* @param socket - Client socket
|
||||
*/
|
||||
setupSocketEventHandlers(socket: plugins.net.Socket | plugins.tls.TLSSocket): void;
|
||||
/**
|
||||
* Get the current connection count
|
||||
* @returns Number of active connections
|
||||
*/
|
||||
getConnectionCount(): number;
|
||||
/**
|
||||
* Check if the server has reached the maximum number of connections
|
||||
* @returns True if max connections reached
|
||||
*/
|
||||
hasReachedMaxConnections(): boolean;
|
||||
/**
|
||||
* Close all active connections
|
||||
*/
|
||||
closeAllConnections(): void;
|
||||
/**
|
||||
* Handle socket close event
|
||||
* @param socket - Client socket
|
||||
* @param hadError - Whether the socket was closed due to error
|
||||
*/
|
||||
private handleSocketClose;
|
||||
/**
|
||||
* Handle socket error event
|
||||
* @param socket - Client socket
|
||||
* @param error - Error object
|
||||
*/
|
||||
private handleSocketError;
|
||||
/**
|
||||
* Handle socket timeout event
|
||||
* @param socket - Client socket
|
||||
*/
|
||||
private handleSocketTimeout;
|
||||
/**
|
||||
* Reject a connection
|
||||
* @param socket - Client socket
|
||||
* @param reason - Reason for rejection
|
||||
*/
|
||||
private rejectConnection;
|
||||
/**
|
||||
* Send greeting message
|
||||
* @param socket - Client socket
|
||||
*/
|
||||
private sendGreeting;
|
||||
/**
|
||||
* Send service closing notification
|
||||
* @param socket - Client socket
|
||||
*/
|
||||
private sendServiceClosing;
|
||||
/**
|
||||
* Send response to client
|
||||
* @param socket - Client socket
|
||||
* @param response - Response to send
|
||||
*/
|
||||
private sendResponse;
|
||||
/**
|
||||
* Handle a new connection (interface requirement)
|
||||
*/
|
||||
handleConnection(socket: plugins.net.Socket | plugins.tls.TLSSocket, secure: boolean): Promise<void>;
|
||||
/**
|
||||
* Check if accepting new connections (interface requirement)
|
||||
*/
|
||||
canAcceptConnection(): boolean;
|
||||
/**
|
||||
* Clean up resources
|
||||
*/
|
||||
destroy(): void;
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
130
dist_ts/mail/delivery/smtpserver/constants.d.ts
vendored
130
dist_ts/mail/delivery/smtpserver/constants.d.ts
vendored
@@ -1,130 +0,0 @@
|
||||
/**
|
||||
* SMTP Server Constants
|
||||
* This file contains all constants and enums used by the SMTP server
|
||||
*/
|
||||
import { SmtpState } from '../interfaces.js';
|
||||
export { SmtpState };
|
||||
/**
|
||||
* SMTP Response Codes
|
||||
* Based on RFC 5321 and common SMTP practice
|
||||
*/
|
||||
export declare enum SmtpResponseCode {
|
||||
SUCCESS = 250,// Requested mail action okay, completed
|
||||
SYSTEM_STATUS = 211,// System status, or system help reply
|
||||
HELP_MESSAGE = 214,// Help message
|
||||
SERVICE_READY = 220,// <domain> Service ready
|
||||
SERVICE_CLOSING = 221,// <domain> Service closing transmission channel
|
||||
AUTHENTICATION_SUCCESSFUL = 235,// Authentication successful
|
||||
OK = 250,// Requested mail action okay, completed
|
||||
FORWARD = 251,// User not local; will forward to <forward-path>
|
||||
CANNOT_VRFY = 252,// Cannot VRFY user, but will accept message and attempt delivery
|
||||
MORE_INFO_NEEDED = 334,// Server challenge for authentication
|
||||
START_MAIL_INPUT = 354,// Start mail input; end with <CRLF>.<CRLF>
|
||||
SERVICE_NOT_AVAILABLE = 421,// <domain> Service not available, closing transmission channel
|
||||
MAILBOX_TEMPORARILY_UNAVAILABLE = 450,// Requested mail action not taken: mailbox unavailable
|
||||
LOCAL_ERROR = 451,// Requested action aborted: local error in processing
|
||||
INSUFFICIENT_STORAGE = 452,// Requested action not taken: insufficient system storage
|
||||
TLS_UNAVAILABLE_TEMP = 454,// TLS not available due to temporary reason
|
||||
SYNTAX_ERROR = 500,// Syntax error, command unrecognized
|
||||
SYNTAX_ERROR_PARAMETERS = 501,// Syntax error in parameters or arguments
|
||||
COMMAND_NOT_IMPLEMENTED = 502,// Command not implemented
|
||||
BAD_SEQUENCE = 503,// Bad sequence of commands
|
||||
COMMAND_PARAMETER_NOT_IMPLEMENTED = 504,// Command parameter not implemented
|
||||
AUTH_REQUIRED = 530,// Authentication required
|
||||
AUTH_FAILED = 535,// Authentication credentials invalid
|
||||
MAILBOX_UNAVAILABLE = 550,// Requested action not taken: mailbox unavailable
|
||||
USER_NOT_LOCAL = 551,// User not local; please try <forward-path>
|
||||
EXCEEDED_STORAGE = 552,// Requested mail action aborted: exceeded storage allocation
|
||||
MAILBOX_NAME_INVALID = 553,// Requested action not taken: mailbox name not allowed
|
||||
TRANSACTION_FAILED = 554,// Transaction failed
|
||||
MAIL_RCPT_PARAMETERS_INVALID = 555
|
||||
}
|
||||
/**
|
||||
* SMTP Command Types
|
||||
*/
|
||||
export declare enum SmtpCommand {
|
||||
HELO = "HELO",
|
||||
EHLO = "EHLO",
|
||||
MAIL_FROM = "MAIL",
|
||||
RCPT_TO = "RCPT",
|
||||
DATA = "DATA",
|
||||
RSET = "RSET",
|
||||
NOOP = "NOOP",
|
||||
QUIT = "QUIT",
|
||||
STARTTLS = "STARTTLS",
|
||||
AUTH = "AUTH",
|
||||
HELP = "HELP",
|
||||
VRFY = "VRFY",
|
||||
EXPN = "EXPN"
|
||||
}
|
||||
/**
|
||||
* Security log event types
|
||||
*/
|
||||
export declare enum SecurityEventType {
|
||||
CONNECTION = "connection",
|
||||
AUTHENTICATION = "authentication",
|
||||
COMMAND = "command",
|
||||
DATA = "data",
|
||||
IP_REPUTATION = "ip_reputation",
|
||||
TLS_NEGOTIATION = "tls_negotiation",
|
||||
DKIM = "dkim",
|
||||
SPF = "spf",
|
||||
DMARC = "dmarc",
|
||||
EMAIL_VALIDATION = "email_validation",
|
||||
SPAM = "spam",
|
||||
ACCESS_CONTROL = "access_control"
|
||||
}
|
||||
/**
|
||||
* Security log levels
|
||||
*/
|
||||
export declare enum SecurityLogLevel {
|
||||
DEBUG = "debug",
|
||||
INFO = "info",
|
||||
WARN = "warn",
|
||||
ERROR = "error"
|
||||
}
|
||||
/**
|
||||
* SMTP Server Defaults
|
||||
*/
|
||||
export declare const SMTP_DEFAULTS: {
|
||||
CONNECTION_TIMEOUT: number;
|
||||
SOCKET_TIMEOUT: number;
|
||||
DATA_TIMEOUT: number;
|
||||
CLEANUP_INTERVAL: number;
|
||||
MAX_CONNECTIONS: number;
|
||||
MAX_RECIPIENTS: number;
|
||||
MAX_MESSAGE_SIZE: number;
|
||||
SMTP_PORT: number;
|
||||
SUBMISSION_PORT: number;
|
||||
SECURE_PORT: number;
|
||||
HOSTNAME: string;
|
||||
CRLF: string;
|
||||
};
|
||||
/**
|
||||
* SMTP Command Patterns
|
||||
* Regular expressions for parsing SMTP commands
|
||||
*/
|
||||
export declare const SMTP_PATTERNS: {
|
||||
EHLO: RegExp;
|
||||
MAIL_FROM: RegExp;
|
||||
RCPT_TO: RegExp;
|
||||
PARAM: RegExp;
|
||||
EMAIL: RegExp;
|
||||
END_DATA: RegExp;
|
||||
};
|
||||
/**
|
||||
* SMTP Extension List
|
||||
* These extensions are advertised in the EHLO response
|
||||
*/
|
||||
export declare const SMTP_EXTENSIONS: {
|
||||
PIPELINING: string;
|
||||
SIZE: string;
|
||||
EIGHTBITMIME: string;
|
||||
STARTTLS: string;
|
||||
AUTH: string;
|
||||
ENHANCEDSTATUSCODES: string;
|
||||
HELP: string;
|
||||
CHUNKING: string;
|
||||
DSN: string;
|
||||
formatExtension(name: string, parameter?: string | number): string;
|
||||
};
|
||||
@@ -1,162 +0,0 @@
|
||||
/**
|
||||
* SMTP Server Constants
|
||||
* This file contains all constants and enums used by the SMTP server
|
||||
*/
|
||||
import { SmtpState } from '../interfaces.js';
|
||||
// Re-export SmtpState enum from the main interfaces file
|
||||
export { SmtpState };
|
||||
/**
|
||||
* SMTP Response Codes
|
||||
* Based on RFC 5321 and common SMTP practice
|
||||
*/
|
||||
export var SmtpResponseCode;
|
||||
(function (SmtpResponseCode) {
|
||||
// Success codes (2xx)
|
||||
SmtpResponseCode[SmtpResponseCode["SUCCESS"] = 250] = "SUCCESS";
|
||||
SmtpResponseCode[SmtpResponseCode["SYSTEM_STATUS"] = 211] = "SYSTEM_STATUS";
|
||||
SmtpResponseCode[SmtpResponseCode["HELP_MESSAGE"] = 214] = "HELP_MESSAGE";
|
||||
SmtpResponseCode[SmtpResponseCode["SERVICE_READY"] = 220] = "SERVICE_READY";
|
||||
SmtpResponseCode[SmtpResponseCode["SERVICE_CLOSING"] = 221] = "SERVICE_CLOSING";
|
||||
SmtpResponseCode[SmtpResponseCode["AUTHENTICATION_SUCCESSFUL"] = 235] = "AUTHENTICATION_SUCCESSFUL";
|
||||
SmtpResponseCode[SmtpResponseCode["OK"] = 250] = "OK";
|
||||
SmtpResponseCode[SmtpResponseCode["FORWARD"] = 251] = "FORWARD";
|
||||
SmtpResponseCode[SmtpResponseCode["CANNOT_VRFY"] = 252] = "CANNOT_VRFY";
|
||||
// Intermediate codes (3xx)
|
||||
SmtpResponseCode[SmtpResponseCode["MORE_INFO_NEEDED"] = 334] = "MORE_INFO_NEEDED";
|
||||
SmtpResponseCode[SmtpResponseCode["START_MAIL_INPUT"] = 354] = "START_MAIL_INPUT";
|
||||
// Temporary error codes (4xx)
|
||||
SmtpResponseCode[SmtpResponseCode["SERVICE_NOT_AVAILABLE"] = 421] = "SERVICE_NOT_AVAILABLE";
|
||||
SmtpResponseCode[SmtpResponseCode["MAILBOX_TEMPORARILY_UNAVAILABLE"] = 450] = "MAILBOX_TEMPORARILY_UNAVAILABLE";
|
||||
SmtpResponseCode[SmtpResponseCode["LOCAL_ERROR"] = 451] = "LOCAL_ERROR";
|
||||
SmtpResponseCode[SmtpResponseCode["INSUFFICIENT_STORAGE"] = 452] = "INSUFFICIENT_STORAGE";
|
||||
SmtpResponseCode[SmtpResponseCode["TLS_UNAVAILABLE_TEMP"] = 454] = "TLS_UNAVAILABLE_TEMP";
|
||||
// Permanent error codes (5xx)
|
||||
SmtpResponseCode[SmtpResponseCode["SYNTAX_ERROR"] = 500] = "SYNTAX_ERROR";
|
||||
SmtpResponseCode[SmtpResponseCode["SYNTAX_ERROR_PARAMETERS"] = 501] = "SYNTAX_ERROR_PARAMETERS";
|
||||
SmtpResponseCode[SmtpResponseCode["COMMAND_NOT_IMPLEMENTED"] = 502] = "COMMAND_NOT_IMPLEMENTED";
|
||||
SmtpResponseCode[SmtpResponseCode["BAD_SEQUENCE"] = 503] = "BAD_SEQUENCE";
|
||||
SmtpResponseCode[SmtpResponseCode["COMMAND_PARAMETER_NOT_IMPLEMENTED"] = 504] = "COMMAND_PARAMETER_NOT_IMPLEMENTED";
|
||||
SmtpResponseCode[SmtpResponseCode["AUTH_REQUIRED"] = 530] = "AUTH_REQUIRED";
|
||||
SmtpResponseCode[SmtpResponseCode["AUTH_FAILED"] = 535] = "AUTH_FAILED";
|
||||
SmtpResponseCode[SmtpResponseCode["MAILBOX_UNAVAILABLE"] = 550] = "MAILBOX_UNAVAILABLE";
|
||||
SmtpResponseCode[SmtpResponseCode["USER_NOT_LOCAL"] = 551] = "USER_NOT_LOCAL";
|
||||
SmtpResponseCode[SmtpResponseCode["EXCEEDED_STORAGE"] = 552] = "EXCEEDED_STORAGE";
|
||||
SmtpResponseCode[SmtpResponseCode["MAILBOX_NAME_INVALID"] = 553] = "MAILBOX_NAME_INVALID";
|
||||
SmtpResponseCode[SmtpResponseCode["TRANSACTION_FAILED"] = 554] = "TRANSACTION_FAILED";
|
||||
SmtpResponseCode[SmtpResponseCode["MAIL_RCPT_PARAMETERS_INVALID"] = 555] = "MAIL_RCPT_PARAMETERS_INVALID";
|
||||
})(SmtpResponseCode || (SmtpResponseCode = {}));
|
||||
/**
|
||||
* SMTP Command Types
|
||||
*/
|
||||
export var SmtpCommand;
|
||||
(function (SmtpCommand) {
|
||||
SmtpCommand["HELO"] = "HELO";
|
||||
SmtpCommand["EHLO"] = "EHLO";
|
||||
SmtpCommand["MAIL_FROM"] = "MAIL";
|
||||
SmtpCommand["RCPT_TO"] = "RCPT";
|
||||
SmtpCommand["DATA"] = "DATA";
|
||||
SmtpCommand["RSET"] = "RSET";
|
||||
SmtpCommand["NOOP"] = "NOOP";
|
||||
SmtpCommand["QUIT"] = "QUIT";
|
||||
SmtpCommand["STARTTLS"] = "STARTTLS";
|
||||
SmtpCommand["AUTH"] = "AUTH";
|
||||
SmtpCommand["HELP"] = "HELP";
|
||||
SmtpCommand["VRFY"] = "VRFY";
|
||||
SmtpCommand["EXPN"] = "EXPN";
|
||||
})(SmtpCommand || (SmtpCommand = {}));
|
||||
/**
|
||||
* Security log event types
|
||||
*/
|
||||
export var SecurityEventType;
|
||||
(function (SecurityEventType) {
|
||||
SecurityEventType["CONNECTION"] = "connection";
|
||||
SecurityEventType["AUTHENTICATION"] = "authentication";
|
||||
SecurityEventType["COMMAND"] = "command";
|
||||
SecurityEventType["DATA"] = "data";
|
||||
SecurityEventType["IP_REPUTATION"] = "ip_reputation";
|
||||
SecurityEventType["TLS_NEGOTIATION"] = "tls_negotiation";
|
||||
SecurityEventType["DKIM"] = "dkim";
|
||||
SecurityEventType["SPF"] = "spf";
|
||||
SecurityEventType["DMARC"] = "dmarc";
|
||||
SecurityEventType["EMAIL_VALIDATION"] = "email_validation";
|
||||
SecurityEventType["SPAM"] = "spam";
|
||||
SecurityEventType["ACCESS_CONTROL"] = "access_control";
|
||||
})(SecurityEventType || (SecurityEventType = {}));
|
||||
/**
|
||||
* Security log levels
|
||||
*/
|
||||
export var SecurityLogLevel;
|
||||
(function (SecurityLogLevel) {
|
||||
SecurityLogLevel["DEBUG"] = "debug";
|
||||
SecurityLogLevel["INFO"] = "info";
|
||||
SecurityLogLevel["WARN"] = "warn";
|
||||
SecurityLogLevel["ERROR"] = "error";
|
||||
})(SecurityLogLevel || (SecurityLogLevel = {}));
|
||||
/**
|
||||
* SMTP Server Defaults
|
||||
*/
|
||||
export const SMTP_DEFAULTS = {
|
||||
// Default timeouts in milliseconds
|
||||
CONNECTION_TIMEOUT: 30000, // 30 seconds
|
||||
SOCKET_TIMEOUT: 300000, // 5 minutes
|
||||
DATA_TIMEOUT: 60000, // 1 minute
|
||||
CLEANUP_INTERVAL: 5000, // 5 seconds
|
||||
// Default limits
|
||||
MAX_CONNECTIONS: 100,
|
||||
MAX_RECIPIENTS: 100,
|
||||
MAX_MESSAGE_SIZE: 10485760, // 10MB
|
||||
// Default ports
|
||||
SMTP_PORT: 25,
|
||||
SUBMISSION_PORT: 587,
|
||||
SECURE_PORT: 465,
|
||||
// Default hostname
|
||||
HOSTNAME: 'mail.lossless.one',
|
||||
// CRLF line ending required by SMTP protocol
|
||||
CRLF: '\r\n',
|
||||
};
|
||||
/**
|
||||
* SMTP Command Patterns
|
||||
* Regular expressions for parsing SMTP commands
|
||||
*/
|
||||
export const SMTP_PATTERNS = {
|
||||
// Match EHLO/HELO command: "EHLO example.com"
|
||||
// Made very permissive to handle various client implementations
|
||||
EHLO: /^(?:EHLO|HELO)\s+(.+)$/i,
|
||||
// Match MAIL FROM command: "MAIL FROM:<user@example.com> [PARAM=VALUE]"
|
||||
// Made more permissive with whitespace and parameter formats
|
||||
MAIL_FROM: /^MAIL\s+FROM\s*:\s*<([^>]*)>((?:\s+[a-zA-Z0-9][a-zA-Z0-9\-]*(?:=[^\s]+)?)*)$/i,
|
||||
// Match RCPT TO command: "RCPT TO:<user@example.com> [PARAM=VALUE]"
|
||||
// Made more permissive with whitespace and parameter formats
|
||||
RCPT_TO: /^RCPT\s+TO\s*:\s*<([^>]*)>((?:\s+[a-zA-Z0-9][a-zA-Z0-9\-]*(?:=[^\s]+)?)*)$/i,
|
||||
// Match parameter format: "PARAM=VALUE"
|
||||
PARAM: /\s+([A-Za-z0-9][A-Za-z0-9\-]*)(?:=([^\s]+))?/g,
|
||||
// Match email address format - basic validation
|
||||
// This pattern rejects common invalid formats while being permissive for edge cases
|
||||
// Checks: no spaces, has @, has domain with dot, no double dots, proper domain format
|
||||
EMAIL: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
|
||||
// Match end of DATA marker: \r\n.\r\n or just .\r\n at the start of a line (to handle various client implementations)
|
||||
END_DATA: /(\r\n\.\r\n$)|(\n\.\r\n$)|(\r\n\.\n$)|(\n\.\n$)|^\.(\r\n|\n)$/,
|
||||
};
|
||||
/**
|
||||
* SMTP Extension List
|
||||
* These extensions are advertised in the EHLO response
|
||||
*/
|
||||
export const SMTP_EXTENSIONS = {
|
||||
// Basic extensions (RFC 1869)
|
||||
PIPELINING: 'PIPELINING',
|
||||
SIZE: 'SIZE',
|
||||
EIGHTBITMIME: '8BITMIME',
|
||||
// Security extensions
|
||||
STARTTLS: 'STARTTLS',
|
||||
AUTH: 'AUTH',
|
||||
// Additional extensions
|
||||
ENHANCEDSTATUSCODES: 'ENHANCEDSTATUSCODES',
|
||||
HELP: 'HELP',
|
||||
CHUNKING: 'CHUNKING',
|
||||
DSN: 'DSN',
|
||||
// Format an extension with a parameter
|
||||
formatExtension(name, parameter) {
|
||||
return parameter !== undefined ? `${name} ${parameter}` : name;
|
||||
}
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uc3RhbnRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vdHMvbWFpbC9kZWxpdmVyeS9zbXRwc2VydmVyL2NvbnN0YW50cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7O0dBR0c7QUFFSCxPQUFPLEVBQUUsU0FBUyxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFN0MseURBQXlEO0FBQ3pELE9BQU8sRUFBRSxTQUFTLEVBQUUsQ0FBQztBQUVyQjs7O0dBR0c7QUFDSCxNQUFNLENBQU4sSUFBWSxnQkFxQ1g7QUFyQ0QsV0FBWSxnQkFBZ0I7SUFDMUIsc0JBQXNCO0lBQ3RCLCtEQUFhLENBQUE7SUFDYiwyRUFBbUIsQ0FBQTtJQUNuQix5RUFBa0IsQ0FBQTtJQUNsQiwyRUFBbUIsQ0FBQTtJQUNuQiwrRUFBcUIsQ0FBQTtJQUNyQixtR0FBK0IsQ0FBQTtJQUMvQixxREFBUSxDQUFBO0lBQ1IsK0RBQWEsQ0FBQTtJQ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FBUyxDQUFDLENBQUMsQ0FBQyxHQUFHLElBQUksSUFBSSxTQUFTLEVBQUUsQ0FBQyxDQUFDLENBQUMsSUFBSSxDQUFDO0lBQ2pFLENBQUM7Q0FDRixDQUFDIn0=
|
||||
@@ -1,14 +0,0 @@
|
||||
/**
|
||||
* SMTP Server Creation Factory
|
||||
* Provides a simple way to create a complete SMTP server
|
||||
*/
|
||||
import { SmtpServer } from './smtp-server.js';
|
||||
import type { ISmtpServerOptions } from './interfaces.js';
|
||||
import { UnifiedEmailServer } from '../../routing/classes.unified.email.server.js';
|
||||
/**
|
||||
* Create a complete SMTP server with all components
|
||||
* @param emailServer - Email server reference
|
||||
* @param options - SMTP server options
|
||||
* @returns Configured SMTP server instance
|
||||
*/
|
||||
export declare function createSmtpServer(emailServer: UnifiedEmailServer, options: ISmtpServerOptions): SmtpServer;
|
||||
@@ -1,28 +0,0 @@
|
||||
/**
|
||||
* SMTP Server Creation Factory
|
||||
* Provides a simple way to create a complete SMTP server
|
||||
*/
|
||||
import { SmtpServer } from './smtp-server.js';
|
||||
import { SessionManager } from './session-manager.js';
|
||||
import { ConnectionManager } from './connection-manager.js';
|
||||
import { CommandHandler } from './command-handler.js';
|
||||
import { DataHandler } from './data-handler.js';
|
||||
import { TlsHandler } from './tls-handler.js';
|
||||
import { SecurityHandler } from './security-handler.js';
|
||||
import { UnifiedEmailServer } from '../../routing/classes.unified.email.server.js';
|
||||
/**
|
||||
* Create a complete SMTP server with all components
|
||||
* @param emailServer - Email server reference
|
||||
* @param options - SMTP server options
|
||||
* @returns Configured SMTP server instance
|
||||
*/
|
||||
export function createSmtpServer(emailServer, options) {
|
||||
// First create the SMTP server instance
|
||||
const smtpServer = new SmtpServer({
|
||||
emailServer,
|
||||
options
|
||||
});
|
||||
// Return the configured server
|
||||
return smtpServer;
|
||||
}
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3JlYXRlLXNlcnZlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3RzL21haWwvZGVsaXZlcnkvc210cHNlcnZlci9jcmVhdGUtc2VydmVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7R0FHRztBQUVILE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUM5QyxPQUFPLEVBQUUsY0FBYyxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFDdEQsT0FBTyxFQUFFLGlCQUFpQixFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFDNUQsT0FBTyxFQUFFLGNBQWMsRUFBRSxNQUFNLHNCQUFzQixDQUFDO0FBQ3RELE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQUNoRCxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFDOUMsT0FBTyxFQUFFLGVBQWUsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBRXhELE9BQU8sRUFBRSxrQkFBa0IsRUFBRSxNQUFNLCtDQUErQyxDQUFDO0FBRW5GOzs7OztHQUtHO0FBQ0gsTUFBTSxVQUFVLGdCQUFnQixDQUFDLFdBQStCLEVBQUUsT0FBMkI7SUFDM0Ysd0NBQXdDO0lBQ3hDLE1BQU0sVUFBVSxHQUFHLElBQUksVUFBVSxDQUFDO1FBQ2hDLFdBQVc7UUFDWCxPQUFPO0tBQ1IsQ0FBQyxDQUFDO0lBRUgsK0JBQStCO0lBQy9CLE9BQU8sVUFBVSxDQUFDO0FBQ3BCLENBQUMifQ==
|
||||
123
dist_ts/mail/delivery/smtpserver/data-handler.d.ts
vendored
123
dist_ts/mail/delivery/smtpserver/data-handler.d.ts
vendored
@@ -1,123 +0,0 @@
|
||||
/**
|
||||
* SMTP Data Handler
|
||||
* Responsible for processing email data during and after DATA command
|
||||
*/
|
||||
import * as plugins from '../../../plugins.js';
|
||||
import type { ISmtpSession, ISmtpTransactionResult } from './interfaces.js';
|
||||
import type { IDataHandler, ISmtpServer } from './interfaces.js';
|
||||
import { Email } from '../../core/classes.email.js';
|
||||
/**
|
||||
* Handles SMTP DATA command and email data processing
|
||||
*/
|
||||
export declare class DataHandler implements IDataHandler {
|
||||
/**
|
||||
* Reference to the SMTP server instance
|
||||
*/
|
||||
private smtpServer;
|
||||
/**
|
||||
* Creates a new data handler
|
||||
* @param smtpServer - SMTP server instance
|
||||
*/
|
||||
constructor(smtpServer: ISmtpServer);
|
||||
/**
|
||||
* Process incoming email data
|
||||
* @param socket - Client socket
|
||||
* @param data - Data chunk
|
||||
* @returns Promise that resolves when the data is processed
|
||||
*/
|
||||
processEmailData(socket: plugins.net.Socket | plugins.tls.TLSSocket, data: string): Promise<void>;
|
||||
/**
|
||||
* Handle raw data chunks during DATA mode (optimized for large messages)
|
||||
* @param socket - Client socket
|
||||
* @param data - Raw data chunk
|
||||
*/
|
||||
handleDataReceived(socket: plugins.net.Socket | plugins.tls.TLSSocket, data: string): Promise<void>;
|
||||
/**
|
||||
* Process email data chunks efficiently for large messages
|
||||
* @param chunks - Array of email data chunks
|
||||
* @returns Processed email data string
|
||||
*/
|
||||
private processEmailDataStreaming;
|
||||
/**
|
||||
* Process a complete email
|
||||
* @param rawData - Raw email data
|
||||
* @param session - SMTP session
|
||||
* @returns Promise that resolves with the Email object
|
||||
*/
|
||||
processEmail(rawData: string, session: ISmtpSession): Promise<Email>;
|
||||
/**
|
||||
* Parse email from raw data
|
||||
* @param rawData - Raw email data
|
||||
* @param session - SMTP session
|
||||
* @returns Email object
|
||||
*/
|
||||
private parseEmailFromData;
|
||||
/**
|
||||
* Process a complete email (legacy method)
|
||||
* @param session - SMTP session
|
||||
* @returns Promise that resolves with the result of the transaction
|
||||
*/
|
||||
processEmailLegacy(session: ISmtpSession): Promise<ISmtpTransactionResult>;
|
||||
/**
|
||||
* Save an email to disk
|
||||
* @param session - SMTP session
|
||||
*/
|
||||
saveEmail(session: ISmtpSession): void;
|
||||
/**
|
||||
* Parse an email into an Email object
|
||||
* @param session - SMTP session
|
||||
* @returns Promise that resolves with the parsed Email object
|
||||
*/
|
||||
parseEmail(session: ISmtpSession): Promise<Email>;
|
||||
/**
|
||||
* Basic fallback method for parsing emails
|
||||
* @param session - SMTP session
|
||||
* @returns The parsed Email object
|
||||
*/
|
||||
private parseEmailBasic;
|
||||
/**
|
||||
* Handle multipart content parsing
|
||||
* @param email - Email object to update
|
||||
* @param bodyText - Body text to parse
|
||||
* @param boundary - MIME boundary
|
||||
*/
|
||||
private handleMultipartContent;
|
||||
/**
|
||||
* Handle end of data marker received
|
||||
* @param socket - Client socket
|
||||
* @param session - SMTP session
|
||||
*/
|
||||
private handleEndOfData;
|
||||
/**
|
||||
* Reset session after email processing
|
||||
* @param session - SMTP session
|
||||
*/
|
||||
private resetSession;
|
||||
/**
|
||||
* Send a response to the client
|
||||
* @param socket - Client socket
|
||||
* @param response - Response message
|
||||
*/
|
||||
private sendResponse;
|
||||
/**
|
||||
* Check if a socket error is potentially recoverable
|
||||
* @param error - The error that occurred
|
||||
* @returns Whether the error is potentially recoverable
|
||||
*/
|
||||
private isRecoverableSocketError;
|
||||
/**
|
||||
* Handle recoverable socket errors with retry logic
|
||||
* @param socket - Client socket
|
||||
* @param error - The error that occurred
|
||||
* @param response - The response that failed to send
|
||||
*/
|
||||
private handleSocketError;
|
||||
/**
|
||||
* Handle email data (interface requirement)
|
||||
*/
|
||||
handleData(socket: plugins.net.Socket | plugins.tls.TLSSocket, data: string, session: ISmtpSession): Promise<void>;
|
||||
/**
|
||||
* Clean up resources
|
||||
*/
|
||||
destroy(): void;
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
20
dist_ts/mail/delivery/smtpserver/index.d.ts
vendored
20
dist_ts/mail/delivery/smtpserver/index.d.ts
vendored
@@ -1,20 +0,0 @@
|
||||
/**
|
||||
* SMTP Server Module Exports
|
||||
* This file exports all components of the refactored SMTP server
|
||||
*/
|
||||
export * from './interfaces.js';
|
||||
export { SmtpServer } from './smtp-server.js';
|
||||
export { SessionManager } from './session-manager.js';
|
||||
export { ConnectionManager } from './connection-manager.js';
|
||||
export { CommandHandler } from './command-handler.js';
|
||||
export { DataHandler } from './data-handler.js';
|
||||
export { TlsHandler } from './tls-handler.js';
|
||||
export { SecurityHandler } from './security-handler.js';
|
||||
export * from './constants.js';
|
||||
export { SmtpLogger } from './utils/logging.js';
|
||||
export * from './utils/validation.js';
|
||||
export * from './utils/helpers.js';
|
||||
export * from './certificate-utils.js';
|
||||
export * from './secure-server.js';
|
||||
export * from './starttls-handler.js';
|
||||
export { createSmtpServer } from './create-server.js';
|
||||
@@ -1,27 +0,0 @@
|
||||
/**
|
||||
* SMTP Server Module Exports
|
||||
* This file exports all components of the refactored SMTP server
|
||||
*/
|
||||
// Export interfaces
|
||||
export * from './interfaces.js';
|
||||
// Export server classes
|
||||
export { SmtpServer } from './smtp-server.js';
|
||||
export { SessionManager } from './session-manager.js';
|
||||
export { ConnectionManager } from './connection-manager.js';
|
||||
export { CommandHandler } from './command-handler.js';
|
||||
export { DataHandler } from './data-handler.js';
|
||||
export { TlsHandler } from './tls-handler.js';
|
||||
export { SecurityHandler } from './security-handler.js';
|
||||
// Export constants
|
||||
export * from './constants.js';
|
||||
// Export utilities
|
||||
export { SmtpLogger } from './utils/logging.js';
|
||||
export * from './utils/validation.js';
|
||||
export * from './utils/helpers.js';
|
||||
// Export TLS and certificate utilities
|
||||
export * from './certificate-utils.js';
|
||||
export * from './secure-server.js';
|
||||
export * from './starttls-handler.js';
|
||||
// Factory function to create a complete SMTP server with default components
|
||||
export { createSmtpServer } from './create-server.js';
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi90cy9tYWlsL2RlbGl2ZXJ5L3NtdHBzZXJ2ZXIvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7OztHQUdHO0FBRUgsb0JBQW9CO0FBQ3BCLGNBQWMsaUJBQWlCLENBQUM7QUFFaEMsd0JBQXdCO0FBQ3hCLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUM5QyxPQUFPLEVBQUUsY0FBYyxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFDdEQsT0FBTyxFQUFFLGlCQUFpQixFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFDNUQsT0FBTyxFQUFFLGNBQWMsRUFBRSxNQUFNLHNCQUFzQixDQUFDO0FBQ3RELE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQUNoRCxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFDOUMsT0FBTyxFQUFFLGVBQWUsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBRXhELG1CQUFtQjtBQUNuQixjQUFjLGdCQUFnQixDQUFDO0FBRS9CLG1CQUFtQjtBQUNuQixPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFDaEQsY0FBYyx1QkFBdUIsQ0FBQztBQUN0QyxjQUFjLG9CQUFvQixDQUFDO0FBRW5DLHVDQUF1QztBQUN2QyxjQUFjLHdCQUF3QixDQUFDO0FBQ3ZDLGNBQWMsb0JBQW9CLENBQUM7QUFDbkMsY0FBYyx1QkFBdUIsQ0FBQztBQUV0Qyw0RUFBNEU7QUFDNUUsT0FBTyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sb0JBQW9CLENBQUMifQ==
|
||||
530
dist_ts/mail/delivery/smtpserver/interfaces.d.ts
vendored
530
dist_ts/mail/delivery/smtpserver/interfaces.d.ts
vendored
@@ -1,530 +0,0 @@
|
||||
/**
|
||||
* SMTP Server Interfaces
|
||||
* Defines all the interfaces used by the SMTP server implementation
|
||||
*/
|
||||
import * as plugins from '../../../plugins.js';
|
||||
import type { Email } from '../../core/classes.email.js';
|
||||
import type { UnifiedEmailServer } from '../../routing/classes.unified.email.server.js';
|
||||
import { SmtpState } from '../interfaces.js';
|
||||
import { SmtpCommand } from './constants.js';
|
||||
export { SmtpState, SmtpCommand };
|
||||
export type { IEnvelopeRecipient } from '../interfaces.js';
|
||||
/**
|
||||
* Interface for components that need cleanup
|
||||
*/
|
||||
export interface IDestroyable {
|
||||
/**
|
||||
* Clean up all resources (timers, listeners, etc)
|
||||
*/
|
||||
destroy(): void | Promise<void>;
|
||||
}
|
||||
/**
|
||||
* SMTP authentication credentials
|
||||
*/
|
||||
export interface ISmtpAuth {
|
||||
/**
|
||||
* Username for authentication
|
||||
*/
|
||||
username: string;
|
||||
/**
|
||||
* Password for authentication
|
||||
*/
|
||||
password: string;
|
||||
}
|
||||
/**
|
||||
* SMTP envelope (sender and recipients)
|
||||
*/
|
||||
export interface ISmtpEnvelope {
|
||||
/**
|
||||
* Mail from address
|
||||
*/
|
||||
mailFrom: {
|
||||
address: string;
|
||||
args?: Record<string, string>;
|
||||
};
|
||||
/**
|
||||
* Recipients list
|
||||
*/
|
||||
rcptTo: Array<{
|
||||
address: string;
|
||||
args?: Record<string, string>;
|
||||
}>;
|
||||
}
|
||||
/**
|
||||
* SMTP session representing a client connection
|
||||
*/
|
||||
export interface ISmtpSession {
|
||||
/**
|
||||
* Unique session identifier
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* Current state of the SMTP session
|
||||
*/
|
||||
state: SmtpState;
|
||||
/**
|
||||
* Client's hostname from EHLO/HELO
|
||||
*/
|
||||
clientHostname: string | null;
|
||||
/**
|
||||
* Whether TLS is active for this session
|
||||
*/
|
||||
secure: boolean;
|
||||
/**
|
||||
* Authentication status
|
||||
*/
|
||||
authenticated: boolean;
|
||||
/**
|
||||
* Authentication username if authenticated
|
||||
*/
|
||||
username?: string;
|
||||
/**
|
||||
* Transaction envelope
|
||||
*/
|
||||
envelope: ISmtpEnvelope;
|
||||
/**
|
||||
* When the session was created
|
||||
*/
|
||||
createdAt: Date;
|
||||
/**
|
||||
* Last activity timestamp
|
||||
*/
|
||||
lastActivity: number;
|
||||
/**
|
||||
* Client's IP address
|
||||
*/
|
||||
remoteAddress: string;
|
||||
/**
|
||||
* Client's port
|
||||
*/
|
||||
remotePort: number;
|
||||
/**
|
||||
* Additional session data
|
||||
*/
|
||||
data?: Record<string, any>;
|
||||
/**
|
||||
* Message size if SIZE extension is used
|
||||
*/
|
||||
messageSize?: number;
|
||||
/**
|
||||
* Server capabilities advertised to client
|
||||
*/
|
||||
capabilities?: string[];
|
||||
/**
|
||||
* Buffer for incomplete data
|
||||
*/
|
||||
dataBuffer?: string;
|
||||
/**
|
||||
* Flag to track if we're currently receiving DATA
|
||||
*/
|
||||
receivingData?: boolean;
|
||||
/**
|
||||
* The raw email data being received
|
||||
*/
|
||||
rawData?: string;
|
||||
/**
|
||||
* Greeting sent to client
|
||||
*/
|
||||
greeting?: string;
|
||||
/**
|
||||
* Whether EHLO has been sent
|
||||
*/
|
||||
ehloSent?: boolean;
|
||||
/**
|
||||
* Whether HELO has been sent
|
||||
*/
|
||||
heloSent?: boolean;
|
||||
/**
|
||||
* TLS options for this session
|
||||
*/
|
||||
tlsOptions?: any;
|
||||
/**
|
||||
* Whether TLS is being used
|
||||
*/
|
||||
useTLS?: boolean;
|
||||
/**
|
||||
* Mail from address for this transaction
|
||||
*/
|
||||
mailFrom?: string;
|
||||
/**
|
||||
* Recipients for this transaction
|
||||
*/
|
||||
rcptTo?: string[];
|
||||
/**
|
||||
* Email data being received
|
||||
*/
|
||||
emailData?: string;
|
||||
/**
|
||||
* Chunks of email data
|
||||
*/
|
||||
emailDataChunks?: string[];
|
||||
/**
|
||||
* Timeout ID for data reception
|
||||
*/
|
||||
dataTimeoutId?: NodeJS.Timeout;
|
||||
/**
|
||||
* Whether connection has ended
|
||||
*/
|
||||
connectionEnded?: boolean;
|
||||
/**
|
||||
* Size of email data being received
|
||||
*/
|
||||
emailDataSize?: number;
|
||||
/**
|
||||
* Processing mode for this session
|
||||
*/
|
||||
processingMode?: string;
|
||||
}
|
||||
/**
|
||||
* Session manager interface
|
||||
*/
|
||||
export interface ISessionManager extends IDestroyable {
|
||||
/**
|
||||
* Create a new session for a socket
|
||||
*/
|
||||
createSession(socket: plugins.net.Socket | plugins.tls.TLSSocket, secure?: boolean): ISmtpSession;
|
||||
/**
|
||||
* Get session by socket
|
||||
*/
|
||||
getSession(socket: plugins.net.Socket | plugins.tls.TLSSocket): ISmtpSession | undefined;
|
||||
/**
|
||||
* Update session state
|
||||
*/
|
||||
updateSessionState(session: ISmtpSession, newState: SmtpState): void;
|
||||
/**
|
||||
* Remove a session
|
||||
*/
|
||||
removeSession(socket: plugins.net.Socket | plugins.tls.TLSSocket): void;
|
||||
/**
|
||||
* Clear all sessions
|
||||
*/
|
||||
clearAllSessions(): void;
|
||||
/**
|
||||
* Get all active sessions
|
||||
*/
|
||||
getAllSessions(): ISmtpSession[];
|
||||
/**
|
||||
* Get session count
|
||||
*/
|
||||
getSessionCount(): number;
|
||||
/**
|
||||
* Update last activity for a session
|
||||
*/
|
||||
updateLastActivity(socket: plugins.net.Socket | plugins.tls.TLSSocket): void;
|
||||
/**
|
||||
* Check for timed out sessions
|
||||
*/
|
||||
checkTimeouts(timeoutMs: number): ISmtpSession[];
|
||||
/**
|
||||
* Update session activity timestamp
|
||||
*/
|
||||
updateSessionActivity(session: ISmtpSession): void;
|
||||
/**
|
||||
* Replace socket in session (for TLS upgrade)
|
||||
*/
|
||||
replaceSocket(oldSocket: plugins.net.Socket | plugins.tls.TLSSocket, newSocket: plugins.net.Socket | plugins.tls.TLSSocket): boolean;
|
||||
}
|
||||
/**
|
||||
* Connection manager interface
|
||||
*/
|
||||
export interface IConnectionManager extends IDestroyable {
|
||||
/**
|
||||
* Handle a new connection
|
||||
*/
|
||||
handleConnection(socket: plugins.net.Socket | plugins.tls.TLSSocket, secure: boolean): Promise<void>;
|
||||
/**
|
||||
* Close all active connections
|
||||
*/
|
||||
closeAllConnections(): void;
|
||||
/**
|
||||
* Get active connection count
|
||||
*/
|
||||
getConnectionCount(): number;
|
||||
/**
|
||||
* Check if accepting new connections
|
||||
*/
|
||||
canAcceptConnection(): boolean;
|
||||
/**
|
||||
* Handle new connection (legacy method name)
|
||||
*/
|
||||
handleNewConnection(socket: plugins.net.Socket): Promise<void>;
|
||||
/**
|
||||
* Handle new secure connection (legacy method name)
|
||||
*/
|
||||
handleNewSecureConnection(socket: plugins.tls.TLSSocket): Promise<void>;
|
||||
/**
|
||||
* Setup socket event handlers
|
||||
*/
|
||||
setupSocketEventHandlers(socket: plugins.net.Socket | plugins.tls.TLSSocket): void;
|
||||
}
|
||||
/**
|
||||
* Command handler interface
|
||||
*/
|
||||
export interface ICommandHandler extends IDestroyable {
|
||||
/**
|
||||
* Handle an SMTP command
|
||||
*/
|
||||
handleCommand(socket: plugins.net.Socket | plugins.tls.TLSSocket, command: SmtpCommand, args: string, session: ISmtpSession): Promise<void>;
|
||||
/**
|
||||
* Get supported commands for current session state
|
||||
*/
|
||||
getSupportedCommands(session: ISmtpSession): SmtpCommand[];
|
||||
/**
|
||||
* Process command (legacy method name)
|
||||
*/
|
||||
processCommand(socket: plugins.net.Socket | plugins.tls.TLSSocket, command: string): Promise<void>;
|
||||
}
|
||||
/**
|
||||
* Data handler interface
|
||||
*/
|
||||
export interface IDataHandler extends IDestroyable {
|
||||
/**
|
||||
* Handle email data
|
||||
*/
|
||||
handleData(socket: plugins.net.Socket | plugins.tls.TLSSocket, data: string, session: ISmtpSession): Promise<void>;
|
||||
/**
|
||||
* Process a complete email
|
||||
*/
|
||||
processEmail(rawData: string, session: ISmtpSession): Promise<Email>;
|
||||
/**
|
||||
* Handle data received (legacy method name)
|
||||
*/
|
||||
handleDataReceived(socket: plugins.net.Socket | plugins.tls.TLSSocket, data: string): Promise<void>;
|
||||
/**
|
||||
* Process email data (legacy method name)
|
||||
*/
|
||||
processEmailData(socket: plugins.net.Socket | plugins.tls.TLSSocket, data: string): Promise<void>;
|
||||
}
|
||||
/**
|
||||
* TLS handler interface
|
||||
*/
|
||||
export interface ITlsHandler extends IDestroyable {
|
||||
/**
|
||||
* Handle STARTTLS command
|
||||
*/
|
||||
handleStartTls(socket: plugins.net.Socket, session: ISmtpSession): Promise<plugins.tls.TLSSocket | null>;
|
||||
/**
|
||||
* Check if TLS is available
|
||||
*/
|
||||
isTlsAvailable(): boolean;
|
||||
/**
|
||||
* Get TLS options
|
||||
*/
|
||||
getTlsOptions(): plugins.tls.TlsOptions;
|
||||
/**
|
||||
* Check if TLS is enabled
|
||||
*/
|
||||
isTlsEnabled(): boolean;
|
||||
}
|
||||
/**
|
||||
* Security handler interface
|
||||
*/
|
||||
export interface ISecurityHandler extends IDestroyable {
|
||||
/**
|
||||
* Check IP reputation
|
||||
*/
|
||||
checkIpReputation(socket: plugins.net.Socket | plugins.tls.TLSSocket): Promise<boolean>;
|
||||
/**
|
||||
* Validate email address
|
||||
*/
|
||||
isValidEmail(email: string): boolean;
|
||||
/**
|
||||
* Authenticate user
|
||||
*/
|
||||
authenticate(auth: ISmtpAuth): Promise<boolean>;
|
||||
}
|
||||
/**
|
||||
* SMTP server options
|
||||
*/
|
||||
export interface ISmtpServerOptions {
|
||||
/**
|
||||
* Port to listen on
|
||||
*/
|
||||
port: number;
|
||||
/**
|
||||
* Hostname of the server
|
||||
*/
|
||||
hostname: string;
|
||||
/**
|
||||
* Host to bind to (optional, defaults to 0.0.0.0)
|
||||
*/
|
||||
host?: string;
|
||||
/**
|
||||
* Secure port for TLS connections
|
||||
*/
|
||||
securePort?: number;
|
||||
/**
|
||||
* TLS/SSL private key (PEM format)
|
||||
*/
|
||||
key?: string;
|
||||
/**
|
||||
* TLS/SSL certificate (PEM format)
|
||||
*/
|
||||
cert?: string;
|
||||
/**
|
||||
* CA certificates for TLS (PEM format)
|
||||
*/
|
||||
ca?: string;
|
||||
/**
|
||||
* Maximum size of messages in bytes
|
||||
*/
|
||||
maxSize?: number;
|
||||
/**
|
||||
* Maximum number of concurrent connections
|
||||
*/
|
||||
maxConnections?: number;
|
||||
/**
|
||||
* Authentication options
|
||||
*/
|
||||
auth?: {
|
||||
/**
|
||||
* Whether authentication is required
|
||||
*/
|
||||
required: boolean;
|
||||
/**
|
||||
* Allowed authentication methods
|
||||
*/
|
||||
methods: ('PLAIN' | 'LOGIN' | 'OAUTH2')[];
|
||||
};
|
||||
/**
|
||||
* Socket timeout in milliseconds (default: 5 minutes / 300000ms)
|
||||
*/
|
||||
socketTimeout?: number;
|
||||
/**
|
||||
* Initial connection timeout in milliseconds (default: 30 seconds / 30000ms)
|
||||
*/
|
||||
connectionTimeout?: number;
|
||||
/**
|
||||
* Interval for checking idle sessions in milliseconds (default: 5 seconds / 5000ms)
|
||||
* For testing, can be set lower (e.g. 1000ms) to detect timeouts more quickly
|
||||
*/
|
||||
cleanupInterval?: number;
|
||||
/**
|
||||
* Maximum number of recipients allowed per message (default: 100)
|
||||
*/
|
||||
maxRecipients?: number;
|
||||
/**
|
||||
* Maximum message size in bytes (default: 10MB / 10485760 bytes)
|
||||
* This is advertised in the EHLO SIZE extension
|
||||
*/
|
||||
size?: number;
|
||||
/**
|
||||
* Timeout for the DATA command in milliseconds (default: 60000ms / 1 minute)
|
||||
* This controls how long to wait for the complete email data
|
||||
*/
|
||||
dataTimeout?: number;
|
||||
}
|
||||
/**
|
||||
* Result of SMTP transaction
|
||||
*/
|
||||
export interface ISmtpTransactionResult {
|
||||
/**
|
||||
* Whether the transaction was successful
|
||||
*/
|
||||
success: boolean;
|
||||
/**
|
||||
* Error message if failed
|
||||
*/
|
||||
error?: string;
|
||||
/**
|
||||
* Message ID if successful
|
||||
*/
|
||||
messageId?: string;
|
||||
/**
|
||||
* Resulting email if successful
|
||||
*/
|
||||
email?: Email;
|
||||
}
|
||||
/**
|
||||
* Interface for SMTP session events
|
||||
* These events are emitted by the session manager
|
||||
*/
|
||||
export interface ISessionEvents {
|
||||
created: (session: ISmtpSession, socket: plugins.net.Socket | plugins.tls.TLSSocket) => void;
|
||||
stateChanged: (session: ISmtpSession, previousState: SmtpState, newState: SmtpState) => void;
|
||||
timeout: (session: ISmtpSession, socket: plugins.net.Socket | plugins.tls.TLSSocket) => void;
|
||||
completed: (session: ISmtpSession, socket: plugins.net.Socket | plugins.tls.TLSSocket) => void;
|
||||
error: (session: ISmtpSession, error: Error) => void;
|
||||
}
|
||||
/**
|
||||
* SMTP Server interface
|
||||
*/
|
||||
export interface ISmtpServer extends IDestroyable {
|
||||
/**
|
||||
* Start the SMTP server
|
||||
*/
|
||||
listen(): Promise<void>;
|
||||
/**
|
||||
* Stop the SMTP server
|
||||
*/
|
||||
close(): Promise<void>;
|
||||
/**
|
||||
* Get the session manager
|
||||
*/
|
||||
getSessionManager(): ISessionManager;
|
||||
/**
|
||||
* Get the connection manager
|
||||
*/
|
||||
getConnectionManager(): IConnectionManager;
|
||||
/**
|
||||
* Get the command handler
|
||||
*/
|
||||
getCommandHandler(): ICommandHandler;
|
||||
/**
|
||||
* Get the data handler
|
||||
*/
|
||||
getDataHandler(): IDataHandler;
|
||||
/**
|
||||
* Get the TLS handler
|
||||
*/
|
||||
getTlsHandler(): ITlsHandler;
|
||||
/**
|
||||
* Get the security handler
|
||||
*/
|
||||
getSecurityHandler(): ISecurityHandler;
|
||||
/**
|
||||
* Get the server options
|
||||
*/
|
||||
getOptions(): ISmtpServerOptions;
|
||||
/**
|
||||
* Get the email server reference
|
||||
*/
|
||||
getEmailServer(): UnifiedEmailServer;
|
||||
}
|
||||
/**
|
||||
* Configuration for creating SMTP server
|
||||
*/
|
||||
export interface ISmtpServerConfig {
|
||||
/**
|
||||
* Email server instance
|
||||
*/
|
||||
emailServer: UnifiedEmailServer;
|
||||
/**
|
||||
* Server options
|
||||
*/
|
||||
options: ISmtpServerOptions;
|
||||
/**
|
||||
* Optional custom session manager
|
||||
*/
|
||||
sessionManager?: ISessionManager;
|
||||
/**
|
||||
* Optional custom connection manager
|
||||
*/
|
||||
connectionManager?: IConnectionManager;
|
||||
/**
|
||||
* Optional custom command handler
|
||||
*/
|
||||
commandHandler?: ICommandHandler;
|
||||
/**
|
||||
* Optional custom data handler
|
||||
*/
|
||||
dataHandler?: IDataHandler;
|
||||
/**
|
||||
* Optional custom TLS handler
|
||||
*/
|
||||
tlsHandler?: ITlsHandler;
|
||||
/**
|
||||
* Optional custom security handler
|
||||
*/
|
||||
securityHandler?: ISecurityHandler;
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
/**
|
||||
* SMTP Server Interfaces
|
||||
* Defines all the interfaces used by the SMTP server implementation
|
||||
*/
|
||||
import * as plugins from '../../../plugins.js';
|
||||
// Re-export types from other modules
|
||||
import { SmtpState } from '../interfaces.js';
|
||||
import { SmtpCommand } from './constants.js';
|
||||
export { SmtpState, SmtpCommand };
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW50ZXJmYWNlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3RzL21haWwvZGVsaXZlcnkvc210cHNlcnZlci9pbnRlcmZhY2VzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7R0FHRztBQUVILE9BQU8sS0FBSyxPQUFPLE1BQU0scUJBQXFCLENBQUM7QUFJL0MsdUNBQXVDO0FBQ3ZDLE9BQU8sRUFBRSxTQUFTLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUM3QyxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0sZ0JBQWdCLENBQUM7QUFDN0MsT0FBTyxFQUFFLFNBQVMsRUFBRSxXQUFXLEVBQUUsQ0FBQyJ9
|
||||
@@ -1,15 +0,0 @@
|
||||
/**
|
||||
* Secure SMTP Server Utility Functions
|
||||
* Provides helper functions for creating and managing secure TLS server
|
||||
*/
|
||||
import * as plugins from '../../../plugins.js';
|
||||
/**
|
||||
* Create a secure TLS server for direct TLS connections
|
||||
* @param options - TLS certificate options
|
||||
* @returns A configured TLS server or undefined if TLS is not available
|
||||
*/
|
||||
export declare function createSecureTlsServer(options: {
|
||||
key: string;
|
||||
cert: string;
|
||||
ca?: string;
|
||||
}): plugins.tls.Server | undefined;
|
||||
@@ -1,79 +0,0 @@
|
||||
/**
|
||||
* Secure SMTP Server Utility Functions
|
||||
* Provides helper functions for creating and managing secure TLS server
|
||||
*/
|
||||
import * as plugins from '../../../plugins.js';
|
||||
import { loadCertificatesFromString, generateSelfSignedCertificates, createTlsOptions } from './certificate-utils.js';
|
||||
import { SmtpLogger } from './utils/logging.js';
|
||||
/**
|
||||
* Create a secure TLS server for direct TLS connections
|
||||
* @param options - TLS certificate options
|
||||
* @returns A configured TLS server or undefined if TLS is not available
|
||||
*/
|
||||
export function createSecureTlsServer(options) {
|
||||
try {
|
||||
// Log the creation attempt
|
||||
SmtpLogger.info('Creating secure TLS server for direct connections');
|
||||
// Load certificates from strings
|
||||
let certificates;
|
||||
try {
|
||||
certificates = loadCertificatesFromString({
|
||||
key: options.key,
|
||||
cert: options.cert,
|
||||
ca: options.ca
|
||||
});
|
||||
SmtpLogger.info('Successfully loaded TLS certificates for secure server');
|
||||
}
|
||||
catch (certificateError) {
|
||||
SmtpLogger.warn(`Failed to load certificates, using self-signed: ${certificateError instanceof Error ? certificateError.message : String(certificateError)}`);
|
||||
certificates = generateSelfSignedCertificates();
|
||||
}
|
||||
// Create server-side TLS options
|
||||
const tlsOptions = createTlsOptions(certificates, true);
|
||||
// Log details for debugging
|
||||
SmtpLogger.debug('Creating secure server with options', {
|
||||
certificates: {
|
||||
keyLength: certificates.key.length,
|
||||
certLength: certificates.cert.length,
|
||||
caLength: certificates.ca ? certificates.ca.length : 0
|
||||
},
|
||||
tlsOptions: {
|
||||
minVersion: tlsOptions.minVersion,
|
||||
maxVersion: tlsOptions.maxVersion,
|
||||
ciphers: tlsOptions.ciphers?.substring(0, 50) + '...' // Truncate long cipher list
|
||||
}
|
||||
});
|
||||
// Create the TLS server
|
||||
const server = new plugins.tls.Server(tlsOptions);
|
||||
// Set up error handlers
|
||||
server.on('error', (err) => {
|
||||
SmtpLogger.error(`Secure server error: ${err.message}`, {
|
||||
component: 'secure-server',
|
||||
error: err,
|
||||
stack: err.stack
|
||||
});
|
||||
});
|
||||
// Log secure connections
|
||||
server.on('secureConnection', (socket) => {
|
||||
const protocol = socket.getProtocol();
|
||||
const cipher = socket.getCipher();
|
||||
SmtpLogger.info('New direct TLS connection established', {
|
||||
component: 'secure-server',
|
||||
remoteAddress: socket.remoteAddress,
|
||||
remotePort: socket.remotePort,
|
||||
protocol: protocol || 'unknown',
|
||||
cipher: cipher?.name || 'unknown'
|
||||
});
|
||||
});
|
||||
return server;
|
||||
}
|
||||
catch (error) {
|
||||
SmtpLogger.error(`Failed to create secure TLS server: ${error instanceof Error ? error.message : String(error)}`, {
|
||||
component: 'secure-server',
|
||||
error: error instanceof Error ? error : new Error(String(error)),
|
||||
stack: error instanceof Error ? error.stack : 'No stack trace available'
|
||||
});
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VjdXJlLXNlcnZlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3RzL21haWwvZGVsaXZlcnkvc210cHNlcnZlci9zZWN1cmUtc2VydmVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7R0FHRztBQUVILE9BQU8sS0FBSyxPQUFPLE1BQU0scUJBQXFCLENBQUM7QUFDL0MsT0FBTyxFQUNMLDBCQUEwQixFQUMxQiw4QkFBOEIsRUFDOUIsZ0JBQWdCLEVBRWpCLE1BQU0sd0JBQXdCLENBQUM7QUFDaEMsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBRWhEOzs7O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bEMsVUFBVSxDQUFDLElBQUksQ0FBQyx1Q0FBdUMsRUFBRTtnQkFDdkQsU0FBUyxFQUFFLGVBQWU7Z0JBQzFCLGFBQWEsRUFBRSxNQUFNLENBQUMsYUFBYTtnQkFDbkMsVUFBVSxFQUFFLE1BQU0sQ0FBQyxVQUFVO2dCQUM3QixRQUFRLEVBQUUsUUFBUSxJQUFJLFNBQVM7Z0JBQy9CLE1BQU0sRUFBRSxNQUFNLEVBQUUsSUFBSSxJQUFJLFNBQVM7YUFDbEMsQ0FBQyxDQUFDO1FBQ0wsQ0FBQyxDQUFDLENBQUM7UUFFSCxPQUFPLE1BQU0sQ0FBQztJQUNoQixDQUFDO0lBQUMsT0FBTyxLQUFLLEVBQUUsQ0FBQztRQUNmLFVBQVUsQ0FBQyxLQUFLLENBQUMsdUNBQXVDLEtBQUssWUFBWSxLQUFLLENBQUMsQ0FBQyxDQUFDLEtBQUssQ0FBQyxPQUFPLENBQUMsQ0FBQyxDQUFDLE1BQU0sQ0FBQyxLQUFLLENBQUMsRUFBRSxFQUFFO1lBQ2hILFNBQVMsRUFBRSxlQUFlO1lBQzFCLEtBQUssRUFBRSxLQUFLLFlBQVksS0FBSyxDQUFDLENBQUMsQ0FBQyxLQUFLLENBQUMsQ0FBQyxDQUFDLElBQUksS0FBSyxDQUFDLE1BQU0sQ0FBQyxLQUFLLENBQUMsQ0FBQztZQUNoRSxLQUFLLEVBQUUsS0FBSyxZQUFZLEtBQUssQ0FBQyxDQUFDLENBQUMsS0FBSyxDQUFDLEtBQUssQ0FBQyxDQUFDLENBQUMsMEJBQTBCO1NBQ3pFLENBQUMsQ0FBQztRQUVILE9BQU8sU0FBUyxDQUFDO0lBQ25CLENBQUM7QUFDSCxDQUFDIn0=
|
||||
@@ -1,86 +0,0 @@
|
||||
/**
|
||||
* SMTP Security Handler
|
||||
* Responsible for security aspects including IP reputation checking,
|
||||
* email validation, and authentication
|
||||
*/
|
||||
import * as plugins from '../../../plugins.js';
|
||||
import type { ISmtpAuth } from './interfaces.js';
|
||||
import type { ISecurityHandler, ISmtpServer } from './interfaces.js';
|
||||
/**
|
||||
* Handles security aspects for SMTP server
|
||||
*/
|
||||
export declare class SecurityHandler implements ISecurityHandler {
|
||||
/**
|
||||
* Reference to the SMTP server instance
|
||||
*/
|
||||
private smtpServer;
|
||||
/**
|
||||
* IP reputation checker service
|
||||
*/
|
||||
private ipReputationService;
|
||||
/**
|
||||
* Simple in-memory IP denylist
|
||||
*/
|
||||
private ipDenylist;
|
||||
/**
|
||||
* Cleanup interval timer
|
||||
*/
|
||||
private cleanupInterval;
|
||||
/**
|
||||
* Creates a new security handler
|
||||
* @param smtpServer - SMTP server instance
|
||||
*/
|
||||
constructor(smtpServer: ISmtpServer);
|
||||
/**
|
||||
* Check IP reputation for a connection
|
||||
* @param socket - Client socket
|
||||
* @returns Promise that resolves to true if IP is allowed, false if blocked
|
||||
*/
|
||||
checkIpReputation(socket: plugins.net.Socket | plugins.tls.TLSSocket): Promise<boolean>;
|
||||
/**
|
||||
* Validate an email address
|
||||
* @param email - Email address to validate
|
||||
* @returns Whether the email address is valid
|
||||
*/
|
||||
isValidEmail(email: string): boolean;
|
||||
/**
|
||||
* Validate authentication credentials
|
||||
* @param auth - Authentication credentials
|
||||
* @returns Promise that resolves to true if authenticated
|
||||
*/
|
||||
authenticate(auth: ISmtpAuth): Promise<boolean>;
|
||||
/**
|
||||
* Log a security event
|
||||
* @param event - Event type
|
||||
* @param level - Log level
|
||||
* @param details - Event details
|
||||
*/
|
||||
logSecurityEvent(event: string, level: string, message: string, details: Record<string, any>): void;
|
||||
/**
|
||||
* Add an IP to the denylist
|
||||
* @param ip - IP address
|
||||
* @param reason - Reason for denylisting
|
||||
* @param duration - Duration in milliseconds (optional, indefinite if not specified)
|
||||
*/
|
||||
private addToDenylist;
|
||||
/**
|
||||
* Check if an IP is denylisted
|
||||
* @param ip - IP address
|
||||
* @returns Whether the IP is denylisted
|
||||
*/
|
||||
private isIpDenylisted;
|
||||
/**
|
||||
* Get the reason an IP was denylisted
|
||||
* @param ip - IP address
|
||||
* @returns Reason for denylisting or undefined if not denylisted
|
||||
*/
|
||||
private getDenylistReason;
|
||||
/**
|
||||
* Clean expired denylist entries
|
||||
*/
|
||||
private cleanExpiredDenylistEntries;
|
||||
/**
|
||||
* Clean up resources
|
||||
*/
|
||||
destroy(): void;
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -1,140 +0,0 @@
|
||||
/**
|
||||
* SMTP Session Manager
|
||||
* Responsible for creating, managing, and cleaning up SMTP sessions
|
||||
*/
|
||||
import * as plugins from '../../../plugins.js';
|
||||
import { SmtpState } from './interfaces.js';
|
||||
import type { ISmtpSession } from './interfaces.js';
|
||||
import type { ISessionManager, ISessionEvents } from './interfaces.js';
|
||||
/**
|
||||
* Manager for SMTP sessions
|
||||
* Handles session creation, tracking, timeout management, and cleanup
|
||||
*/
|
||||
export declare class SessionManager implements ISessionManager {
|
||||
/**
|
||||
* Map of socket ID to session
|
||||
*/
|
||||
private sessions;
|
||||
/**
|
||||
* Map of socket to socket ID
|
||||
*/
|
||||
private socketIds;
|
||||
/**
|
||||
* SMTP server options
|
||||
*/
|
||||
private options;
|
||||
/**
|
||||
* Event listeners
|
||||
*/
|
||||
private eventListeners;
|
||||
/**
|
||||
* Timer for cleanup interval
|
||||
*/
|
||||
private cleanupTimer;
|
||||
/**
|
||||
* Creates a new session manager
|
||||
* @param options - Session manager options
|
||||
*/
|
||||
constructor(options?: {
|
||||
socketTimeout?: number;
|
||||
connectionTimeout?: number;
|
||||
cleanupInterval?: number;
|
||||
});
|
||||
/**
|
||||
* Creates a new session for a socket connection
|
||||
* @param socket - Client socket
|
||||
* @param secure - Whether the connection is secure (TLS)
|
||||
* @returns New SMTP session
|
||||
*/
|
||||
createSession(socket: plugins.net.Socket | plugins.tls.TLSSocket, secure: boolean): ISmtpSession;
|
||||
/**
|
||||
* Updates the session state
|
||||
* @param session - SMTP session
|
||||
* @param newState - New state
|
||||
*/
|
||||
updateSessionState(session: ISmtpSession, newState: SmtpState): void;
|
||||
/**
|
||||
* Updates the session's last activity timestamp
|
||||
* @param session - SMTP session
|
||||
*/
|
||||
updateSessionActivity(session: ISmtpSession): void;
|
||||
/**
|
||||
* Removes a session
|
||||
* @param socket - Client socket
|
||||
*/
|
||||
removeSession(socket: plugins.net.Socket | plugins.tls.TLSSocket): void;
|
||||
/**
|
||||
* Gets a session for a socket
|
||||
* @param socket - Client socket
|
||||
* @returns SMTP session or undefined if not found
|
||||
*/
|
||||
getSession(socket: plugins.net.Socket | plugins.tls.TLSSocket): ISmtpSession | undefined;
|
||||
/**
|
||||
* Cleans up idle sessions
|
||||
*/
|
||||
cleanupIdleSessions(): void;
|
||||
/**
|
||||
* Gets the current number of active sessions
|
||||
* @returns Number of active sessions
|
||||
*/
|
||||
getSessionCount(): number;
|
||||
/**
|
||||
* Clears all sessions (used when shutting down)
|
||||
*/
|
||||
clearAllSessions(): void;
|
||||
/**
|
||||
* Register an event listener
|
||||
* @param event - Event name
|
||||
* @param listener - Event listener function
|
||||
*/
|
||||
on<K extends keyof ISessionEvents>(event: K, listener: ISessionEvents[K]): void;
|
||||
/**
|
||||
* Remove an event listener
|
||||
* @param event - Event name
|
||||
* @param listener - Event listener function
|
||||
*/
|
||||
off<K extends keyof ISessionEvents>(event: K, listener: ISessionEvents[K]): void;
|
||||
/**
|
||||
* Emit an event to registered listeners
|
||||
* @param event - Event name
|
||||
* @param args - Event arguments
|
||||
*/
|
||||
private emitEvent;
|
||||
/**
|
||||
* Start the cleanup timer
|
||||
*/
|
||||
private startCleanupTimer;
|
||||
/**
|
||||
* Stop the cleanup timer
|
||||
*/
|
||||
private stopCleanupTimer;
|
||||
/**
|
||||
* Replace socket mapping for STARTTLS upgrades
|
||||
* @param oldSocket - Original plain socket
|
||||
* @param newSocket - New TLS socket
|
||||
* @returns Whether the replacement was successful
|
||||
*/
|
||||
replaceSocket(oldSocket: plugins.net.Socket | plugins.tls.TLSSocket, newSocket: plugins.net.Socket | plugins.tls.TLSSocket): boolean;
|
||||
/**
|
||||
* Gets a unique key for a socket
|
||||
* @param socket - Client socket
|
||||
* @returns Socket key
|
||||
*/
|
||||
private getSocketKey;
|
||||
/**
|
||||
* Get all active sessions
|
||||
*/
|
||||
getAllSessions(): ISmtpSession[];
|
||||
/**
|
||||
* Update last activity for a session by socket
|
||||
*/
|
||||
updateLastActivity(socket: plugins.net.Socket | plugins.tls.TLSSocket): void;
|
||||
/**
|
||||
* Check for timed out sessions
|
||||
*/
|
||||
checkTimeouts(timeoutMs: number): ISmtpSession[];
|
||||
/**
|
||||
* Clean up resources
|
||||
*/
|
||||
destroy(): void;
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
137
dist_ts/mail/delivery/smtpserver/smtp-server.d.ts
vendored
137
dist_ts/mail/delivery/smtpserver/smtp-server.d.ts
vendored
@@ -1,137 +0,0 @@
|
||||
/**
|
||||
* SMTP Server
|
||||
* Core implementation for the refactored SMTP server
|
||||
*/
|
||||
import type { ISmtpServerOptions } from './interfaces.js';
|
||||
import type { ISmtpServer, ISmtpServerConfig, ISessionManager, IConnectionManager, ICommandHandler, IDataHandler, ITlsHandler, ISecurityHandler } from './interfaces.js';
|
||||
import { UnifiedEmailServer } from '../../routing/classes.unified.email.server.js';
|
||||
/**
|
||||
* SMTP Server implementation
|
||||
* The main server class that coordinates all components
|
||||
*/
|
||||
export declare class SmtpServer implements ISmtpServer {
|
||||
/**
|
||||
* Email server reference
|
||||
*/
|
||||
private emailServer;
|
||||
/**
|
||||
* Session manager
|
||||
*/
|
||||
private sessionManager;
|
||||
/**
|
||||
* Connection manager
|
||||
*/
|
||||
private connectionManager;
|
||||
/**
|
||||
* Command handler
|
||||
*/
|
||||
private commandHandler;
|
||||
/**
|
||||
* Data handler
|
||||
*/
|
||||
private dataHandler;
|
||||
/**
|
||||
* TLS handler
|
||||
*/
|
||||
private tlsHandler;
|
||||
/**
|
||||
* Security handler
|
||||
*/
|
||||
private securityHandler;
|
||||
/**
|
||||
* SMTP server options
|
||||
*/
|
||||
private options;
|
||||
/**
|
||||
* Net server instance
|
||||
*/
|
||||
private server;
|
||||
/**
|
||||
* Secure server instance
|
||||
*/
|
||||
private secureServer;
|
||||
/**
|
||||
* Whether the server is running
|
||||
*/
|
||||
private running;
|
||||
/**
|
||||
* Server recovery state
|
||||
*/
|
||||
private recoveryState;
|
||||
/**
|
||||
* Creates a new SMTP server
|
||||
* @param config - Server configuration
|
||||
*/
|
||||
constructor(config: ISmtpServerConfig);
|
||||
/**
|
||||
* Start the SMTP server
|
||||
* @returns Promise that resolves when server is started
|
||||
*/
|
||||
listen(): Promise<void>;
|
||||
/**
|
||||
* Stop the SMTP server
|
||||
* @returns Promise that resolves when server is stopped
|
||||
*/
|
||||
close(): Promise<void>;
|
||||
/**
|
||||
* Get the session manager
|
||||
* @returns Session manager instance
|
||||
*/
|
||||
getSessionManager(): ISessionManager;
|
||||
/**
|
||||
* Get the connection manager
|
||||
* @returns Connection manager instance
|
||||
*/
|
||||
getConnectionManager(): IConnectionManager;
|
||||
/**
|
||||
* Get the command handler
|
||||
* @returns Command handler instance
|
||||
*/
|
||||
getCommandHandler(): ICommandHandler;
|
||||
/**
|
||||
* Get the data handler
|
||||
* @returns Data handler instance
|
||||
*/
|
||||
getDataHandler(): IDataHandler;
|
||||
/**
|
||||
* Get the TLS handler
|
||||
* @returns TLS handler instance
|
||||
*/
|
||||
getTlsHandler(): ITlsHandler;
|
||||
/**
|
||||
* Get the security handler
|
||||
* @returns Security handler instance
|
||||
*/
|
||||
getSecurityHandler(): ISecurityHandler;
|
||||
/**
|
||||
* Get the server options
|
||||
* @returns SMTP server options
|
||||
*/
|
||||
getOptions(): ISmtpServerOptions;
|
||||
/**
|
||||
* Get the email server reference
|
||||
* @returns Email server instance
|
||||
*/
|
||||
getEmailServer(): UnifiedEmailServer;
|
||||
/**
|
||||
* Check if the server is running
|
||||
* @returns Whether the server is running
|
||||
*/
|
||||
isRunning(): boolean;
|
||||
/**
|
||||
* Check if we should attempt to recover from an error
|
||||
* @param error - The error that occurred
|
||||
* @returns Whether recovery should be attempted
|
||||
*/
|
||||
private shouldAttemptRecovery;
|
||||
/**
|
||||
* Attempt to recover the server after a critical error
|
||||
* @param serverType - The type of server to recover ('standard' or 'secure')
|
||||
* @param error - The error that triggered recovery
|
||||
*/
|
||||
private attemptServerRecovery;
|
||||
/**
|
||||
* Clean up all component resources
|
||||
*/
|
||||
destroy(): Promise<void>;
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -1,21 +0,0 @@
|
||||
/**
|
||||
* STARTTLS Implementation
|
||||
* Provides an improved implementation for STARTTLS upgrades
|
||||
*/
|
||||
import * as plugins from '../../../plugins.js';
|
||||
import type { ISmtpSession, ISessionManager, IConnectionManager } from './interfaces.js';
|
||||
import { SmtpState } from '../interfaces.js';
|
||||
/**
|
||||
* Enhanced STARTTLS handler for more reliable TLS upgrades
|
||||
*/
|
||||
export declare function performStartTLS(socket: plugins.net.Socket, options: {
|
||||
key: string;
|
||||
cert: string;
|
||||
ca?: string;
|
||||
session?: ISmtpSession;
|
||||
sessionManager?: ISessionManager;
|
||||
connectionManager?: IConnectionManager;
|
||||
onSuccess?: (tlsSocket: plugins.tls.TLSSocket) => void;
|
||||
onFailure?: (error: Error) => void;
|
||||
updateSessionState?: (session: ISmtpSession, state: SmtpState) => void;
|
||||
}): Promise<plugins.tls.TLSSocket | undefined>;
|
||||
File diff suppressed because one or more lines are too long
@@ -1,66 +0,0 @@
|
||||
/**
|
||||
* SMTP TLS Handler
|
||||
* Responsible for handling TLS-related SMTP functionality
|
||||
*/
|
||||
import * as plugins from '../../../plugins.js';
|
||||
import type { ITlsHandler, ISmtpServer, ISmtpSession } from './interfaces.js';
|
||||
/**
|
||||
* Handles TLS functionality for SMTP server
|
||||
*/
|
||||
export declare class TlsHandler implements ITlsHandler {
|
||||
/**
|
||||
* Reference to the SMTP server instance
|
||||
*/
|
||||
private smtpServer;
|
||||
/**
|
||||
* Certificate data
|
||||
*/
|
||||
private certificates;
|
||||
/**
|
||||
* TLS options
|
||||
*/
|
||||
private options;
|
||||
/**
|
||||
* Creates a new TLS handler
|
||||
* @param smtpServer - SMTP server instance
|
||||
*/
|
||||
constructor(smtpServer: ISmtpServer);
|
||||
/**
|
||||
* Handle STARTTLS command
|
||||
* @param socket - Client socket
|
||||
*/
|
||||
handleStartTls(socket: plugins.net.Socket, session: ISmtpSession): Promise<plugins.tls.TLSSocket | null>;
|
||||
/**
|
||||
* Upgrade a connection to TLS
|
||||
* @param socket - Client socket
|
||||
*/
|
||||
startTLS(socket: plugins.net.Socket): Promise<plugins.tls.TLSSocket>;
|
||||
/**
|
||||
* Create a secure server
|
||||
* @returns TLS server instance or undefined if TLS is not enabled
|
||||
*/
|
||||
createSecureServer(): plugins.tls.Server | undefined;
|
||||
/**
|
||||
* Check if TLS is enabled
|
||||
* @returns Whether TLS is enabled
|
||||
*/
|
||||
isTlsEnabled(): boolean;
|
||||
/**
|
||||
* Send a response to the client
|
||||
* @param socket - Client socket
|
||||
* @param response - Response message
|
||||
*/
|
||||
private sendResponse;
|
||||
/**
|
||||
* Check if TLS is available (interface requirement)
|
||||
*/
|
||||
isTlsAvailable(): boolean;
|
||||
/**
|
||||
* Get TLS options (interface requirement)
|
||||
*/
|
||||
getTlsOptions(): plugins.tls.TlsOptions;
|
||||
/**
|
||||
* Clean up resources
|
||||
*/
|
||||
destroy(): void;
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -1,117 +0,0 @@
|
||||
/**
|
||||
* Adaptive SMTP Logging System
|
||||
* Automatically switches between logging modes based on server load (active connections)
|
||||
* to maintain performance during high-concurrency scenarios
|
||||
*/
|
||||
import * as plugins from '../../../../plugins.js';
|
||||
import { SecurityLogLevel, SecurityEventType } from '../constants.js';
|
||||
import type { ISmtpSession } from '../interfaces.js';
|
||||
import type { LogLevel, ISmtpLogOptions } from './logging.js';
|
||||
/**
|
||||
* Log modes based on server load
|
||||
*/
|
||||
export declare enum LogMode {
|
||||
VERBOSE = "VERBOSE",// < 20 connections: Full detailed logging
|
||||
REDUCED = "REDUCED",// 20-40 connections: Limited command/response logging, full error logging
|
||||
MINIMAL = "MINIMAL"
|
||||
}
|
||||
/**
|
||||
* Configuration for adaptive logging thresholds
|
||||
*/
|
||||
export interface IAdaptiveLogConfig {
|
||||
verboseThreshold: number;
|
||||
reducedThreshold: number;
|
||||
aggregationInterval: number;
|
||||
maxAggregatedEntries: number;
|
||||
}
|
||||
/**
|
||||
* Connection metadata for aggregation tracking
|
||||
*/
|
||||
interface IConnectionTracker {
|
||||
activeConnections: number;
|
||||
peakConnections: number;
|
||||
totalConnections: number;
|
||||
connectionsPerSecond: number;
|
||||
lastConnectionTime: number;
|
||||
}
|
||||
/**
|
||||
* Adaptive SMTP Logger that scales logging based on server load
|
||||
*/
|
||||
export declare class AdaptiveSmtpLogger {
|
||||
private static instance;
|
||||
private currentMode;
|
||||
private config;
|
||||
private aggregatedEntries;
|
||||
private aggregationTimer;
|
||||
private connectionTracker;
|
||||
private constructor();
|
||||
/**
|
||||
* Get singleton instance
|
||||
*/
|
||||
static getInstance(config?: Partial<IAdaptiveLogConfig>): AdaptiveSmtpLogger;
|
||||
/**
|
||||
* Update active connection count and adjust log mode if needed
|
||||
*/
|
||||
updateConnectionCount(activeConnections: number): void;
|
||||
/**
|
||||
* Track new connection for rate calculation
|
||||
*/
|
||||
trackConnection(): void;
|
||||
/**
|
||||
* Get current logging mode
|
||||
*/
|
||||
getCurrentMode(): LogMode;
|
||||
/**
|
||||
* Get connection statistics
|
||||
*/
|
||||
getConnectionStats(): IConnectionTracker;
|
||||
/**
|
||||
* Log a message with adaptive behavior
|
||||
*/
|
||||
log(level: LogLevel, message: string, options?: ISmtpLogOptions): void;
|
||||
/**
|
||||
* Log command with adaptive behavior
|
||||
*/
|
||||
logCommand(command: string, socket: plugins.net.Socket | plugins.tls.TLSSocket, session?: ISmtpSession): void;
|
||||
/**
|
||||
* Log response with adaptive behavior
|
||||
*/
|
||||
logResponse(response: string, socket: plugins.net.Socket | plugins.tls.TLSSocket): void;
|
||||
/**
|
||||
* Log connection event with adaptive behavior
|
||||
*/
|
||||
logConnection(socket: plugins.net.Socket | plugins.tls.TLSSocket, eventType: 'connect' | 'close' | 'error', session?: ISmtpSession, error?: Error): void;
|
||||
/**
|
||||
* Log security event (always logged regardless of mode)
|
||||
*/
|
||||
logSecurityEvent(level: SecurityLogLevel, type: SecurityEventType, message: string, details: Record<string, any>, ipAddress?: string, domain?: string, success?: boolean): void;
|
||||
/**
|
||||
* Determine appropriate log mode based on connection count
|
||||
*/
|
||||
private determineLogMode;
|
||||
/**
|
||||
* Switch to a new log mode
|
||||
*/
|
||||
private switchLogMode;
|
||||
/**
|
||||
* Add entry to aggregation buffer
|
||||
*/
|
||||
private aggregateEntry;
|
||||
/**
|
||||
* Start the aggregation timer
|
||||
*/
|
||||
private startAggregationTimer;
|
||||
/**
|
||||
* Flush aggregated entries to logs
|
||||
*/
|
||||
private flushAggregatedEntries;
|
||||
/**
|
||||
* Cleanup resources
|
||||
*/
|
||||
destroy(): void;
|
||||
}
|
||||
/**
|
||||
* Default instance for easy access
|
||||
*/
|
||||
export declare const adaptiveLogger: AdaptiveSmtpLogger;
|
||||
export {};
|
||||
File diff suppressed because one or more lines are too long
@@ -1,78 +0,0 @@
|
||||
/**
|
||||
* SMTP Helper Functions
|
||||
* Provides utility functions for SMTP server implementation
|
||||
*/
|
||||
import * as plugins from '../../../../plugins.js';
|
||||
import type { ISmtpServerOptions } from '../interfaces.js';
|
||||
/**
|
||||
* Formats a multi-line SMTP response according to RFC 5321
|
||||
* @param code - Response code
|
||||
* @param lines - Response lines
|
||||
* @returns Formatted SMTP response
|
||||
*/
|
||||
export declare function formatMultilineResponse(code: number, lines: string[]): string;
|
||||
/**
|
||||
* Generates a unique session ID
|
||||
* @returns Unique session ID
|
||||
*/
|
||||
export declare function generateSessionId(): string;
|
||||
/**
|
||||
* Safely parses an integer from string with a default value
|
||||
* @param value - String value to parse
|
||||
* @param defaultValue - Default value if parsing fails
|
||||
* @returns Parsed integer or default value
|
||||
*/
|
||||
export declare function safeParseInt(value: string | undefined, defaultValue: number): number;
|
||||
/**
|
||||
* Safely gets the socket details
|
||||
* @param socket - Socket to get details from
|
||||
* @returns Socket details object
|
||||
*/
|
||||
export declare function getSocketDetails(socket: plugins.net.Socket | plugins.tls.TLSSocket): {
|
||||
remoteAddress: string;
|
||||
remotePort: number;
|
||||
remoteFamily: string;
|
||||
localAddress: string;
|
||||
localPort: number;
|
||||
encrypted: boolean;
|
||||
};
|
||||
/**
|
||||
* Gets TLS details if socket is TLS
|
||||
* @param socket - Socket to get TLS details from
|
||||
* @returns TLS details or undefined if not TLS
|
||||
*/
|
||||
export declare function getTlsDetails(socket: plugins.net.Socket | plugins.tls.TLSSocket): {
|
||||
protocol?: string;
|
||||
cipher?: string;
|
||||
authorized?: boolean;
|
||||
} | undefined;
|
||||
/**
|
||||
* Merges default options with provided options
|
||||
* @param options - User provided options
|
||||
* @returns Merged options with defaults
|
||||
*/
|
||||
export declare function mergeWithDefaults(options: Partial<ISmtpServerOptions>): ISmtpServerOptions;
|
||||
/**
|
||||
* Creates a text response formatter for the SMTP server
|
||||
* @param socket - Socket to send responses to
|
||||
* @returns Function to send formatted response
|
||||
*/
|
||||
export declare function createResponseFormatter(socket: plugins.net.Socket | plugins.tls.TLSSocket): (response: string) => void;
|
||||
/**
|
||||
* Extracts SMTP command name from a command line
|
||||
* @param commandLine - Full command line
|
||||
* @returns Command name in uppercase
|
||||
*/
|
||||
export declare function extractCommandName(commandLine: string): string;
|
||||
/**
|
||||
* Extracts SMTP command arguments from a command line
|
||||
* @param commandLine - Full command line
|
||||
* @returns Arguments string
|
||||
*/
|
||||
export declare function extractCommandArgs(commandLine: string): string;
|
||||
/**
|
||||
* Sanitizes data for logging (hides sensitive info)
|
||||
* @param data - Data to sanitize
|
||||
* @returns Sanitized data
|
||||
*/
|
||||
export declare function sanitizeForLogging(data: any): any;
|
||||
File diff suppressed because one or more lines are too long
106
dist_ts/mail/delivery/smtpserver/utils/logging.d.ts
vendored
106
dist_ts/mail/delivery/smtpserver/utils/logging.d.ts
vendored
@@ -1,106 +0,0 @@
|
||||
/**
|
||||
* SMTP Logging Utilities
|
||||
* Provides structured logging for SMTP server components
|
||||
*/
|
||||
import * as plugins from '../../../../plugins.js';
|
||||
import { SecurityLogLevel, SecurityEventType } from '../constants.js';
|
||||
import type { ISmtpSession } from '../interfaces.js';
|
||||
/**
|
||||
* SMTP connection metadata to include in logs
|
||||
*/
|
||||
export interface IConnectionMetadata {
|
||||
remoteAddress?: string;
|
||||
remotePort?: number;
|
||||
socketId?: string;
|
||||
secure?: boolean;
|
||||
sessionId?: string;
|
||||
}
|
||||
/**
|
||||
* Log levels for SMTP server
|
||||
*/
|
||||
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
||||
/**
|
||||
* Options for SMTP log
|
||||
*/
|
||||
export interface ISmtpLogOptions {
|
||||
level?: LogLevel;
|
||||
sessionId?: string;
|
||||
sessionState?: string;
|
||||
remoteAddress?: string;
|
||||
remotePort?: number;
|
||||
command?: string;
|
||||
error?: Error;
|
||||
[key: string]: any;
|
||||
}
|
||||
/**
|
||||
* SMTP logger - provides structured logging for SMTP server
|
||||
*/
|
||||
export declare class SmtpLogger {
|
||||
/**
|
||||
* Log a message with context
|
||||
* @param level - Log level
|
||||
* @param message - Log message
|
||||
* @param options - Additional log options
|
||||
*/
|
||||
static log(level: LogLevel, message: string, options?: ISmtpLogOptions): void;
|
||||
/**
|
||||
* Log debug level message
|
||||
* @param message - Log message
|
||||
* @param options - Additional log options
|
||||
*/
|
||||
static debug(message: string, options?: ISmtpLogOptions): void;
|
||||
/**
|
||||
* Log info level message
|
||||
* @param message - Log message
|
||||
* @param options - Additional log options
|
||||
*/
|
||||
static info(message: string, options?: ISmtpLogOptions): void;
|
||||
/**
|
||||
* Log warning level message
|
||||
* @param message - Log message
|
||||
* @param options - Additional log options
|
||||
*/
|
||||
static warn(message: string, options?: ISmtpLogOptions): void;
|
||||
/**
|
||||
* Log error level message
|
||||
* @param message - Log message
|
||||
* @param options - Additional log options
|
||||
*/
|
||||
static error(message: string, options?: ISmtpLogOptions): void;
|
||||
/**
|
||||
* Log command received from client
|
||||
* @param command - The command string
|
||||
* @param socket - The client socket
|
||||
* @param session - The SMTP session
|
||||
*/
|
||||
static logCommand(command: string, socket: plugins.net.Socket | plugins.tls.TLSSocket, session?: ISmtpSession): void;
|
||||
/**
|
||||
* Log response sent to client
|
||||
* @param response - The response string
|
||||
* @param socket - The client socket
|
||||
*/
|
||||
static logResponse(response: string, socket: plugins.net.Socket | plugins.tls.TLSSocket): void;
|
||||
/**
|
||||
* Log client connection event
|
||||
* @param socket - The client socket
|
||||
* @param eventType - Type of connection event (connect, close, error)
|
||||
* @param session - The SMTP session
|
||||
* @param error - Optional error object for error events
|
||||
*/
|
||||
static logConnection(socket: plugins.net.Socket | plugins.tls.TLSSocket, eventType: 'connect' | 'close' | 'error', session?: ISmtpSession, error?: Error): void;
|
||||
/**
|
||||
* Log security event
|
||||
* @param level - Security log level
|
||||
* @param type - Security event type
|
||||
* @param message - Log message
|
||||
* @param details - Event details
|
||||
* @param ipAddress - Client IP address
|
||||
* @param domain - Optional domain involved
|
||||
* @param success - Whether the security check was successful
|
||||
*/
|
||||
static logSecurityEvent(level: SecurityLogLevel, type: SecurityEventType, message: string, details: Record<string, any>, ipAddress?: string, domain?: string, success?: boolean): void;
|
||||
}
|
||||
/**
|
||||
* Default instance for backward compatibility
|
||||
*/
|
||||
export declare const smtpLogger: typeof SmtpLogger;
|
||||
File diff suppressed because one or more lines are too long
@@ -1,69 +0,0 @@
|
||||
/**
|
||||
* SMTP Validation Utilities
|
||||
* Provides validation functions for SMTP server
|
||||
*/
|
||||
import { SmtpState } from '../interfaces.js';
|
||||
/**
|
||||
* Detects header injection attempts in input strings
|
||||
* @param input - The input string to check
|
||||
* @param context - The context where this input is being used ('smtp-command' or 'email-header')
|
||||
* @returns true if header injection is detected, false otherwise
|
||||
*/
|
||||
export declare function detectHeaderInjection(input: string, context?: 'smtp-command' | 'email-header'): boolean;
|
||||
/**
|
||||
* Sanitizes input by removing or escaping potentially dangerous characters
|
||||
* @param input - The input string to sanitize
|
||||
* @returns Sanitized string
|
||||
*/
|
||||
export declare function sanitizeInput(input: string): string;
|
||||
/**
|
||||
* Validates an email address
|
||||
* @param email - Email address to validate
|
||||
* @returns Whether the email address is valid
|
||||
*/
|
||||
export declare function isValidEmail(email: string): boolean;
|
||||
/**
|
||||
* Validates the MAIL FROM command syntax
|
||||
* @param args - Arguments string from the MAIL FROM command
|
||||
* @returns Object with validation result and extracted data
|
||||
*/
|
||||
export declare function validateMailFrom(args: string): {
|
||||
isValid: boolean;
|
||||
address?: string;
|
||||
params?: Record<string, string>;
|
||||
errorMessage?: string;
|
||||
};
|
||||
/**
|
||||
* Validates the RCPT TO command syntax
|
||||
* @param args - Arguments string from the RCPT TO command
|
||||
* @returns Object with validation result and extracted data
|
||||
*/
|
||||
export declare function validateRcptTo(args: string): {
|
||||
isValid: boolean;
|
||||
address?: string;
|
||||
params?: Record<string, string>;
|
||||
errorMessage?: string;
|
||||
};
|
||||
/**
|
||||
* Validates the EHLO command syntax
|
||||
* @param args - Arguments string from the EHLO command
|
||||
* @returns Object with validation result and extracted data
|
||||
*/
|
||||
export declare function validateEhlo(args: string): {
|
||||
isValid: boolean;
|
||||
hostname?: string;
|
||||
errorMessage?: string;
|
||||
};
|
||||
/**
|
||||
* Validates command in the current SMTP state
|
||||
* @param command - SMTP command
|
||||
* @param currentState - Current SMTP state
|
||||
* @returns Whether the command is valid in the current state
|
||||
*/
|
||||
export declare function isValidCommandSequence(command: string, currentState: SmtpState): boolean;
|
||||
/**
|
||||
* Validates if a hostname is valid according to RFC 5321
|
||||
* @param hostname - Hostname to validate
|
||||
* @returns Whether the hostname is valid
|
||||
*/
|
||||
export declare function isValidHostname(hostname: string): boolean;
|
||||
File diff suppressed because one or more lines are too long
@@ -1,4 +1,3 @@
|
||||
import * as plugins from '../../plugins.js';
|
||||
import { EventEmitter } from 'events';
|
||||
import { DKIMCreator } from '../security/classes.dkimcreator.js';
|
||||
interface IIPWarmupConfig {
|
||||
@@ -154,12 +153,6 @@ export declare class UnifiedEmailServer extends EventEmitter {
|
||||
* Start the unified email server
|
||||
*/
|
||||
start(): Promise<void>;
|
||||
/**
|
||||
* Handle a socket from smartproxy in socket-handler mode
|
||||
* @param socket The socket to handle
|
||||
* @param port The port this connection is for (25, 587, 465)
|
||||
*/
|
||||
handleSocket(socket: plugins.net.Socket | plugins.tls.TLSSocket, port: number): Promise<void>;
|
||||
/**
|
||||
* Stop the unified email server
|
||||
*/
|
||||
@@ -176,8 +169,8 @@ export declare class UnifiedEmailServer extends EventEmitter {
|
||||
*/
|
||||
private handleRustAuthRequest;
|
||||
/**
|
||||
* Verify inbound email security (DKIM/SPF/DMARC) using the Rust bridge.
|
||||
* Falls back gracefully if the bridge is not running.
|
||||
* Verify inbound email security (DKIM/SPF/DMARC) using pre-computed Rust results
|
||||
* or falling back to IPC call if no pre-computed results are available.
|
||||
*/
|
||||
private verifyInboundSecurity;
|
||||
/**
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user