The firewall-pc scenario and FirewallWindowRun use Java's window as a person does and send a ping, a TCP connection and a DNS question from the server's network and from behind the router after each step. The core adds and removes port rules (personalFirewall.ts) and writes both into the firewall's log, which now carries each line's time; the room takes the window's actions and sends its view and the log as lines; the editor shows Java's window with its two tabs. Not adopted from Java: any integer as a port, a port after a space refused without a word, a log one can type into. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
66 lines
2.6 KiB
TypeScript
66 lines
2.6 KiB
TypeScript
// A server's lines as Java's server windows write them (ServerAnwendung,
|
|
// ServerMitarbeiter, TCPSocket's failures), and the generic client's as its
|
|
// window writes them (ClientBaustein, Socket, TCPSocket), in the person's
|
|
// language: one line each (a failed connection two), as Java appends them to
|
|
// its window's text area. And a computer's firewall's log as its window
|
|
// writes it (Firewall.benachrichtigeBeobachter, GUIApplicationFirewallWindow).
|
|
|
|
import { firewallRuleText, PORT_RULE_PROTOCOL_NAMES, type FirewallLogEntry, type ServerLogEntry, type SimpleClientLogEntry } from '@mdg-filius/core';
|
|
import type { Translate } from '../i18n/i18n.js';
|
|
|
|
export function serverLine(entry: ServerLogEntry, t: Translate): string {
|
|
switch (entry.kind) {
|
|
case 'acceptingStarted':
|
|
case 'acceptingStopped':
|
|
case 'serverSocketClosed':
|
|
case 'serverSocketFailed':
|
|
return t(`server.${entry.kind}`);
|
|
case 'connectionAccepted':
|
|
case 'connectionClosed':
|
|
return t(`server.${entry.kind}`, { address: `${entry.address}:${entry.port}` });
|
|
case 'received':
|
|
return `>>${entry.text}`;
|
|
case 'sent':
|
|
return `<<${entry.text}`;
|
|
case 'sendFailed':
|
|
return t(`server.sendFailed.${entry.failure}`);
|
|
}
|
|
}
|
|
|
|
export function simpleClientLine(entry: SimpleClientLogEntry, t: Translate): string {
|
|
switch (entry.kind) {
|
|
case 'connected':
|
|
case 'disconnected':
|
|
case 'notConnected':
|
|
case 'receiveFailed':
|
|
return t(`simpleClient.${entry.kind}`);
|
|
case 'connectFailed':
|
|
return `${t('simpleClient.notConnected')}\n${t(`simpleClient.failure.${entry.failure}`)}`;
|
|
case 'connectionClosed':
|
|
return t('simpleClient.connectionClosed', { address: `${entry.address}:${entry.port}` });
|
|
case 'received':
|
|
return `>>${entry.text}`;
|
|
case 'sent':
|
|
return `<<${entry.text}`;
|
|
case 'sendFailed':
|
|
return t(`server.sendFailed.${entry.failure}`);
|
|
}
|
|
}
|
|
|
|
export function firewallLine(entry: FirewallLogEntry, t: Translate): string {
|
|
switch (entry.kind) {
|
|
case 'ruleMatched':
|
|
return t('personalFirewall.ruleMatched', {
|
|
number: entry.ruleNumber,
|
|
rule: firewallRuleText(entry.rule, entry.firstInterface),
|
|
action: t(entry.accepted ? 'firewall.accept' : 'firewall.drop'),
|
|
});
|
|
case 'icmpDropped':
|
|
return t('personalFirewall.icmpDropped', { sender: entry.senderIPAddress, receiver: entry.receiverIPAddress, code: entry.code, type: entry.type });
|
|
case 'portRuleAdded':
|
|
return t('personalFirewall.portRuleAdded', { port: entry.port, protocol: PORT_RULE_PROTOCOL_NAMES[entry.protocol] });
|
|
case 'portRuleRemoved':
|
|
return t('personalFirewall.portRuleRemoved');
|
|
}
|
|
}
|