start the path to rust

This commit is contained in:
2026-02-10 15:54:09 +00:00
parent 237dba3bab
commit 8bd8c295b0
318 changed files with 28352 additions and 428 deletions

View File

@@ -0,0 +1,106 @@
/**
* 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;