From 59e24322312e3cdf368f1fccb23803575c5761d8 Mon Sep 17 00:00:00 2001 From: Viktor Liu <17948409+lixmal@users.noreply.github.com> Date: Thu, 27 Feb 2025 12:29:50 +0100 Subject: [PATCH] Add event proto fields (#3397) --- management/proto/flow.pb.go | 524 ++++++++++++++++++++++++++++-- management/proto/flow.proto | 61 +++- management/proto/management.pb.go | 2 +- 3 files changed, 558 insertions(+), 29 deletions(-) diff --git a/management/proto/flow.pb.go b/management/proto/flow.pb.go index 9487bd694..4f1a5f2d4 100644 --- a/management/proto/flow.pb.go +++ b/management/proto/flow.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.26.0 -// protoc v3.21.12 +// protoc v4.24.3 // source: flow.proto package proto @@ -9,6 +9,7 @@ package proto import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" reflect "reflect" sync "sync" ) @@ -20,6 +21,106 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// Flow event types +type Type int32 + +const ( + Type_TypeUnknown Type = 0 + Type_TypeStart Type = 1 + Type_TypeEnd Type = 2 +) + +// Enum value maps for Type. +var ( + Type_name = map[int32]string{ + 0: "TypeUnknown", + 1: "TypeStart", + 2: "TypeEnd", + } + Type_value = map[string]int32{ + "TypeUnknown": 0, + "TypeStart": 1, + "TypeEnd": 2, + } +) + +func (x Type) Enum() *Type { + p := new(Type) + *p = x + return p +} + +func (x Type) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Type) Descriptor() protoreflect.EnumDescriptor { + return file_flow_proto_enumTypes[0].Descriptor() +} + +func (Type) Type() protoreflect.EnumType { + return &file_flow_proto_enumTypes[0] +} + +func (x Type) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Type.Descriptor instead. +func (Type) EnumDescriptor() ([]byte, []int) { + return file_flow_proto_rawDescGZIP(), []int{0} +} + +// Flow direction +type Direction int32 + +const ( + Direction_DirectionUnknown Direction = 0 + Direction_Ingress Direction = 1 + Direction_Egress Direction = 2 +) + +// Enum value maps for Direction. +var ( + Direction_name = map[int32]string{ + 0: "DirectionUnknown", + 1: "Ingress", + 2: "Egress", + } + Direction_value = map[string]int32{ + "DirectionUnknown": 0, + "Ingress": 1, + "Egress": 2, + } +) + +func (x Direction) Enum() *Direction { + p := new(Direction) + *p = x + return p +} + +func (x Direction) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Direction) Descriptor() protoreflect.EnumDescriptor { + return file_flow_proto_enumTypes[1].Descriptor() +} + +func (Direction) Type() protoreflect.EnumType { + return &file_flow_proto_enumTypes[1] +} + +func (x Direction) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Direction.Descriptor instead. +func (Direction) EnumDescriptor() ([]byte, []int) { + return file_flow_proto_rawDescGZIP(), []int{1} +} + type FlowEvent struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -29,6 +130,11 @@ type FlowEvent struct { EventId string `protobuf:"bytes,1,opt,name=event_id,json=eventId,proto3" json:"event_id,omitempty"` // Unique client flow session identifier FlowId string `protobuf:"bytes,2,opt,name=flow_id,json=flowId,proto3" json:"flow_id,omitempty"` + // When the event occurred + Timestamp *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=Timestamp,proto3" json:"Timestamp,omitempty"` + // Public key of the sending peer + PublicKey []byte `protobuf:"bytes,4,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` + EventFields *EventFields `protobuf:"bytes,5,opt,name=EventFields,proto3" json:"EventFields,omitempty"` } func (x *FlowEvent) Reset() { @@ -77,6 +183,27 @@ func (x *FlowEvent) GetFlowId() string { return "" } +func (x *FlowEvent) GetTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.Timestamp + } + return nil +} + +func (x *FlowEvent) GetPublicKey() []byte { + if x != nil { + return x.PublicKey + } + return nil +} + +func (x *FlowEvent) GetEventFields() *EventFields { + if x != nil { + return x.EventFields + } + return nil +} + type FlowEventAck struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -125,24 +252,313 @@ func (x *FlowEventAck) GetEventId() string { return "" } +type EventFields struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Event type + Type Type `protobuf:"varint,1,opt,name=Type,proto3,enum=management.Type" json:"Type,omitempty"` + // Initiating traffic direction + Direction Direction `protobuf:"varint,2,opt,name=Direction,proto3,enum=management.Direction" json:"Direction,omitempty"` + // IP protocol number + Protocol uint32 `protobuf:"varint,3,opt,name=Protocol,proto3" json:"Protocol,omitempty"` + // Source IP address + SourceIP []byte `protobuf:"bytes,4,opt,name=SourceIP,proto3" json:"SourceIP,omitempty"` + // Destination IP address + DestIP []byte `protobuf:"bytes,5,opt,name=DestIP,proto3" json:"DestIP,omitempty"` + // Layer 4 -specific information + // + // Types that are assignable to ConnectionInfo: + // + // *EventFields_PortInfo + // *EventFields_IcmpInfo + ConnectionInfo isEventFields_ConnectionInfo `protobuf_oneof:"connection_info"` +} + +func (x *EventFields) Reset() { + *x = EventFields{} + if protoimpl.UnsafeEnabled { + mi := &file_flow_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *EventFields) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EventFields) ProtoMessage() {} + +func (x *EventFields) ProtoReflect() protoreflect.Message { + mi := &file_flow_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EventFields.ProtoReflect.Descriptor instead. +func (*EventFields) Descriptor() ([]byte, []int) { + return file_flow_proto_rawDescGZIP(), []int{2} +} + +func (x *EventFields) GetType() Type { + if x != nil { + return x.Type + } + return Type_TypeUnknown +} + +func (x *EventFields) GetDirection() Direction { + if x != nil { + return x.Direction + } + return Direction_DirectionUnknown +} + +func (x *EventFields) GetProtocol() uint32 { + if x != nil { + return x.Protocol + } + return 0 +} + +func (x *EventFields) GetSourceIP() []byte { + if x != nil { + return x.SourceIP + } + return nil +} + +func (x *EventFields) GetDestIP() []byte { + if x != nil { + return x.DestIP + } + return nil +} + +func (m *EventFields) GetConnectionInfo() isEventFields_ConnectionInfo { + if m != nil { + return m.ConnectionInfo + } + return nil +} + +func (x *EventFields) GetPortInfo() *PortInfo { + if x, ok := x.GetConnectionInfo().(*EventFields_PortInfo); ok { + return x.PortInfo + } + return nil +} + +func (x *EventFields) GetIcmpInfo() *ICMPInfo { + if x, ok := x.GetConnectionInfo().(*EventFields_IcmpInfo); ok { + return x.IcmpInfo + } + return nil +} + +type isEventFields_ConnectionInfo interface { + isEventFields_ConnectionInfo() +} + +type EventFields_PortInfo struct { + // TCP/UDP port information + PortInfo *PortInfo `protobuf:"bytes,6,opt,name=port_info,json=portInfo,proto3,oneof"` +} + +type EventFields_IcmpInfo struct { + // ICMP type and code + IcmpInfo *ICMPInfo `protobuf:"bytes,7,opt,name=icmp_info,json=icmpInfo,proto3,oneof"` +} + +func (*EventFields_PortInfo) isEventFields_ConnectionInfo() {} + +func (*EventFields_IcmpInfo) isEventFields_ConnectionInfo() {} + +// TCP/UDP port information +type PortInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SourcePort uint32 `protobuf:"varint,1,opt,name=SourcePort,proto3" json:"SourcePort,omitempty"` + DestPort uint32 `protobuf:"varint,2,opt,name=DestPort,proto3" json:"DestPort,omitempty"` +} + +func (x *PortInfo) Reset() { + *x = PortInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_flow_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PortInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PortInfo) ProtoMessage() {} + +func (x *PortInfo) ProtoReflect() protoreflect.Message { + mi := &file_flow_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PortInfo.ProtoReflect.Descriptor instead. +func (*PortInfo) Descriptor() ([]byte, []int) { + return file_flow_proto_rawDescGZIP(), []int{3} +} + +func (x *PortInfo) GetSourcePort() uint32 { + if x != nil { + return x.SourcePort + } + return 0 +} + +func (x *PortInfo) GetDestPort() uint32 { + if x != nil { + return x.DestPort + } + return 0 +} + +// ICMP message information +type ICMPInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ICMPType uint32 `protobuf:"varint,1,opt,name=ICMPType,proto3" json:"ICMPType,omitempty"` + ICMPCode uint32 `protobuf:"varint,2,opt,name=ICMPCode,proto3" json:"ICMPCode,omitempty"` +} + +func (x *ICMPInfo) Reset() { + *x = ICMPInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_flow_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ICMPInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ICMPInfo) ProtoMessage() {} + +func (x *ICMPInfo) ProtoReflect() protoreflect.Message { + mi := &file_flow_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ICMPInfo.ProtoReflect.Descriptor instead. +func (*ICMPInfo) Descriptor() ([]byte, []int) { + return file_flow_proto_rawDescGZIP(), []int{4} +} + +func (x *ICMPInfo) GetICMPType() uint32 { + if x != nil { + return x.ICMPType + } + return 0 +} + +func (x *ICMPInfo) GetICMPCode() uint32 { + if x != nil { + return x.ICMPCode + } + return 0 +} + var File_flow_proto protoreflect.FileDescriptor var file_flow_proto_rawDesc = []byte{ 0x0a, 0x0a, 0x66, 0x6c, 0x6f, 0x77, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x6d, 0x61, - 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x3f, 0x0a, 0x09, 0x46, 0x6c, 0x6f, 0x77, - 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x49, 0x64, - 0x12, 0x17, 0x0a, 0x07, 0x66, 0x6c, 0x6f, 0x77, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x06, 0x66, 0x6c, 0x6f, 0x77, 0x49, 0x64, 0x22, 0x29, 0x0a, 0x0c, 0x46, 0x6c, 0x6f, - 0x77, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x41, 0x63, 0x6b, 0x12, 0x19, 0x0a, 0x08, 0x65, 0x76, 0x65, - 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x65, 0x76, 0x65, - 0x6e, 0x74, 0x49, 0x64, 0x32, 0x4e, 0x0a, 0x0b, 0x46, 0x6c, 0x6f, 0x77, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x12, 0x3f, 0x0a, 0x06, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x15, 0x2e, - 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x46, 0x6c, 0x6f, 0x77, 0x45, - 0x76, 0x65, 0x6e, 0x74, 0x1a, 0x18, 0x2e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, - 0x74, 0x2e, 0x46, 0x6c, 0x6f, 0x77, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x41, 0x63, 0x6b, 0x22, 0x00, - 0x28, 0x01, 0x30, 0x01, 0x42, 0x08, 0x5a, 0x06, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xd3, 0x01, 0x0a, 0x09, 0x46, 0x6c, + 0x6f, 0x77, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x65, 0x76, 0x65, 0x6e, 0x74, + 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74, + 0x49, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x66, 0x6c, 0x6f, 0x77, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x66, 0x6c, 0x6f, 0x77, 0x49, 0x64, 0x12, 0x38, 0x0a, 0x09, 0x54, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x54, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, + 0x6b, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, + 0x63, 0x4b, 0x65, 0x79, 0x12, 0x39, 0x0a, 0x0b, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x46, 0x69, 0x65, + 0x6c, 0x64, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x6d, 0x61, 0x6e, 0x61, + 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x46, 0x69, 0x65, 0x6c, + 0x64, 0x73, 0x52, 0x0b, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x22, + 0x29, 0x0a, 0x0c, 0x46, 0x6c, 0x6f, 0x77, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x41, 0x63, 0x6b, 0x12, + 0x19, 0x0a, 0x08, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x22, 0xb5, 0x02, 0x0a, 0x0b, 0x45, + 0x76, 0x65, 0x6e, 0x74, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x12, 0x24, 0x0a, 0x04, 0x54, 0x79, + 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x6d, 0x61, 0x6e, 0x61, 0x67, + 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x54, 0x79, 0x70, 0x65, + 0x12, 0x33, 0x0a, 0x09, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, + 0x2e, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x09, 0x44, 0x69, 0x72, 0x65, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, + 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, + 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x50, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x08, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x50, 0x12, 0x16, 0x0a, + 0x06, 0x44, 0x65, 0x73, 0x74, 0x49, 0x50, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x44, + 0x65, 0x73, 0x74, 0x49, 0x50, 0x12, 0x33, 0x0a, 0x09, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x69, 0x6e, + 0x66, 0x6f, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6d, 0x61, 0x6e, 0x61, 0x67, + 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x48, 0x00, + 0x52, 0x08, 0x70, 0x6f, 0x72, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x33, 0x0a, 0x09, 0x69, 0x63, + 0x6d, 0x70, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, + 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x49, 0x43, 0x4d, 0x50, 0x49, + 0x6e, 0x66, 0x6f, 0x48, 0x00, 0x52, 0x08, 0x69, 0x63, 0x6d, 0x70, 0x49, 0x6e, 0x66, 0x6f, 0x42, + 0x11, 0x0a, 0x0f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x6e, + 0x66, 0x6f, 0x22, 0x46, 0x0a, 0x08, 0x50, 0x6f, 0x72, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1e, + 0x0a, 0x0a, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x6f, 0x72, 0x74, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0d, 0x52, 0x0a, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x1a, + 0x0a, 0x08, 0x44, 0x65, 0x73, 0x74, 0x50, 0x6f, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, + 0x52, 0x08, 0x44, 0x65, 0x73, 0x74, 0x50, 0x6f, 0x72, 0x74, 0x22, 0x42, 0x0a, 0x08, 0x49, 0x43, + 0x4d, 0x50, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1a, 0x0a, 0x08, 0x49, 0x43, 0x4d, 0x50, 0x54, 0x79, + 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x49, 0x43, 0x4d, 0x50, 0x54, 0x79, + 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x49, 0x43, 0x4d, 0x50, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x49, 0x43, 0x4d, 0x50, 0x43, 0x6f, 0x64, 0x65, 0x2a, 0x33, + 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x79, 0x70, 0x65, 0x55, 0x6e, + 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x54, 0x79, 0x70, 0x65, 0x53, + 0x74, 0x61, 0x72, 0x74, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x54, 0x79, 0x70, 0x65, 0x45, 0x6e, + 0x64, 0x10, 0x02, 0x2a, 0x3a, 0x0a, 0x09, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x14, 0x0a, 0x10, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x6e, 0x6b, + 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x49, 0x6e, 0x67, 0x72, 0x65, 0x73, + 0x73, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x45, 0x67, 0x72, 0x65, 0x73, 0x73, 0x10, 0x02, 0x32, + 0x4e, 0x0a, 0x0b, 0x46, 0x6c, 0x6f, 0x77, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3f, + 0x0a, 0x06, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x15, 0x2e, 0x6d, 0x61, 0x6e, 0x61, 0x67, + 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x46, 0x6c, 0x6f, 0x77, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x1a, + 0x18, 0x2e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x46, 0x6c, 0x6f, + 0x77, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x41, 0x63, 0x6b, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x42, + 0x08, 0x5a, 0x06, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( @@ -157,19 +573,32 @@ func file_flow_proto_rawDescGZIP() []byte { return file_flow_proto_rawDescData } -var file_flow_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_flow_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_flow_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_flow_proto_goTypes = []interface{}{ - (*FlowEvent)(nil), // 0: management.FlowEvent - (*FlowEventAck)(nil), // 1: management.FlowEventAck + (Type)(0), // 0: management.Type + (Direction)(0), // 1: management.Direction + (*FlowEvent)(nil), // 2: management.FlowEvent + (*FlowEventAck)(nil), // 3: management.FlowEventAck + (*EventFields)(nil), // 4: management.EventFields + (*PortInfo)(nil), // 5: management.PortInfo + (*ICMPInfo)(nil), // 6: management.ICMPInfo + (*timestamppb.Timestamp)(nil), // 7: google.protobuf.Timestamp } var file_flow_proto_depIdxs = []int32{ - 0, // 0: management.FlowService.Events:input_type -> management.FlowEvent - 1, // 1: management.FlowService.Events:output_type -> management.FlowEventAck - 1, // [1:2] is the sub-list for method output_type - 0, // [0:1] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 7, // 0: management.FlowEvent.Timestamp:type_name -> google.protobuf.Timestamp + 4, // 1: management.FlowEvent.EventFields:type_name -> management.EventFields + 0, // 2: management.EventFields.Type:type_name -> management.Type + 1, // 3: management.EventFields.Direction:type_name -> management.Direction + 5, // 4: management.EventFields.port_info:type_name -> management.PortInfo + 6, // 5: management.EventFields.icmp_info:type_name -> management.ICMPInfo + 2, // 6: management.FlowService.Events:input_type -> management.FlowEvent + 3, // 7: management.FlowService.Events:output_type -> management.FlowEventAck + 7, // [7:8] is the sub-list for method output_type + 6, // [6:7] is the sub-list for method input_type + 6, // [6:6] is the sub-list for extension type_name + 6, // [6:6] is the sub-list for extension extendee + 0, // [0:6] is the sub-list for field type_name } func init() { file_flow_proto_init() } @@ -202,19 +631,60 @@ func file_flow_proto_init() { return nil } } + file_flow_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*EventFields); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_flow_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PortInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_flow_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ICMPInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_flow_proto_msgTypes[2].OneofWrappers = []interface{}{ + (*EventFields_PortInfo)(nil), + (*EventFields_IcmpInfo)(nil), } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_flow_proto_rawDesc, - NumEnums: 0, - NumMessages: 2, + NumEnums: 2, + NumMessages: 5, NumExtensions: 0, NumServices: 1, }, GoTypes: file_flow_proto_goTypes, DependencyIndexes: file_flow_proto_depIdxs, + EnumInfos: file_flow_proto_enumTypes, MessageInfos: file_flow_proto_msgTypes, }.Build() File_flow_proto = out.File diff --git a/management/proto/flow.proto b/management/proto/flow.proto index ce909940a..fdfb25a2b 100644 --- a/management/proto/flow.proto +++ b/management/proto/flow.proto @@ -1,5 +1,7 @@ syntax = "proto3"; +import "google/protobuf/timestamp.proto"; + option go_package = "/proto"; package management; @@ -16,7 +18,13 @@ message FlowEvent { // Unique client flow session identifier string flow_id = 2; - // @todo define event props + // When the event occurred + google.protobuf.Timestamp timestamp = 3; + + // Public key of the sending peer + bytes public_key = 4; + + EventFields event_fields = 5; } message FlowEventAck { @@ -24,3 +32,54 @@ message FlowEventAck { string event_id = 1; } +message EventFields { + // Event type + Type type = 1; + + // Initiating traffic direction + Direction direction = 2; + + // IP protocol number + uint32 protocol = 3; + + // Source IP address + bytes source_ip = 4; + + // Destination IP address + bytes dest_ip = 5; + + // Layer 4 -specific information + oneof connection_info { + // TCP/UDP port information + PortInfo port_info = 6; + + // ICMP type and code + ICMPInfo icmp_info = 7; + } +} + +// Flow event types +enum Type { + TYPE_UNKNOWN = 0; + TYPE_START = 1; + TYPE_END = 2; +} + +// Flow direction +enum Direction { + DIRECTION_UNKNOWN = 0; + INGRESS = 1; + EGRESS = 2; +} + +// TCP/UDP port information +message PortInfo { + uint32 source_port = 1; + uint32 dest_port = 2; +} + +// ICMP message information +message ICMPInfo { + uint32 icmp_type = 1; + uint32 icmp_code = 2; +} diff --git a/management/proto/management.pb.go b/management/proto/management.pb.go index bbbc34e15..df84a5a01 100644 --- a/management/proto/management.pb.go +++ b/management/proto/management.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.26.0 -// protoc v3.21.12 +// protoc v4.24.3 // source: management.proto package proto