TNT's Not Tunnel
Find a file
m1ngsama 25a277ab27
Some checks are pending
CI / build-and-test (macos-latest) (push) Waiting to run
CI / build-and-test (ubuntu-latest) (push) Waiting to run
Deploy / test (push) Waiting to run
Deploy / deploy (push) Blocked by required conditions
feat: add SSH keepalive and CI/CD auto-deploy
Send keepalive every 30s to prevent NAT/firewall from silently
dropping idle SSH connections. Add deploy workflow that auto-deploys
to production server after CI passes on main.
2026-02-08 11:54:27 +08:00
.github/workflows feat: add SSH keepalive and CI/CD auto-deploy 2026-02-08 11:54:27 +08:00
docs docs: add GitHub Wiki setup instructions 2026-02-07 23:32:58 +08:00
include refactor: optimize rendering, log loading, and migrate to libssh callback API (#9) 2026-02-07 23:17:55 +08:00
scripts feat: enhance anonymous access and long-term stability 2026-01-22 15:06:54 +08:00
src feat: add SSH keepalive and CI/CD auto-deploy 2026-02-08 11:54:27 +08:00
tests test: add comprehensive unit tests for UTF-8 and message functions 2026-02-08 10:29:19 +08:00
.gitignore Add development and testing infrastructure 2025-12-02 10: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 refactor: optimize rendering, log loading, and migrate to libssh callback API (#9) 2026-02-07 23:17:55 +08:00
README.md docs: reorganize documentation structure 2026-02-07 23:31:53 +08:00
tnt.service feat: enhance anonymous access and long-term stability 2026-01-22 15:06:54 +08:00
TODO.md refactor: optimize rendering, log loading, and migrate to libssh callback API (#9) 2026-02-07 23:17:55 +08:00

TNT - Terminal Network Talk

A minimalist terminal chat server with Vim-style interface over SSH.

Features

  • Zero config - Download and run, auto-generates SSH keys
  • SSH-based - Leverage mature SSH protocol for encryption and auth
  • Vim-style UI - Modal editing (INSERT/NORMAL/COMMAND)
  • UTF-8 native - Full Unicode support
  • High performance - Pure C, multi-threaded, sub-100ms startup
  • Secure - Rate limiting, auth failure protection, input validation
  • Persistent - Auto-saves chat history
  • Elegant - Flicker-free TUI rendering

Quick Start

Installation

One-liner:

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

From source:

git clone https://github.com/m1ngsama/TNT.git
cd TNT
make
sudo make install

Binary releases: https://github.com/m1ngsama/TNT/releases

Running

tnt              # default port 2222
tnt -p 3333      # custom port
PORT=3333 tnt    # via env var

Connecting

ssh -p 2222 localhost

Anonymous access by default: Users can connect with ANY username/password (or empty password). No SSH keys required. Perfect for public chat servers.

Usage

Keybindings

INSERT mode (default)

ESC        - Enter NORMAL mode
Enter      - Send message
Backspace  - Delete character
Ctrl+W     - Delete last word
Ctrl+U     - Delete line
Ctrl+C     - Enter NORMAL mode

NORMAL mode

i          - Return to INSERT mode
:          - Enter COMMAND mode
j/k        - Scroll down/up
g/G        - Scroll to top/bottom
?          - Show help

COMMAND mode

:list, :users, :who  - Show online users
:help, :commands     - Show available commands
:clear, :cls         - Clear command output
ESC                  - Return to NORMAL mode

Security Configuration

Access control:

# Require password
TNT_ACCESS_TOKEN="secret" tnt

# Bind to localhost only
TNT_BIND_ADDR=127.0.0.1 tnt

# Bind to specific IP
TNT_BIND_ADDR=192.168.1.100 tnt

Rate limiting:

# Max total connections (default 64)
TNT_MAX_CONNECTIONS=100 tnt

# Max connections per IP (default 5)
TNT_MAX_CONN_PER_IP=10 tnt

# Disable rate limiting (testing only)
TNT_RATE_LIMIT=0 tnt

SSH logging:

# 0=none, 1=warning, 2=protocol, 3=packet, 4=functions (default 1)
TNT_SSH_LOG_LEVEL=3 tnt

Production example:

TNT_ACCESS_TOKEN="strong-password-123" \
TNT_BIND_ADDR=0.0.0.0 \
TNT_MAX_CONNECTIONS=200 \
TNT_MAX_CONN_PER_IP=3 \
TNT_SSH_LOG_LEVEL=1 \
tnt -p 2222

Development

Building

make              # standard build
make debug        # debug build (with symbols)
make asan         # AddressSanitizer build
make check        # static analysis (cppcheck)
make clean        # clean build artifacts

Testing

make test         # run comprehensive test suite

# Individual tests
cd tests
./test_basic.sh              # basic functionality
./test_security_features.sh  # security features
./test_anonymous_access.sh   # anonymous access
./test_stress.sh             # stress test

Test coverage:

  • Basic functionality: 3 tests
  • Anonymous access: 2 tests
  • Security features: 11 tests
  • Stress test: concurrent connections

Dependencies

  • libssh (>= 0.9.0) - SSH protocol library
  • pthread - POSIX threads
  • gcc/clang - C11 compiler

Ubuntu/Debian:

sudo apt-get install libssh-dev

macOS:

brew install libssh

Fedora/RHEL:

sudo dnf install libssh-devel

Project Structure

TNT/
├── src/              # source code
│   ├── main.c        # entry point
│   ├── ssh_server.c  # SSH server implementation
│   ├── chat_room.c   # chat room logic
│   ├── message.c     # message persistence
│   ├── tui.c         # terminal UI rendering
│   └── utf8.c        # UTF-8 character handling
├── include/          # header files
├── tests/            # test scripts
├── docs/             # documentation
├── scripts/          # operational scripts
├── Makefile          # build configuration
└── README.md         # this file

Deployment

systemd Service

sudo cp tnt.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable tnt
sudo systemctl start tnt

Docker

FROM alpine:latest
RUN apk add --no-cache libssh
COPY tnt /usr/local/bin/
EXPOSE 2222
CMD ["tnt"]

See docs/DEPLOYMENT.md for details.

Files

messages.log    - Chat history (RFC3339 format)
host_key        - SSH host key (auto-generated, 4096-bit RSA)
tnt.service     - systemd service unit

Documentation

Performance

  • Startup: < 100ms (even with 100k+ message history)
  • Memory: ~2MB (idle)
  • Concurrency: Supports 100+ concurrent connections
  • Throughput: 1000+ messages/second

Known Limitations

  • Single chat room (no multi-room support yet)
  • Keeps only last 100 messages in memory
  • Ctrl+W only recognizes ASCII space as word boundary

Contributing

Contributions welcome! See CONTRIBUTING.md

Process:

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/AmazingFeature)
  3. Commit changes (git commit -m 'Add some AmazingFeature')
  4. Push to branch (git push origin feature/AmazingFeature)
  5. Open Pull Request

License

MIT License - see LICENSE

Acknowledgments

  • libssh - SSH protocol implementation
  • Linux kernel community - Code style and engineering practices

Contact


"Talk is cheap. Show me the code." - Linus Torvalds