fengweiqiang 4 rokov pred
rodič
commit
e4d5e70b96

+ 0 - 4
udpdataclear/udpSensitiveWords/grpc_server/main.go

@@ -139,10 +139,6 @@ func (s *server) Search(ctx context.Context, in *proto_grpc.Request) (*proto_grp
 	return &proto_grpc.ResultSensitiveWords{SensitiveWords: rada}, nil
 }
 
-func (s *server) Registration(ctx context.Context, in *proto_grpc.NumberOfRegistrations) (*proto_grpc.RequestComplete, error) {
-	customizedCounterMetric.WithLabelValues("Registration").Inc()
-	return &proto_grpc.RequestComplete{Text: "ok"}, nil
-}
 
 type YAMLConfig struct {
 	MixdataMgoAddr  string `yaml:"mixdataMgoAddr"`

+ 19 - 151
udpdataclear/udpSensitiveWords/proto_grpc/sensitive_words.pb.go

@@ -174,100 +174,6 @@ func (x *ResultSensitiveWords) GetSensitiveWords() string {
 	return ""
 }
 
-type NumberOfRegistrations struct {
-	state         protoimpl.MessageState
-	sizeCache     protoimpl.SizeCache
-	unknownFields protoimpl.UnknownFields
-
-	Count uint32 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"`
-}
-
-func (x *NumberOfRegistrations) Reset() {
-	*x = NumberOfRegistrations{}
-	if protoimpl.UnsafeEnabled {
-		mi := &file_sensitive_words_proto_msgTypes[2]
-		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
-		ms.StoreMessageInfo(mi)
-	}
-}
-
-func (x *NumberOfRegistrations) String() string {
-	return protoimpl.X.MessageStringOf(x)
-}
-
-func (*NumberOfRegistrations) ProtoMessage() {}
-
-func (x *NumberOfRegistrations) ProtoReflect() protoreflect.Message {
-	mi := &file_sensitive_words_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 NumberOfRegistrations.ProtoReflect.Descriptor instead.
-func (*NumberOfRegistrations) Descriptor() ([]byte, []int) {
-	return file_sensitive_words_proto_rawDescGZIP(), []int{2}
-}
-
-func (x *NumberOfRegistrations) GetCount() uint32 {
-	if x != nil {
-		return x.Count
-	}
-	return 0
-}
-
-type RequestComplete struct {
-	state         protoimpl.MessageState
-	sizeCache     protoimpl.SizeCache
-	unknownFields protoimpl.UnknownFields
-
-	Text string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"`
-}
-
-func (x *RequestComplete) Reset() {
-	*x = RequestComplete{}
-	if protoimpl.UnsafeEnabled {
-		mi := &file_sensitive_words_proto_msgTypes[3]
-		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
-		ms.StoreMessageInfo(mi)
-	}
-}
-
-func (x *RequestComplete) String() string {
-	return protoimpl.X.MessageStringOf(x)
-}
-
-func (*RequestComplete) ProtoMessage() {}
-
-func (x *RequestComplete) ProtoReflect() protoreflect.Message {
-	mi := &file_sensitive_words_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 RequestComplete.ProtoReflect.Descriptor instead.
-func (*RequestComplete) Descriptor() ([]byte, []int) {
-	return file_sensitive_words_proto_rawDescGZIP(), []int{3}
-}
-
-func (x *RequestComplete) GetText() string {
-	if x != nil {
-		return x.Text
-	}
-	return ""
-}
-
 var File_sensitive_words_proto protoreflect.FileDescriptor
 
 var file_sensitive_words_proto_rawDesc = []byte{
@@ -282,27 +188,17 @@ var file_sensitive_words_proto_rawDesc = []byte{
 	0x69, 0x74, 0x69, 0x76, 0x65, 0x57, 0x6f, 0x72, 0x64, 0x73, 0x12, 0x26, 0x0a, 0x0e, 0x53, 0x65,
 	0x6e, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x57, 0x6f, 0x72, 0x64, 0x73, 0x18, 0x01, 0x20, 0x01,
 	0x28, 0x09, 0x52, 0x0e, 0x53, 0x65, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x57, 0x6f, 0x72,
-	0x64, 0x73, 0x22, 0x2d, 0x0a, 0x15, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x4f, 0x66, 0x52, 0x65,
-	0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x63,
-	0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e,
-	0x74, 0x22, 0x25, 0x0a, 0x0f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x70,
-	0x6c, 0x65, 0x74, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01,
-	0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x2a, 0x38, 0x0a, 0x0a, 0x43, 0x6f, 0x72, 0x70,
-	0x75, 0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x4c, 0x4c, 0x10, 0x00, 0x12,
-	0x09, 0x0a, 0x05, 0x42, 0x55, 0x59, 0x45, 0x52, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x41, 0x47,
-	0x45, 0x4e, 0x43, 0x59, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x57, 0x49, 0x4e, 0x4e, 0x45, 0x52,
-	0x10, 0x03, 0x32, 0xa1, 0x01, 0x0a, 0x0e, 0x53, 0x65, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65,
-	0x57, 0x6f, 0x72, 0x64, 0x73, 0x12, 0x3f, 0x0a, 0x06, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x12,
-	0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x5f, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x71,
-	0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x5f, 0x67, 0x72, 0x70,
-	0x63, 0x2e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x53, 0x65, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x76,
-	0x65, 0x57, 0x6f, 0x72, 0x64, 0x73, 0x12, 0x4e, 0x0a, 0x0c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74,
-	0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x21, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x5f, 0x67,
-	0x72, 0x70, 0x63, 0x2e, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x4f, 0x66, 0x52, 0x65, 0x67, 0x69,
-	0x73, 0x74, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x74,
-	0x6f, 0x5f, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x43, 0x6f,
-	0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x0d, 0x5a, 0x0b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x5f,
-	0x67, 0x72, 0x70, 0x63, 0x2f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x64, 0x73, 0x2a, 0x38, 0x0a, 0x0a, 0x43, 0x6f, 0x72, 0x70, 0x75, 0x73, 0x54, 0x79, 0x70, 0x65,
+	0x12, 0x07, 0x0a, 0x03, 0x41, 0x4c, 0x4c, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x42, 0x55, 0x59,
+	0x45, 0x52, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x41, 0x47, 0x45, 0x4e, 0x43, 0x59, 0x10, 0x02,
+	0x12, 0x0a, 0x0a, 0x06, 0x57, 0x49, 0x4e, 0x4e, 0x45, 0x52, 0x10, 0x03, 0x32, 0x51, 0x0a, 0x0e,
+	0x53, 0x65, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x57, 0x6f, 0x72, 0x64, 0x73, 0x12, 0x3f,
+	0x0a, 0x06, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x12, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
+	0x5f, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e,
+	0x70, 0x72, 0x6f, 0x74, 0x6f, 0x5f, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x73, 0x75, 0x6c,
+	0x74, 0x53, 0x65, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x57, 0x6f, 0x72, 0x64, 0x73, 0x42,
+	0x0d, 0x5a, 0x0b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x5f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x62, 0x06,
+	0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var (
@@ -318,22 +214,18 @@ func file_sensitive_words_proto_rawDescGZIP() []byte {
 }
 
 var file_sensitive_words_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
-var file_sensitive_words_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
+var file_sensitive_words_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
 var file_sensitive_words_proto_goTypes = []interface{}{
-	(CorpusType)(0),               // 0: proto_grpc.CorpusType
-	(*Request)(nil),               // 1: proto_grpc.Request
-	(*ResultSensitiveWords)(nil),  // 2: proto_grpc.ResultSensitiveWords
-	(*NumberOfRegistrations)(nil), // 3: proto_grpc.NumberOfRegistrations
-	(*RequestComplete)(nil),       // 4: proto_grpc.RequestComplete
+	(CorpusType)(0),              // 0: proto_grpc.CorpusType
+	(*Request)(nil),              // 1: proto_grpc.Request
+	(*ResultSensitiveWords)(nil), // 2: proto_grpc.ResultSensitiveWords
 }
 var file_sensitive_words_proto_depIdxs = []int32{
 	0, // 0: proto_grpc.Request.corpus:type_name -> proto_grpc.CorpusType
 	1, // 1: proto_grpc.SensitiveWords.Search:input_type -> proto_grpc.Request
-	3, // 2: proto_grpc.SensitiveWords.Registration:input_type -> proto_grpc.NumberOfRegistrations
-	2, // 3: proto_grpc.SensitiveWords.Search:output_type -> proto_grpc.ResultSensitiveWords
-	4, // 4: proto_grpc.SensitiveWords.Registration:output_type -> proto_grpc.RequestComplete
-	3, // [3:5] is the sub-list for method output_type
-	1, // [1:3] is the sub-list for method input_type
+	2, // 2: proto_grpc.SensitiveWords.Search:output_type -> proto_grpc.ResultSensitiveWords
+	2, // [2:3] is the sub-list for method output_type
+	1, // [1:2] is the sub-list for method input_type
 	1, // [1:1] is the sub-list for extension type_name
 	1, // [1:1] is the sub-list for extension extendee
 	0, // [0:1] is the sub-list for field type_name
@@ -369,30 +261,6 @@ func file_sensitive_words_proto_init() {
 				return nil
 			}
 		}
-		file_sensitive_words_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
-			switch v := v.(*NumberOfRegistrations); i {
-			case 0:
-				return &v.state
-			case 1:
-				return &v.sizeCache
-			case 2:
-				return &v.unknownFields
-			default:
-				return nil
-			}
-		}
-		file_sensitive_words_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
-			switch v := v.(*RequestComplete); i {
-			case 0:
-				return &v.state
-			case 1:
-				return &v.sizeCache
-			case 2:
-				return &v.unknownFields
-			default:
-				return nil
-			}
-		}
 	}
 	type x struct{}
 	out := protoimpl.TypeBuilder{
@@ -400,7 +268,7 @@ func file_sensitive_words_proto_init() {
 			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
 			RawDescriptor: file_sensitive_words_proto_rawDesc,
 			NumEnums:      1,
-			NumMessages:   4,
+			NumMessages:   2,
 			NumExtensions: 0,
 			NumServices:   1,
 		},

+ 0 - 36
udpdataclear/udpSensitiveWords/proto_grpc/sensitive_words_grpc.pb.go

@@ -19,7 +19,6 @@ const _ = grpc.SupportPackageIsVersion7
 // 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 SensitiveWordsClient interface {
 	Search(ctx context.Context, in *Request, opts ...grpc.CallOption) (*ResultSensitiveWords, error)
-	Registration(ctx context.Context, in *NumberOfRegistrations, opts ...grpc.CallOption) (*RequestComplete, error)
 }
 
 type sensitiveWordsClient struct {
@@ -39,21 +38,11 @@ func (c *sensitiveWordsClient) Search(ctx context.Context, in *Request, opts ...
 	return out, nil
 }
 
-func (c *sensitiveWordsClient) Registration(ctx context.Context, in *NumberOfRegistrations, opts ...grpc.CallOption) (*RequestComplete, error) {
-	out := new(RequestComplete)
-	err := c.cc.Invoke(ctx, "/proto_grpc.SensitiveWords/Registration", in, out, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return out, nil
-}
-
 // SensitiveWordsServer is the server API for SensitiveWords service.
 // All implementations must embed UnimplementedSensitiveWordsServer
 // for forward compatibility
 type SensitiveWordsServer interface {
 	Search(context.Context, *Request) (*ResultSensitiveWords, error)
-	Registration(context.Context, *NumberOfRegistrations) (*RequestComplete, error)
 	mustEmbedUnimplementedSensitiveWordsServer()
 }
 
@@ -64,9 +53,6 @@ type UnimplementedSensitiveWordsServer struct {
 func (UnimplementedSensitiveWordsServer) Search(context.Context, *Request) (*ResultSensitiveWords, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method Search not implemented")
 }
-func (UnimplementedSensitiveWordsServer) Registration(context.Context, *NumberOfRegistrations) (*RequestComplete, error) {
-	return nil, status.Errorf(codes.Unimplemented, "method Registration not implemented")
-}
 func (UnimplementedSensitiveWordsServer) mustEmbedUnimplementedSensitiveWordsServer() {}
 
 // UnsafeSensitiveWordsServer may be embedded to opt out of forward compatibility for this service.
@@ -98,24 +84,6 @@ func _SensitiveWords_Search_Handler(srv interface{}, ctx context.Context, dec fu
 	return interceptor(ctx, in, info, handler)
 }
 
-func _SensitiveWords_Registration_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(NumberOfRegistrations)
-	if err := dec(in); err != nil {
-		return nil, err
-	}
-	if interceptor == nil {
-		return srv.(SensitiveWordsServer).Registration(ctx, in)
-	}
-	info := &grpc.UnaryServerInfo{
-		Server:     srv,
-		FullMethod: "/proto_grpc.SensitiveWords/Registration",
-	}
-	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(SensitiveWordsServer).Registration(ctx, req.(*NumberOfRegistrations))
-	}
-	return interceptor(ctx, in, info, handler)
-}
-
 // SensitiveWords_ServiceDesc is the grpc.ServiceDesc for SensitiveWords service.
 // It's only intended for direct use with grpc.RegisterService,
 // and not to be introspected or modified (even as a copy)
@@ -127,10 +95,6 @@ var SensitiveWords_ServiceDesc = grpc.ServiceDesc{
 			MethodName: "Search",
 			Handler:    _SensitiveWords_Search_Handler,
 		},
-		{
-			MethodName: "Registration",
-			Handler:    _SensitiveWords_Registration_Handler,
-		},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "sensitive_words.proto",

+ 0 - 7
udpdataclear/udpSensitiveWords/protos/sensitive_words.proto

@@ -20,12 +20,5 @@ message ResultSensitiveWords{
 
 service SensitiveWords{
   rpc Search(Request) returns (ResultSensitiveWords);
-  rpc Registration(NumberOfRegistrations) returns (RequestComplete);
 }
 
-message NumberOfRegistrations{
-  uint32 count = 1;
-}
-message RequestComplete{
-  string text = 1;
-}

+ 1 - 1
udpdataclear/udpSensitiveWords/util/config.go

@@ -52,7 +52,7 @@ func InitC() {
 			log.Fatalf("did not connect: %s %v", v, err)
 		}
 		c := proto_grpc.NewSensitiveWordsClient(conn)
-		_, err = c.Registration(ctx, &proto_grpc.NumberOfRegistrations{Count: 1})
+		_, err = c.Search(ctx, &proto_grpc.Request{})
 		if err != nil {
 			log.Fatalln(err)
 		} else {

+ 34 - 2
udpdataclear/udpSensitiveWords/util/udpdata.go

@@ -134,8 +134,9 @@ func query_grpc(enterprise, findC string) string {
 			break
 		}
 	}
-
-	return strings.Join(result, ",")
+	rarr := handleData(result)
+	rstr := strings.Join(rarr, ",")
+	return rstr
 }
 
 func processUdpMsg(act byte, data []byte, ra *net.UDPAddr) {
@@ -179,3 +180,34 @@ func processUdpMsg(act byte, data []byte, ra *net.UDPAddr) {
 		log.Println(string(data))
 	}
 }
+func handleData(datas []string) []string {
+	del := map[int]bool{}
+	dataslen := len(datas)
+	for i := 0; i < dataslen; i++ {
+		if !del[i] {
+			for j := i + 1; j < dataslen; j++ {
+				jdata := datas[j]
+				idata := datas[i]
+				if len(jdata) > len(idata) && strings.Contains(jdata, idata) {
+					del[i] = true
+					break
+				} else if len(idata) > len(jdata) && strings.Contains(idata, jdata) {
+					del[j] = true
+					break
+				}
+			}
+		}
+	}
+	caplen := dataslen - len(del)
+	rdata := make([]string, caplen, caplen)
+	var m int
+	for i, v := range datas {
+		if !del[i] {
+			rdata[m] = v
+			m++
+		}
+	}
+
+	log.Println(rdata)
+	return rdata
+}