This commit is contained in:
2025-05-22 23:02:37 +00:00
parent f065a9c952
commit 50350bd78d
10 changed files with 633 additions and 779 deletions

View File

@ -122,58 +122,18 @@ export class SmtpServer implements ISmtpServer {
this.emailServer = config.emailServer;
this.options = mergeWithDefaults(config.options);
// Create components or use provided ones
// Create components - all components now receive the SMTP server instance
this.sessionManager = config.sessionManager || new SessionManager({
socketTimeout: this.options.socketTimeout,
connectionTimeout: this.options.connectionTimeout,
cleanupInterval: this.options.cleanupInterval
});
this.securityHandler = config.securityHandler || new SecurityHandler(
this.emailServer,
undefined, // IP reputation service
this.options.auth
);
this.tlsHandler = config.tlsHandler || new TlsHandler(
this.sessionManager,
{
key: this.options.key,
cert: this.options.cert,
ca: this.options.ca
}
);
this.dataHandler = config.dataHandler || new DataHandler(
this.sessionManager,
this.emailServer,
{
size: this.options.size
}
);
this.commandHandler = config.commandHandler || new CommandHandler(
this.sessionManager,
{
hostname: this.options.hostname,
size: this.options.size,
maxRecipients: this.options.maxRecipients,
auth: this.options.auth
},
this.dataHandler,
this.tlsHandler,
this.securityHandler
);
this.connectionManager = config.connectionManager || new ConnectionManager(
this.sessionManager,
(socket, line) => this.commandHandler.processCommand(socket, line),
{
hostname: this.options.hostname,
maxConnections: this.options.maxConnections,
socketTimeout: this.options.socketTimeout
}
);
this.securityHandler = config.securityHandler || new SecurityHandler(this);
this.tlsHandler = config.tlsHandler || new TlsHandler(this);
this.dataHandler = config.dataHandler || new DataHandler(this);
this.commandHandler = config.commandHandler || new CommandHandler(this);
this.connectionManager = config.connectionManager || new ConnectionManager(this);
}
/**