From 9e53c6987700735063dccae15ef554ad0f129a46 Mon Sep 17 00:00:00 2001 From: "alex.dibert" Date: Wed, 11 Sep 2024 17:06:45 +0200 Subject: [PATCH] [FEG-1381] Add proxy_protocol_tlv_processor filter api --- .../v3/proxy_protocol_tlv_processor.pb.go | 225 ++++++++++++++++++ ...roxy_protocol_tlv_processor.pb.validate.go | 147 ++++++++++++ ...proxy_protocol_tlv_processor_vtproto.pb.go | 137 +++++++++++ pkg/wellknown/wellknown.go | 2 + 4 files changed, 511 insertions(+) create mode 100755 envoy/extensions/filters/http/proxy_protocol_tlv_processor/v3/proxy_protocol_tlv_processor.pb.go create mode 100755 envoy/extensions/filters/http/proxy_protocol_tlv_processor/v3/proxy_protocol_tlv_processor.pb.validate.go create mode 100755 envoy/extensions/filters/http/proxy_protocol_tlv_processor/v3/proxy_protocol_tlv_processor_vtproto.pb.go diff --git a/envoy/extensions/filters/http/proxy_protocol_tlv_processor/v3/proxy_protocol_tlv_processor.pb.go b/envoy/extensions/filters/http/proxy_protocol_tlv_processor/v3/proxy_protocol_tlv_processor.pb.go new file mode 100755 index 0000000000..37fcb96062 --- /dev/null +++ b/envoy/extensions/filters/http/proxy_protocol_tlv_processor/v3/proxy_protocol_tlv_processor.pb.go @@ -0,0 +1,225 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.30.0 +// protoc v5.26.1 +// source: envoy/extensions/filters/http/proxy_protocol_tlv_processor/v3/proxy_protocol_tlv_processor.proto + +package proxy_protocol_tlv_processorv3 + +import ( + _ "github.com/cncf/xds/go/udpa/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// ProxyProtocolTLVProcessor filter config. +// [#next-free-field: 6] +type ProxyProtocolTlvProcessor struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // A list of proxy protocol v2 tlvs to be considered by the filter. + // Tlvs not mentioned in the list will be ignored. + // The filter is a noop if this list is empty. + Tlvs []uint32 `protobuf:"varint,1,rep,packed,name=tlvs,proto3" json:"tlvs,omitempty"` + // If true tlvs will be base64 encoded and set as an http header each + SetHeaders bool `protobuf:"varint,2,opt,name=set_headers,json=setHeaders,proto3" json:"set_headers,omitempty"` + // If true tlvs will be set a filter dynamic metadata + SetMetadata bool `protobuf:"varint,3,opt,name=set_metadata,json=setMetadata,proto3" json:"set_metadata,omitempty"` + // A prefix to the header names. + // The header name for a tlv will be header_prefix + tlv.type. + // If not set defaults to `ppv2_tlv_`. + HeaderPrefix string `protobuf:"bytes,4,opt,name=header_prefix,json=headerPrefix,proto3" json:"header_prefix,omitempty"` + // A metadata namespace where tlv values are set. + // If not set defaults to `envoy.filters.http.proxy_protocol_tlv_processor`. + MetadataNamespace string `protobuf:"bytes,5,opt,name=metadata_namespace,json=metadataNamespace,proto3" json:"metadata_namespace,omitempty"` +} + +func (x *ProxyProtocolTlvProcessor) Reset() { + *x = ProxyProtocolTlvProcessor{} + if protoimpl.UnsafeEnabled { + mi := &file_envoy_extensions_filters_http_proxy_protocol_tlv_processor_v3_proxy_protocol_tlv_processor_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ProxyProtocolTlvProcessor) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ProxyProtocolTlvProcessor) ProtoMessage() {} + +func (x *ProxyProtocolTlvProcessor) ProtoReflect() protoreflect.Message { + mi := &file_envoy_extensions_filters_http_proxy_protocol_tlv_processor_v3_proxy_protocol_tlv_processor_proto_msgTypes[0] + 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 ProxyProtocolTlvProcessor.ProtoReflect.Descriptor instead. +func (*ProxyProtocolTlvProcessor) Descriptor() ([]byte, []int) { + return file_envoy_extensions_filters_http_proxy_protocol_tlv_processor_v3_proxy_protocol_tlv_processor_proto_rawDescGZIP(), []int{0} +} + +func (x *ProxyProtocolTlvProcessor) GetTlvs() []uint32 { + if x != nil { + return x.Tlvs + } + return nil +} + +func (x *ProxyProtocolTlvProcessor) GetSetHeaders() bool { + if x != nil { + return x.SetHeaders + } + return false +} + +func (x *ProxyProtocolTlvProcessor) GetSetMetadata() bool { + if x != nil { + return x.SetMetadata + } + return false +} + +func (x *ProxyProtocolTlvProcessor) GetHeaderPrefix() string { + if x != nil { + return x.HeaderPrefix + } + return "" +} + +func (x *ProxyProtocolTlvProcessor) GetMetadataNamespace() string { + if x != nil { + return x.MetadataNamespace + } + return "" +} + +var File_envoy_extensions_filters_http_proxy_protocol_tlv_processor_v3_proxy_protocol_tlv_processor_proto protoreflect.FileDescriptor + +var file_envoy_extensions_filters_http_proxy_protocol_tlv_processor_v3_proxy_protocol_tlv_processor_proto_rawDesc = []byte{ + 0x0a, 0x60, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, + 0x6e, 0x73, 0x2f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x73, 0x2f, 0x68, 0x74, 0x74, 0x70, 0x2f, + 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x5f, 0x74, + 0x6c, 0x76, 0x5f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x2f, 0x76, 0x33, 0x2f, + 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x5f, 0x74, + 0x6c, 0x76, 0x5f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x12, 0x3d, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, + 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x73, 0x2e, 0x68, 0x74, 0x74, + 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, + 0x5f, 0x74, 0x6c, 0x76, 0x5f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x2e, 0x76, + 0x33, 0x1a, 0x1d, 0x75, 0x64, 0x70, 0x61, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x22, 0xc7, 0x01, 0x0a, 0x19, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, + 0x6f, 0x6c, 0x54, 0x6c, 0x76, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x12, 0x12, + 0x0a, 0x04, 0x74, 0x6c, 0x76, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0d, 0x52, 0x04, 0x74, 0x6c, + 0x76, 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x65, 0x74, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, + 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x73, 0x65, 0x74, 0x48, 0x65, 0x61, 0x64, + 0x65, 0x72, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x65, 0x74, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x73, 0x65, 0x74, 0x4d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x23, 0x0a, 0x0d, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, + 0x5f, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x68, + 0x65, 0x61, 0x64, 0x65, 0x72, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x12, 0x2d, 0x0a, 0x12, 0x6d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, + 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, + 0x61, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x42, 0xfd, 0x01, 0xba, 0x80, 0xc8, + 0xd1, 0x06, 0x02, 0x10, 0x01, 0x0a, 0x4b, 0x69, 0x6f, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, + 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x65, 0x78, 0x74, 0x65, 0x6e, + 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x73, 0x2e, 0x68, 0x74, + 0x74, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, + 0x6c, 0x5f, 0x74, 0x6c, 0x76, 0x5f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x2e, + 0x76, 0x33, 0x42, 0x1e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, + 0x6c, 0x54, 0x6c, 0x76, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x50, 0x72, 0x6f, + 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x83, 0x01, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x67, 0x6f, 0x2d, + 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x65, 0x6e, + 0x76, 0x6f, 0x79, 0x2f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x66, + 0x69, 0x6c, 0x74, 0x65, 0x72, 0x73, 0x2f, 0x68, 0x74, 0x74, 0x70, 0x2f, 0x70, 0x72, 0x6f, 0x78, + 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x5f, 0x74, 0x6c, 0x76, 0x5f, 0x70, + 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x2f, 0x76, 0x33, 0x3b, 0x70, 0x72, 0x6f, 0x78, + 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x5f, 0x74, 0x6c, 0x76, 0x5f, 0x70, + 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x76, 0x33, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, +} + +var ( + file_envoy_extensions_filters_http_proxy_protocol_tlv_processor_v3_proxy_protocol_tlv_processor_proto_rawDescOnce sync.Once + file_envoy_extensions_filters_http_proxy_protocol_tlv_processor_v3_proxy_protocol_tlv_processor_proto_rawDescData = file_envoy_extensions_filters_http_proxy_protocol_tlv_processor_v3_proxy_protocol_tlv_processor_proto_rawDesc +) + +func file_envoy_extensions_filters_http_proxy_protocol_tlv_processor_v3_proxy_protocol_tlv_processor_proto_rawDescGZIP() []byte { + file_envoy_extensions_filters_http_proxy_protocol_tlv_processor_v3_proxy_protocol_tlv_processor_proto_rawDescOnce.Do(func() { + file_envoy_extensions_filters_http_proxy_protocol_tlv_processor_v3_proxy_protocol_tlv_processor_proto_rawDescData = protoimpl.X.CompressGZIP(file_envoy_extensions_filters_http_proxy_protocol_tlv_processor_v3_proxy_protocol_tlv_processor_proto_rawDescData) + }) + return file_envoy_extensions_filters_http_proxy_protocol_tlv_processor_v3_proxy_protocol_tlv_processor_proto_rawDescData +} + +var file_envoy_extensions_filters_http_proxy_protocol_tlv_processor_v3_proxy_protocol_tlv_processor_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_envoy_extensions_filters_http_proxy_protocol_tlv_processor_v3_proxy_protocol_tlv_processor_proto_goTypes = []interface{}{ + (*ProxyProtocolTlvProcessor)(nil), // 0: envoy.extensions.filters.http.proxy_protocol_tlv_processor.v3.ProxyProtocolTlvProcessor +} +var file_envoy_extensions_filters_http_proxy_protocol_tlv_processor_v3_proxy_protocol_tlv_processor_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] 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 +} + +func init() { + file_envoy_extensions_filters_http_proxy_protocol_tlv_processor_v3_proxy_protocol_tlv_processor_proto_init() +} +func file_envoy_extensions_filters_http_proxy_protocol_tlv_processor_v3_proxy_protocol_tlv_processor_proto_init() { + if File_envoy_extensions_filters_http_proxy_protocol_tlv_processor_v3_proxy_protocol_tlv_processor_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_envoy_extensions_filters_http_proxy_protocol_tlv_processor_v3_proxy_protocol_tlv_processor_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ProxyProtocolTlvProcessor); 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{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_envoy_extensions_filters_http_proxy_protocol_tlv_processor_v3_proxy_protocol_tlv_processor_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_envoy_extensions_filters_http_proxy_protocol_tlv_processor_v3_proxy_protocol_tlv_processor_proto_goTypes, + DependencyIndexes: file_envoy_extensions_filters_http_proxy_protocol_tlv_processor_v3_proxy_protocol_tlv_processor_proto_depIdxs, + MessageInfos: file_envoy_extensions_filters_http_proxy_protocol_tlv_processor_v3_proxy_protocol_tlv_processor_proto_msgTypes, + }.Build() + File_envoy_extensions_filters_http_proxy_protocol_tlv_processor_v3_proxy_protocol_tlv_processor_proto = out.File + file_envoy_extensions_filters_http_proxy_protocol_tlv_processor_v3_proxy_protocol_tlv_processor_proto_rawDesc = nil + file_envoy_extensions_filters_http_proxy_protocol_tlv_processor_v3_proxy_protocol_tlv_processor_proto_goTypes = nil + file_envoy_extensions_filters_http_proxy_protocol_tlv_processor_v3_proxy_protocol_tlv_processor_proto_depIdxs = nil +} diff --git a/envoy/extensions/filters/http/proxy_protocol_tlv_processor/v3/proxy_protocol_tlv_processor.pb.validate.go b/envoy/extensions/filters/http/proxy_protocol_tlv_processor/v3/proxy_protocol_tlv_processor.pb.validate.go new file mode 100755 index 0000000000..78857a0193 --- /dev/null +++ b/envoy/extensions/filters/http/proxy_protocol_tlv_processor/v3/proxy_protocol_tlv_processor.pb.validate.go @@ -0,0 +1,147 @@ +//go:build !disable_pgv +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: envoy/extensions/filters/http/proxy_protocol_tlv_processor/v3/proxy_protocol_tlv_processor.proto + +package proxy_protocol_tlv_processorv3 + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on ProxyProtocolTlvProcessor with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *ProxyProtocolTlvProcessor) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ProxyProtocolTlvProcessor with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ProxyProtocolTlvProcessorMultiError, or nil if none found. +func (m *ProxyProtocolTlvProcessor) ValidateAll() error { + return m.validate(true) +} + +func (m *ProxyProtocolTlvProcessor) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for SetHeaders + + // no validation rules for SetMetadata + + // no validation rules for HeaderPrefix + + // no validation rules for MetadataNamespace + + if len(errors) > 0 { + return ProxyProtocolTlvProcessorMultiError(errors) + } + + return nil +} + +// ProxyProtocolTlvProcessorMultiError is an error wrapping multiple validation +// errors returned by ProxyProtocolTlvProcessor.ValidateAll() if the +// designated constraints aren't met. +type ProxyProtocolTlvProcessorMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ProxyProtocolTlvProcessorMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ProxyProtocolTlvProcessorMultiError) AllErrors() []error { return m } + +// ProxyProtocolTlvProcessorValidationError is the validation error returned by +// ProxyProtocolTlvProcessor.Validate if the designated constraints aren't met. +type ProxyProtocolTlvProcessorValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ProxyProtocolTlvProcessorValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ProxyProtocolTlvProcessorValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ProxyProtocolTlvProcessorValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ProxyProtocolTlvProcessorValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ProxyProtocolTlvProcessorValidationError) ErrorName() string { + return "ProxyProtocolTlvProcessorValidationError" +} + +// Error satisfies the builtin error interface +func (e ProxyProtocolTlvProcessorValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sProxyProtocolTlvProcessor.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ProxyProtocolTlvProcessorValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ProxyProtocolTlvProcessorValidationError{} diff --git a/envoy/extensions/filters/http/proxy_protocol_tlv_processor/v3/proxy_protocol_tlv_processor_vtproto.pb.go b/envoy/extensions/filters/http/proxy_protocol_tlv_processor/v3/proxy_protocol_tlv_processor_vtproto.pb.go new file mode 100755 index 0000000000..f04551e276 --- /dev/null +++ b/envoy/extensions/filters/http/proxy_protocol_tlv_processor/v3/proxy_protocol_tlv_processor_vtproto.pb.go @@ -0,0 +1,137 @@ +//go:build vtprotobuf +// +build vtprotobuf + +// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. +// source: envoy/extensions/filters/http/proxy_protocol_tlv_processor/v3/proxy_protocol_tlv_processor.proto + +package proxy_protocol_tlv_processorv3 + +import ( + protohelpers "github.com/planetscale/vtprotobuf/protohelpers" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +func (m *ProxyProtocolTlvProcessor) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ProxyProtocolTlvProcessor) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *ProxyProtocolTlvProcessor) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.MetadataNamespace) > 0 { + i -= len(m.MetadataNamespace) + copy(dAtA[i:], m.MetadataNamespace) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.MetadataNamespace))) + i-- + dAtA[i] = 0x2a + } + if len(m.HeaderPrefix) > 0 { + i -= len(m.HeaderPrefix) + copy(dAtA[i:], m.HeaderPrefix) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.HeaderPrefix))) + i-- + dAtA[i] = 0x22 + } + if m.SetMetadata { + i-- + if m.SetMetadata { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x18 + } + if m.SetHeaders { + i-- + if m.SetHeaders { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } + if len(m.Tlvs) > 0 { + var pksize2 int + for _, num := range m.Tlvs { + pksize2 += protohelpers.SizeOfVarint(uint64(num)) + } + i -= pksize2 + j1 := i + for _, num := range m.Tlvs { + for num >= 1<<7 { + dAtA[j1] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j1++ + } + dAtA[j1] = uint8(num) + j1++ + } + i = protohelpers.EncodeVarint(dAtA, i, uint64(pksize2)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ProxyProtocolTlvProcessor) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Tlvs) > 0 { + l = 0 + for _, e := range m.Tlvs { + l += protohelpers.SizeOfVarint(uint64(e)) + } + n += 1 + protohelpers.SizeOfVarint(uint64(l)) + l + } + if m.SetHeaders { + n += 2 + } + if m.SetMetadata { + n += 2 + } + l = len(m.HeaderPrefix) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.MetadataNamespace) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} diff --git a/pkg/wellknown/wellknown.go b/pkg/wellknown/wellknown.go index 4d2f5b6e3d..cc1553f82c 100644 --- a/pkg/wellknown/wellknown.go +++ b/pkg/wellknown/wellknown.go @@ -58,6 +58,8 @@ const ( HTTPGRPCStats = "envoy.filters.http.grpc_stats" // HTTP WASM filter HTTPWasm = "envoy.extensions.filters.http.wasm.v3.Wasm" + // ProxyProtocolTlvProcessor sets ppv2 tlvs as http headers and/or l7 dynamic metadata + ProxyProtocolTlvProcessor = "envoy.filters.http.proxy_protocol_tlv_processor" ) // Network filter names