update
This commit is contained in:
@ -93,6 +93,8 @@ export class SessionManager implements ISessionManager {
|
||||
useTLS: secure || false,
|
||||
connectionEnded: false,
|
||||
remoteAddress: socketDetails.remoteAddress,
|
||||
remotePort: socketDetails.remotePort,
|
||||
createdAt: new Date(),
|
||||
secure: secure || false,
|
||||
authenticated: false,
|
||||
envelope: {
|
||||
@ -501,6 +503,39 @@ export class SessionManager implements ISessionManager {
|
||||
return `${details.remoteAddress}:${details.remotePort}-${Date.now()}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all active sessions
|
||||
*/
|
||||
public getAllSessions(): ISmtpSession[] {
|
||||
return Array.from(this.sessions.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* Update last activity for a session by socket
|
||||
*/
|
||||
public updateLastActivity(socket: plugins.net.Socket | plugins.tls.TLSSocket): void {
|
||||
const session = this.getSession(socket);
|
||||
if (session) {
|
||||
this.updateSessionActivity(session);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for timed out sessions
|
||||
*/
|
||||
public checkTimeouts(timeoutMs: number): ISmtpSession[] {
|
||||
const now = Date.now();
|
||||
const timedOutSessions: ISmtpSession[] = [];
|
||||
|
||||
for (const session of this.sessions.values()) {
|
||||
if (now - session.lastActivity > timeoutMs) {
|
||||
timedOutSessions.push(session);
|
||||
}
|
||||
}
|
||||
|
||||
return timedOutSessions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up resources
|
||||
*/
|
||||
|
Reference in New Issue
Block a user