Files
yusing 69d04f1b76 refactor(agent): remove goutils/server dependency and use direct HTTP server setup
- Replaced `goutils/server` helper library with manual HTTP server configuration for agent socketproxy
- Removed entire `agent/pkg/server/server.go` package (43 lines) that wrapped TLS/HTTP server functionality
- Added explicit TCP listener and integrated zerolog with server's error logging
- Cleaned up 17 unused indirect agent dependencies
2026-01-09 20:27:48 +08:00
..

agent/cmd

The main entry point for the GoDoxy Agent, a secure monitoring and proxy agent that runs alongside Docker containers.

Overview

This package contains the main.go entry point for the GoDoxy Agent. The agent is a TLS-enabled server that provides:

  • Secure Docker socket proxying with client certificate authentication
  • HTTP proxy capabilities for container traffic
  • System metrics collection and monitoring
  • Health check endpoints

Architecture

graph TD
    A[main] --> B[Logger Init]
    A --> C[Load CA Certificate]
    A --> D[Load Server Certificate]
    A --> E[Log Version Info]
    A --> F[Start Agent Server]
    A --> G[Start Socket Proxy]
    A --> H[Start System Info Poller]
    A --> I[Wait Exit]

    F --> F1[TLS with mTLS]
    F --> F2[Agent Handler]
    G --> G1[Docker Socket Proxy]

Main Function Flow

  1. Logger Setup: Configures zerolog with console output
  2. Certificate Loading: Loads CA and server certificates for TLS/mTLS
  3. Version Logging: Logs agent version and configuration
  4. Agent Server: Starts the main HTTPS server with agent handlers
  5. Socket Proxy: Starts Docker socket proxy if configured
  6. System Monitoring: Starts system info polling
  7. Graceful Shutdown: Waits for exit signal (3 second timeout)

Configuration

See agent/pkg/env/README.md for configuration options.

Dependencies

  • agent/pkg/agent - Core agent types and constants
  • agent/pkg/env - Environment configuration
  • agent/pkg/server - Server implementation
  • socketproxy/pkg - Docker socket proxy
  • internal/metrics/systeminfo - System metrics