/telweb

Telnet based www

Primary LanguageRust

TelWeb

Project Description

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.

Features

  • 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.
    • quit or exit: 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.

Technical Details

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.

Environment Variables

The application uses the following environment variables:

  • PORT: Specifies the port on which the TelWeb server listens. Defaults to 2323 if not set.
  • DATA_DIR: Specifies the directory containing the Markdown files. Defaults to /data if not set.

Docker Configuration

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 /data inside the container.
    • Publishes the service port (e.g., 2323:2323).

Usage

  1. Build and run the Docker container.
  2. Connect to the service using a Telnet client:
    telnet <host> 2323
    
  3. Start browsing Markdown files, beginning with index.md.

Example Commands

  • 1: Follow the first link in the file.
  • back: Return to the previous file.
  • quit: Exit the session.

Requirements

Functional Requirements

  1. Connection:
    • Clients connect via telnet host port.
    • Automatically opens index.md upon connection.
  2. File Display:
    • Reads and displays the content of index.md from the mounted directory.
    • Supports plain Markdown (text and links).
  3. Navigation:
    • Displays a numbered list of links at the bottom of the page.
    • Allows navigation using link numbers.
    • Supports back and quit commands.
  4. Access Control:
    • Restricts access to files within the mounted directory.
    • Displays "File not found" for missing files.

Non-Functional Requirements

  • Implementation: Written in Rust for performance and safety.
  • Statelessness: Maintains client state only during the session.
  • Concurrency: Supports multiple simultaneous connections.