Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/telnet-charset #122

Merged
merged 5 commits into from
Nov 3, 2024
Merged

feat/telnet-charset #122

merged 5 commits into from
Nov 3, 2024

Conversation

mystiker
Copy link
Collaborator

@mystiker mystiker commented Sep 13, 2024

This PR adds support for multiple character encodings (charsets) in the Mud client and introduces a new ENVIRONMENT variable for enabling development-specific features.

Supported Charsets

The Mud client now supports the following charsets:

  • utf-8
    - latin1 (ISO-8859-1)
    - ascii (US-ASCII)

Charset conversion on the client-side is handled through the function mapToServerEncodings, which maps the client-used charsets to those supported by the server.

How It Works

During the Telnet negotiation (TELOPT_CHARSET), the client checks which charsets are supported by the server. The client's preferred charset (defined via the environment variable CHARSET) Only UTF-8 is compared against the charsets offered by the server. If the client's preferred charset is not supported, the client defaults to utf-8 an error is thrown.

Server-side Charset Check: During the Telnet charset negotiation, the client's preferred charset (e.g., utf-8, latin1, ascii) is checked against the charsets supported by the server.
Fault Tolerance: If the server does not support the client's charset, the encoding defaults to utf-8, and a warning is logged.

New Environment Variable ENVIRONMENT

A new environment variable ENVIRONMENT has been introduced, which can be set to either "development" or "production" (default). This variable controls whether certain development-only features are enabled.

Validation: If ENVIRONMENT is set to anything other than "development" or "production", an error is thrown to ensure valid configuration.

Development Mode Debug Endpoints

When the environment is set to "development", debug REST endpoints are enabled. These endpoints provide information about the currently connected clients and their Telnet negotiations.

The /api/info endpoint provides a list of all active Telnet connections and their associated negotiation status.

This allows developers to monitor connected clients and inspect their negotiation status directly from the REST endpoint during development.

Fixes #111

Edit: The client is now fixed at "utf-8". The old CHARSET environment variable has been discarded.

- added ENVIRONMENT environment flag that can be set to 'development' or 'production' (default)
- added a rest endpoint via /api/info for further inspection of the server state
- show telnet negotiations in the debug endpoint
- added CHARSET environment variable. supported values: utf-8, latin1 (ISO-8859-1), ascii (US-ASCII)
- added charset subnegotiaton with fallback to utf-8
- 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
@mystiker mystiker self-assigned this Sep 14, 2024
@mystiker mystiker mentioned this pull request Sep 14, 2024
- removed environment variable
- negotiate only utf-8
- if utf-8 is not supported, throw an error
@mystiker
Copy link
Collaborator Author

mystiker commented Oct 3, 2024

After some testing it turns out that supporting multiple encodings just for unitopia alone is not sufficient. I'm pretty sure one can provide the missing implementation for different encodings with ease but I have no testing partner right now and most, if not all, MUDs should support utf-8 anyways.

I changed the PR description. Main changes:

  • The client now only supports utf-8. No environment variable needed.
  • If the MUD does not support utf-8, an error will be thrown

Copy link
Contributor

@myonara myonara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all ok and bespoken

@mystiker mystiker merged commit 7ae3c4d into develop Nov 3, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

telnet option CHARSET,
2 participants