Skip to content

sdsalyer/moonbase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Moonbase BBS (Bulletin Board System)

A modern traditional BBS implementation in Rust with intelligent telnet protocol support and adaptive terminal capabilities.

Project Goals

  • Learn Rust network programming fundamentals
  • Minimize external dependencies (except Crossterm/Ratatui for UI)
  • Build incrementally with working software at each step
  • Create something fun and nostalgic

Next Steps

  1. Add user-to-user messaging system
  2. Implement file library with upload/download
  3. Add online user tracking and directory
  4. Doors/Mods plugin support
  5. Add SSH support alongside Telnet
  6. System administration features

Current Status

Core Infrastructure

  • Project setup
  • Advanced telnet protocol support with RFC-compliant option negotiation
  • Intelligent terminal capability detection and adaptive UI
  • Multi-threaded connection management
  • Configurable BBS system via bbs.conf
  • Clean modular architecture
  • Comprehensive testing framework (24 tests passing)

User Interface System

  • Adaptive terminal width detection using NAWS (RFC 1073)
  • Smart color support based on terminal capabilities
  • Intelligent ANSI support detection and box style selection
  • Configurable box-drawing system with automatic fallbacks
  • Menu system with responsive layout
  • Retro BBS-style interface with modern enhancements

Menu System

  • Main menu with user status display
  • Bulletin board menu (FULLY IMPLEMENTED)
  • User directory menu (placeholder)
  • Private messages menu (placeholder)
  • File library menu (placeholder)
  • Feature-aware menus (hide disabled features)

Session Management

  • Secure password input with telnet echo negotiation (RFC 857)
  • Terminal capability negotiation during session startup
  • Advanced user session tracking with terminal state management
  • User registration and persistent storage
  • Secure authentication with masked password input
  • Anonymous access control
  • Connection timeout handling
  • Graceful connection cleanup

Configuration System

  • Auto-detection configuration options with manual overrides
  • Responsive layout configuration with fallback options
  • Full configuration via INI-style file with backward compatibility
  • Server settings (ports, timeouts, connection limits)
  • BBS branding and information
  • Feature toggles
  • Advanced UI customization (adaptive width, smart colors, ANSI detection)

User System

  • Secure user registration with masked password input
  • User registration with validation
  • User data persistence (file-based)
  • User profiles and preferences
  • Enhanced password authentication with telnet echo control

Bulletin System

  • Create and post new bulletins
  • Read existing bulletins with content display
  • Mark bulletins as read (per-user tracking)
  • Bulletin statistics (total, unread count)
  • Recent bulletins display with status indicators
  • Sticky bulletin support
  • Persistent storage (JSON-based)
  • Anonymous and registered user support
  • Full menu navigation and state management

BBS Core Features

  • Responsive bulletin display with adaptive width
  • Bulletin posting and reading with full menu navigation
  • Private messaging system (basic implementation)
  • File upload/download system
  • Online user tracking
  • User directory with search

Advanced Features

  • Full telnet protocol negotiation (RFC 854, 857, 1073, 1091)
  • Terminal capability detection and adaptive rendering
  • SSH support (alongside Telnet)
  • System administration features
  • Message threading and organization
  • File categorization and search
  • User permissions and groups

Enhanced Telnet Integration ✨

Terminal Capability Detection

  • Auto-detect terminal width using NAWS option (RFC 1073)
  • Smart ANSI support detection from terminal type (RFC 1091)
  • Intelligent color support based on terminal capabilities
  • Graceful degradation for limited terminals

Security Enhancements

  • Secure password input with telnet echo negotiation (RFC 857)
  • Masked authentication during login and registration
  • RFC-compliant telnet option handling

Responsive Design

  • Adaptive UI layouts that respond to terminal width
  • Smart box drawing with ANSI fallbacks
  • Dynamic color themes based on terminal capabilities
  • Consistent experience across diverse terminal types

Architecture

Current Module Structure

src/
├── main.rs                  # Server startup and connection handling
├── config.rs                # Enhanced configuration with Phase 7 auto-detection
├── errors.rs                # Custom error types
├── box_renderer.rs          # Adaptive UI rendering system
├── session.rs               # Session management with telnet capability detection
├── users.rs                 # User data types and validation
├── user_repository.rs       # User storage and authentication
├── bulletins.rs             # Bulletin data types and validation
├── bulletin_repository.rs   # Bulletin storage and statistics
├── messages.rs              # Private message data types
├── message_repository.rs    # Message storage and management
├── services/                # Service layer for business logic
│   ├── mod.rs
│   ├── bulletin_service.rs
│   ├── message_service.rs
│   └── user_service.rs
└── menu/                    # Responsive menu system
    ├── mod.rs               # Menu traits and common types
    ├── menu_main.rs         # Main menu implementation
    ├── menu_bulletin.rs     # Bulletin board menu (FULLY IMPLEMENTED)
    ├── menu_user.rs         # User directory menu
    └── menu_message.rs      # Private messaging menu

