Rewrite README in classic Unix style

- README: BSD man page format (NAME/SYNOPSIS/OPTIONS/etc)
- README.md: Minimal markdown (82 lines vs 200+)

Philosophy: Dense information, no fluff, reference style.
Inspired by original Unix manuals and BSD docs.

Changes:
- Removed emojis and badges
- Condensed verbose sections
- Clear command examples
- Direct references to detailed docs
This commit is contained in:
m1ngsama 2025-12-02 12:57:18 +08:00
parent 27854e8e1d
commit abe477f713
2 changed files with 154 additions and 131 deletions

98
README Normal file
View file

@ -0,0 +1,98 @@
TNT(1) User Commands TNT(1)
NAME
tnt - terminal chat server with vim-style interface
SYNOPSIS
tnt [-p port] [-h]
DESCRIPTION
TNT (TNT's Not Tunnel) is a lightweight SSH chat server.
Supports vim-style navigation and message history browsing.
INSTALLATION
curl -sSL https://raw.githubusercontent.com/m1ngsama/TNT/main/install.sh | sh
Or download binary from:
https://github.com/m1ngsama/TNT/releases
USAGE
Start server:
tnt # Listen on port 2222
tnt -p 3333 # Listen on port 3333
PORT=3333 tnt # Same as above
Connect as client:
ssh -p 2222 localhost
OPTIONS
-p port Listen on specified port (default: 2222)
-h Display help message
MODES
INSERT Type and send messages (default mode)
ESC Switch to NORMAL mode
Enter Send message
Backspace Delete character
NORMAL Browse message history
i Return to INSERT mode
: Enter COMMAND mode
j/k Scroll down/up
g/G Jump to top/bottom
? Show help
COMMAND Execute commands
:list List online users
:help Show available commands
ESC Return to NORMAL mode
ENVIRONMENT
PORT Server port (default: 2222)
FILES
messages.log Message history (append-only)
host_key SSH host key (auto-generated)
EXAMPLES
Start server on port 3000:
PORT=3000 tnt
Connect and set username:
ssh -p 2222 localhost
# Enter username when prompted
Production deployment with systemd:
sudo cp tnt.service /etc/systemd/system/
sudo systemctl enable --now tnt
DIAGNOSTICS
Build with debug symbols:
make debug
Check for memory leaks:
make asan
ASAN_OPTIONS=detect_leaks=1 ./tnt
Run tests:
./test_basic.sh
./test_stress.sh 50 120
BUGS
Report bugs at: https://github.com/m1ngsama/TNT/issues
SEE ALSO
ssh(1), sshd(8)
Project documentation:
HACKING Developer guide
DEPLOYMENT.md Production setup
CICD.md CI/CD workflow
AUTHOR
Written by m1ng.
LICENSE
MIT License. See LICENSE file for details.
TNT 1.0 December 2025 TNT(1)

187
README.md
View file

@ -1,157 +1,82 @@
# TNT # TNT
**TNT's Not Tunnel** - A lightweight terminal chat server written in C Terminal chat server. Vim-style interface. SSH-based.
![License](https://img.shields.io/badge/license-MIT-blue.svg) ## Install
![Language](https://img.shields.io/badge/language-C-blue.svg)
## Features ```sh
- ✨ **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:**
```bash
# On macOS
brew install libssh
# On Ubuntu/Debian
sudo apt-get install libssh-dev
# On Fedora/RHEL
sudo dnf install libssh-devel
```
**Build:**
```bash
make
```
For debug build:
```bash
make debug
```
## Installation
**Quick install (recommended):**
```bash
curl -sSL https://raw.githubusercontent.com/m1ngsama/TNT/main/install.sh | sh curl -sSL https://raw.githubusercontent.com/m1ngsama/TNT/main/install.sh | sh
``` ```
**Or download from [releases](https://github.com/m1ngsama/TNT/releases)** Or download from [releases](https://github.com/m1ngsama/TNT/releases).
See [DEPLOYMENT.md](DEPLOYMENT.md) for production setup. ## Run
## Running ```sh
tnt # port 2222
```bash tnt -p 3333 # custom port
./tnt PORT=3333 tnt # env var
``` ```
Connect from another terminal: Connect: `ssh -p 2222 localhost`
```bash
ssh -p 2222 localhost ## Keys
**INSERT** (default)
- `ESC` → NORMAL
- `Enter` → send
- `Backspace` → delete
**NORMAL**
- `i` → INSERT
- `:` → COMMAND
- `j/k` → scroll
- `g/G` → top/bottom
- `?` → help
**COMMAND**
- `:list` → users
- `:help` → commands
- `ESC` → back
## Build
```sh
make # normal
make debug # with symbols
make asan # sanitizer
make check # static analysis
``` ```
The server will prompt for a password (any password is accepted) and then ask for your username. Requires: `libssh`
## Usage ## Deploy
### Operating Modes See [DEPLOYMENT.md](DEPLOYMENT.md) for systemd setup.
- **INSERT** - Type and send messages (default) ## Files
- **NORMAL** - Browse message history
- **COMMAND** - Execute commands
### Keyboard Shortcuts ```
messages.log chat history
#### INSERT Mode host_key SSH key (auto-gen)
- `ESC` - Enter NORMAL mode tnt.service systemd unit
- `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:
```bash
PORT=3333 ./tnt
``` ```
## Technical Details ## Test
- Written in C11 ```sh
- POSIX-compliant ./test_basic.sh # functional
- Thread-safe operations ./test_stress.sh 50 # 50 clients
- 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
```bash
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](HACKING) for development details. ## Docs
## Security - `README` - man page style
- `HACKING` - dev guide
- **Encrypted connections**: All traffic is encrypted via SSH - `DEPLOYMENT.md` - production
- **Host key authentication**: RSA host key generated on first run - `CICD.md` - automation
- **Password authentication**: Currently accepts any password (customize for production) - `QUICKREF` - cheat sheet
- **Host key persistence**: Stored in `host_key` file
- **No plaintext**: Unlike telnet, all data is encrypted in transit
## License ## License
MIT License - see LICENSE file MIT