Vemari

Documentation

Complete reference for the Vemari CLI binary and all its features.

Overview

Vemari is a lightweight TCP tunneling system that enables secure access to remote services through a central proxy server. It operates in three modes and supports both command-line flags and configuration file management:

Producer Mode

Expose a local service (database, web server, etc.) to be accessible through the proxy via STCP.

Consumer Mode

Access a remote service through a local port, as if it were running on your machine.

Expose Mode

Expose a local HTTP service publicly with a custom subdomain at vemari.one. Automatically secured with HTTPS.

Quick Start

Vemari can be used in two ways: with command-line flags for quick one-off connections, or with a configuration file for managing multiple services. By default, Vemari connects to a proxy server. You can override this with the -proxy flag or in your configuration file.

Configuration File Mode

For managing multiple services, create a vemari.toml file next to the binary and use commands like vemari list, vemari run, etc. See the Configuration section for details.

Producer (Server with Database)
$ vemari -produce mydb -target localhost:5432
Consumer (Your Local Machine)
$ vemari -consume mydb -local 15432

Now connect to localhost:15432 and traffic will be tunneled to the remote database.

Configuration File

Vemari supports configuration via a TOML file named vemari.toml placed next to the binary. When a configuration file exists, you can use service management commands instead of command-line flags.

Quick Start

Run vemari init to create a configuration file, install vemari as a system service, and start it automatically. Use vemari init --force to stop, uninstall, overwrite config, and reinstall everything from scratch.

Edit Configuration

Run vemari config to open the configuration file in your default editor. If the file doesn't exist, it will be created automatically. Use vemari config --force to overwrite an existing configuration with defaults. Permission elevation is automatically requested if needed.

Configuration File Location

Place vemari.toml in the same directory as the vemari binary. The configuration file is automatically detected when running commands.

Configuration Format

# Global proxy server address
proxy = "proxy.example.com:PORT"

# Self-healing configuration (enabled by default)
# [heal]
# enabled = false
# interval = 30
# failure_threshold = 3

# Services configuration
# Each service has a UUID (auto-generated), name, and required secret (auto-generated)

[[services]]
id = "550e8400-e29b-41d4-a716-446655440000"
name = "mydb"
type = "produce"
target = "localhost:5432"
secret = "auto-generated-strong-secret"
enabled = true

[[services]]
id = "550e8400-e29b-41d4-a716-446655440001"
name = "remotedb"
type = "consume"
local = 5433
secret = "same-secret-as-producer"
enabled = true

Service Configuration Fields

FieldDescriptionRequired
idUUID for unique service identification (auto-generated if missing)Auto-generated
nameHuman-readable service nameYes
typeService type: "produce", "consume", or "expose"Yes
targetLocal address (for produce/expose services)For produce/expose (or use folder)
folderFolder path to share (for produce/expose services)For produce/expose (alternative to target)
localLocal port number (for consume services)For consume
secretRequired secret key for service access (auto-generated if missing)Auto-generated
enabledWhether the service should start automaticallyNo (default: false)

UUID-Based Identification

Services are identified by UUID to prevent naming conflicts. You can reference services by either UUID or name in commands. UUIDs and secrets are automatically generated when creating services.

Backward Compatibility

Command-line flags (-produce, -consume, -expose) continue to work as before. Configuration files are only used when not running with these flags.

Service Management Commands

When using a configuration file, Vemari provides commands to manage your services:

Quick Start (Initialize Everything)

$ vemari init
$ vemari init --force

Create config file, install vemari as a system service, and start it. If the service is already running, it will tell you. Use --force to stop, uninstall, overwrite config, and reinstall from scratch.

Edit Configuration

$ vemari config
$ vemari config --force

Open configuration file for editing in your default editor. If the file doesn't exist, it will be created automatically. Use --force to overwrite with defaults. Permission elevation is automatically requested if needed.

Add Services

$ vemari add
$ vemari add <token>

Interactive service creation wizard, or add service from encrypted pairing token.

Generate Pairing Token

$ vemari token mydb
$ vemari token <uuid>

Generate encrypted pairing token for an existing service (by name or UUID).

List Services

$ vemari list

Display all configured services with UUIDs, names, and status.

Run Services

$ vemari run
$ vemari run mydb
$ vemari run <uuid>

Run all enabled services, or a specific service by name or UUID.

System Service Management

