1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-17 14:37:02 +00:00

Update protobuf library to v2

There is a new protobuf library (and corresponding code generator) for
Go: google.golang.org/protobuf.

It is fairly compatible with the previous v1 API
(github.com/golang/protobuf), but there are some changes.

This patch adjusts the code and generated files to the new API.

The on-wire/on-disk format remains unchanged so this should be
transparent to the users.
This commit is contained in:
Alberto Bertogli
2020-05-16 10:12:51 +01:00
parent 5ec567b27e
commit 50986a7b7e
19 changed files with 1206 additions and 609 deletions

View File

@@ -11,7 +11,7 @@ import (
)
// Command to generate domaininfo.pb.go.
//go:generate protoc --go_out=. domaininfo.proto
//go:generate protoc --go_out=. --go_opt=paths=source_relative domaininfo.proto
// DB represents the persistent domain information database.
type DB struct {

View File

@@ -1,24 +1,29 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.23.0
// protoc v3.11.4
// source: domaininfo.proto
package domaininfo
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
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)
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type SecLevel int32
@@ -33,104 +38,204 @@ const (
SecLevel_TLS_SECURE SecLevel = 3
)
var SecLevel_name = map[int32]string{
0: "PLAIN",
1: "TLS_CLIENT",
2: "TLS_INSECURE",
3: "TLS_SECURE",
}
// Enum value maps for SecLevel.
var (
SecLevel_name = map[int32]string{
0: "PLAIN",
1: "TLS_CLIENT",
2: "TLS_INSECURE",
3: "TLS_SECURE",
}
SecLevel_value = map[string]int32{
"PLAIN": 0,
"TLS_CLIENT": 1,
"TLS_INSECURE": 2,
"TLS_SECURE": 3,
}
)
var SecLevel_value = map[string]int32{
"PLAIN": 0,
"TLS_CLIENT": 1,
"TLS_INSECURE": 2,
"TLS_SECURE": 3,
func (x SecLevel) Enum() *SecLevel {
p := new(SecLevel)
*p = x
return p
}
func (x SecLevel) String() string {
return proto.EnumName(SecLevel_name, int32(x))
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (SecLevel) Descriptor() protoreflect.EnumDescriptor {
return file_domaininfo_proto_enumTypes[0].Descriptor()
}
func (SecLevel) Type() protoreflect.EnumType {
return &file_domaininfo_proto_enumTypes[0]
}
func (x SecLevel) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use SecLevel.Descriptor instead.
func (SecLevel) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_622326b6f7a15daa, []int{0}
return file_domaininfo_proto_rawDescGZIP(), []int{0}
}
type Domain struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
// Security level for mail coming from this domain (they send to us).
IncomingSecLevel SecLevel `protobuf:"varint,2,opt,name=incoming_sec_level,json=incomingSecLevel,proto3,enum=domaininfo.SecLevel" json:"incoming_sec_level,omitempty"`
// Security level for mail going to this domain (we send to them).
OutgoingSecLevel SecLevel `protobuf:"varint,3,opt,name=outgoing_sec_level,json=outgoingSecLevel,proto3,enum=domaininfo.SecLevel" json:"outgoing_sec_level,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
OutgoingSecLevel SecLevel `protobuf:"varint,3,opt,name=outgoing_sec_level,json=outgoingSecLevel,proto3,enum=domaininfo.SecLevel" json:"outgoing_sec_level,omitempty"`
}
func (m *Domain) Reset() { *m = Domain{} }
func (m *Domain) String() string { return proto.CompactTextString(m) }
func (*Domain) ProtoMessage() {}
func (x *Domain) Reset() {
*x = Domain{}
if protoimpl.UnsafeEnabled {
mi := &file_domaininfo_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Domain) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Domain) ProtoMessage() {}
func (x *Domain) ProtoReflect() protoreflect.Message {
mi := &file_domaininfo_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 Domain.ProtoReflect.Descriptor instead.
func (*Domain) Descriptor() ([]byte, []int) {
return fileDescriptor_622326b6f7a15daa, []int{0}
return file_domaininfo_proto_rawDescGZIP(), []int{0}
}
func (m *Domain) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Domain.Unmarshal(m, b)
}
func (m *Domain) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Domain.Marshal(b, m, deterministic)
}
func (m *Domain) XXX_Merge(src proto.Message) {
xxx_messageInfo_Domain.Merge(m, src)
}
func (m *Domain) XXX_Size() int {
return xxx_messageInfo_Domain.Size(m)
}
func (m *Domain) XXX_DiscardUnknown() {
xxx_messageInfo_Domain.DiscardUnknown(m)
}
var xxx_messageInfo_Domain proto.InternalMessageInfo
func (m *Domain) GetName() string {
if m != nil {
return m.Name
func (x *Domain) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (m *Domain) GetIncomingSecLevel() SecLevel {
if m != nil {
return m.IncomingSecLevel
func (x *Domain) GetIncomingSecLevel() SecLevel {
if x != nil {
return x.IncomingSecLevel
}
return SecLevel_PLAIN
}
func (m *Domain) GetOutgoingSecLevel() SecLevel {
if m != nil {
return m.OutgoingSecLevel
func (x *Domain) GetOutgoingSecLevel() SecLevel {
if x != nil {
return x.OutgoingSecLevel
}
return SecLevel_PLAIN
}
func init() {
proto.RegisterEnum("domaininfo.SecLevel", SecLevel_name, SecLevel_value)
proto.RegisterType((*Domain)(nil), "domaininfo.Domain")
var File_domaininfo_proto protoreflect.FileDescriptor
var file_domaininfo_proto_rawDesc = []byte{
0x0a, 0x10, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x66, 0x6f, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x12, 0x0a, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x66, 0x6f, 0x22, 0xa4,
0x01, 0x0a, 0x06, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d,
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x42, 0x0a,
0x12, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x5f, 0x73, 0x65, 0x63, 0x5f, 0x6c, 0x65,
0x76, 0x65, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x64, 0x6f, 0x6d, 0x61,
0x69, 0x6e, 0x69, 0x6e, 0x66, 0x6f, 0x2e, 0x53, 0x65, 0x63, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x52,
0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x63, 0x4c, 0x65, 0x76, 0x65,
0x6c, 0x12, 0x42, 0x0a, 0x12, 0x6f, 0x75, 0x74, 0x67, 0x6f, 0x69, 0x6e, 0x67, 0x5f, 0x73, 0x65,
0x63, 0x5f, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e,
0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x66, 0x6f, 0x2e, 0x53, 0x65, 0x63, 0x4c, 0x65,
0x76, 0x65, 0x6c, 0x52, 0x10, 0x6f, 0x75, 0x74, 0x67, 0x6f, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x63,
0x4c, 0x65, 0x76, 0x65, 0x6c, 0x2a, 0x47, 0x0a, 0x08, 0x53, 0x65, 0x63, 0x4c, 0x65, 0x76, 0x65,
0x6c, 0x12, 0x09, 0x0a, 0x05, 0x50, 0x4c, 0x41, 0x49, 0x4e, 0x10, 0x00, 0x12, 0x0e, 0x0a, 0x0a,
0x54, 0x4c, 0x53, 0x5f, 0x43, 0x4c, 0x49, 0x45, 0x4e, 0x54, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c,
0x54, 0x4c, 0x53, 0x5f, 0x49, 0x4e, 0x53, 0x45, 0x43, 0x55, 0x52, 0x45, 0x10, 0x02, 0x12, 0x0e,
0x0a, 0x0a, 0x54, 0x4c, 0x53, 0x5f, 0x53, 0x45, 0x43, 0x55, 0x52, 0x45, 0x10, 0x03, 0x42, 0x30,
0x5a, 0x2e, 0x62, 0x6c, 0x69, 0x74, 0x69, 0x72, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x72,
0x2f, 0x67, 0x6f, 0x2f, 0x63, 0x68, 0x61, 0x73, 0x71, 0x75, 0x69, 0x64, 0x2f, 0x69, 0x6e, 0x74,
0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x66, 0x6f,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
func init() { proto.RegisterFile("domaininfo.proto", fileDescriptor_622326b6f7a15daa) }
var (
file_domaininfo_proto_rawDescOnce sync.Once
file_domaininfo_proto_rawDescData = file_domaininfo_proto_rawDesc
)
var fileDescriptor_622326b6f7a15daa = []byte{
// 190 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x48, 0xc9, 0xcf, 0x4d,
0xcc, 0xcc, 0xcb, 0xcc, 0x4b, 0xcb, 0xd7, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x42, 0x88,
0x28, 0x2d, 0x61, 0xe4, 0x62, 0x73, 0x01, 0x73, 0x85, 0x84, 0xb8, 0x58, 0xf2, 0x12, 0x73, 0x53,
0x25, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0xc0, 0x6c, 0x21, 0x27, 0x2e, 0xa1, 0xcc, 0xbc, 0xe4,
0xfc, 0xdc, 0xcc, 0xbc, 0xf4, 0xf8, 0xe2, 0xd4, 0xe4, 0xf8, 0x9c, 0xd4, 0xb2, 0xd4, 0x1c, 0x09,
0x26, 0x05, 0x46, 0x0d, 0x3e, 0x23, 0x11, 0x3d, 0x24, 0x93, 0x83, 0x53, 0x93, 0x7d, 0x40, 0x72,
0x41, 0x02, 0x30, 0xf5, 0x30, 0x11, 0x90, 0x19, 0xf9, 0xa5, 0x25, 0xe9, 0xf9, 0xa8, 0x66, 0x30,
0xe3, 0x33, 0x03, 0xa6, 0x1e, 0x26, 0xa2, 0xe5, 0xce, 0xc5, 0x01, 0x37, 0x8f, 0x93, 0x8b, 0x35,
0xc0, 0xc7, 0xd1, 0xd3, 0x4f, 0x80, 0x41, 0x88, 0x8f, 0x8b, 0x2b, 0xc4, 0x27, 0x38, 0xde, 0xd9,
0xc7, 0xd3, 0xd5, 0x2f, 0x44, 0x80, 0x51, 0x48, 0x80, 0x8b, 0x07, 0xc4, 0xf7, 0xf4, 0x0b, 0x76,
0x75, 0x0e, 0x0d, 0x72, 0x15, 0x60, 0x82, 0xa9, 0x80, 0xf2, 0x99, 0x93, 0xd8, 0xc0, 0x41, 0x60,
0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x2c, 0x78, 0x65, 0x5b, 0x16, 0x01, 0x00, 0x00,
func file_domaininfo_proto_rawDescGZIP() []byte {
file_domaininfo_proto_rawDescOnce.Do(func() {
file_domaininfo_proto_rawDescData = protoimpl.X.CompressGZIP(file_domaininfo_proto_rawDescData)
})
return file_domaininfo_proto_rawDescData
}
var file_domaininfo_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_domaininfo_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_domaininfo_proto_goTypes = []interface{}{
(SecLevel)(0), // 0: domaininfo.SecLevel
(*Domain)(nil), // 1: domaininfo.Domain
}
var file_domaininfo_proto_depIdxs = []int32{
0, // 0: domaininfo.Domain.incoming_sec_level:type_name -> domaininfo.SecLevel
0, // 1: domaininfo.Domain.outgoing_sec_level:type_name -> domaininfo.SecLevel
2, // [2:2] is the sub-list for method output_type
2, // [2:2] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
}
func init() { file_domaininfo_proto_init() }
func file_domaininfo_proto_init() {
if File_domaininfo_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_domaininfo_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Domain); 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_domaininfo_proto_rawDesc,
NumEnums: 1,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_domaininfo_proto_goTypes,
DependencyIndexes: file_domaininfo_proto_depIdxs,
EnumInfos: file_domaininfo_proto_enumTypes,
MessageInfos: file_domaininfo_proto_msgTypes,
}.Build()
File_domaininfo_proto = out.File
file_domaininfo_proto_rawDesc = nil
file_domaininfo_proto_goTypes = nil
file_domaininfo_proto_depIdxs = nil
}

View File

@@ -2,6 +2,7 @@
syntax = "proto3";
package domaininfo;
option go_package = "blitiri.com.ar/go/chasquid/internal/domaininfo";
enum SecLevel {
// Does not do TLS.