Switch gRPC admin API to Unix socket only, add client package

- Remove TCP listener support from gRPC server; Unix socket is now the
  only transport for the admin API (access controlled via filesystem
  permissions)
- Add standard gRPC health check service (grpc.health.v1.Health)
- Implement MCPROXY_* environment variable overrides for config
- Create client/mcproxy package with full API coverage and tests
- Update ARCHITECTURE.md and dev config (srv/mc-proxy.toml)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-03-19 07:48:11 -07:00
parent b25e1b0e79
commit f24fa2a2b0
9 changed files with 810 additions and 137 deletions

41
client/mcproxy/doc.go Normal file
View File

@@ -0,0 +1,41 @@
// Package mcproxy provides a Go client for the mc-proxy gRPC admin API.
//
// The client connects to mc-proxy via Unix socket and provides methods
// for managing routes, firewall rules, and querying server status.
//
// # Basic Usage
//
// client, err := mcproxy.Dial("/var/run/mc-proxy.sock")
// if err != nil {
// log.Fatal(err)
// }
// defer client.Close()
//
// // Get server status
// status, err := client.GetStatus(ctx)
// if err != nil {
// log.Fatal(err)
// }
// fmt.Printf("mc-proxy %s, %d connections\n", status.Version, status.TotalConnections)
//
// // List routes for a listener
// routes, err := client.ListRoutes(ctx, ":443")
// if err != nil {
// log.Fatal(err)
// }
// for _, r := range routes {
// fmt.Printf(" %s -> %s\n", r.Hostname, r.Backend)
// }
//
// // Add a route
// err = client.AddRoute(ctx, ":443", "example.com", "127.0.0.1:8443")
//
// // Add a firewall rule
// err = client.AddFirewallRule(ctx, mcproxy.FirewallRuleCIDR, "10.0.0.0/8")
//
// // Check health
// health, err := client.CheckHealth(ctx)
// if health == mcproxy.HealthServing {
// fmt.Println("Server is healthy")
// }
package mcproxy