tchivert 8a2310ed5c
build / build (push) Successful in 1m57s
update registry
2026-10-24 00:20:10 +02:00
2026-10-24 00:20:10 +02:00
2024-12-21 18:15:08 +01:00
2026-10-24 00:20:10 +02:00
2024-12-24 15:14:31 +01:00
2026-10-20 15:11:59 +02:00
2023-06-30 16:04:05 +02:00

tbin

tbin is a simple pastebin application that allows you to store and share text snippets from your terminal.

Prerequisites

Before building and starting tbin, ensure that you have the following software installed on your system:

  • Docker
  • Go 1.27+ (if you want to build the application from source)

Building from source

To build tbin from source, follow these steps:

  1. Clone the tbin repository: git clone https://git.rznet.fr/tchivert/tbin
  2. Change into the project directory: cd tbin
  3. Build the application using Go: go build -o tbin
  4. The tbin binary will be generated in the project directory.

Starting tbin with Docker

tbin can also be started using Docker. To do this, follow these steps:

  1. Make sure you have Docker installed and running on your machine.
  2. Clone the tbin repository: git clone https://git.rznet.fr/tchivert/tbin
  3. Change into the project directory: cd tbin
  4. Start the application using Docker Compose: docker-compose up -d
  5. tbin will be started as a Docker container and will be accessible via telnet and HTTP.

The Docker container runs as a non-root user (UID 1000) and uses a named volume (tbin-data) for data persistence.

Usage

To submit a text snippet using the telnet interface, follow these steps:

  1. Open a terminal session.
  2. Use the nc command to connect to the tbin server: echo "Your text snippet" | nc localhost 4242
  3. The server will generate a unique URL for your text snippet, which will be displayed in the terminal.

Purges can be trigged with the /purge endpoint (localhost only). It will remove all snippets olders than the configuered TTL (default: 48 hours).

Configuration

tbin can be configured using command-line flags when starting the application.

  • --host: Host address to listen on (default: 0.0.0.0).
  • --port: Port number to listen on for telnet connections (default: 4242).
  • --http-port: Port number to listen on for HTTP connections (default: 8080).
  • --http-url: Base URL to send back to the client (default: http://localhost:8080/).
  • --dir: Directory to store snippets (default: ./data).
  • --ttl: Time-to-live in hours for the snippets (default: 48).
  • --buff: Buffer size in MB for handling incoming data (default: 8).
  • --chunk: Chunk size in bytes for reading data (default: 8192).
  • --conn-time: Connection timeout in seconds (default: 10).
  • --read-time: Read timeout in seconds (default: 2).
  • --verbose: Enable verbose (debug-level) logging (default: false).
  • --plaintext: Only allow plaintext snippets (default: false).
  • --max-conns: Maximum concurrent TCP connections (default: 100).
  • --rate-limit: Max requests per second per IP, 0 to disable (default: 10).
  • --metrics-addr: Prometheus metrics listen address, empty to disable (default: "").

Monitoring

tbin exposes Prometheus metrics when --metrics-addr is set. The metrics server runs on a separate port and is not exposed on the main HTTP port. Available metrics:

  • tbin_pastes_total: Total pastes created
  • tbin_pastes_bytes_total: Total bytes of pastes created
  • tbin_http_requests_total: HTTP requests by method, endpoint, and status
  • tbin_tcp_connections_total: Total TCP connections accepted
  • tbin_tcp_active_connections: Current active TCP connections
  • tbin_purge_runs_total: Total purge operations executed
  • tbin_purge_files_total: Files processed during purge by result
  • tbin_removes_total: Total manual remove requests

A /health endpoint is also available on the HTTP port for health checks.

Security

  • HTTP server has read/write/idle timeouts to prevent slowloris attacks
  • Request body size is limited via http.MaxBytesReader
  • TCP connections are rate-limited per-IP and capped with --max-conns
  • HTTP requests are rate-limited per-IP
  • Paste files are created with 0600 permissions and O_EXCL to prevent races
  • The /purge endpoint is restricted to localhost
  • Security headers (CSP, X-Frame-Options, etc.) are set on all responses
  • Graceful shutdown on SIGTERM/SIGINT with WaitGroup tracking of in-flight requests
  • Docker container runs as non-root user (UID 1000)
  • Docker base images are pinned (golang:1.27-alpine, alpine:3.24)

License

tbin is licensed under the MIT License. See the LICENSE file for more information.

S
Description
A simple pastebin you can use from your terminal
https://tbin.fr/
Readme MIT
86 KiB
1 Watchers 0 Forks
Languages
Go 78.3%
HTML 19.8%
Dockerfile 1.9%