From 8875c82648bb43f17362455ad8bedb9ad24ad30d Mon Sep 17 00:00:00 2001 From: guillaumemichel Date: Fri, 17 Jan 2025 11:59:49 +0100 Subject: [PATCH] fix: ipns protobuf namespace conflict --- CHANGELOG.md | 2 +- ipns/pb/Makefile | 31 +++ ipns/pb/ipns-record.pb.go | 270 ------------------- ipns/pb/record.pb.go | 272 ++++++++++++++++++++ ipns/pb/{ipns-record.proto => record.proto} | 0 ipns/record.go | 1 - 6 files changed, 304 insertions(+), 272 deletions(-) create mode 100644 ipns/pb/Makefile delete mode 100644 ipns/pb/ipns-record.pb.go create mode 100644 ipns/pb/record.pb.go rename ipns/pb/{ipns-record.proto => record.proto} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f98ac052..fbc1caed9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,7 +29,7 @@ The following emojis are used to highlight certain changes: ### Fixed - `gateway` Fix redirect URLs for subdirectories with characters that need escaping. [#779](https://github.com/ipfs/boxo/pull/779) -- `ipns` Defined a `go_package` name in `ipns-record.proto` to avoid protobuf conflicts [#789](https://github.com/ipfs/boxo/pull/789) +- `ipns` Fix `ipns` protobuf namespace conflicts by using full package name `github.com/ipfs/boxo/ipns/pb/record.proto` instead of the generic `record.proto` [#794](https://github.com/ipfs/boxo/pull/794) ### Security diff --git a/ipns/pb/Makefile b/ipns/pb/Makefile new file mode 100644 index 000000000..dead1fee2 --- /dev/null +++ b/ipns/pb/Makefile @@ -0,0 +1,31 @@ +# This Makefile is designed to work around namespace conflicts that occur when +# multiple repositories depend on .proto files with generic filenames. Due to +# the way protobuf registers files (e.g., foo.proto or pb/foo.proto), naming +# collisions can occur when the same filename is used across different +# packages. +# +# The only way to generate a *.pb.go file that includes the full package path +# (e.g., github.com/org/repo/pb/foo.proto) is to place the .proto file in a +# directory structure that mirrors its package path. +# +# References: +# * https://protobuf.dev/reference/go/faq#namespace-conflict +# * https://github.com/golang/protobuf/issues/1122#issuecomment-2045945265 + +PKG_PATH = github.com/ipfs/boxo/ipns/pb +PROTONAME = record +PROTOFILE = ${PROTONAME}.proto + +all: clean build + +build: + mkdir -p ${PKG_PATH} + cp ${PROTOFILE} ${PKG_PATH} + protoc --go_out=. ${PKG_PATH}/${PROTOFILE} + mv ${PKG_PATH}/${PROTONAME}.pb.go . + rm -rf $(firstword $(subst /, ,${PKG_PATH})) + +clean: + rm -f *.pb.go + +.PHONY: all build clean diff --git a/ipns/pb/ipns-record.pb.go b/ipns/pb/ipns-record.pb.go deleted file mode 100644 index 40ffa56ed..000000000 --- a/ipns/pb/ipns-record.pb.go +++ /dev/null @@ -1,270 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.0 -// protoc v3.21.12 -// source: ipns-record.proto - -package pb - -import ( - 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) -) - -type IpnsRecord_ValidityType int32 - -const ( - IpnsRecord_EOL IpnsRecord_ValidityType = 0 -) - -// Enum value maps for IpnsRecord_ValidityType. -var ( - IpnsRecord_ValidityType_name = map[int32]string{ - 0: "EOL", - } - IpnsRecord_ValidityType_value = map[string]int32{ - "EOL": 0, - } -) - -func (x IpnsRecord_ValidityType) Enum() *IpnsRecord_ValidityType { - p := new(IpnsRecord_ValidityType) - *p = x - return p -} - -func (x IpnsRecord_ValidityType) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (IpnsRecord_ValidityType) Descriptor() protoreflect.EnumDescriptor { - return file_ipns_record_proto_enumTypes[0].Descriptor() -} - -func (IpnsRecord_ValidityType) Type() protoreflect.EnumType { - return &file_ipns_record_proto_enumTypes[0] -} - -func (x IpnsRecord_ValidityType) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use IpnsRecord_ValidityType.Descriptor instead. -func (IpnsRecord_ValidityType) EnumDescriptor() ([]byte, []int) { - return file_ipns_record_proto_rawDescGZIP(), []int{0, 0} -} - -// https://specs.ipfs.tech/ipns/ipns-record/#record-serialization-format -type IpnsRecord struct { - state protoimpl.MessageState `protogen:"open.v1"` - // 1-6 are legacy fields used only in V1+V2 records - Value []byte `protobuf:"bytes,1,opt,name=value,proto3,oneof" json:"value,omitempty"` - SignatureV1 []byte `protobuf:"bytes,2,opt,name=signatureV1,proto3,oneof" json:"signatureV1,omitempty"` - ValidityType *IpnsRecord_ValidityType `protobuf:"varint,3,opt,name=validityType,proto3,enum=github.com.boxo.ipns.pb.IpnsRecord_ValidityType,oneof" json:"validityType,omitempty"` - Validity []byte `protobuf:"bytes,4,opt,name=validity,proto3,oneof" json:"validity,omitempty"` - Sequence *uint64 `protobuf:"varint,5,opt,name=sequence,proto3,oneof" json:"sequence,omitempty"` - Ttl *uint64 `protobuf:"varint,6,opt,name=ttl,proto3,oneof" json:"ttl,omitempty"` - // 7-9 are V2 records - PubKey []byte `protobuf:"bytes,7,opt,name=pubKey,proto3,oneof" json:"pubKey,omitempty"` - SignatureV2 []byte `protobuf:"bytes,8,opt,name=signatureV2,proto3,oneof" json:"signatureV2,omitempty"` - Data []byte `protobuf:"bytes,9,opt,name=data,proto3,oneof" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *IpnsRecord) Reset() { - *x = IpnsRecord{} - mi := &file_ipns_record_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *IpnsRecord) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*IpnsRecord) ProtoMessage() {} - -func (x *IpnsRecord) ProtoReflect() protoreflect.Message { - mi := &file_ipns_record_proto_msgTypes[0] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use IpnsRecord.ProtoReflect.Descriptor instead. -func (*IpnsRecord) Descriptor() ([]byte, []int) { - return file_ipns_record_proto_rawDescGZIP(), []int{0} -} - -func (x *IpnsRecord) GetValue() []byte { - if x != nil { - return x.Value - } - return nil -} - -func (x *IpnsRecord) GetSignatureV1() []byte { - if x != nil { - return x.SignatureV1 - } - return nil -} - -func (x *IpnsRecord) GetValidityType() IpnsRecord_ValidityType { - if x != nil && x.ValidityType != nil { - return *x.ValidityType - } - return IpnsRecord_EOL -} - -func (x *IpnsRecord) GetValidity() []byte { - if x != nil { - return x.Validity - } - return nil -} - -func (x *IpnsRecord) GetSequence() uint64 { - if x != nil && x.Sequence != nil { - return *x.Sequence - } - return 0 -} - -func (x *IpnsRecord) GetTtl() uint64 { - if x != nil && x.Ttl != nil { - return *x.Ttl - } - return 0 -} - -func (x *IpnsRecord) GetPubKey() []byte { - if x != nil { - return x.PubKey - } - return nil -} - -func (x *IpnsRecord) GetSignatureV2() []byte { - if x != nil { - return x.SignatureV2 - } - return nil -} - -func (x *IpnsRecord) GetData() []byte { - if x != nil { - return x.Data - } - return nil -} - -var File_ipns_record_proto protoreflect.FileDescriptor - -var file_ipns_record_proto_rawDesc = []byte{ - 0x0a, 0x11, 0x69, 0x70, 0x6e, 0x73, 0x2d, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x12, 0x17, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, - 0x62, 0x6f, 0x78, 0x6f, 0x2e, 0x69, 0x70, 0x6e, 0x73, 0x2e, 0x70, 0x62, 0x22, 0xe9, 0x03, 0x0a, - 0x0a, 0x49, 0x70, 0x6e, 0x73, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x19, 0x0a, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x88, 0x01, 0x01, 0x12, 0x25, 0x0a, 0x0b, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, - 0x75, 0x72, 0x65, 0x56, 0x31, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x01, 0x52, 0x0b, 0x73, - 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x56, 0x31, 0x88, 0x01, 0x01, 0x12, 0x59, 0x0a, - 0x0c, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x69, 0x74, 0x79, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0e, 0x32, 0x30, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2e, 0x62, 0x6f, 0x78, 0x6f, 0x2e, 0x69, 0x70, 0x6e, 0x73, 0x2e, 0x70, 0x62, 0x2e, 0x49, 0x70, - 0x6e, 0x73, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x69, 0x74, - 0x79, 0x54, 0x79, 0x70, 0x65, 0x48, 0x02, 0x52, 0x0c, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x69, 0x74, - 0x79, 0x54, 0x79, 0x70, 0x65, 0x88, 0x01, 0x01, 0x12, 0x1f, 0x0a, 0x08, 0x76, 0x61, 0x6c, 0x69, - 0x64, 0x69, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x03, 0x52, 0x08, 0x76, 0x61, - 0x6c, 0x69, 0x64, 0x69, 0x74, 0x79, 0x88, 0x01, 0x01, 0x12, 0x1f, 0x0a, 0x08, 0x73, 0x65, 0x71, - 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x48, 0x04, 0x52, 0x08, 0x73, - 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x88, 0x01, 0x01, 0x12, 0x15, 0x0a, 0x03, 0x74, 0x74, - 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x48, 0x05, 0x52, 0x03, 0x74, 0x74, 0x6c, 0x88, 0x01, - 0x01, 0x12, 0x1b, 0x0a, 0x06, 0x70, 0x75, 0x62, 0x4b, 0x65, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, - 0x0c, 0x48, 0x06, 0x52, 0x06, 0x70, 0x75, 0x62, 0x4b, 0x65, 0x79, 0x88, 0x01, 0x01, 0x12, 0x25, - 0x0a, 0x0b, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x56, 0x32, 0x18, 0x08, 0x20, - 0x01, 0x28, 0x0c, 0x48, 0x07, 0x52, 0x0b, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, - 0x56, 0x32, 0x88, 0x01, 0x01, 0x12, 0x17, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x09, 0x20, - 0x01, 0x28, 0x0c, 0x48, 0x08, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x88, 0x01, 0x01, 0x22, 0x17, - 0x0a, 0x0c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x69, 0x74, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x07, - 0x0a, 0x03, 0x45, 0x4f, 0x4c, 0x10, 0x00, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x42, 0x0e, 0x0a, 0x0c, 0x5f, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x56, - 0x31, 0x42, 0x0f, 0x0a, 0x0d, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x69, 0x74, 0x79, 0x54, 0x79, - 0x70, 0x65, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x69, 0x74, 0x79, 0x42, - 0x0b, 0x0a, 0x09, 0x5f, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x42, 0x06, 0x0a, 0x04, - 0x5f, 0x74, 0x74, 0x6c, 0x42, 0x09, 0x0a, 0x07, 0x5f, 0x70, 0x75, 0x62, 0x4b, 0x65, 0x79, 0x42, - 0x0e, 0x0a, 0x0c, 0x5f, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x56, 0x32, 0x42, - 0x07, 0x0a, 0x05, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x42, 0x1e, 0x5a, 0x1c, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x70, 0x66, 0x73, 0x2f, 0x62, 0x6f, 0x78, 0x6f, - 0x2f, 0x69, 0x70, 0x6e, 0x73, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_ipns_record_proto_rawDescOnce sync.Once - file_ipns_record_proto_rawDescData = file_ipns_record_proto_rawDesc -) - -func file_ipns_record_proto_rawDescGZIP() []byte { - file_ipns_record_proto_rawDescOnce.Do(func() { - file_ipns_record_proto_rawDescData = protoimpl.X.CompressGZIP(file_ipns_record_proto_rawDescData) - }) - return file_ipns_record_proto_rawDescData -} - -var file_ipns_record_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_ipns_record_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_ipns_record_proto_goTypes = []any{ - (IpnsRecord_ValidityType)(0), // 0: github.com.boxo.ipns.pb.IpnsRecord.ValidityType - (*IpnsRecord)(nil), // 1: github.com.boxo.ipns.pb.IpnsRecord -} -var file_ipns_record_proto_depIdxs = []int32{ - 0, // 0: github.com.boxo.ipns.pb.IpnsRecord.validityType:type_name -> github.com.boxo.ipns.pb.IpnsRecord.ValidityType - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] 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 -} - -func init() { file_ipns_record_proto_init() } -func file_ipns_record_proto_init() { - if File_ipns_record_proto != nil { - return - } - file_ipns_record_proto_msgTypes[0].OneofWrappers = []any{} - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_ipns_record_proto_rawDesc, - NumEnums: 1, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_ipns_record_proto_goTypes, - DependencyIndexes: file_ipns_record_proto_depIdxs, - EnumInfos: file_ipns_record_proto_enumTypes, - MessageInfos: file_ipns_record_proto_msgTypes, - }.Build() - File_ipns_record_proto = out.File - file_ipns_record_proto_rawDesc = nil - file_ipns_record_proto_goTypes = nil - file_ipns_record_proto_depIdxs = nil -} diff --git a/ipns/pb/record.pb.go b/ipns/pb/record.pb.go new file mode 100644 index 000000000..526e12f17 --- /dev/null +++ b/ipns/pb/record.pb.go @@ -0,0 +1,272 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.3 +// protoc v5.29.2 +// source: github.com/ipfs/boxo/ipns/pb/record.proto + +package pb + +import ( + 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) +) + +type IpnsRecord_ValidityType int32 + +const ( + IpnsRecord_EOL IpnsRecord_ValidityType = 0 +) + +// Enum value maps for IpnsRecord_ValidityType. +var ( + IpnsRecord_ValidityType_name = map[int32]string{ + 0: "EOL", + } + IpnsRecord_ValidityType_value = map[string]int32{ + "EOL": 0, + } +) + +func (x IpnsRecord_ValidityType) Enum() *IpnsRecord_ValidityType { + p := new(IpnsRecord_ValidityType) + *p = x + return p +} + +func (x IpnsRecord_ValidityType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (IpnsRecord_ValidityType) Descriptor() protoreflect.EnumDescriptor { + return file_github_com_ipfs_boxo_ipns_pb_record_proto_enumTypes[0].Descriptor() +} + +func (IpnsRecord_ValidityType) Type() protoreflect.EnumType { + return &file_github_com_ipfs_boxo_ipns_pb_record_proto_enumTypes[0] +} + +func (x IpnsRecord_ValidityType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use IpnsRecord_ValidityType.Descriptor instead. +func (IpnsRecord_ValidityType) EnumDescriptor() ([]byte, []int) { + return file_github_com_ipfs_boxo_ipns_pb_record_proto_rawDescGZIP(), []int{0, 0} +} + +// https://specs.ipfs.tech/ipns/ipns-record/#record-serialization-format +type IpnsRecord struct { + state protoimpl.MessageState `protogen:"open.v1"` + // 1-6 are legacy fields used only in V1+V2 records + Value []byte `protobuf:"bytes,1,opt,name=value,proto3,oneof" json:"value,omitempty"` + SignatureV1 []byte `protobuf:"bytes,2,opt,name=signatureV1,proto3,oneof" json:"signatureV1,omitempty"` + ValidityType *IpnsRecord_ValidityType `protobuf:"varint,3,opt,name=validityType,proto3,enum=github.com.boxo.ipns.pb.IpnsRecord_ValidityType,oneof" json:"validityType,omitempty"` + Validity []byte `protobuf:"bytes,4,opt,name=validity,proto3,oneof" json:"validity,omitempty"` + Sequence *uint64 `protobuf:"varint,5,opt,name=sequence,proto3,oneof" json:"sequence,omitempty"` + Ttl *uint64 `protobuf:"varint,6,opt,name=ttl,proto3,oneof" json:"ttl,omitempty"` + // 7-9 are V2 records + PubKey []byte `protobuf:"bytes,7,opt,name=pubKey,proto3,oneof" json:"pubKey,omitempty"` + SignatureV2 []byte `protobuf:"bytes,8,opt,name=signatureV2,proto3,oneof" json:"signatureV2,omitempty"` + Data []byte `protobuf:"bytes,9,opt,name=data,proto3,oneof" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *IpnsRecord) Reset() { + *x = IpnsRecord{} + mi := &file_github_com_ipfs_boxo_ipns_pb_record_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *IpnsRecord) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IpnsRecord) ProtoMessage() {} + +func (x *IpnsRecord) ProtoReflect() protoreflect.Message { + mi := &file_github_com_ipfs_boxo_ipns_pb_record_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use IpnsRecord.ProtoReflect.Descriptor instead. +func (*IpnsRecord) Descriptor() ([]byte, []int) { + return file_github_com_ipfs_boxo_ipns_pb_record_proto_rawDescGZIP(), []int{0} +} + +func (x *IpnsRecord) GetValue() []byte { + if x != nil { + return x.Value + } + return nil +} + +func (x *IpnsRecord) GetSignatureV1() []byte { + if x != nil { + return x.SignatureV1 + } + return nil +} + +func (x *IpnsRecord) GetValidityType() IpnsRecord_ValidityType { + if x != nil && x.ValidityType != nil { + return *x.ValidityType + } + return IpnsRecord_EOL +} + +func (x *IpnsRecord) GetValidity() []byte { + if x != nil { + return x.Validity + } + return nil +} + +func (x *IpnsRecord) GetSequence() uint64 { + if x != nil && x.Sequence != nil { + return *x.Sequence + } + return 0 +} + +func (x *IpnsRecord) GetTtl() uint64 { + if x != nil && x.Ttl != nil { + return *x.Ttl + } + return 0 +} + +func (x *IpnsRecord) GetPubKey() []byte { + if x != nil { + return x.PubKey + } + return nil +} + +func (x *IpnsRecord) GetSignatureV2() []byte { + if x != nil { + return x.SignatureV2 + } + return nil +} + +func (x *IpnsRecord) GetData() []byte { + if x != nil { + return x.Data + } + return nil +} + +var File_github_com_ipfs_boxo_ipns_pb_record_proto protoreflect.FileDescriptor + +var file_github_com_ipfs_boxo_ipns_pb_record_proto_rawDesc = []byte{ + 0x0a, 0x29, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x70, 0x66, + 0x73, 0x2f, 0x62, 0x6f, 0x78, 0x6f, 0x2f, 0x69, 0x70, 0x6e, 0x73, 0x2f, 0x70, 0x62, 0x2f, 0x72, + 0x65, 0x63, 0x6f, 0x72, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x17, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x6f, 0x78, 0x6f, 0x2e, 0x69, 0x70, 0x6e, + 0x73, 0x2e, 0x70, 0x62, 0x22, 0xe9, 0x03, 0x0a, 0x0a, 0x49, 0x70, 0x6e, 0x73, 0x52, 0x65, 0x63, + 0x6f, 0x72, 0x64, 0x12, 0x19, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0c, 0x48, 0x00, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x88, 0x01, 0x01, 0x12, 0x25, + 0x0a, 0x0b, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x56, 0x31, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0c, 0x48, 0x01, 0x52, 0x0b, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, + 0x56, 0x31, 0x88, 0x01, 0x01, 0x12, 0x59, 0x0a, 0x0c, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x69, 0x74, + 0x79, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x30, 0x2e, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x6f, 0x78, 0x6f, 0x2e, 0x69, 0x70, + 0x6e, 0x73, 0x2e, 0x70, 0x62, 0x2e, 0x49, 0x70, 0x6e, 0x73, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, + 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x69, 0x74, 0x79, 0x54, 0x79, 0x70, 0x65, 0x48, 0x02, 0x52, + 0x0c, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x69, 0x74, 0x79, 0x54, 0x79, 0x70, 0x65, 0x88, 0x01, 0x01, + 0x12, 0x1f, 0x0a, 0x08, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x69, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x0c, 0x48, 0x03, 0x52, 0x08, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x69, 0x74, 0x79, 0x88, 0x01, + 0x01, 0x12, 0x1f, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x04, 0x48, 0x04, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x88, + 0x01, 0x01, 0x12, 0x15, 0x0a, 0x03, 0x74, 0x74, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x48, + 0x05, 0x52, 0x03, 0x74, 0x74, 0x6c, 0x88, 0x01, 0x01, 0x12, 0x1b, 0x0a, 0x06, 0x70, 0x75, 0x62, + 0x4b, 0x65, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x06, 0x52, 0x06, 0x70, 0x75, 0x62, + 0x4b, 0x65, 0x79, 0x88, 0x01, 0x01, 0x12, 0x25, 0x0a, 0x0b, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, + 0x75, 0x72, 0x65, 0x56, 0x32, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x07, 0x52, 0x0b, 0x73, + 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x56, 0x32, 0x88, 0x01, 0x01, 0x12, 0x17, 0x0a, + 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x08, 0x52, 0x04, 0x64, + 0x61, 0x74, 0x61, 0x88, 0x01, 0x01, 0x22, 0x17, 0x0a, 0x0c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x69, + 0x74, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x45, 0x4f, 0x4c, 0x10, 0x00, 0x42, + 0x08, 0x0a, 0x06, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x0e, 0x0a, 0x0c, 0x5f, 0x73, 0x69, + 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x56, 0x31, 0x42, 0x0f, 0x0a, 0x0d, 0x5f, 0x76, 0x61, + 0x6c, 0x69, 0x64, 0x69, 0x74, 0x79, 0x54, 0x79, 0x70, 0x65, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x76, + 0x61, 0x6c, 0x69, 0x64, 0x69, 0x74, 0x79, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x73, 0x65, 0x71, 0x75, + 0x65, 0x6e, 0x63, 0x65, 0x42, 0x06, 0x0a, 0x04, 0x5f, 0x74, 0x74, 0x6c, 0x42, 0x09, 0x0a, 0x07, + 0x5f, 0x70, 0x75, 0x62, 0x4b, 0x65, 0x79, 0x42, 0x0e, 0x0a, 0x0c, 0x5f, 0x73, 0x69, 0x67, 0x6e, + 0x61, 0x74, 0x75, 0x72, 0x65, 0x56, 0x32, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x64, 0x61, 0x74, 0x61, + 0x42, 0x1e, 0x5a, 0x1c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, + 0x70, 0x66, 0x73, 0x2f, 0x62, 0x6f, 0x78, 0x6f, 0x2f, 0x69, 0x70, 0x6e, 0x73, 0x2f, 0x70, 0x62, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_github_com_ipfs_boxo_ipns_pb_record_proto_rawDescOnce sync.Once + file_github_com_ipfs_boxo_ipns_pb_record_proto_rawDescData = file_github_com_ipfs_boxo_ipns_pb_record_proto_rawDesc +) + +func file_github_com_ipfs_boxo_ipns_pb_record_proto_rawDescGZIP() []byte { + file_github_com_ipfs_boxo_ipns_pb_record_proto_rawDescOnce.Do(func() { + file_github_com_ipfs_boxo_ipns_pb_record_proto_rawDescData = protoimpl.X.CompressGZIP(file_github_com_ipfs_boxo_ipns_pb_record_proto_rawDescData) + }) + return file_github_com_ipfs_boxo_ipns_pb_record_proto_rawDescData +} + +var file_github_com_ipfs_boxo_ipns_pb_record_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_github_com_ipfs_boxo_ipns_pb_record_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_github_com_ipfs_boxo_ipns_pb_record_proto_goTypes = []any{ + (IpnsRecord_ValidityType)(0), // 0: github.com.boxo.ipns.pb.IpnsRecord.ValidityType + (*IpnsRecord)(nil), // 1: github.com.boxo.ipns.pb.IpnsRecord +} +var file_github_com_ipfs_boxo_ipns_pb_record_proto_depIdxs = []int32{ + 0, // 0: github.com.boxo.ipns.pb.IpnsRecord.validityType:type_name -> github.com.boxo.ipns.pb.IpnsRecord.ValidityType + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] 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 +} + +func init() { file_github_com_ipfs_boxo_ipns_pb_record_proto_init() } +func file_github_com_ipfs_boxo_ipns_pb_record_proto_init() { + if File_github_com_ipfs_boxo_ipns_pb_record_proto != nil { + return + } + file_github_com_ipfs_boxo_ipns_pb_record_proto_msgTypes[0].OneofWrappers = []any{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_github_com_ipfs_boxo_ipns_pb_record_proto_rawDesc, + NumEnums: 1, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_github_com_ipfs_boxo_ipns_pb_record_proto_goTypes, + DependencyIndexes: file_github_com_ipfs_boxo_ipns_pb_record_proto_depIdxs, + EnumInfos: file_github_com_ipfs_boxo_ipns_pb_record_proto_enumTypes, + MessageInfos: file_github_com_ipfs_boxo_ipns_pb_record_proto_msgTypes, + }.Build() + File_github_com_ipfs_boxo_ipns_pb_record_proto = out.File + file_github_com_ipfs_boxo_ipns_pb_record_proto_rawDesc = nil + file_github_com_ipfs_boxo_ipns_pb_record_proto_goTypes = nil + file_github_com_ipfs_boxo_ipns_pb_record_proto_depIdxs = nil +} diff --git a/ipns/pb/ipns-record.proto b/ipns/pb/record.proto similarity index 100% rename from ipns/pb/ipns-record.proto rename to ipns/pb/record.proto diff --git a/ipns/record.go b/ipns/record.go index 147190a3b..d5eb5b3c4 100644 --- a/ipns/record.go +++ b/ipns/record.go @@ -1,4 +1,3 @@ -//go:generate protoc -I=pb --go_out=paths=source_relative:pb pb/ipns-record.proto package ipns import (