From cb093100a2de215978835845a4733b9a9ec45a35 Mon Sep 17 00:00:00 2001 From: Tommaso Gragnato Date: Tue, 19 Nov 2024 14:38:48 +0100 Subject: [PATCH] fix(protobuf): remove SrcAddrIp and DstAddrIp --- pb/flow.pb.go | 76 +++++++++++++++-------------------------- pb/flow.proto | 6 ++-- producer/proto/proto.go | 8 ----- 3 files changed, 30 insertions(+), 60 deletions(-) diff --git a/pb/flow.pb.go b/pb/flow.pb.go index 0a53e0e..cb6a6c5 100644 --- a/pb/flow.pb.go +++ b/pb/flow.pb.go @@ -236,10 +236,8 @@ type FlowMessage struct { SrcCountry string `protobuf:"bytes,1000,opt,name=src_country,json=srcCountry,proto3" json:"src_country,omitempty"` DstCountry string `protobuf:"bytes,1001,opt,name=dst_country,json=dstCountry,proto3" json:"dst_country,omitempty"` LmsTargetIndex string `protobuf:"bytes,1002,opt,name=lms_target_index,json=lmsTargetIndex,proto3" json:"lms_target_index,omitempty"` - SrcAddrIp []byte `protobuf:"bytes,1003,opt,name=src_addr_ip,json=srcAddrIp,proto3" json:"src_addr_ip,omitempty"` - DstAddrIp []byte `protobuf:"bytes,1004,opt,name=dst_addr_ip,json=dstAddrIp,proto3" json:"dst_addr_ip,omitempty"` - SrcAsn string `protobuf:"bytes,1005,opt,name=src_asn,json=srcAsn,proto3" json:"src_asn,omitempty"` - DstAsn string `protobuf:"bytes,1006,opt,name=dst_asn,json=dstAsn,proto3" json:"dst_asn,omitempty"` + SrcAsn string `protobuf:"bytes,1003,opt,name=src_asn,json=srcAsn,proto3" json:"src_asn,omitempty"` + DstAsn string `protobuf:"bytes,1004,opt,name=dst_asn,json=dstAsn,proto3" json:"dst_asn,omitempty"` } func (x *FlowMessage) Reset() { @@ -643,20 +641,6 @@ func (x *FlowMessage) GetLmsTargetIndex() string { return "" } -func (x *FlowMessage) GetSrcAddrIp() []byte { - if x != nil { - return x.SrcAddrIp - } - return nil -} - -func (x *FlowMessage) GetDstAddrIp() []byte { - if x != nil { - return x.DstAddrIp - } - return nil -} - func (x *FlowMessage) GetSrcAsn() string { if x != nil { return x.SrcAsn @@ -675,7 +659,7 @@ var File_pb_flow_proto protoreflect.FileDescriptor var file_pb_flow_proto_rawDesc = []byte{ 0x0a, 0x0d, 0x70, 0x62, 0x2f, 0x66, 0x6c, 0x6f, 0x77, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x06, 0x66, 0x6c, 0x6f, 0x77, 0x70, 0x62, 0x22, 0x83, 0x11, 0x0a, 0x0b, 0x46, 0x6c, 0x6f, 0x77, + 0x06, 0x66, 0x6c, 0x6f, 0x77, 0x70, 0x62, 0x22, 0xc1, 0x10, 0x0a, 0x0b, 0x46, 0x6c, 0x6f, 0x77, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1c, 0x2e, 0x66, 0x6c, 0x6f, 0x77, 0x70, 0x62, 0x2e, 0x46, 0x6c, 0x6f, 0x77, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x46, 0x6c, 0x6f, 0x77, 0x54, @@ -786,35 +770,31 @@ var file_pb_flow_proto_rawDesc = []byte{ 0x09, 0x52, 0x0a, 0x64, 0x73, 0x74, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x29, 0x0a, 0x10, 0x6c, 0x6d, 0x73, 0x5f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0xea, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x6c, 0x6d, 0x73, 0x54, 0x61, 0x72, - 0x67, 0x65, 0x74, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x72, 0x63, 0x5f, - 0x61, 0x64, 0x64, 0x72, 0x5f, 0x69, 0x70, 0x18, 0xeb, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, - 0x73, 0x72, 0x63, 0x41, 0x64, 0x64, 0x72, 0x49, 0x70, 0x12, 0x1f, 0x0a, 0x0b, 0x64, 0x73, 0x74, - 0x5f, 0x61, 0x64, 0x64, 0x72, 0x5f, 0x69, 0x70, 0x18, 0xec, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x09, 0x64, 0x73, 0x74, 0x41, 0x64, 0x64, 0x72, 0x49, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x72, - 0x63, 0x5f, 0x61, 0x73, 0x6e, 0x18, 0xed, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x72, - 0x63, 0x41, 0x73, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x73, 0x74, 0x5f, 0x61, 0x73, 0x6e, 0x18, - 0xee, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x73, 0x74, 0x41, 0x73, 0x6e, 0x22, 0x53, - 0x0a, 0x08, 0x46, 0x6c, 0x6f, 0x77, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x46, 0x4c, - 0x4f, 0x57, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x53, - 0x46, 0x4c, 0x4f, 0x57, 0x5f, 0x35, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x4e, 0x45, 0x54, 0x46, - 0x4c, 0x4f, 0x57, 0x5f, 0x56, 0x35, 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x4e, 0x45, 0x54, 0x46, - 0x4c, 0x4f, 0x57, 0x5f, 0x56, 0x39, 0x10, 0x03, 0x12, 0x09, 0x0a, 0x05, 0x49, 0x50, 0x46, 0x49, - 0x58, 0x10, 0x04, 0x22, 0xc7, 0x01, 0x0a, 0x0a, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x53, 0x74, 0x61, - 0x63, 0x6b, 0x12, 0x0c, 0x0a, 0x08, 0x45, 0x74, 0x68, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x10, 0x00, - 0x12, 0x08, 0x0a, 0x04, 0x49, 0x50, 0x76, 0x34, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x49, 0x50, - 0x76, 0x36, 0x10, 0x02, 0x12, 0x07, 0x0a, 0x03, 0x54, 0x43, 0x50, 0x10, 0x03, 0x12, 0x07, 0x0a, - 0x03, 0x55, 0x44, 0x50, 0x10, 0x04, 0x12, 0x08, 0x0a, 0x04, 0x4d, 0x50, 0x4c, 0x53, 0x10, 0x05, - 0x12, 0x09, 0x0a, 0x05, 0x44, 0x6f, 0x74, 0x31, 0x51, 0x10, 0x06, 0x12, 0x08, 0x0a, 0x04, 0x49, - 0x43, 0x4d, 0x50, 0x10, 0x07, 0x12, 0x0a, 0x0a, 0x06, 0x49, 0x43, 0x4d, 0x50, 0x76, 0x36, 0x10, - 0x08, 0x12, 0x07, 0x0a, 0x03, 0x47, 0x52, 0x45, 0x10, 0x09, 0x12, 0x15, 0x0a, 0x11, 0x49, 0x50, - 0x76, 0x36, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x10, - 0x0a, 0x12, 0x16, 0x0a, 0x12, 0x49, 0x50, 0x76, 0x36, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x46, - 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x10, 0x0b, 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x65, 0x6e, - 0x65, 0x76, 0x65, 0x10, 0x0c, 0x12, 0x0a, 0x0a, 0x06, 0x54, 0x65, 0x72, 0x65, 0x64, 0x6f, 0x10, - 0x0d, 0x12, 0x0a, 0x0a, 0x06, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x10, 0x63, 0x42, 0x27, 0x5a, - 0x25, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x67, 0x72, 0x61, - 0x67, 0x6e, 0x61, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x66, 0x6c, 0x6f, 0x77, 0x2f, 0x70, 0x62, 0x3b, - 0x66, 0x6c, 0x6f, 0x77, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x67, 0x65, 0x74, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x72, 0x63, 0x5f, + 0x61, 0x73, 0x6e, 0x18, 0xeb, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x72, 0x63, 0x41, + 0x73, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x73, 0x74, 0x5f, 0x61, 0x73, 0x6e, 0x18, 0xec, 0x07, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x73, 0x74, 0x41, 0x73, 0x6e, 0x22, 0x53, 0x0a, 0x08, + 0x46, 0x6c, 0x6f, 0x77, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x46, 0x4c, 0x4f, 0x57, + 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x46, 0x4c, + 0x4f, 0x57, 0x5f, 0x35, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x4e, 0x45, 0x54, 0x46, 0x4c, 0x4f, + 0x57, 0x5f, 0x56, 0x35, 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x4e, 0x45, 0x54, 0x46, 0x4c, 0x4f, + 0x57, 0x5f, 0x56, 0x39, 0x10, 0x03, 0x12, 0x09, 0x0a, 0x05, 0x49, 0x50, 0x46, 0x49, 0x58, 0x10, + 0x04, 0x22, 0xc7, 0x01, 0x0a, 0x0a, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x53, 0x74, 0x61, 0x63, 0x6b, + 0x12, 0x0c, 0x0a, 0x08, 0x45, 0x74, 0x68, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x10, 0x00, 0x12, 0x08, + 0x0a, 0x04, 0x49, 0x50, 0x76, 0x34, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x49, 0x50, 0x76, 0x36, + 0x10, 0x02, 0x12, 0x07, 0x0a, 0x03, 0x54, 0x43, 0x50, 0x10, 0x03, 0x12, 0x07, 0x0a, 0x03, 0x55, + 0x44, 0x50, 0x10, 0x04, 0x12, 0x08, 0x0a, 0x04, 0x4d, 0x50, 0x4c, 0x53, 0x10, 0x05, 0x12, 0x09, + 0x0a, 0x05, 0x44, 0x6f, 0x74, 0x31, 0x51, 0x10, 0x06, 0x12, 0x08, 0x0a, 0x04, 0x49, 0x43, 0x4d, + 0x50, 0x10, 0x07, 0x12, 0x0a, 0x0a, 0x06, 0x49, 0x43, 0x4d, 0x50, 0x76, 0x36, 0x10, 0x08, 0x12, + 0x07, 0x0a, 0x03, 0x47, 0x52, 0x45, 0x10, 0x09, 0x12, 0x15, 0x0a, 0x11, 0x49, 0x50, 0x76, 0x36, + 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x10, 0x0a, 0x12, + 0x16, 0x0a, 0x12, 0x49, 0x50, 0x76, 0x36, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x46, 0x72, 0x61, + 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x10, 0x0b, 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x65, 0x6e, 0x65, 0x76, + 0x65, 0x10, 0x0c, 0x12, 0x0a, 0x0a, 0x06, 0x54, 0x65, 0x72, 0x65, 0x64, 0x6f, 0x10, 0x0d, 0x12, + 0x0a, 0x0a, 0x06, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x10, 0x63, 0x42, 0x27, 0x5a, 0x25, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x67, 0x72, 0x61, 0x67, 0x6e, + 0x61, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x66, 0x6c, 0x6f, 0x77, 0x2f, 0x70, 0x62, 0x3b, 0x66, 0x6c, + 0x6f, 0x77, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pb/flow.proto b/pb/flow.proto index d8c1e94..675889b 100644 --- a/pb/flow.proto +++ b/pb/flow.proto @@ -123,8 +123,6 @@ message FlowMessage { string src_country = 1000; string dst_country = 1001; string lms_target_index = 1002; - bytes src_addr_ip = 1003; - bytes dst_addr_ip = 1004; - string src_asn = 1005; - string dst_asn = 1006; + string src_asn = 1003; + string dst_asn = 1004; } diff --git a/producer/proto/proto.go b/producer/proto/proto.go index f7ba21e..adfb73b 100644 --- a/producer/proto/proto.go +++ b/producer/proto/proto.go @@ -56,10 +56,8 @@ func (p *ProtoProducer) Produce(msg interface{}, args *producer.ProduceArgs) (fl fmsg.TimeReceivedNs = tr fmsg.SamplerAddress = sa fmsg.LmsTargetIndex = LMS_TARGET_INDEX - fmsg.SrcAddrIp = fmsg.SrcAddr fmsg.SrcCountry = geoip.GetCountryByByteSlice(fmsg.SrcAddr) fmsg.SrcAs, fmsg.SrcAsn = geoip.GetASNByByteSlice(fmsg.SrcAddr) - fmsg.DstAddrIp = fmsg.DstAddr fmsg.DstCountry = geoip.GetCountryByByteSlice(fmsg.DstAddr) fmsg.DstAs, fmsg.DstAsn = geoip.GetASNByByteSlice(fmsg.DstAddr) if len(fmsg.AsPath) == 0 { @@ -74,10 +72,8 @@ func (p *ProtoProducer) Produce(msg interface{}, args *producer.ProduceArgs) (fl fmsg.TimeReceivedNs = tr fmsg.SamplerAddress = sa fmsg.LmsTargetIndex = LMS_TARGET_INDEX - fmsg.SrcAddrIp = fmsg.SrcAddr fmsg.SrcCountry = geoip.GetCountryByByteSlice(fmsg.SrcAddr) fmsg.SrcAs, fmsg.SrcAsn = geoip.GetASNByByteSlice(fmsg.SrcAddr) - fmsg.DstAddrIp = fmsg.DstAddr fmsg.DstCountry = geoip.GetCountryByByteSlice(fmsg.DstAddr) fmsg.DstAs, fmsg.DstAsn = geoip.GetASNByByteSlice(fmsg.DstAddr) if len(fmsg.AsPath) == 0 { @@ -92,10 +88,8 @@ func (p *ProtoProducer) Produce(msg interface{}, args *producer.ProduceArgs) (fl fmsg.TimeReceivedNs = tr fmsg.SamplerAddress = sa fmsg.LmsTargetIndex = LMS_TARGET_INDEX - fmsg.SrcAddrIp = fmsg.SrcAddr fmsg.SrcCountry = geoip.GetCountryByByteSlice(fmsg.SrcAddr) fmsg.SrcAs, fmsg.SrcAsn = geoip.GetASNByByteSlice(fmsg.SrcAddr) - fmsg.DstAddrIp = fmsg.DstAddr fmsg.DstCountry = geoip.GetCountryByByteSlice(fmsg.DstAddr) fmsg.DstAs, fmsg.DstAsn = geoip.GetASNByByteSlice(fmsg.DstAddr) if len(fmsg.AsPath) == 0 { @@ -110,10 +104,8 @@ func (p *ProtoProducer) Produce(msg interface{}, args *producer.ProduceArgs) (fl fmsg.TimeFlowStartNs = tr fmsg.TimeFlowEndNs = tr fmsg.LmsTargetIndex = LMS_TARGET_INDEX - fmsg.SrcAddrIp = fmsg.SrcAddr fmsg.SrcCountry = geoip.GetCountryByByteSlice(fmsg.SrcAddr) fmsg.SrcAs, fmsg.SrcAsn = geoip.GetASNByByteSlice(fmsg.SrcAddr) - fmsg.DstAddrIp = fmsg.DstAddr fmsg.DstCountry = geoip.GetCountryByByteSlice(fmsg.DstAddr) fmsg.DstAs, fmsg.DstAsn = geoip.GetASNByByteSlice(fmsg.DstAddr) if len(fmsg.AsPath) == 0 {