The steady-state host<->manager transport, resolving the design's OPEN FORK to bespoke gRPC (not OTLP+Wazuh). One long-lived, host-dialed, mTLS bidi stream: health/metrics up, desired-state/commands down — no polling, real-time control, still no inbound host port. - proto/fleet_agent.proto: FleetAgent.Session(stream AgentUp) -> stream ManagerDown. AgentUp = Hello | HealthSnapshot | CommandResult; ManagerDown = DesiredState | Command(reboot/drain/resync). int64 unix times (no well-known-type dep). Generated stubs committed (CI needs no protoc). - agent.go: gRPC server with mTLS verified by the FLEET CA (the host's reused TPM identity cert — distinct from the admin plane's admin CA). Identity is the peer cert SERIAL, taken from the verified cert = inventory key, never self-asserted; an unenrolled serial is refused (enrolment gates the stream). Per-conn send channel decouples admin pushes from stream.Send. Stream registry (serial->conn) with reconnect eviction. On connect + on change, desired-state is pushed live; inventory stays authoritative so offline hosts reconcile on reconnect. Metrics go through a MetricsSink seam (no-op now; InfluxDB in ckpt 4). - main.go: agent plane starts only when its cert/key/CA are set; admin can run standalone. Lifecycle PUT now live-pushes and reports pushed_live. Full mTLS integration test (in-process fleet CA + host client cert): initial desired-state on connect, Hello+snapshot -> inventory + online presence, live desired-state push, and unenrolled-serial rejection. go build/test/vet/gofmt clean. Deps (server-side only): google.golang.org/grpc + protobuf.
131 lines
5.4 KiB
Go
131 lines
5.4 KiB
Go
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
|
// versions:
|
|
// - protoc-gen-go-grpc v1.6.2
|
|
// - protoc v3.21.12
|
|
// source: proto/fleet_agent.proto
|
|
|
|
// The steady-state contract between the on-host fleet agent and the
|
|
// fleet-manager. ONE long-lived, host-dialed, mTLS bidi stream (health/metrics
|
|
// up, desired-state down) — the design's resolved transport fork (bespoke gRPC,
|
|
// not OTLP+Wazuh). See docs/fleet-management-design.md + tpm-enrolment-design.md.
|
|
//
|
|
// Identity is the mTLS peer cert (the host's reused TPM identity cert, fleet CA);
|
|
// the manager derives the cert serial (= inventory key) from it, so AgentUp
|
|
// messages carry NO self-asserted identity — a host can only ever be itself.
|
|
|
|
package fleetpb
|
|
|
|
import (
|
|
context "context"
|
|
grpc "google.golang.org/grpc"
|
|
codes "google.golang.org/grpc/codes"
|
|
status "google.golang.org/grpc/status"
|
|
)
|
|
|
|
// This is a compile-time assertion to ensure that this generated file
|
|
// is compatible with the grpc package it is being compiled against.
|
|
// Requires gRPC-Go v1.64.0 or later.
|
|
const _ = grpc.SupportPackageIsVersion9
|
|
|
|
const (
|
|
FleetAgent_Session_FullMethodName = "/fleet.agent.v1.FleetAgent/Session"
|
|
)
|
|
|
|
// FleetAgentClient is the client API for FleetAgent service.
|
|
//
|
|
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
|
type FleetAgentClient interface {
|
|
// Session: the single bidirectional stream. The host opens it (dials out, no
|
|
// inbound host port); the manager pushes desired-state/commands back over the
|
|
// same connection. Closing/keepalive-timeout = the host's offline signal.
|
|
Session(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[AgentUp, ManagerDown], error)
|
|
}
|
|
|
|
type fleetAgentClient struct {
|
|
cc grpc.ClientConnInterface
|
|
}
|
|
|
|
func NewFleetAgentClient(cc grpc.ClientConnInterface) FleetAgentClient {
|
|
return &fleetAgentClient{cc}
|
|
}
|
|
|
|
func (c *fleetAgentClient) Session(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[AgentUp, ManagerDown], error) {
|
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
stream, err := c.cc.NewStream(ctx, &FleetAgent_ServiceDesc.Streams[0], FleetAgent_Session_FullMethodName, cOpts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
x := &grpc.GenericClientStream[AgentUp, ManagerDown]{ClientStream: stream}
|
|
return x, nil
|
|
}
|
|
|
|
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
|
type FleetAgent_SessionClient = grpc.BidiStreamingClient[AgentUp, ManagerDown]
|
|
|
|
// FleetAgentServer is the server API for FleetAgent service.
|
|
// All implementations must embed UnimplementedFleetAgentServer
|
|
// for forward compatibility.
|
|
type FleetAgentServer interface {
|
|
// Session: the single bidirectional stream. The host opens it (dials out, no
|
|
// inbound host port); the manager pushes desired-state/commands back over the
|
|
// same connection. Closing/keepalive-timeout = the host's offline signal.
|
|
Session(grpc.BidiStreamingServer[AgentUp, ManagerDown]) error
|
|
mustEmbedUnimplementedFleetAgentServer()
|
|
}
|
|
|
|
// UnimplementedFleetAgentServer must be embedded to have
|
|
// forward compatible implementations.
|
|
//
|
|
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
|
// pointer dereference when methods are called.
|
|
type UnimplementedFleetAgentServer struct{}
|
|
|
|
func (UnimplementedFleetAgentServer) Session(grpc.BidiStreamingServer[AgentUp, ManagerDown]) error {
|
|
return status.Error(codes.Unimplemented, "method Session not implemented")
|
|
}
|
|
func (UnimplementedFleetAgentServer) mustEmbedUnimplementedFleetAgentServer() {}
|
|
func (UnimplementedFleetAgentServer) testEmbeddedByValue() {}
|
|
|
|
// UnsafeFleetAgentServer may be embedded to opt out of forward compatibility for this service.
|
|
// Use of this interface is not recommended, as added methods to FleetAgentServer will
|
|
// result in compilation errors.
|
|
type UnsafeFleetAgentServer interface {
|
|
mustEmbedUnimplementedFleetAgentServer()
|
|
}
|
|
|
|
func RegisterFleetAgentServer(s grpc.ServiceRegistrar, srv FleetAgentServer) {
|
|
// If the following call panics, it indicates UnimplementedFleetAgentServer was
|
|
// embedded by pointer and is nil. This will cause panics if an
|
|
// unimplemented method is ever invoked, so we test this at initialization
|
|
// time to prevent it from happening at runtime later due to I/O.
|
|
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
|
t.testEmbeddedByValue()
|
|
}
|
|
s.RegisterService(&FleetAgent_ServiceDesc, srv)
|
|
}
|
|
|
|
func _FleetAgent_Session_Handler(srv interface{}, stream grpc.ServerStream) error {
|
|
return srv.(FleetAgentServer).Session(&grpc.GenericServerStream[AgentUp, ManagerDown]{ServerStream: stream})
|
|
}
|
|
|
|
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
|
type FleetAgent_SessionServer = grpc.BidiStreamingServer[AgentUp, ManagerDown]
|
|
|
|
// FleetAgent_ServiceDesc is the grpc.ServiceDesc for FleetAgent service.
|
|
// It's only intended for direct use with grpc.RegisterService,
|
|
// and not to be introspected or modified (even as a copy)
|
|
var FleetAgent_ServiceDesc = grpc.ServiceDesc{
|
|
ServiceName: "fleet.agent.v1.FleetAgent",
|
|
HandlerType: (*FleetAgentServer)(nil),
|
|
Methods: []grpc.MethodDesc{},
|
|
Streams: []grpc.StreamDesc{
|
|
{
|
|
StreamName: "Session",
|
|
Handler: _FleetAgent_Session_Handler,
|
|
ServerStreams: true,
|
|
ClientStreams: true,
|
|
},
|
|
},
|
|
Metadata: "proto/fleet_agent.proto",
|
|
}
|