TelWeb is a Telnet-based Markdown browser that allows users to navigate through Markdown files in a specified directory. The service is designed to be lightweight and stateless, supporting multiple simultaneous client connections. Users can connect to the service using a Telnet client and interact with the Markdown files by following links, navigating back, or exiting the session.
- Markdown File Display: Displays the content of Markdown files, starting with
index.md. - Link Navigation: Supports navigation through links in the format
[text](file.md)or[text](subdir/file.md). - Command Support:
number: Navigate to the selected link.back: Return to the previous page.quitorexit: End the session.
- Access Control: Ensures users cannot access files outside the mounted directory.
- Error Handling: Displays "File not found" if the requested file does not exist.
- Multi-User Support: Handles multiple client connections simultaneously.
The service is implemented in Rust and adheres to the following requirements:
- Stateless Design: Client state is maintained only during the session.
- Concurrency: Supports multiple clients by spawning a new thread for each connection.
- Markdown Parsing: Extracts and displays links from Markdown files using regular expressions.
- Path Safety: Prevents directory traversal attacks by validating file paths.
The application uses the following environment variables:
PORT: Specifies the port on which the TelWeb server listens. Defaults to2323if not set.DATA_DIR: Specifies the directory containing the Markdown files. Defaults to/dataif not set.
The service is containerized for easy deployment. The Docker setup includes:
- Dockerfile: Builds the service image.
- docker-compose.yml: Configures the service with the following:
- Mounts a host directory to
/datainside the container. - Publishes the service port (e.g.,
2323:2323).
- Mounts a host directory to
- Build and run the Docker container.
- Connect to the service using a Telnet client:
telnet <host> 2323 - Start browsing Markdown files, beginning with
index.md.
1: Follow the first link in the file.back: Return to the previous file.quit: Exit the session.
- Connection:
- Clients connect via
telnet host port. - Automatically opens
index.mdupon connection.
- Clients connect via
- File Display:
- Reads and displays the content of
index.mdfrom the mounted directory. - Supports plain Markdown (text and links).
- Reads and displays the content of
- Navigation:
- Displays a numbered list of links at the bottom of the page.
- Allows navigation using link numbers.
- Supports
backandquitcommands.
- Access Control:
- Restricts access to files within the mounted directory.
- Displays "File not found" for missing files.
- Implementation: Written in Rust for performance and safety.
- Statelessness: Maintains client state only during the session.
- Concurrency: Supports multiple simultaneous connections.