Skip to content

Commit

Permalink
refactor(backend): extracted telnet options from client
Browse files Browse the repository at this point in the history
- negotiations are now optional since they need to be set one-by-one (server and client)
- added TelnetOptionHandler to define seperate telnet options
- re-implemented charset as handle-charset-option
- re-implemented echo as handle-echo-option
- all other options are answered with a negative DONT or WONT
- refactored telnet-client
  • Loading branch information
mystiker committed Sep 14, 2024
1 parent e3a640c commit 44a0b4c
Show file tree
Hide file tree
Showing 8 changed files with 426 additions and 228 deletions.
24 changes: 20 additions & 4 deletions backend/src/core/middleware/use-rest-endpoints.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Express, Request, Response } from 'express';

import { TelnetControlSequences } from '../../features/telnet/types/telnet-control-sequences.js';
import { TelnetOptions } from '../../features/telnet/types/telnet-options.js';
import { logger } from '../../shared/utils/logger.js';
import { SocketManager } from '../sockets/socket-manager.js';

Expand All @@ -13,10 +15,24 @@ export const useRestEndpoints = (
const connections = Object.entries(socketManager.mudConnections).flatMap(
([connectionKey, con]) => {
const negotiations = Object.entries(con.telnet?.negotiations || {}).map(
([negotiationKey, negotiations]) => ({
code: negotiationKey,
...negotiations,
}),
([negotiationKey, negotiations]) => {
const key = Number(negotiationKey);

return {
code: TelnetOptions[key],
...{
server: negotiations?.server
? TelnetControlSequences[negotiations?.server]
: {},
},
...{
client: negotiations?.client
? TelnetControlSequences[negotiations?.client]
: {},
},
...negotiations?.subnegotiation,
};
},
);

return {
Expand Down
Loading

0 comments on commit 44a0b4c

Please sign in to comment.