Files
godoxy/agent/cmd
yusing 6da7227f9b refactor(errs): migrate from gperr.Error to standard Go error interface
This is a large-scale refactoring across the codebase that replaces the custom
`gperr.Error` type with Go's standard `error` interface. The changes include:

- Replacing `gperr.Error` return types with `error` in function signatures
- Using `errors.New()` and `fmt.Errorf()` instead of `gperr.New()` and `gperr.Errorf()`
- Using `%w` format verb for error wrapping instead of `.With()` method
- Replacing `gperr.Subject()` calls with `gperr.PrependSubject()`
- Converting error logging from `gperr.Log*()` functions to zerolog's `.Err().Msg()` pattern
- Update NewLogger to handle multiline error message
- Updating `goutils` submodule to latest commit

This refactoring aligns with Go idioms and removes the dependency on
custom error handling abstractions in favor of standard library patterns.
2026-02-08 12:07:36 +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