Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 47 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ It's current features include:

- **gRPC Communication**: High-performance, cross-platform RPC
- **TLS Encryption**: Secure communication between all components
- **Web Interface**: User-friendly HTTP dashboard and REST API
- **Tag-based Targeting**: Flexible minion selection using tags
- **Real-time Command Streaming**: Live command delivery to minions
- **Command Result Tracking**: Complete audit trail of command execution
Expand Down Expand Up @@ -163,11 +164,16 @@ make build
```
┌─────────────┐ gRPC ┌─────────────┐ PostgreSQL ┌──────────────┐
│ Console │◄───────────►│ Nexus │◄─────────────────│ Database │
│ Client │ │ Server │ │ │
└─────────────┘ └─────────────┘ └──────────────┘
│ Client │ (mTLS) │ Server │ │ │
└─────────────┘ :11973 │ │ └──────────────┘
│ Triple- │
┌─────────────┐ HTTP │ Server │
│ Web Browser │◄───────────►│ Architecture│
│ Dashboard │ :8086 │ │
└─────────────┘ └─────────────┘
gRPC │
gRPC │ (TLS)
:11972
┌─────────────┼─────────────┐
│ │ │
▼ ▼ ▼
Expand All @@ -177,13 +183,22 @@ make build
└─────────────┘ └─────────────┘ └─────────────┘
```

### Triple-Server Architecture

The Nexus server runs three concurrent services:

- **Minion Server** (port 11972): TLS gRPC server for minion connections
- **Console Server** (port 11973): mTLS gRPC server for console connections
- **Web Server** (port 8086): HTTP server for web interface and REST API


## Documentation

More documentation is available in the [`documentation/`](documentation/) directory:

- **[adding_commands.md](documentation/adding_commands.md)** - Developer oriented guide to add commands to Minexus
- **[configuration.md](documentation/configuration.md)** - Complete configuration guide for all components
- **[Webserver.md](documentation/Webserver.md)** - Web interface and REST API documentation
- **[version.md](documentation/version.md)** - Version handling, building, and querying guide
- **[commands.md](documentation/commands.md)** - Complete guide to all console and minion commands
- **[testing.md](documentation/testing.md)** - Comprehensive testing guide and best practices
Expand Down Expand Up @@ -264,9 +279,10 @@ docker compose down
### Service Overview

- **nexus_db**: PostgreSQL database with automatic schema initialization
- **nexus**: Nexus server with dual-port architecture:
- **nexus**: Nexus server with triple-server architecture:
- **Port 11972** (`NEXUS_MINION_PORT`) - Minion connections with standard TLS
- **Port 11973** (`NEXUS_CONSOLE_PORT`) - Console connections with mutual TLS (mTLS)
- **Port 8086** (`NEXUS_WEB_PORT`) - Web interface and REST API over HTTP
- **minion**: Single minion client that connects to nexus using `NEXUS_SERVER` + `NEXUS_MINION_PORT`
- **console**: Interactive console client that connects using `NEXUS_SERVER` + `NEXUS_CONSOLE_PORT` (optional, use `--profile console`)

Expand All @@ -289,6 +305,32 @@ docker compose --profile console up
docker compose exec console /app/console
```

### Web Interface Access

The web interface provides a user-friendly dashboard and REST API for monitoring and managing your Minexus infrastructure:

```bash
# Access the web dashboard (when nexus is running)
open http://localhost:8086

# Or use the REST API directly
curl http://localhost:8086/api/status
curl http://localhost:8086/api/minions
curl http://localhost:8086/api/health

# Download pre-built binaries
curl -O http://localhost:8086/download/minion/linux-amd64
curl -O http://localhost:8086/download/console/windows-amd64.exe
```

**Web Interface Features:**
- **Dashboard**: Real-time system status, connected minions, and server health
- **REST API**: Programmatic access to system information
- **Binary Downloads**: Direct access to pre-built minion and console binaries
- **Monitoring**: Standard HTTP endpoints for integration with monitoring tools

For complete web interface documentation, see [documentation/Webserver.md](documentation/Webserver.md).

## Usage Examples

### Docker Compose Management
Expand Down
53 changes: 43 additions & 10 deletions cmd/nexus/nexus.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/arhuman/minexus/internal/logging"
"github.com/arhuman/minexus/internal/nexus"
"github.com/arhuman/minexus/internal/version"
"github.com/arhuman/minexus/internal/web"
pb "github.com/arhuman/minexus/protogen"

"go.uber.org/zap"
Expand Down Expand Up @@ -57,7 +58,7 @@ func main() {
defer logging.FuncExit(logger, start)

// Display version information
logger.Info("Starting Nexus with dual-port architecture", zap.String("version", version.Component("Nexus")))
logger.Info("Starting Nexus with triple-server architecture", zap.String("version", version.Component("Nexus")))

// Log the configuration (with sensitive data masked)
cfg.LogConfig(logger)
Expand Down Expand Up @@ -104,11 +105,11 @@ func main() {
reflection.Register(minionServer)
reflection.Register(consoleServer)

// Start both servers concurrently
// Start all three servers concurrently
var wg sync.WaitGroup
var serverReady sync.WaitGroup
wg.Add(2)
serverReady.Add(2)
wg.Add(3)
serverReady.Add(3)

// Start minion server
go func() {
Expand Down Expand Up @@ -148,22 +149,49 @@ func main() {
}
}()

// Wait for both servers to be ready
// Start web server
go func() {
defer wg.Done()
logger.Info("Web server starting (HTTP)",
zap.Int("port", cfg.WebPort),
zap.Bool("enabled", cfg.WebEnabled))

// Signal server is about to start
go func() {
time.Sleep(100 * time.Millisecond) // Brief delay for server to initialize
if cfg.WebEnabled {
logger.Info("Web server ready for connections", zap.Int("port", cfg.WebPort))
} else {
logger.Info("Web server disabled")
}
serverReady.Done()
}()

if err := web.StartWebServer(cfg, nexusServer, logger); err != nil {
if cfg.WebEnabled {
logger.Error("Web server failed", zap.Error(err))
}
}
}()

// Wait for all three servers to be ready
go func() {
serverReady.Wait()
logger.Info("🚀 NEXUS FULLY READY - Both minion and console servers accepting connections",
logger.Info("🚀 NEXUS FULLY READY - All servers accepting connections",
zap.Int("minion_port", cfg.MinionPort),
zap.Int("console_port", cfg.ConsolePort))
zap.Int("console_port", cfg.ConsolePort),
zap.Int("web_port", cfg.WebPort),
zap.Bool("web_enabled", cfg.WebEnabled))
}()

// Set up graceful shutdown
quit := make(chan os.Signal, 1)
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
<-quit

logger.Info("Shutting down both gRPC servers...")
logger.Info("Shutting down all servers...")

// Gracefully stop both servers
// Gracefully stop all servers
go func() {
logger.Info("Stopping minion server...")
minionServer.GracefulStop()
Expand All @@ -174,7 +202,12 @@ func main() {
consoleServer.GracefulStop()
}()

// Wait for both servers to finish
go func() {
logger.Info("Stopping web server...")
// Web server shutdown is handled by process termination
}()

// Wait for all servers to finish
wg.Wait()
logger.Info("All servers stopped")
}
Expand Down
Loading
Loading