TNT's Not Tunnel
Find a file
m1ngsama 8e24ae5633 Add CI/CD and deployment automation
GitHub Actions workflows:
- ci.yml: Auto-test on push/PR
  * Build on Ubuntu and macOS
  * Run AddressSanitizer
  * Memory leak checks with Valgrind

- release.yml: Auto-release on tags
  * Build for Linux (amd64, arm64)
  * Build for macOS (amd64, arm64)
  * Generate checksums
  * Create GitHub release with binaries

Deployment tools:
- install.sh: One-line installer
  * Auto-detect OS and arch
  * Download from releases
  * Install to /usr/local/bin

- tnt.service: systemd unit file
  * Auto-restart on failure
  * Security hardening
  * Runs as dedicated user

- DEPLOYMENT.md: Complete deployment guide
  * Quick install
  * systemd setup
  * Firewall config
  * Docker alternative

Usage:
  curl -sSL https://raw.githubusercontent.com/m1ngsama/TNT/main/install.sh | sh

Create release:
  git tag v1.0.0
  git push origin v1.0.0
2025-12-02 12:47:15 +08:00
.github/workflows Add CI/CD and deployment automation 2025-12-02 12:47:15 +08:00
include Fix critical memory and concurrency bugs 2025-11-30 09:00:00 +08:00
src Merge pull request #4 from m1ngsama/optimize/message-loading 2025-12-02 12:39:34 +08:00
.gitignore Add development and testing infrastructure 2025-12-02 10:00:00 +08:00
CHANGELOG.md Add developer documentation 2025-12-02 15:00:00 +08:00
CICD.md Add CI/CD and deployment automation 2025-12-02 12:47:15 +08:00
DEPLOYMENT.md Add CI/CD and deployment automation 2025-12-02 12:47:15 +08:00
HACKING Add developer documentation 2025-12-02 15:00:00 +08:00
install.sh Add CI/CD and deployment automation 2025-12-02 12:47:15 +08:00
LICENSE Initial commit 2025-07-01 09:00:00 +08:00
Makefile Add development and testing infrastructure 2025-12-02 10:00:00 +08:00
QUICKREF Add developer documentation 2025-12-02 15:00:00 +08:00
README.md Add CI/CD and deployment automation 2025-12-02 12:47:15 +08:00
test_basic.sh Add development and testing infrastructure 2025-12-02 10:00:00 +08:00
test_stress.sh Add development and testing infrastructure 2025-12-02 10:00:00 +08:00
tnt.service Add CI/CD and deployment automation 2025-12-02 12:47:15 +08:00

TNT

TNT's Not Tunnel - A lightweight terminal chat server written in C

License Language

Features

  • Vim-style operations - INSERT/NORMAL/COMMAND modes
  • 📜 Message history - Browse with j/k keys
  • 🕐 Full timestamps - Year-month-day hour:minute with timezone
  • 📖 Bilingual help - Press ? for Chinese/English help
  • 🌏 UTF-8 support - Full support for Chinese, Japanese, Korean
  • 📦 Single binary - Lightweight executable
  • 🔒 SSH access - Secure encrypted connections
  • 🖥️ Auto terminal detection - Adapts to your terminal size
  • 💾 Message persistence - All messages saved to log file
  • Low resource usage - Minimal memory and CPU

Building

Dependencies:

  • libssh (required for SSH support)

Install dependencies:

# On macOS
brew install libssh

# On Ubuntu/Debian
sudo apt-get install libssh-dev

# On Fedora/RHEL
sudo dnf install libssh-devel

Build:

make

For debug build:

make debug

Installation

Quick install (recommended):

curl -sSL https://raw.githubusercontent.com/m1ngsama/TNT/main/install.sh | sh

Or download from releases

See DEPLOYMENT.md for production setup.

Running

./tnt

Connect from another terminal:

ssh -p 2222 localhost

The server will prompt for a password (any password is accepted) and then ask for your username.

Usage

Operating Modes

  • INSERT - Type and send messages (default)
  • NORMAL - Browse message history
  • COMMAND - Execute commands

Keyboard Shortcuts

INSERT Mode

  • ESC - Enter NORMAL mode
  • Enter - Send message
  • Backspace - Delete character
  • Ctrl+C - Exit

NORMAL Mode

  • i - Return to INSERT mode
  • : - Enter COMMAND mode
  • j - Scroll down (older messages)
  • k - Scroll up (newer messages)
  • g - Jump to top
  • G - Jump to bottom
  • ? - Show help
  • Ctrl+C - Exit

COMMAND Mode

  • Enter - Execute command
  • ESC - Cancel, return to NORMAL
  • Backspace - Delete character

Available Commands

  • list, users, who - Show online users
  • help, commands - Show available commands
  • clear, cls - Clear command output

Architecture

  • Network: Multi-threaded SSH server using libssh
  • TUI: ANSI escape sequences with automatic terminal size detection
  • Storage: Append-only log file
  • Concurrency: pthread + rwlock
  • Security: Encrypted SSH connections with host key authentication

Configuration

Set port via environment variable:

PORT=3333 ./tnt

Technical Details

  • Written in C11
  • POSIX-compliant
  • Thread-safe operations
  • Proper UTF-8 handling for CJK characters
  • Box-drawing characters for UI
  • SSH protocol with PTY support for terminal size detection
  • Dynamic window resize handling

Development

make debug        # Build with debug symbols
make asan         # Build with AddressSanitizer
make check        # Run static analysis
./test_basic.sh   # Run basic tests
./test_stress.sh  # Run stress test

See HACKING for development details.

Security

  • Encrypted connections: All traffic is encrypted via SSH
  • Host key authentication: RSA host key generated on first run
  • Password authentication: Currently accepts any password (customize for production)
  • Host key persistence: Stored in host_key file
  • No plaintext: Unlike telnet, all data is encrypted in transit

License

MIT License - see LICENSE file