138 lines
3.4 KiB
TypeScript
138 lines
3.4 KiB
TypeScript
|
|
/**
|
||
|
|
* 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>;
|
||
|
|
}
|