update
This commit is contained in:
@ -35,7 +35,7 @@ export class CommandHandler implements ICommandHandler {
|
||||
* @param socket - Client socket
|
||||
* @param commandLine - Command line from client
|
||||
*/
|
||||
public processCommand(socket: plugins.net.Socket | plugins.tls.TLSSocket, commandLine: string): void {
|
||||
public async processCommand(socket: plugins.net.Socket | plugins.tls.TLSSocket, commandLine: string): Promise<void> {
|
||||
// Get the session for this socket
|
||||
const session = this.smtpServer.getSessionManager().getSession(socket);
|
||||
if (!session) {
|
||||
@ -216,7 +216,7 @@ export class CommandHandler implements ICommandHandler {
|
||||
case SmtpCommand.STARTTLS:
|
||||
const tlsHandler = this.smtpServer.getTlsHandler();
|
||||
if (tlsHandler && tlsHandler.isTlsEnabled()) {
|
||||
tlsHandler.handleStartTls(socket);
|
||||
await tlsHandler.handleStartTls(socket, session);
|
||||
} else {
|
||||
SmtpLogger.warn('STARTTLS requested but TLS is not enabled', {
|
||||
remoteAddress: socket.remoteAddress,
|
||||
@ -1018,6 +1018,48 @@ export class CommandHandler implements ICommandHandler {
|
||||
return isValidCommandSequence(command, session.state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an SMTP command (interface requirement)
|
||||
*/
|
||||
public async handleCommand(
|
||||
socket: plugins.net.Socket | plugins.tls.TLSSocket,
|
||||
command: SmtpCommand,
|
||||
args: string,
|
||||
session: ISmtpSession
|
||||
): Promise<void> {
|
||||
// Delegate to processCommand for now
|
||||
this.processCommand(socket, `${command} ${args}`.trim());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get supported commands for current session state (interface requirement)
|
||||
*/
|
||||
public getSupportedCommands(session: ISmtpSession): SmtpCommand[] {
|
||||
const commands: SmtpCommand[] = [SmtpCommand.NOOP, SmtpCommand.QUIT, SmtpCommand.RSET];
|
||||
|
||||
switch (session.state) {
|
||||
case SmtpState.GREETING:
|
||||
commands.push(SmtpCommand.EHLO, SmtpCommand.HELO);
|
||||
break;
|
||||
case SmtpState.AFTER_EHLO:
|
||||
commands.push(SmtpCommand.MAIL_FROM, SmtpCommand.STARTTLS);
|
||||
if (!session.authenticated) {
|
||||
commands.push(SmtpCommand.AUTH);
|
||||
}
|
||||
break;
|
||||
case SmtpState.MAIL_FROM:
|
||||
commands.push(SmtpCommand.RCPT_TO);
|
||||
break;
|
||||
case SmtpState.RCPT_TO:
|
||||
commands.push(SmtpCommand.RCPT_TO, SmtpCommand.DATA);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return commands;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up resources
|
||||
*/
|
||||
|
Reference in New Issue
Block a user