product-os-command-control 0.0.29

Product OS : Command and Control provides a set of tools for running command and control across a distributed set of Product OS : Servers.
Documentation

Product OS : Command Control

Crates.io Documentation Rust 1.80+ License: GPL-3.0

Product OS : Command and Control provides a set of tools for running command and control across a distributed set of Product OS : Servers.

What is Product OS?

Product OS is a collection of packages that provide different tools and features that can work together to build products more easily for the Rust ecosystem.

Feature Flags

Feature Default Description
std_base Yes Standard library support. Pulls in core Product OS dependencies with their defaults.
framework_axum Yes Use Axum as the HTTP framework (forwarded to router and capabilities).
framework_flow No Use Flow as the HTTP framework (forwarded to router and capabilities).
monitor Yes (via std_base) Enable the monitoring service via product-os-monitoring.
tokio No Enable the Tokio async executor via product-os-async-executor.
distributed No Enable distributed node discovery and communication (placeholder).
relational_store No Base relational store support from product-os-store.
postgres_store No PostgreSQL relational store (enables relational_store).
sqlite_store No SQLite relational store (enables relational_store).
redis_key_value_store No Redis key-value store.
memory_key_value_store No In-memory key-value store.
file_key_value_store No File-based key-value store.
redis_queue_store No Redis queue store.
memory_queue_store No In-memory queue store.

The default feature set is ["std_base", "framework_axum"].

Installation

[dependencies]
product-os-command-control = "0.0.1"

Pin the version to match the crate Cargo.toml when using path or git dependencies.

Documentation

Full API documentation is available at docs.rs/product-os-command-control.

Usage

Overview

Product OS : Command and Control provides a distributed command and control system for coordinating multiple Product OS server instances. It enables secure communication, service discovery, and workload distribution across a cluster of nodes.

Features

  • Secure Communication: Authentication framework using Diffie-Hellman key exchange
  • Service Discovery: Automatic node registration and discovery
  • Load Balancing: Smart routing to available nodes based on capabilities
  • Health Monitoring: Pulse checks and automatic failure detection
  • Feature Management: Dynamic feature and service registration
  • No-std Compatible Structure: Uses no_std_compat for structural no_std compatibility, though the crate currently requires an allocator and OS-level features (e.g., machine-uid, networking)

Installation

Add Product OS : Command and Control to your Cargo.toml:

[dependencies]
product-os-command-control = { version = "0.0.29" }

Quick Start

use product_os_command_control::ProductOSController;
use product_os_command_control::CommandControl;
use product_os_security::certificates::Certificates;

async fn example() {
    // Create configuration and certificates
    let config = CommandControl::default();
    let certs = Certificates::new_self_signed(
        vec![("CN".to_string(), "localhost".to_string())],
        None, None, None, None, None,
    );

    // Initialize the controller
    let controller = ProductOSController::new(
        config,
        certs,
        None, // Optional key-value store
    );

    // Access the registry
    let registry = controller.get_registry();
    let my_node = registry.get_me();
    println!("Node ID: {}", my_node.get_identifier());
}

Architecture

The command and control system consists of several key components:

  • ProductOSController: Main coordinator that manages nodes and services
  • Registry: Tracks available nodes and their capabilities
  • Node: Represents a single server instance in the cluster
  • Commands: Structured way to send instructions to remote nodes

Security

All node-to-node communication is secured using:

  • TLS/SSL certificates for transport security
  • Diffie-Hellman key exchange for establishing shared secrets
  • Message authentication using HMAC

Service Management

use product_os_command_control::ProductOSController;
use std::sync::Arc;

async fn manage_services(controller: &mut ProductOSController) {
    // Add a service
    let service = /* ... */;
    controller.add_service(service).await;
    
    // Start all services
    controller.start_services().await;
    
    // Start a specific service
    controller.start_service("my-service").await;
    
    // Stop a service
    controller.stop_service("my-service").await;
}

Node Discovery

use product_os_command_control::ProductOSController;

async fn discover(controller: &mut ProductOSController) {
    // Discover other nodes in the cluster
    controller.discover_nodes().await;
    
    // Get the registry with all known nodes
    let registry = controller.get_registry();
}

Testing

# Run all tests
cargo test --all-features

# Run with specific features
cargo test --features "monitor,tokio"

# Generate documentation
cargo doc --all-features --open

Contributing

Contributions are not currently available but will be available on a public repository soon.

License

This project is licensed under the GNU GPLv3.