feat(sim): F4.6f1 what a run leaves goes back into the document
The oracle SaveAfterRunRun saves Java's project after a run. The room writes what a run leaves that Java keeps - files, running servers, virtual hosts, mail servers' domains and accounts, mail programs' accounts and folders, firewalls, DHCP clients' addresses - into the document as origin 'sim', at most once a second, after each action and at the stop; writeRunState writes only what differs. The command line now goes on in a folder made before a restart, as Java's does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
// /mailserver/konten.txt at once), and an e-mail program's inbox and sent
|
||||
// mails.
|
||||
|
||||
import { portSnapshot, topologySnapshot, type DnsServerConfiguration, type EchoServerSnapshot, type EmailServerSnapshot, type Id, type WebServerSnapshot, type TopologySnapshot } from '@mdg-filius/core';
|
||||
import { portSnapshot, topologySnapshot, type DnsServerConfiguration, type EchoServerSnapshot, type EmailServerConfiguration, type EmailServerSnapshot, type Id, type WebServerSnapshot, type TopologySnapshot } from '@mdg-filius/core';
|
||||
import type { ImportedProject } from './importProject.js';
|
||||
|
||||
export function projectSnapshot(project: ImportedProject): TopologySnapshot {
|
||||
@@ -72,18 +72,23 @@ export function projectSnapshot(project: ImportedProject): TopologySnapshot {
|
||||
});
|
||||
}
|
||||
|
||||
/** An e-mail server's settings as a run left them: its domain and accounts, the next message's number after their mails. */
|
||||
export function emailServerAfterRun(configuration: EmailServerConfiguration, server: EmailServerSnapshot): EmailServerConfiguration {
|
||||
const messages = server.accounts.reduce((count, account) => count + account.mailbox.length, 0);
|
||||
return { ...configuration, domain: server.domain, accounts: server.accounts, nextMessageID: messages + 1 };
|
||||
}
|
||||
|
||||
/**
|
||||
* The project with what the simulation changed that Java keeps, as the run's
|
||||
* snapshot holds it: the firewalls, the e-mail servers' mailboxes, and the
|
||||
* e-mail programs' inboxes and sent mails.
|
||||
* snapshot holds it: the firewalls, the e-mail servers' domains and
|
||||
* mailboxes, and the e-mail programs' accounts, inboxes and sent mails.
|
||||
*/
|
||||
export function projectWithSimulationChanges(project: ImportedProject, snapshot: TopologySnapshot): ImportedProject {
|
||||
const emailServers = new Map(project.emailServerConfigurations);
|
||||
for (const [nodeId, server] of snapshot.emailServersByNodeId) {
|
||||
const configuration = emailServers.get(nodeId);
|
||||
if (configuration === undefined) continue;
|
||||
const messages = server.accounts.reduce((count, account) => count + account.mailbox.length, 0);
|
||||
emailServers.set(nodeId, { ...configuration, accounts: server.accounts, nextMessageID: messages + 1 });
|
||||
emailServers.set(nodeId, emailServerAfterRun(configuration, server));
|
||||
}
|
||||
const emailClients = new Map(project.emailClientConfigurations);
|
||||
for (const [nodeId, client] of snapshot.emailClientsByNodeId) {
|
||||
|
||||
Reference in New Issue
Block a user