$ vemari install
$ vemari uninstall
$ vemari reinstall
$ vemari start
$ vemari stop
$ vemari restart
$ vemari status

Install vemari as a system service for automatic startup on boot. Self-healing is enabled by default in service mode. Use reinstall to update the service after upgrading vemari.

Automatic Resume on Linux

On Linux, vemari install also creates a resume service that automatically restarts vemari when the system wakes from suspend/hibernate. This ensures your tunnels reconnect after laptop lid open or sleep.

Monitoring & Self-Healing

$ vemari ping
$ vemari heal
$ vemari heal --once

Monitor service health and run self-healing watchdog. See the Self-Healing section for details.

Self-Healing

Vemari includes a built-in self-healing watchdog that monitors the proxy server connection and automatically restarts the service when connectivity issues are detected and resolved. This ensures your tunnels stay connected even after network interruptions.

Enabled by Default

Self-healing is automatically enabled when running as a system service. You can customize or disable it via configuration.

How It Works

1

Periodically checks if the vemari proxy server is reachable

2

Tracks consecutive connection failures

3

When server becomes unreachable for the configured threshold, marks as unhealthy

4

When server becomes reachable again, automatically restarts the vemari service to re-establish all tunnel connections

Configuration

Add a [heal] section to your vemari.toml to customize self-healing behavior:

# Self-healing configuration (enabled by default)
# Monitors server connection and auto-restarts when needed
[heal]
enabled = false # Set to false to disable auto-healing
interval = 30 # Check interval in seconds (default: 30)
failure_threshold = 3 # Consecutive failures before triggering recovery (default: 3)

Manual Monitoring

You can also run the watchdog manually for monitoring and testing:

Continuous monitoring (runs until Ctrl+C):

vemari heal

Custom check interval (every 60 seconds):

vemari heal --interval=60

Custom failure threshold (5 failures before unhealthy):

vemari heal --threshold=5

Single health check (useful for cron/scripts):

vemari heal --once # exit code: 0=healthy, 1=unhealthy

Use Cases

Automatic Recovery

Automatically recover from network interruptions without manual intervention

Production Reliability

Ensure tunnels stay connected in production environments

Monitoring Integration

Use `--once` mode for integration with monitoring systems

Server Availability

Monitor proxy server availability and connection health

Produce Command

The -produce flag exposes a local service to be accessible through the proxy server.

Syntax

vemari [-proxy <server:port>] -produce <service-name> -target <local-address> [-secret <key>]

Parameters

FlagDescriptionRequiredExample
-proxyProxy server addressNoproxy.example.com:PORT
-produceUnique name for the serviceYesmydb, webapp
-targetLocal address to expose (or use -folder)Yes*localhost:5432
-folderFolder path to share (alternative to -target)No/home/user/documents
-secretSecret key for service access (auto-generated in config mode)No*my-secret-key

UUID-Based Identification

Services are identified by UUID to prevent naming conflicts. Service names are for display purposes only.

STCP Protocol

Services are exposed using STCP (Secure TCP), which requires consumers to know the service UUID/name and secret key. No public ports are exposed.

Consume Command

The -consume flag creates a local listener that tunnels connections to a remote service.

Syntax

vemari [-proxy <server:port>] -consume <service-name> -local <port> [-secret <key>]

Parameters

FlagDescriptionRequiredExample
-proxyProxy server addressNoproxy.example.com:PORT
-consumeName of service to connect toYesmydb
-localLocal port to listen on (1-65535)Yes*15432
-folderPath for folder service (creates WebDAV server)No/mnt/remote-files
-secretSecret key matching producer's secret (required, auto-generated in config mode)No*my-secret-key

Local Port Binding

The service will be accessible on your local machine at the specified port. Make sure the port is not already in use by another service.

Expose Command

The -expose flag exposes a local HTTP service publicly with a custom subdomain at vemari.one. All services are automatically secured with HTTPS.

Syntax

vemari [-proxy <server:port>] -expose [subdomain] -target <local-address>

Parameters

FlagDescriptionRequiredExample
-proxyProxy server addressNoproxy.example.com:PORT
-exposeSubdomain name (optional, random name generated if not provided)Nomyapp, api, or omit for random name
-targetLocal HTTP service address (or use -folder)Yes*localhost:8080
-folderFolder path to expose with file browserNo/home/user/public

Automatic HTTPS