telnet-negotiation/          # RFC-compliant telnet library
├── src/
│   ├── lib.rs              # Library entry point and exports
│   ├── protocol.rs         # Telnet protocol constants (RFC 854)
│   ├── parser.rs           # Command parsing and data separation  
│   ├── negotiation.rs      # Option negotiation state machine (RFC 1143)
│   ├── stream.rs           # TelnetStream wrapper with high-level API
│   └── options/            # Specific option implementations
│       ├── mod.rs
│       ├── echo.rs         # Echo option (RFC 857) for secure passwords
│       ├── terminal_type.rs # Terminal Type (RFC 1091) for capabilities
│       └── naws.rs         # Window Size (RFC 1073) for responsive layout
└── examples/               # Protocol demonstration programs

Design Principles

  • Single responsibility - Each module has a clear purpose
  • Pure functions - Menu logic separated from I/O
  • Configurable - Extensive customization without code changes
  • Testable - Clean interfaces for unit testing
  • Extensible - Easy to add new menus and features

Future considerations

Phase 1: Stay with Enhanced MVC (Current)

Small improvements:

  • Add event logging for observability
  • Extract more traits for testability
  • Better error handling with context

Phase 2: Add Event System

When adding notifications/real-time features

// Add this layer on top of current MVC
struct EventBus {
    handlers: HashMap<TypeId, Vec<Box<dyn EventHandler>>>,
}

// Current code stays the same, just publishes events
session.handle_bulletin_submit(title, content)?;
event_bus.publish(BulletinPosted { id, author })?;

Phase 3: Consider Hexagonal

When you want to add SSH, HTTP API, or WebSocket support, hexagonal architecture becomes valuable.

  • Session layer knows about TCP streams
  • Storage layer tied to JSON files
  • Terminal rendering mixed with business logic

How It Would Look:

// Core domain - no external dependencies
mod domain {
    pub struct BulletinService {
        repo: Box<dyn BulletinRepository>,
    }

    impl BulletinService {
        pub fn post_bulletin(&mut self, request: BulletinRequest) -> Result<BulletinId> {
            // Pure business logic
        }
    }
}

// Adapters - handle external concerns
mod adapters {
    struct TelnetAdapter;
    struct SSHAdapter;
    struct WebAdapter; // Future HTTP interface

    struct JsonStorageAdapter;
    struct DatabaseAdapter; // Future SQL storage
}

Dependencies

  • crossterm - Terminal manipulation and input handling
  • jiff - Datetime handling
  • serde - Serialization
  • Standard library only for core networking and file I/O

Getting Started

git clone <repository>
cd <repository>
cargo run

Then connect with:

telnet 127.0.0.1 2323

Configuration

On first run, a default bbs.conf file is created. Customize your BBS by editing:

[bbs]
name = "My Awesome BBS"
tagline = "The coolest retro BBS in cyberspace!"
sysop_name = "YourName"

[server]
telnet_port = 2323
max_connections = 50

[ui]
# User interface configuration
box_style = "ascii"          # "ascii" (recommended for compatibility)
use_colors = false           # Force colors on/off

# Phase 7: Clean width configuration  
width_mode = "auto"          # "auto" or "fixed"
width_value = 80             # Width in characters (fixed value or fallback for auto)

# Phase 7: Terminal capability detection
ansi_support = "auto"        # "auto", "true", "false"  
color_support = "auto"       # "auto", "true", "false"
adaptive_layout = true       # Enable responsive design

[features]
allow_anonymous = true
bulletins_enabled = true
file_uploads_enabled = true

Phase 7 Configuration Guide

Clean Width Configuration:

  • width_mode = "auto" - Automatically detects client terminal width using NAWS
  • width_mode = "fixed" - Uses fixed width specified in width_value
  • width_value = 80 - Width in characters (fixed value or fallback when auto-detection fails)

Auto-Detection Options:

  • ansi_support = "auto" - Detects ANSI capabilities from terminal type
  • color_support = "auto" - Enables colors based on terminal capabilities
  • adaptive_layout = true - Enables responsive menu layouts

Manual Override Options:

  • Use "true"/"false" instead of "auto" to force specific behavior
  • All configuration is backward compatible with graceful fallbacks

Learning Focus Areas Covered

  • TCP socket programming with std::net
  • Concurrent programming with threads (Arc and Mutex)
  • Terminal control and ANSI escape sequences
  • File I/O and configuration parsing
  • Error handling with custom types
  • Modular architecture design
  • Rust traits and polymorphism
  • Data persistence and serialization
  • Advanced telnet protocol negotiation (RFC 854, 857, 1073, 1091)
  • State machines and protocol implementation
  • Network protocol parsing and byte stream handling
  • Adaptive system design with capability detection
  • SSH implementation

About

A simple BBS implementation.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages