This commit is contained in:
2025-05-23 00:06:07 +00:00
parent f058b2d1e7
commit 4905595cbb
7 changed files with 351 additions and 99 deletions

View File

@ -281,7 +281,7 @@ export class ConnectionManager implements IConnectionManager {
* Handle a new connection with resource management
* @param socket - Client socket
*/
public handleNewConnection(socket: plugins.net.Socket): void {
public async handleNewConnection(socket: plugins.net.Socket): Promise<void> {
// Update connection stats
this.connectionStats.totalConnections++;
this.connectionStats.activeConnections = this.activeConnections.size + 1;
@ -437,7 +437,7 @@ export class ConnectionManager implements IConnectionManager {
* Handle a new secure TLS connection with resource management
* @param socket - Client TLS socket
*/
public handleNewSecureConnection(socket: plugins.tls.TLSSocket): void {
public async handleNewSecureConnection(socket: plugins.tls.TLSSocket): Promise<void> {
// Update connection stats
this.connectionStats.totalConnections++;
this.connectionStats.activeConnections = this.activeConnections.size + 1;
@ -961,6 +961,24 @@ export class ConnectionManager implements IConnectionManager {
}
}
/**
* Handle a new connection (interface requirement)
*/
public async handleConnection(socket: plugins.net.Socket | plugins.tls.TLSSocket, secure: boolean): Promise<void> {
if (secure) {
this.handleNewSecureConnection(socket as plugins.tls.TLSSocket);
} else {
this.handleNewConnection(socket as plugins.net.Socket);
}
}
/**
* Check if accepting new connections (interface requirement)
*/
public canAcceptConnection(): boolean {
return !this.hasReachedMaxConnections();
}
/**
* Clean up resources
*/
@ -976,8 +994,18 @@ export class ConnectionManager implements IConnectionManager {
// Clear maps
this.activeConnections.clear();
this.connectionTimestamps.clear();
this.ipConnectionCounts.clear();
this.ipConnections.clear();
// Reset connection stats
this.connectionStats = {
totalConnections: 0,
activeConnections: 0,
peakConnections: 0,
rejectedConnections: 0,
closedConnections: 0,
erroredConnections: 0,
timedOutConnections: 0
};
SmtpLogger.debug('ConnectionManager destroyed');
}