Add mcp dns and mcp node routes commands
mcp dns queries MCNS via an agent to list all zones and DNS records. mcp node routes queries mc-proxy on each node for listener/route status, matching the mcproxyctl status output format. New agent RPCs: ListDNSRecords, ListProxyRoutes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
46
internal/agent/proxy_rpc.go
Normal file
46
internal/agent/proxy_rpc.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
mcpv1 "git.wntrmute.dev/mc/mcp/gen/mcp/v1"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
// ListProxyRoutes queries mc-proxy for its current status and routes.
|
||||
func (a *Agent) ListProxyRoutes(ctx context.Context, _ *mcpv1.ListProxyRoutesRequest) (*mcpv1.ListProxyRoutesResponse, error) {
|
||||
a.Logger.Debug("ListProxyRoutes called")
|
||||
|
||||
status, err := a.Proxy.GetStatus(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("get mc-proxy status: %w", err)
|
||||
}
|
||||
|
||||
resp := &mcpv1.ListProxyRoutesResponse{
|
||||
Version: status.Version,
|
||||
TotalConnections: status.TotalConnections,
|
||||
}
|
||||
if !status.StartedAt.IsZero() {
|
||||
resp.StartedAt = timestamppb.New(status.StartedAt)
|
||||
}
|
||||
|
||||
for _, ls := range status.Listeners {
|
||||
listener := &mcpv1.ProxyListenerInfo{
|
||||
Addr: ls.Addr,
|
||||
RouteCount: int32(ls.RouteCount), //nolint:gosec // bounded
|
||||
ActiveConnections: ls.ActiveConnections,
|
||||
}
|
||||
for _, r := range ls.Routes {
|
||||
listener.Routes = append(listener.Routes, &mcpv1.ProxyRouteInfo{
|
||||
Hostname: r.Hostname,
|
||||
Backend: r.Backend,
|
||||
Mode: r.Mode,
|
||||
BackendTls: r.BackendTLS,
|
||||
})
|
||||
}
|
||||
resp.Listeners = append(resp.Listeners, listener)
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
Reference in New Issue
Block a user