All exposed services are automatically secured with TLS using Let's Encrypt wildcard certificates. Your service will be accessible at https://{subdomain}.vemari.one with valid SSL certificates.

Public Access

Your service will be accessible at https://{subdomain}.vemari.one. The subdomain must be unique across all exposed services.

Interactive Service Creation

Vemari includes an interactive service creation wizard that guides you through setting up any service type. Secrets are automatically generated, and for produce/expose services, you'll receive an encrypted pairing token.

Starting the Wizard

vemari add

What the Wizard Does

1

Prompts for service type (produce, consume, or expose)

2

Asks for service name and type-specific configuration

3

Auto-generates a cryptographically secure secret key

4

For produce/expose services, outputs an encrypted pairing token

Auto-Generated Secrets

All services automatically get a strong, unique secret key. No need to manually create or share secrets when using the interactive wizard.

Token-Based Service Pairing

Vemari supports encrypted pairing tokens for easy service setup across different machines. Tokens contain all necessary configuration (UUID, name, secret, proxy address) encrypted with AES-GCM.

Generating a Token

Generate a pairing token for any existing service (by name or UUID):

vemari token mydb
vemari token 550e8400-e29b-41d4-a716-446655440000

The token contains the opposite service type. For example, a produce service generates a consume token.

Using a Token

On another machine, add the service from the token:

vemari add <encrypted-token>

This automatically creates the matching service with all correct settings, including the secret key.

Token Security

Tokens are encrypted with AES-GCM using a shared encryption key

Only clients with the shared key can decrypt tokens

Tokens include secrets, eliminating manual secret sharing

Token Workflow

1. Create a produce service with vemari add
2. Copy the generated token
3. On another machine, run vemari add <token>
4. The matching consume service is automatically created

Secret Keys

All services require a secret key for security. Secrets are automatically generated when creating services interactively or via configuration file. Secrets are cryptographically secure 32-byte random values.

Auto-Generation

1

When creating services with vemari add, secrets are auto-generated

2

When saving configuration files, missing secrets are auto-generated

3

Secrets are included in pairing tokens for easy sharing

Manual Secret Specification

For command-line flag mode, you can manually specify secrets:

Producer side:

vemari -produce mydb -target localhost:5432 -secret my-secret-key

Consumer side (must match):

vemari -consume mydb -local 5432 -secret my-secret-key

Secret Matching

The secret key must match exactly between producer and consumer. When using token-based pairing, secrets are automatically shared securely through encrypted tokens.

Encryption

All communication between clients and the proxy server is encrypted end-to-end using AES-256-GCM.

Confidentiality

Data is unreadable to eavesdroppers

Integrity

Tampering is detected

Authenticity

Only authorized clients can connect

Environment Variables

Vemari uses environment variables for configuration. The client ID defaults to "client".

Available Variables

VariableDescriptionDefault
VEMARI_AUTH_TOKENAuthentication token for proxy serverDefault encryption key

Example:

export VEMARI_AUTH_TOKEN=my-auth-token
vemari -produce mydb -target localhost:5432

Example: Database Access

Access a remote PostgreSQL database through Vemari:

On the database server:

vemari -produce postgres -target localhost:5432

On your local machine:

vemari -consume postgres -local 5433

Connect using psql:

psql -h localhost -p 5433 -U myuser -d mydb

Example: Web Services

Access a remote web application or API using STCP:

On the server running the web app:

vemari -produce webapp -target localhost:3000

On your local machine:

vemari -consume webapp -local 8080

Access the app:

curl http://localhost:8080

Or expose your web service publicly (automatically secured with HTTPS):

Expose local HTTP service:

vemari -expose myapp -target localhost:3000

Access publicly:

curl https://myapp.vemari.one

Example: Folder Sharing

Vemari supports sharing folders via STCP (produce/consume) or exposing them publicly via HTTP with a rich file browser interface.

Share Folder via STCP

Share a folder securely with remote clients using STCP:

On the server with the folder:

vemari -produce myfiles -folder /home/user/documents -secret my-secret-key

On remote machine, access folder via WebDAV:

vemari -consume myfiles -folder . -secret my-secret-key

Expose Folder Publicly with File Browser

Expose a folder publicly with a beautiful web-based file browser:

Expose folder with custom subdomain:

vemari -expose myfiles -folder /home/user/public -secret optional-secret

Access publicly:

curl https://myfiles.vemari.one

© 2025 DA Solutions. All Rights Reserved.