How mysteriumnetwork/node works
Purpose and Executables
Mysterium Node is a cross-platform Go implementation of a decentralized VPN node: provider and consumer roles, a local HTTP “Tequila” API, and CLI control. The principal binary starts from cmd/mysterium_node/mysterium_node.go, with composition/bootstrap in cmd/bootstrap.go and cmd/node.go. Supporting executables include the secure package updater (cmd/myst_updater/main.go), NAT discovery (cmd/natdisco/main.go), port checking, and a privileged supervisor.
Process Composition and Local Control Plane
Dependency injection wires configuration, identity, storage, networking, service implementations, API, and lifecycle management at startup. CLI commands expose account, connection, service, daemon, configuration, and reset operations through cmd/commands/. Tequila is the node’s local HTTP boundary: routes/handlers translate client requests into core operations, enforce auth middleware, and expose SSE/events and API contracts. Key paths: tequilapi/http_api_server.go, tequilapi/endpoints/, tequilapi/contract/.
Node Lifecycle, State, and Persistence
Core orchestration manages node options, service registration, connections, sessions, state events, and cleanup. BoltDB persists registration, identities-related state, session/settlement histories, and migration state; it is an important restart and upgrade boundary. Event bus and typed event packages decouple state changes from API/status consumers. Key paths: core/node/, core/service/manager.go, core/connection/manager.go, core/storage/boltdb/storage.go.
Marketplace Discovery and Identity
Consumers discover purchasable provider proposals through interchangeable API, broker, and DHT repositories, then filter/sort/reduce proposals before connecting. Node identity is filesystem-keystore-backed, signs/verifies protocol data, and supports blockchain registry/transactor integration. Market types define contacts, locations, pricing, quality, and proposals. Key paths: core/discovery/, identity/manager.go, identity/registry/, market/service_proposal.go.
VPN Transport and Network Boundaries
The service layer abstracts transport types and registers WireGuard, QUIC, OpenVPN, data transfer, monitoring, and no-op implementations. WireGuard is the supported underlying VPN transport and has endpoint variants for kernel/userspace, netstack, proxy, remote, and platform-specific TUN/network behavior. Connection setup crosses OS networking/DNS/routing/firewall boundaries; provider-facing NAT traversal, UPnP mapping, hole punching, and reachability support inbound connectivity. Key paths: services/wireguard/, p2p/, nat/, firewall/.
Sessions, Payments, and Remote Messaging
Session creation connects consumer and provider service endpoints, tracks bandwidth/time/connectivity, and publishes lifecycle events. Ping-pong settlement calculates usage pricing, exchanges invoices/promises, tracks balances, and persists settlement history; Hermes is the payment-channel-facing integration. NATS-backed communication provides signed messaging/request-response for broker discovery and related remote control flows. Key paths: session/pingpong/, consumer/session/, communication/nats/, pilvytis/.
Deployment, Platforms, and Operations
Runtime targets desktop/server Linux, Windows, macOS, Android/iOS mobile bindings, and Docker. Linux packaging installs systemd node and updater services; the updater validates authenticated Debian artifacts and verifies post-update health. A separate supervisor handles privileged platform/WireGuard operations. External integrations include Ethereum/geth-compatible chain operations, NATS, discovery APIs/DHT, Hermes/Pilvytis payment services, Elasticsearch/Morqa quality reporting, GitHub version release lookup, and optional Docker. Key paths: supervisor/daemon/, updater/deb/updater.go, bin/package/installation/, mobile/mysterium/.
Main entry points: http_api_server.go Tequila API server · bootstrap.go Bootstrap composition · manager.go Connection manager · mysterium_node.go Mysterium Node
Components 21
Entrypoints
- Mysterium Node · Principal provider and consumer node process.
cmd/mysterium_node/mysterium_node.go - Bootstrap composition · Wires runtime dependencies and lifecycle.
cmd/bootstrap.go - CLI commands
Local Control Plane
- Tequila API server · Authenticated local API with SSE events.
tequilapi/http_api_server.go - API endpoints
- API contracts
Node Core
- Node orchestration · Coordinates options, services, connections, sessions, and cleanup.
- Service manager
core/service/manager.go - Connection manager
core/connection/manager.go - BoltDB storage · Restart, history, and migration persistence boundary.
core/storage/boltdb/storage.go - Identity manager · Filesystem-backed signing identity.
identity/manager.go
Network & Marketplace
- Proposal discovery · Combines API, broker, and DHT proposal sources.
- Market proposals
market/service_proposal.go - WireGuard service · Supports kernel, userspace, netstack, proxy, remote, and platform endpoints.
- P2P and NAT traversal · Hole punching, UPnP, and reachability support.
- Consumer sessions · Connects consumer and provider endpoints and tracks usage.
- Ping-pong settlement · Exchanges invoices and promises and records balances.
- NATS communication · Broker request-response and remote control transport.
Platform Operations
- Privileged supervisor · Performs privileged platform and WireGuard operations.
- Secure package updater · Validates Debian artifacts and post-update health.
updater/deb/updater.go - Mobile bindings
Connections 23
- Mysterium Node → Bootstrap composition: starts
- Bootstrap composition → Node orchestration: composes
- Bootstrap composition → Tequila API server: starts
- CLI commands → Tequila API server: controls
- Tequila API server → API endpoints: routes to
- API endpoints → API contracts: uses
- API endpoints → Node orchestration: invokes
- Node orchestration → Service manager: registers services
- Node orchestration → Connection manager: manages
- Node orchestration → BoltDB storage: persists state
- Node orchestration → Identity manager: uses
- Connection manager → Proposal discovery: selects proposals
- Proposal discovery → Market proposals: filters and ranks
- Proposal discovery → NATS communication: uses broker discovery
- Service manager → WireGuard service: registers
- Connection manager → Consumer sessions: creates
- Consumer sessions → WireGuard service: connects through
- Consumer sessions → Ping-pong settlement: reports usage
- Ping-pong settlement → BoltDB storage: stores history
- WireGuard service → P2P and NAT traversal: requires reachability
- WireGuard service → Privileged supervisor: delegates privileged operations
- Secure package updater → Mysterium Node: updates
- Mobile bindings → Tequila API server: controls node via