Commit 2f020dcb authored by Yong Tang's avatar Yong Tang Committed by GitHub

Update to use the latest protobuf package to build pb (#5193)

* Update to use the latest protobuf package to build pb

The pb package was generated some time ago with old version
of https://github.com/golang/protobuf which was deprecated
and in favor of google.golang.org/protobuf (see
deprecation notice in https://pkg.go.dev/github.com/golang/protobuf)

This PR updates the generation of pb package with
v1.27.1 of google.golang.org/protobuf.
Signed-off-by: default avatarYong Tang <yong.tang.github@outlook.com>

* Exclude pb from import test
Signed-off-by: default avatarYong Tang <yong.tang.github@outlook.com>
parent c0c72e58
...@@ -22,6 +22,7 @@ import ( ...@@ -22,6 +22,7 @@ import (
// ServergRPC represents an instance of a DNS-over-gRPC server. // ServergRPC represents an instance of a DNS-over-gRPC server.
type ServergRPC struct { type ServergRPC struct {
*Server *Server
*pb.UnimplementedDnsServiceServer
grpcServer *grpc.Server grpcServer *grpc.Server
listenAddr net.Addr listenAddr net.Addr
tlsConfig *tls.Config tlsConfig *tls.Config
......
...@@ -2,11 +2,18 @@ ...@@ -2,11 +2,18 @@
# from: https://github.com/golang/protobuf to make this work. # from: https://github.com/golang/protobuf to make this work.
# The generate dns.pb.go is checked into git, so for normal builds we don't need # The generate dns.pb.go is checked into git, so for normal builds we don't need
# to run this generation step. # to run this generation step.
# Note: The following has been used when regenerate pb:
# curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.19.4/protoc-3.19.4-linux-x86_64.zip
# go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.27.1
# go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2.0
# export PATH="$PATH:$(go env GOPATH)/bin"
# rm pb/dns.pb.go pb/dns_grpc.pb.go
# make pb
all: dns.pb.go all: dns.pb.go
dns.pb.go: dns.proto dns.pb.go: dns.proto
protoc --go_out=plugins=grpc:. dns.proto protoc --go_out=. --go-grpc_out=. dns.proto
.PHONY: clean .PHONY: clean
clean: clean:
......
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.27.1
// protoc v3.19.4
// source: dns.proto // source: dns.proto
package pb package pb
import ( import (
context "context" protoreflect "google.golang.org/protobuf/reflect/protoreflect"
fmt "fmt" protoimpl "google.golang.org/protobuf/runtime/protoimpl"
math "math" reflect "reflect"
sync "sync"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
) )
// Reference imports to suppress errors if they are not otherwise used. const (
var _ = proto.Marshal // Verify that this generated code is sufficiently up-to-date.
var _ = fmt.Errorf _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
var _ = math.Inf // Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
/* Miek: disabled this manually, because I don't know what the heck */ )
/*
// 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
*/
type DnsPacket struct { type DnsPacket struct {
Msg []byte `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"` state protoimpl.MessageState
XXX_NoUnkeyedLiteral struct{} `json:"-"` sizeCache protoimpl.SizeCache
XXX_unrecognized []byte `json:"-"` unknownFields protoimpl.UnknownFields
XXX_sizecache int32 `json:"-"`
}
func (m *DnsPacket) Reset() { *m = DnsPacket{} } Msg []byte `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"`
func (m *DnsPacket) String() string { return proto.CompactTextString(m) }
func (*DnsPacket) ProtoMessage() {}
func (*DnsPacket) Descriptor() ([]byte, []int) {
return fileDescriptor_638ff8d8aaf3d8ae, []int{0}
} }
func (m *DnsPacket) XXX_Unmarshal(b []byte) error { func (x *DnsPacket) Reset() {
return xxx_messageInfo_DnsPacket.Unmarshal(m, b) *x = DnsPacket{}
} if protoimpl.UnsafeEnabled {
func (m *DnsPacket) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { mi := &file_dns_proto_msgTypes[0]
return xxx_messageInfo_DnsPacket.Marshal(b, m, deterministic) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
} ms.StoreMessageInfo(mi)
func (m *DnsPacket) XXX_Merge(src proto.Message) { }
xxx_messageInfo_DnsPacket.Merge(m, src)
}
func (m *DnsPacket) XXX_Size() int {
return xxx_messageInfo_DnsPacket.Size(m)
} }
func (m *DnsPacket) XXX_DiscardUnknown() {
xxx_messageInfo_DnsPacket.DiscardUnknown(m) func (x *DnsPacket) String() string {
return protoimpl.X.MessageStringOf(x)
} }
var xxx_messageInfo_DnsPacket proto.InternalMessageInfo func (*DnsPacket) ProtoMessage() {}
func (m *DnsPacket) GetMsg() []byte { func (x *DnsPacket) ProtoReflect() protoreflect.Message {
if m != nil { mi := &file_dns_proto_msgTypes[0]
return m.Msg if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
} }
return nil return mi.MessageOf(x)
} }
func init() { // Deprecated: Use DnsPacket.ProtoReflect.Descriptor instead.
proto.RegisterType((*DnsPacket)(nil), "coredns.dns.DnsPacket") func (*DnsPacket) Descriptor() ([]byte, []int) {
return file_dns_proto_rawDescGZIP(), []int{0}
} }
func init() { proto.RegisterFile("dns.proto", fileDescriptor_638ff8d8aaf3d8ae) } func (x *DnsPacket) GetMsg() []byte {
if x != nil {
var fileDescriptor_638ff8d8aaf3d8ae = []byte{ return x.Msg
// 120 bytes of a gzipped FileDescriptorProto }
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4c, 0xc9, 0x2b, 0xd6, return nil
0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x4e, 0xce, 0x2f, 0x4a, 0x05, 0x71, 0x53, 0xf2, 0x8a,
0x95, 0x64, 0xb9, 0x38, 0x5d, 0xf2, 0x8a, 0x03, 0x12, 0x93, 0xb3, 0x53, 0x4b, 0x84, 0x04, 0xb8,
0x98, 0x73, 0x8b, 0xd3, 0x25, 0x18, 0x15, 0x18, 0x35, 0x78, 0x82, 0x40, 0x4c, 0x23, 0x57, 0x2e,
0x2e, 0x97, 0xbc, 0xe2, 0xe0, 0xd4, 0xa2, 0xb2, 0xcc, 0xe4, 0x54, 0x21, 0x73, 0x2e, 0xd6, 0xc0,
0xd2, 0xd4, 0xa2, 0x4a, 0x21, 0x31, 0x3d, 0x24, 0x33, 0xf4, 0xe0, 0x06, 0x48, 0xe1, 0x10, 0x77,
0x62, 0x89, 0x62, 0x2a, 0x48, 0x4a, 0x62, 0x03, 0xdb, 0x6f, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff,
0xf5, 0xd1, 0x3f, 0x26, 0x8c, 0x00, 0x00, 0x00,
} }
// Reference imports to suppress errors if they are not otherwise used. var File_dns_proto protoreflect.FileDescriptor
var _ context.Context
var _ grpc.ClientConn
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion4
// DnsServiceClient is the client API for DnsService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type DnsServiceClient interface {
Query(ctx context.Context, in *DnsPacket, opts ...grpc.CallOption) (*DnsPacket, error)
}
type dnsServiceClient struct { var file_dns_proto_rawDesc = []byte{
cc *grpc.ClientConn 0x0a, 0x09, 0x64, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x63, 0x6f, 0x72,
0x65, 0x64, 0x6e, 0x73, 0x2e, 0x64, 0x6e, 0x73, 0x22, 0x1d, 0x0a, 0x09, 0x44, 0x6e, 0x73, 0x50,
0x61, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x01, 0x20, 0x01,
0x28, 0x0c, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x32, 0x45, 0x0a, 0x0a, 0x44, 0x6e, 0x73, 0x53, 0x65,
0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x37, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x16,
0x2e, 0x63, 0x6f, 0x72, 0x65, 0x64, 0x6e, 0x73, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x44, 0x6e, 0x73,
0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x1a, 0x16, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x64, 0x6e, 0x73,
0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x44, 0x6e, 0x73, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x42, 0x06,
0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
func NewDnsServiceClient(cc *grpc.ClientConn) DnsServiceClient { var (
return &dnsServiceClient{cc} file_dns_proto_rawDescOnce sync.Once
} file_dns_proto_rawDescData = file_dns_proto_rawDesc
)
func (c *dnsServiceClient) Query(ctx context.Context, in *DnsPacket, opts ...grpc.CallOption) (*DnsPacket, error) { func file_dns_proto_rawDescGZIP() []byte {
out := new(DnsPacket) file_dns_proto_rawDescOnce.Do(func() {
err := c.cc.Invoke(ctx, "/coredns.dns.DnsService/Query", in, out, opts...) file_dns_proto_rawDescData = protoimpl.X.CompressGZIP(file_dns_proto_rawDescData)
if err != nil { })
return nil, err return file_dns_proto_rawDescData
}
return out, nil
} }
// DnsServiceServer is the server API for DnsService service. var file_dns_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
type DnsServiceServer interface { var file_dns_proto_goTypes = []interface{}{
Query(context.Context, *DnsPacket) (*DnsPacket, error) (*DnsPacket)(nil), // 0: coredns.dns.DnsPacket
} }
var file_dns_proto_depIdxs = []int32{
func RegisterDnsServiceServer(s *grpc.Server, srv DnsServiceServer) { 0, // 0: coredns.dns.DnsService.Query:input_type -> coredns.dns.DnsPacket
s.RegisterService(&_DnsService_serviceDesc, srv) 0, // 1: coredns.dns.DnsService.Query:output_type -> coredns.dns.DnsPacket
1, // [1:2] is the sub-list for method output_type
0, // [0:1] 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 _DnsService_Query_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { func init() { file_dns_proto_init() }
in := new(DnsPacket) func file_dns_proto_init() {
if err := dec(in); err != nil { if File_dns_proto != nil {
return nil, err return
}
if interceptor == nil {
return srv.(DnsServiceServer).Query(ctx, in)
} }
info := &grpc.UnaryServerInfo{ if !protoimpl.UnsafeEnabled {
Server: srv, file_dns_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
FullMethod: "/coredns.dns.DnsService/Query", switch v := v.(*DnsPacket); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
} }
handler := func(ctx context.Context, req interface{}) (interface{}, error) { type x struct{}
return srv.(DnsServiceServer).Query(ctx, req.(*DnsPacket)) out := protoimpl.TypeBuilder{
} File: protoimpl.DescBuilder{
return interceptor(ctx, in, info, handler) GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
} RawDescriptor: file_dns_proto_rawDesc,
NumEnums: 0,
var _DnsService_serviceDesc = grpc.ServiceDesc{ NumMessages: 1,
ServiceName: "coredns.dns.DnsService", NumExtensions: 0,
HandlerType: (*DnsServiceServer)(nil), NumServices: 1,
Methods: []grpc.MethodDesc{
{
MethodName: "Query",
Handler: _DnsService_Query_Handler,
}, },
}, GoTypes: file_dns_proto_goTypes,
Streams: []grpc.StreamDesc{}, DependencyIndexes: file_dns_proto_depIdxs,
Metadata: "dns.proto", MessageInfos: file_dns_proto_msgTypes,
}.Build()
File_dns_proto = out.File
file_dns_proto_rawDesc = nil
file_dns_proto_goTypes = nil
file_dns_proto_depIdxs = nil
} }
syntax = "proto3"; syntax = "proto3";
package coredns.dns; package coredns.dns;
option go_package = "pb"; option go_package = ".;pb";
message DnsPacket { message DnsPacket {
bytes msg = 1; bytes msg = 1;
......
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v3.19.4
// source: dns.proto
package pb
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// DnsServiceClient is the client API for DnsService service.
//
// 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 DnsServiceClient interface {
Query(ctx context.Context, in *DnsPacket, opts ...grpc.CallOption) (*DnsPacket, error)
}
type dnsServiceClient struct {
cc grpc.ClientConnInterface
}
func NewDnsServiceClient(cc grpc.ClientConnInterface) DnsServiceClient {
return &dnsServiceClient{cc}
}
func (c *dnsServiceClient) Query(ctx context.Context, in *DnsPacket, opts ...grpc.CallOption) (*DnsPacket, error) {
out := new(DnsPacket)
err := c.cc.Invoke(ctx, "/coredns.dns.DnsService/Query", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// DnsServiceServer is the server API for DnsService service.
// All implementations must embed UnimplementedDnsServiceServer
// for forward compatibility
type DnsServiceServer interface {
Query(context.Context, *DnsPacket) (*DnsPacket, error)
mustEmbedUnimplementedDnsServiceServer()
}
// UnimplementedDnsServiceServer must be embedded to have forward compatible implementations.
type UnimplementedDnsServiceServer struct {
}
func (UnimplementedDnsServiceServer) Query(context.Context, *DnsPacket) (*DnsPacket, error) {
return nil, status.Errorf(codes.Unimplemented, "method Query not implemented")
}
func (UnimplementedDnsServiceServer) mustEmbedUnimplementedDnsServiceServer() {}
// UnsafeDnsServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to DnsServiceServer will
// result in compilation errors.
type UnsafeDnsServiceServer interface {
mustEmbedUnimplementedDnsServiceServer()
}
func RegisterDnsServiceServer(s grpc.ServiceRegistrar, srv DnsServiceServer) {
s.RegisterService(&DnsService_ServiceDesc, srv)
}
func _DnsService_Query_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DnsPacket)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DnsServiceServer).Query(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/coredns.dns.DnsService/Query",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DnsServiceServer).Query(ctx, req.(*DnsPacket))
}
return interceptor(ctx, in, info, handler)
}
// DnsService_ServiceDesc is the grpc.ServiceDesc for DnsService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var DnsService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "coredns.dns.DnsService",
HandlerType: (*DnsServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Query",
Handler: _DnsService_Query_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "dns.proto",
}
...@@ -250,6 +250,10 @@ func (w *testImportOrderingWalker) walk(path string, info os.FileInfo, _ error) ...@@ -250,6 +250,10 @@ func (w *testImportOrderingWalker) walk(path string, info os.FileInfo, _ error)
if filepath.Ext(path) != ".go" { if filepath.Ext(path) != ".go" {
return nil return nil
} }
// pb files are autogenerated by protoc
if strings.HasPrefix(path, "../pb/") {
return nil
}
fs := token.NewFileSet() fs := token.NewFileSet()
f, err := parser.ParseFile(fs, path, nil, parser.AllErrors) f, err := parser.ParseFile(fs, path, nil, parser.AllErrors)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment