From 5924b8a5f36bdf3f629840bb3ae38184f21996f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Thu, 30 Jul 2020 22:41:49 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=B6=E6=AE=B5=E6=80=A7=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/db/models/node_dao.go | 17 +- internal/db/models/node_login_dao.go | 52 ++ internal/rpc/pb/model_node.pb.go | 39 +- internal/rpc/pb/model_node_grant.pb.go | 42 +- internal/rpc/pb/model_node_login.pb.go | 174 +++++ internal/rpc/pb/service_node.pb.go | 649 +++++++++++++++++-- internal/rpc/pb/service_node_grant.pb.go | 439 +++++++++++-- internal/rpc/protos/model_node.proto | 2 + internal/rpc/protos/model_node_grant.proto | 11 +- internal/rpc/protos/model_node_login.proto | 11 + internal/rpc/protos/service_node.proto | 41 ++ internal/rpc/protos/service_node_grant.proto | 28 +- internal/rpc/services/service_node.go | 109 +++- internal/rpc/services/service_node_grant.go | 53 ++ 14 files changed, 1520 insertions(+), 147 deletions(-) create mode 100644 internal/rpc/pb/model_node_login.pb.go create mode 100644 internal/rpc/protos/model_node_login.proto diff --git a/internal/db/models/node_dao.go b/internal/db/models/node_dao.go index f1abe98c..66245398 100644 --- a/internal/db/models/node_dao.go +++ b/internal/db/models/node_dao.go @@ -1,6 +1,7 @@ package models import ( + "errors" _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/dbs" @@ -37,15 +38,16 @@ func (this *NodeDAO) EnableNode(id uint32) (rowsAffected int64, err error) { } // 禁用条目 -func (this *NodeDAO) DisableNode(id uint32) (rowsAffected int64, err error) { - return this.Query(). +func (this *NodeDAO) DisableNode(id int64) (err error) { + _, err = this.Query(). Pk(id). Set("state", NodeStateDisabled). Update() + return err } // 查找启用中的条目 -func (this *NodeDAO) FindEnabledNode(id uint32) (*Node, error) { +func (this *NodeDAO) FindEnabledNode(id int64) (*Node, error) { result, err := this.Query(). Pk(id). Attr("state", NodeStateEnabled). @@ -66,7 +68,7 @@ func (this *NodeDAO) FindNodeName(id uint32) (string, error) { } // 创建节点 -func (this *NodeDAO) CreateNode(name string, clusterId int) (nodeId int, err error) { +func (this *NodeDAO) CreateNode(name string, clusterId int64) (nodeId int64, err error) { op := NewNodeOperator() op.Name = name op.NodeId = rands.HexString(32) @@ -79,11 +81,14 @@ func (this *NodeDAO) CreateNode(name string, clusterId int) (nodeId int, err err return 0, err } - return types.Int(op.Id), nil + return types.Int64(op.Id), nil } // 修改节点 -func (this *NodeDAO) UpdateNode(nodeId int, name string, clusterId int) error { +func (this *NodeDAO) UpdateNode(nodeId int64, name string, clusterId int64) error { + if nodeId <= 0 { + return errors.New("invalid nodeId") + } op := NewNodeOperator() op.Id = nodeId op.Name = name diff --git a/internal/db/models/node_login_dao.go b/internal/db/models/node_login_dao.go index 596b934d..35d1ff21 100644 --- a/internal/db/models/node_login_dao.go +++ b/internal/db/models/node_login_dao.go @@ -1,9 +1,11 @@ package models import ( + "errors" _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/dbs" + "github.com/iwind/TeaGo/types" ) const ( @@ -62,3 +64,53 @@ func (this *NodeLoginDAO) FindNodeLoginName(id uint32) (string, error) { FindCol("") return name.(string), err } + +// 创建认证 +func (this *NodeLoginDAO) CreateNodeLogin(nodeId int64, name string, loginType string, paramsJSON []byte) (loginId int64, err error) { + login := NewNodeLoginOperator() + login.NodeId = nodeId + login.Name = name + login.Type = loginType + login.Params = string(paramsJSON) + login.State = NodeLoginStateEnabled + _, err = this.Save(login) + return types.Int64(login.Id), err +} + +// 修改认证 +func (this *NodeLoginDAO) UpdateNodeLogin(loginId int64, name string, loginType string, paramsJSON []byte) error { + if loginId <= 0 { + return errors.New("invalid loginId") + } + login := NewNodeLoginOperator() + login.Id = loginId + login.Name = name + login.Type = loginType + login.Params = string(paramsJSON) + _, err := this.Save(login) + return err +} + +// 查找认证 +func (this *NodeLoginDAO) FindEnabledNodeLoginWithNodeId(nodeId int64) (*NodeLogin, error) { + one, err := this.Query(). + Attr("nodeId", nodeId). + State(NodeLoginStateEnabled). + Find() + if err != nil { + return nil, err + } + if one == nil { + return nil, nil + } + return one.(*NodeLogin), nil +} + +// 禁用某个节点的认证 +func (this *NodeLoginDAO) DisableNodeLogins(nodeId int64) error { + _, err := this.Query(). + Attr("nodeId", nodeId). + Set("state", NodeLoginStateDisabled). + Update() + return err +} diff --git a/internal/rpc/pb/model_node.pb.go b/internal/rpc/pb/model_node.pb.go index e599d7d9..1427f941 100644 --- a/internal/rpc/pb/model_node.pb.go +++ b/internal/rpc/pb/model_node.pb.go @@ -33,6 +33,7 @@ type Node struct { Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` Cluster *NodeCluster `protobuf:"bytes,32,opt,name=cluster,proto3" json:"cluster,omitempty"` + Login *NodeLogin `protobuf:"bytes,33,opt,name=login,proto3" json:"login,omitempty"` } func (x *Node) Reset() { @@ -88,19 +89,30 @@ func (x *Node) GetCluster() *NodeCluster { return nil } +func (x *Node) GetLogin() *NodeLogin { + if x != nil { + return x.Login + } + return nil +} + var File_model_node_proto protoreflect.FileDescriptor var file_model_node_proto_rawDesc = []byte{ 0x0a, 0x10, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x1a, 0x18, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x22, 0x55, 0x0a, 0x04, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x29, 0x0a, 0x07, - 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x18, 0x20, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, - 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x07, - 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x1a, 0x16, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x6c, 0x6f, 0x67, + 0x69, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x7a, 0x0a, 0x04, 0x4e, 0x6f, 0x64, 0x65, + 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x29, 0x0a, 0x07, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x18, + 0x20, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x43, + 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x07, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x12, + 0x23, 0x0a, 0x05, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x18, 0x21, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, + 0x2e, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x05, 0x6c, + 0x6f, 0x67, 0x69, 0x6e, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -119,14 +131,16 @@ var file_model_node_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_model_node_proto_goTypes = []interface{}{ (*Node)(nil), // 0: pb.Node (*NodeCluster)(nil), // 1: pb.NodeCluster + (*NodeLogin)(nil), // 2: pb.NodeLogin } var file_model_node_proto_depIdxs = []int32{ 1, // 0: pb.Node.cluster:type_name -> pb.NodeCluster - 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 + 2, // 1: pb.Node.login:type_name -> pb.NodeLogin + 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_model_node_proto_init() } @@ -135,6 +149,7 @@ func file_model_node_proto_init() { return } file_model_node_cluster_proto_init() + file_model_node_login_proto_init() if !protoimpl.UnsafeEnabled { file_model_node_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Node); i { diff --git a/internal/rpc/pb/model_node_grant.pb.go b/internal/rpc/pb/model_node_grant.pb.go index 89bf63a1..cb227aab 100644 --- a/internal/rpc/pb/model_node_grant.pb.go +++ b/internal/rpc/pb/model_node_grant.pb.go @@ -33,11 +33,12 @@ type NodeGrant struct { Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` Method string `protobuf:"bytes,3,opt,name=method,proto3" json:"method,omitempty"` - Password string `protobuf:"bytes,4,opt,name=password,proto3" json:"password,omitempty"` - Su bool `protobuf:"varint,5,opt,name=su,proto3" json:"su,omitempty"` - PrivateKey string `protobuf:"bytes,6,opt,name=privateKey,proto3" json:"privateKey,omitempty"` - Description string `protobuf:"bytes,7,opt,name=description,proto3" json:"description,omitempty"` - NodeId int64 `protobuf:"varint,8,opt,name=nodeId,proto3" json:"nodeId,omitempty"` + Username string `protobuf:"bytes,4,opt,name=username,proto3" json:"username,omitempty"` + Password string `protobuf:"bytes,5,opt,name=password,proto3" json:"password,omitempty"` + Su bool `protobuf:"varint,6,opt,name=su,proto3" json:"su,omitempty"` + PrivateKey string `protobuf:"bytes,7,opt,name=privateKey,proto3" json:"privateKey,omitempty"` + Description string `protobuf:"bytes,8,opt,name=description,proto3" json:"description,omitempty"` + NodeId int64 `protobuf:"varint,9,opt,name=nodeId,proto3" json:"nodeId,omitempty"` } func (x *NodeGrant) Reset() { @@ -93,6 +94,13 @@ func (x *NodeGrant) GetMethod() string { return "" } +func (x *NodeGrant) GetUsername() string { + if x != nil { + return x.Username + } + return "" +} + func (x *NodeGrant) GetPassword() string { if x != nil { return x.Password @@ -132,21 +140,23 @@ var File_model_node_grant_proto protoreflect.FileDescriptor var file_model_node_grant_proto_rawDesc = []byte{ 0x0a, 0x16, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x67, 0x72, 0x61, - 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x22, 0xcd, 0x01, 0x0a, + 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x22, 0xe9, 0x01, 0x0a, 0x09, 0x4e, 0x6f, 0x64, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, - 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, - 0x72, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, - 0x72, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x73, 0x75, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x02, - 0x73, 0x75, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, - 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x4b, - 0x65, 0x79, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, - 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x18, 0x08, - 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x42, 0x06, 0x5a, 0x04, - 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, + 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x0e, + 0x0a, 0x02, 0x73, 0x75, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x02, 0x73, 0x75, 0x12, 0x1e, + 0x0a, 0x0a, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x18, 0x07, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0a, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x12, 0x20, + 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x08, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/internal/rpc/pb/model_node_login.pb.go b/internal/rpc/pb/model_node_login.pb.go new file mode 100644 index 00000000..75582e24 --- /dev/null +++ b/internal/rpc/pb/model_node_login.pb.go @@ -0,0 +1,174 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.12.3 +// source: model_node_login.proto + +package pb + +import ( + proto "github.com/golang/protobuf/proto" + 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) +) + +// 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 NodeLogin struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"` + Params []byte `protobuf:"bytes,4,opt,name=params,proto3" json:"params,omitempty"` +} + +func (x *NodeLogin) Reset() { + *x = NodeLogin{} + if protoimpl.UnsafeEnabled { + mi := &file_model_node_login_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *NodeLogin) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NodeLogin) ProtoMessage() {} + +func (x *NodeLogin) ProtoReflect() protoreflect.Message { + mi := &file_model_node_login_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 NodeLogin.ProtoReflect.Descriptor instead. +func (*NodeLogin) Descriptor() ([]byte, []int) { + return file_model_node_login_proto_rawDescGZIP(), []int{0} +} + +func (x *NodeLogin) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *NodeLogin) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *NodeLogin) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *NodeLogin) GetParams() []byte { + if x != nil { + return x.Params + } + return nil +} + +var File_model_node_login_proto protoreflect.FileDescriptor + +var file_model_node_login_proto_rawDesc = []byte{ + 0x0a, 0x16, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x6c, 0x6f, 0x67, + 0x69, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x22, 0x5b, 0x0a, 0x09, + 0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, + 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, + 0x65, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, + 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_model_node_login_proto_rawDescOnce sync.Once + file_model_node_login_proto_rawDescData = file_model_node_login_proto_rawDesc +) + +func file_model_node_login_proto_rawDescGZIP() []byte { + file_model_node_login_proto_rawDescOnce.Do(func() { + file_model_node_login_proto_rawDescData = protoimpl.X.CompressGZIP(file_model_node_login_proto_rawDescData) + }) + return file_model_node_login_proto_rawDescData +} + +var file_model_node_login_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_model_node_login_proto_goTypes = []interface{}{ + (*NodeLogin)(nil), // 0: pb.NodeLogin +} +var file_model_node_login_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_model_node_login_proto_init() } +func file_model_node_login_proto_init() { + if File_model_node_login_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_model_node_login_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*NodeLogin); 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_model_node_login_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_model_node_login_proto_goTypes, + DependencyIndexes: file_model_node_login_proto_depIdxs, + MessageInfos: file_model_node_login_proto_msgTypes, + }.Build() + File_model_node_login_proto = out.File + file_model_node_login_proto_rawDesc = nil + file_model_node_login_proto_goTypes = nil + file_model_node_login_proto_depIdxs = nil +} diff --git a/internal/rpc/pb/service_node.pb.go b/internal/rpc/pb/service_node.pb.go index 6a049087..1481787f 100644 --- a/internal/rpc/pb/service_node.pb.go +++ b/internal/rpc/pb/service_node.pb.go @@ -35,8 +35,9 @@ type CreateNodeRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - ClusterId int64 `protobuf:"varint,2,opt,name=clusterId,proto3" json:"clusterId,omitempty"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + ClusterId int64 `protobuf:"varint,2,opt,name=clusterId,proto3" json:"clusterId,omitempty"` + Login *NodeLogin `protobuf:"bytes,3,opt,name=Login,proto3" json:"Login,omitempty"` } func (x *CreateNodeRequest) Reset() { @@ -85,6 +86,13 @@ func (x *CreateNodeRequest) GetClusterId() int64 { return 0 } +func (x *CreateNodeRequest) GetLogin() *NodeLogin { + if x != nil { + return x.Login + } + return nil +} + type CreateNodeResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -321,49 +329,377 @@ func (x *ListEnabledNodesResponse) GetNodes() []*Node { return nil } +// 禁用节点 +type DisableNodeRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + NodeId int64 `protobuf:"varint,1,opt,name=nodeId,proto3" json:"nodeId,omitempty"` +} + +func (x *DisableNodeRequest) Reset() { + *x = DisableNodeRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_service_node_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DisableNodeRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DisableNodeRequest) ProtoMessage() {} + +func (x *DisableNodeRequest) ProtoReflect() protoreflect.Message { + mi := &file_service_node_proto_msgTypes[6] + 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 DisableNodeRequest.ProtoReflect.Descriptor instead. +func (*DisableNodeRequest) Descriptor() ([]byte, []int) { + return file_service_node_proto_rawDescGZIP(), []int{6} +} + +func (x *DisableNodeRequest) GetNodeId() int64 { + if x != nil { + return x.NodeId + } + return 0 +} + +type DisableNodeResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *DisableNodeResponse) Reset() { + *x = DisableNodeResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_service_node_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DisableNodeResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DisableNodeResponse) ProtoMessage() {} + +func (x *DisableNodeResponse) ProtoReflect() protoreflect.Message { + mi := &file_service_node_proto_msgTypes[7] + 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 DisableNodeResponse.ProtoReflect.Descriptor instead. +func (*DisableNodeResponse) Descriptor() ([]byte, []int) { + return file_service_node_proto_rawDescGZIP(), []int{7} +} + +// 修改节点 +type UpdateNodeRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + NodeId int64 `protobuf:"varint,1,opt,name=nodeId,proto3" json:"nodeId,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + ClusterId int64 `protobuf:"varint,3,opt,name=clusterId,proto3" json:"clusterId,omitempty"` + Login *NodeLogin `protobuf:"bytes,4,opt,name=Login,proto3" json:"Login,omitempty"` +} + +func (x *UpdateNodeRequest) Reset() { + *x = UpdateNodeRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_service_node_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateNodeRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateNodeRequest) ProtoMessage() {} + +func (x *UpdateNodeRequest) ProtoReflect() protoreflect.Message { + mi := &file_service_node_proto_msgTypes[8] + 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 UpdateNodeRequest.ProtoReflect.Descriptor instead. +func (*UpdateNodeRequest) Descriptor() ([]byte, []int) { + return file_service_node_proto_rawDescGZIP(), []int{8} +} + +func (x *UpdateNodeRequest) GetNodeId() int64 { + if x != nil { + return x.NodeId + } + return 0 +} + +func (x *UpdateNodeRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *UpdateNodeRequest) GetClusterId() int64 { + if x != nil { + return x.ClusterId + } + return 0 +} + +func (x *UpdateNodeRequest) GetLogin() *NodeLogin { + if x != nil { + return x.Login + } + return nil +} + +type UpdateNodeResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *UpdateNodeResponse) Reset() { + *x = UpdateNodeResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_service_node_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateNodeResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateNodeResponse) ProtoMessage() {} + +func (x *UpdateNodeResponse) ProtoReflect() protoreflect.Message { + mi := &file_service_node_proto_msgTypes[9] + 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 UpdateNodeResponse.ProtoReflect.Descriptor instead. +func (*UpdateNodeResponse) Descriptor() ([]byte, []int) { + return file_service_node_proto_rawDescGZIP(), []int{9} +} + +// 查找节点 +type FindEnabledNodeRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + NodeId int64 `protobuf:"varint,1,opt,name=nodeId,proto3" json:"nodeId,omitempty"` +} + +func (x *FindEnabledNodeRequest) Reset() { + *x = FindEnabledNodeRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_service_node_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FindEnabledNodeRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FindEnabledNodeRequest) ProtoMessage() {} + +func (x *FindEnabledNodeRequest) ProtoReflect() protoreflect.Message { + mi := &file_service_node_proto_msgTypes[10] + 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 FindEnabledNodeRequest.ProtoReflect.Descriptor instead. +func (*FindEnabledNodeRequest) Descriptor() ([]byte, []int) { + return file_service_node_proto_rawDescGZIP(), []int{10} +} + +func (x *FindEnabledNodeRequest) GetNodeId() int64 { + if x != nil { + return x.NodeId + } + return 0 +} + +type FindEnabledNodeResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Node *Node `protobuf:"bytes,1,opt,name=node,proto3" json:"node,omitempty"` +} + +func (x *FindEnabledNodeResponse) Reset() { + *x = FindEnabledNodeResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_service_node_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FindEnabledNodeResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FindEnabledNodeResponse) ProtoMessage() {} + +func (x *FindEnabledNodeResponse) ProtoReflect() protoreflect.Message { + mi := &file_service_node_proto_msgTypes[11] + 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 FindEnabledNodeResponse.ProtoReflect.Descriptor instead. +func (*FindEnabledNodeResponse) Descriptor() ([]byte, []int) { + return file_service_node_proto_rawDescGZIP(), []int{11} +} + +func (x *FindEnabledNodeResponse) GetNode() *Node { + if x != nil { + return x.Node + } + return nil +} + var File_service_node_proto protoreflect.FileDescriptor var file_service_node_proto_rawDesc = []byte{ 0x0a, 0x12, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x1a, 0x10, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, - 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x45, 0x0a, 0x11, 0x43, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, - 0x64, 0x22, 0x2c, 0x0a, 0x12, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x22, - 0x1d, 0x0a, 0x1b, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, - 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x34, - 0x0a, 0x1c, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, - 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, - 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x45, 0x0a, 0x17, 0x4c, 0x69, 0x73, 0x74, 0x45, 0x6e, 0x61, 0x62, - 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x22, 0x3a, 0x0a, 0x18, 0x4c, - 0x69, 0x73, 0x74, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1e, 0x0a, 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, - 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x64, 0x65, - 0x52, 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x32, 0xf4, 0x01, 0x0a, 0x0b, 0x4e, 0x6f, 0x64, 0x65, - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3b, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x15, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x70, - 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x59, 0x0a, 0x14, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x41, 0x6c, 0x6c, - 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x1f, 0x2e, 0x70, - 0x62, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, - 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, - 0x70, 0x62, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, - 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x4d, 0x0a, 0x10, 0x6c, 0x69, 0x73, 0x74, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, - 0x64, 0x65, 0x73, 0x12, 0x1b, 0x2e, 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x45, 0x6e, 0x61, - 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x1c, 0x2e, 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, - 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x06, - 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x16, 0x6d, 0x6f, 0x64, 0x65, + 0x6c, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x22, 0x6a, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x63, + 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, + 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x05, 0x4c, 0x6f, 0x67, + 0x69, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x70, 0x62, 0x2e, 0x4e, 0x6f, + 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x05, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x22, 0x2c, + 0x0a, 0x12, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x22, 0x1d, 0x0a, 0x1b, + 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, + 0x6f, 0x64, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x34, 0x0a, 0x1c, 0x43, + 0x6f, 0x75, 0x6e, 0x74, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, + 0x64, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x22, 0x45, 0x0a, 0x17, 0x4c, 0x69, 0x73, 0x74, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, + 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, + 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6f, 0x66, + 0x66, 0x73, 0x65, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x03, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x22, 0x3a, 0x0a, 0x18, 0x4c, 0x69, 0x73, 0x74, + 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1e, 0x0a, 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x05, 0x6e, + 0x6f, 0x64, 0x65, 0x73, 0x22, 0x2c, 0x0a, 0x12, 0x44, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x4e, + 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x6f, + 0x64, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, + 0x49, 0x64, 0x22, 0x15, 0x0a, 0x13, 0x44, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x6f, 0x64, + 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x82, 0x01, 0x0a, 0x11, 0x55, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x16, 0x0a, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x63, + 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, + 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x05, 0x4c, 0x6f, 0x67, + 0x69, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x70, 0x62, 0x2e, 0x4e, 0x6f, + 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x05, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x22, 0x14, + 0x0a, 0x12, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x30, 0x0a, 0x16, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, + 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, + 0x0a, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, + 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x22, 0x37, 0x0a, 0x17, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e, + 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x1c, 0x0a, 0x04, 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x08, 0x2e, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6e, 0x6f, 0x64, 0x65, 0x32, + 0xbd, 0x03, 0x0a, 0x0b, 0x4e, 0x6f, 0x64, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, + 0x3b, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x15, 0x2e, + 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x59, 0x0a, 0x14, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, + 0x6f, 0x64, 0x65, 0x73, 0x12, 0x1f, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x41, + 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, + 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4d, 0x0a, 0x10, 0x6c, 0x69, 0x73, 0x74, 0x45, + 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x1b, 0x2e, 0x70, 0x62, + 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x70, 0x62, 0x2e, 0x4c, 0x69, + 0x73, 0x74, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3e, 0x0a, 0x0b, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, + 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x16, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x69, 0x73, 0x61, 0x62, + 0x6c, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, + 0x70, 0x62, 0x2e, 0x44, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3b, 0x0a, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x15, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x70, 0x62, + 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x4a, 0x0a, 0x0f, 0x66, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, + 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x1a, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, + 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, + 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, + 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -378,7 +714,7 @@ func file_service_node_proto_rawDescGZIP() []byte { return file_service_node_proto_rawDescData } -var file_service_node_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_service_node_proto_msgTypes = make([]protoimpl.MessageInfo, 12) var file_service_node_proto_goTypes = []interface{}{ (*CreateNodeRequest)(nil), // 0: pb.CreateNodeRequest (*CreateNodeResponse)(nil), // 1: pb.CreateNodeResponse @@ -386,21 +722,37 @@ var file_service_node_proto_goTypes = []interface{}{ (*CountAllEnabledNodesResponse)(nil), // 3: pb.CountAllEnabledNodesResponse (*ListEnabledNodesRequest)(nil), // 4: pb.ListEnabledNodesRequest (*ListEnabledNodesResponse)(nil), // 5: pb.ListEnabledNodesResponse - (*Node)(nil), // 6: pb.Node + (*DisableNodeRequest)(nil), // 6: pb.DisableNodeRequest + (*DisableNodeResponse)(nil), // 7: pb.DisableNodeResponse + (*UpdateNodeRequest)(nil), // 8: pb.UpdateNodeRequest + (*UpdateNodeResponse)(nil), // 9: pb.UpdateNodeResponse + (*FindEnabledNodeRequest)(nil), // 10: pb.FindEnabledNodeRequest + (*FindEnabledNodeResponse)(nil), // 11: pb.FindEnabledNodeResponse + (*NodeLogin)(nil), // 12: pb.NodeLogin + (*Node)(nil), // 13: pb.Node } var file_service_node_proto_depIdxs = []int32{ - 6, // 0: pb.ListEnabledNodesResponse.nodes:type_name -> pb.Node - 0, // 1: pb.NodeService.createNode:input_type -> pb.CreateNodeRequest - 2, // 2: pb.NodeService.countAllEnabledNodes:input_type -> pb.CountAllEnabledNodesRequest - 4, // 3: pb.NodeService.listEnabledNodes:input_type -> pb.ListEnabledNodesRequest - 1, // 4: pb.NodeService.createNode:output_type -> pb.CreateNodeResponse - 3, // 5: pb.NodeService.countAllEnabledNodes:output_type -> pb.CountAllEnabledNodesResponse - 5, // 6: pb.NodeService.listEnabledNodes:output_type -> pb.ListEnabledNodesResponse - 4, // [4:7] is the sub-list for method output_type - 1, // [1:4] 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 + 12, // 0: pb.CreateNodeRequest.Login:type_name -> pb.NodeLogin + 13, // 1: pb.ListEnabledNodesResponse.nodes:type_name -> pb.Node + 12, // 2: pb.UpdateNodeRequest.Login:type_name -> pb.NodeLogin + 13, // 3: pb.FindEnabledNodeResponse.node:type_name -> pb.Node + 0, // 4: pb.NodeService.createNode:input_type -> pb.CreateNodeRequest + 2, // 5: pb.NodeService.countAllEnabledNodes:input_type -> pb.CountAllEnabledNodesRequest + 4, // 6: pb.NodeService.listEnabledNodes:input_type -> pb.ListEnabledNodesRequest + 6, // 7: pb.NodeService.disableNode:input_type -> pb.DisableNodeRequest + 8, // 8: pb.NodeService.updateNode:input_type -> pb.UpdateNodeRequest + 10, // 9: pb.NodeService.findEnabledNode:input_type -> pb.FindEnabledNodeRequest + 1, // 10: pb.NodeService.createNode:output_type -> pb.CreateNodeResponse + 3, // 11: pb.NodeService.countAllEnabledNodes:output_type -> pb.CountAllEnabledNodesResponse + 5, // 12: pb.NodeService.listEnabledNodes:output_type -> pb.ListEnabledNodesResponse + 7, // 13: pb.NodeService.disableNode:output_type -> pb.DisableNodeResponse + 9, // 14: pb.NodeService.updateNode:output_type -> pb.UpdateNodeResponse + 11, // 15: pb.NodeService.findEnabledNode:output_type -> pb.FindEnabledNodeResponse + 10, // [10:16] is the sub-list for method output_type + 4, // [4:10] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_service_node_proto_init() } @@ -409,6 +761,7 @@ func file_service_node_proto_init() { return } file_model_node_proto_init() + file_model_node_login_proto_init() if !protoimpl.UnsafeEnabled { file_service_node_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*CreateNodeRequest); i { @@ -482,6 +835,78 @@ func file_service_node_proto_init() { return nil } } + file_service_node_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DisableNodeRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_node_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DisableNodeResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_node_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateNodeRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_node_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateNodeResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_node_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FindEnabledNodeRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_node_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FindEnabledNodeResponse); 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{ @@ -489,7 +914,7 @@ func file_service_node_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_service_node_proto_rawDesc, NumEnums: 0, - NumMessages: 6, + NumMessages: 12, NumExtensions: 0, NumServices: 1, }, @@ -521,6 +946,12 @@ type NodeServiceClient interface { CountAllEnabledNodes(ctx context.Context, in *CountAllEnabledNodesRequest, opts ...grpc.CallOption) (*CountAllEnabledNodesResponse, error) // 列出单页节点 ListEnabledNodes(ctx context.Context, in *ListEnabledNodesRequest, opts ...grpc.CallOption) (*ListEnabledNodesResponse, error) + // 禁用节点 + DisableNode(ctx context.Context, in *DisableNodeRequest, opts ...grpc.CallOption) (*DisableNodeResponse, error) + // 修改节点 + UpdateNode(ctx context.Context, in *UpdateNodeRequest, opts ...grpc.CallOption) (*UpdateNodeResponse, error) + // 查看单个节点 + FindEnabledNode(ctx context.Context, in *FindEnabledNodeRequest, opts ...grpc.CallOption) (*FindEnabledNodeResponse, error) } type nodeServiceClient struct { @@ -558,6 +989,33 @@ func (c *nodeServiceClient) ListEnabledNodes(ctx context.Context, in *ListEnable return out, nil } +func (c *nodeServiceClient) DisableNode(ctx context.Context, in *DisableNodeRequest, opts ...grpc.CallOption) (*DisableNodeResponse, error) { + out := new(DisableNodeResponse) + err := c.cc.Invoke(ctx, "/pb.NodeService/disableNode", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *nodeServiceClient) UpdateNode(ctx context.Context, in *UpdateNodeRequest, opts ...grpc.CallOption) (*UpdateNodeResponse, error) { + out := new(UpdateNodeResponse) + err := c.cc.Invoke(ctx, "/pb.NodeService/updateNode", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *nodeServiceClient) FindEnabledNode(ctx context.Context, in *FindEnabledNodeRequest, opts ...grpc.CallOption) (*FindEnabledNodeResponse, error) { + out := new(FindEnabledNodeResponse) + err := c.cc.Invoke(ctx, "/pb.NodeService/findEnabledNode", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // NodeServiceServer is the server API for NodeService service. type NodeServiceServer interface { // 创建节点 @@ -566,6 +1024,12 @@ type NodeServiceServer interface { CountAllEnabledNodes(context.Context, *CountAllEnabledNodesRequest) (*CountAllEnabledNodesResponse, error) // 列出单页节点 ListEnabledNodes(context.Context, *ListEnabledNodesRequest) (*ListEnabledNodesResponse, error) + // 禁用节点 + DisableNode(context.Context, *DisableNodeRequest) (*DisableNodeResponse, error) + // 修改节点 + UpdateNode(context.Context, *UpdateNodeRequest) (*UpdateNodeResponse, error) + // 查看单个节点 + FindEnabledNode(context.Context, *FindEnabledNodeRequest) (*FindEnabledNodeResponse, error) } // UnimplementedNodeServiceServer can be embedded to have forward compatible implementations. @@ -581,6 +1045,15 @@ func (*UnimplementedNodeServiceServer) CountAllEnabledNodes(context.Context, *Co func (*UnimplementedNodeServiceServer) ListEnabledNodes(context.Context, *ListEnabledNodesRequest) (*ListEnabledNodesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ListEnabledNodes not implemented") } +func (*UnimplementedNodeServiceServer) DisableNode(context.Context, *DisableNodeRequest) (*DisableNodeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DisableNode not implemented") +} +func (*UnimplementedNodeServiceServer) UpdateNode(context.Context, *UpdateNodeRequest) (*UpdateNodeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateNode not implemented") +} +func (*UnimplementedNodeServiceServer) FindEnabledNode(context.Context, *FindEnabledNodeRequest) (*FindEnabledNodeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method FindEnabledNode not implemented") +} func RegisterNodeServiceServer(s *grpc.Server, srv NodeServiceServer) { s.RegisterService(&_NodeService_serviceDesc, srv) @@ -640,6 +1113,60 @@ func _NodeService_ListEnabledNodes_Handler(srv interface{}, ctx context.Context, return interceptor(ctx, in, info, handler) } +func _NodeService_DisableNode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DisableNodeRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(NodeServiceServer).DisableNode(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pb.NodeService/DisableNode", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(NodeServiceServer).DisableNode(ctx, req.(*DisableNodeRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _NodeService_UpdateNode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateNodeRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(NodeServiceServer).UpdateNode(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pb.NodeService/UpdateNode", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(NodeServiceServer).UpdateNode(ctx, req.(*UpdateNodeRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _NodeService_FindEnabledNode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(FindEnabledNodeRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(NodeServiceServer).FindEnabledNode(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pb.NodeService/FindEnabledNode", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(NodeServiceServer).FindEnabledNode(ctx, req.(*FindEnabledNodeRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _NodeService_serviceDesc = grpc.ServiceDesc{ ServiceName: "pb.NodeService", HandlerType: (*NodeServiceServer)(nil), @@ -656,6 +1183,18 @@ var _NodeService_serviceDesc = grpc.ServiceDesc{ MethodName: "listEnabledNodes", Handler: _NodeService_ListEnabledNodes_Handler, }, + { + MethodName: "disableNode", + Handler: _NodeService_DisableNode_Handler, + }, + { + MethodName: "updateNode", + Handler: _NodeService_UpdateNode_Handler, + }, + { + MethodName: "findEnabledNode", + Handler: _NodeService_FindEnabledNode_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "service_node.proto", diff --git a/internal/rpc/pb/service_node_grant.pb.go b/internal/rpc/pb/service_node_grant.pb.go index 01d2cdbd..69104def 100644 --- a/internal/rpc/pb/service_node_grant.pb.go +++ b/internal/rpc/pb/service_node_grant.pb.go @@ -486,7 +486,7 @@ func (x *CountAllEnabledNodeGrantsResponse) GetCount() int64 { return 0 } -// 列出所有认证 +// 列出单页认证 type ListEnabledNodeGrantsRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -589,6 +589,187 @@ func (x *ListEnabledNodeGrantsResponse) GetGrants() []*NodeGrant { return nil } +// 获取所有认证信息 +type FindAllEnabledNodeGrantsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *FindAllEnabledNodeGrantsRequest) Reset() { + *x = FindAllEnabledNodeGrantsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_service_node_grant_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FindAllEnabledNodeGrantsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FindAllEnabledNodeGrantsRequest) ProtoMessage() {} + +func (x *FindAllEnabledNodeGrantsRequest) ProtoReflect() protoreflect.Message { + mi := &file_service_node_grant_proto_msgTypes[10] + 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 FindAllEnabledNodeGrantsRequest.ProtoReflect.Descriptor instead. +func (*FindAllEnabledNodeGrantsRequest) Descriptor() ([]byte, []int) { + return file_service_node_grant_proto_rawDescGZIP(), []int{10} +} + +type FindAllEnabledNodeGrantsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Grants []*NodeGrant `protobuf:"bytes,1,rep,name=grants,proto3" json:"grants,omitempty"` +} + +func (x *FindAllEnabledNodeGrantsResponse) Reset() { + *x = FindAllEnabledNodeGrantsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_service_node_grant_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FindAllEnabledNodeGrantsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FindAllEnabledNodeGrantsResponse) ProtoMessage() {} + +func (x *FindAllEnabledNodeGrantsResponse) ProtoReflect() protoreflect.Message { + mi := &file_service_node_grant_proto_msgTypes[11] + 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 FindAllEnabledNodeGrantsResponse.ProtoReflect.Descriptor instead. +func (*FindAllEnabledNodeGrantsResponse) Descriptor() ([]byte, []int) { + return file_service_node_grant_proto_rawDescGZIP(), []int{11} +} + +func (x *FindAllEnabledNodeGrantsResponse) GetGrants() []*NodeGrant { + if x != nil { + return x.Grants + } + return nil +} + +// 获取认证信息 +type FindEnabledGrantRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + GrantId int64 `protobuf:"varint,1,opt,name=grantId,proto3" json:"grantId,omitempty"` +} + +func (x *FindEnabledGrantRequest) Reset() { + *x = FindEnabledGrantRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_service_node_grant_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FindEnabledGrantRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FindEnabledGrantRequest) ProtoMessage() {} + +func (x *FindEnabledGrantRequest) ProtoReflect() protoreflect.Message { + mi := &file_service_node_grant_proto_msgTypes[12] + 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 FindEnabledGrantRequest.ProtoReflect.Descriptor instead. +func (*FindEnabledGrantRequest) Descriptor() ([]byte, []int) { + return file_service_node_grant_proto_rawDescGZIP(), []int{12} +} + +func (x *FindEnabledGrantRequest) GetGrantId() int64 { + if x != nil { + return x.GrantId + } + return 0 +} + +type FindEnabledGrantResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Grant *NodeGrant `protobuf:"bytes,1,opt,name=grant,proto3" json:"grant,omitempty"` +} + +func (x *FindEnabledGrantResponse) Reset() { + *x = FindEnabledGrantResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_service_node_grant_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FindEnabledGrantResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FindEnabledGrantResponse) ProtoMessage() {} + +func (x *FindEnabledGrantResponse) ProtoReflect() protoreflect.Message { + mi := &file_service_node_grant_proto_msgTypes[13] + 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 FindEnabledGrantResponse.ProtoReflect.Descriptor instead. +func (*FindEnabledGrantResponse) Descriptor() ([]byte, []int) { + return file_service_node_grant_proto_rawDescGZIP(), []int{13} +} + +func (x *FindEnabledGrantResponse) GetGrant() *NodeGrant { + if x != nil { + return x.Grant + } + return nil +} + var File_service_node_grant_proto protoreflect.FileDescriptor var file_service_node_grant_proto_rawDesc = []byte{ @@ -649,36 +830,62 @@ var file_service_node_grant_proto_rawDesc = []byte{ 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x06, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x52, 0x06, - 0x67, 0x72, 0x61, 0x6e, 0x74, 0x73, 0x32, 0xc1, 0x03, 0x0a, 0x10, 0x4e, 0x6f, 0x64, 0x65, 0x47, - 0x72, 0x61, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x4a, 0x0a, 0x0f, 0x63, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x12, 0x1a, + 0x67, 0x72, 0x61, 0x6e, 0x74, 0x73, 0x22, 0x21, 0x0a, 0x1f, 0x46, 0x69, 0x6e, 0x64, 0x41, 0x6c, + 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x47, 0x72, 0x61, 0x6e, + 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x49, 0x0a, 0x20, 0x46, 0x69, 0x6e, + 0x64, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x47, + 0x72, 0x61, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, + 0x06, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, + 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x52, 0x06, 0x67, 0x72, + 0x61, 0x6e, 0x74, 0x73, 0x22, 0x33, 0x0a, 0x17, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, + 0x6c, 0x65, 0x64, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x18, 0x0a, 0x07, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x07, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x22, 0x3f, 0x0a, 0x18, 0x46, 0x69, 0x6e, + 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23, 0x0a, 0x05, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x47, 0x72, + 0x61, 0x6e, 0x74, 0x52, 0x05, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x32, 0xf7, 0x04, 0x0a, 0x10, 0x4e, + 0x6f, 0x64, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, + 0x4a, 0x0a, 0x0f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x47, 0x72, 0x61, + 0x6e, 0x74, 0x12, 0x1a, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x6f, + 0x64, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x47, 0x72, + 0x61, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4a, 0x0a, 0x0f, 0x75, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x12, 0x1a, + 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x70, 0x62, 0x2e, - 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4a, 0x0a, 0x0f, 0x75, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x12, 0x1a, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x4d, 0x0a, 0x10, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x6f, - 0x64, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x12, 0x1b, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x69, 0x73, - 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x69, 0x73, 0x61, 0x62, 0x6c, - 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x68, 0x0a, 0x19, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x41, 0x6c, 0x6c, 0x45, 0x6e, - 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x73, 0x12, - 0x24, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, - 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, - 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x47, 0x72, - 0x61, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5c, 0x0a, 0x15, - 0x4c, 0x69, 0x73, 0x74, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x47, - 0x72, 0x61, 0x6e, 0x74, 0x73, 0x12, 0x20, 0x2e, 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x45, - 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73, - 0x74, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x47, 0x72, 0x61, 0x6e, - 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, - 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4d, 0x0a, 0x10, 0x64, 0x69, 0x73, 0x61, 0x62, + 0x6c, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x12, 0x1b, 0x2e, 0x70, 0x62, + 0x2e, 0x44, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x47, 0x72, 0x61, 0x6e, + 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x69, + 0x73, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x68, 0x0a, 0x19, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x41, + 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x47, 0x72, 0x61, + 0x6e, 0x74, 0x73, 0x12, 0x24, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x41, 0x6c, + 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x47, 0x72, 0x61, 0x6e, + 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x70, 0x62, 0x2e, 0x43, + 0x6f, 0x75, 0x6e, 0x74, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, + 0x64, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x5c, 0x0a, 0x15, 0x4c, 0x69, 0x73, 0x74, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, + 0x6f, 0x64, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x73, 0x12, 0x20, 0x2e, 0x70, 0x62, 0x2e, 0x4c, + 0x69, 0x73, 0x74, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x47, 0x72, + 0x61, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x70, 0x62, + 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, + 0x47, 0x72, 0x61, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x65, + 0x0a, 0x18, 0x46, 0x69, 0x6e, 0x64, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, + 0x4e, 0x6f, 0x64, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x73, 0x12, 0x23, 0x2e, 0x70, 0x62, 0x2e, + 0x46, 0x69, 0x6e, 0x64, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, + 0x64, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x24, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, + 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4d, 0x0a, 0x10, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, + 0x62, 0x6c, 0x65, 0x64, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x12, 0x1b, 0x2e, 0x70, 0x62, 0x2e, 0x46, + 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, + 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -693,7 +900,7 @@ func file_service_node_grant_proto_rawDescGZIP() []byte { return file_service_node_grant_proto_rawDescData } -var file_service_node_grant_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_service_node_grant_proto_msgTypes = make([]protoimpl.MessageInfo, 14) var file_service_node_grant_proto_goTypes = []interface{}{ (*CreateNodeGrantRequest)(nil), // 0: pb.CreateNodeGrantRequest (*CreateNodeGrantResponse)(nil), // 1: pb.CreateNodeGrantResponse @@ -705,25 +912,35 @@ var file_service_node_grant_proto_goTypes = []interface{}{ (*CountAllEnabledNodeGrantsResponse)(nil), // 7: pb.CountAllEnabledNodeGrantsResponse (*ListEnabledNodeGrantsRequest)(nil), // 8: pb.ListEnabledNodeGrantsRequest (*ListEnabledNodeGrantsResponse)(nil), // 9: pb.ListEnabledNodeGrantsResponse - (*NodeGrant)(nil), // 10: pb.NodeGrant + (*FindAllEnabledNodeGrantsRequest)(nil), // 10: pb.FindAllEnabledNodeGrantsRequest + (*FindAllEnabledNodeGrantsResponse)(nil), // 11: pb.FindAllEnabledNodeGrantsResponse + (*FindEnabledGrantRequest)(nil), // 12: pb.FindEnabledGrantRequest + (*FindEnabledGrantResponse)(nil), // 13: pb.FindEnabledGrantResponse + (*NodeGrant)(nil), // 14: pb.NodeGrant } var file_service_node_grant_proto_depIdxs = []int32{ - 10, // 0: pb.ListEnabledNodeGrantsResponse.grants:type_name -> pb.NodeGrant - 0, // 1: pb.NodeGrantService.createNodeGrant:input_type -> pb.CreateNodeGrantRequest - 2, // 2: pb.NodeGrantService.updateNodeGrant:input_type -> pb.UpdateNodeGrantRequest - 4, // 3: pb.NodeGrantService.disableNodeGrant:input_type -> pb.DisableNodeGrantRequest - 6, // 4: pb.NodeGrantService.countAllEnabledNodeGrants:input_type -> pb.CountAllEnabledNodeGrantsRequest - 8, // 5: pb.NodeGrantService.ListEnabledNodeGrants:input_type -> pb.ListEnabledNodeGrantsRequest - 1, // 6: pb.NodeGrantService.createNodeGrant:output_type -> pb.CreateNodeGrantResponse - 3, // 7: pb.NodeGrantService.updateNodeGrant:output_type -> pb.UpdateNodeGrantResponse - 5, // 8: pb.NodeGrantService.disableNodeGrant:output_type -> pb.DisableNodeGrantResponse - 7, // 9: pb.NodeGrantService.countAllEnabledNodeGrants:output_type -> pb.CountAllEnabledNodeGrantsResponse - 9, // 10: pb.NodeGrantService.ListEnabledNodeGrants:output_type -> pb.ListEnabledNodeGrantsResponse - 6, // [6:11] is the sub-list for method output_type - 1, // [1:6] 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 + 14, // 0: pb.ListEnabledNodeGrantsResponse.grants:type_name -> pb.NodeGrant + 14, // 1: pb.FindAllEnabledNodeGrantsResponse.grants:type_name -> pb.NodeGrant + 14, // 2: pb.FindEnabledGrantResponse.grant:type_name -> pb.NodeGrant + 0, // 3: pb.NodeGrantService.createNodeGrant:input_type -> pb.CreateNodeGrantRequest + 2, // 4: pb.NodeGrantService.updateNodeGrant:input_type -> pb.UpdateNodeGrantRequest + 4, // 5: pb.NodeGrantService.disableNodeGrant:input_type -> pb.DisableNodeGrantRequest + 6, // 6: pb.NodeGrantService.countAllEnabledNodeGrants:input_type -> pb.CountAllEnabledNodeGrantsRequest + 8, // 7: pb.NodeGrantService.ListEnabledNodeGrants:input_type -> pb.ListEnabledNodeGrantsRequest + 10, // 8: pb.NodeGrantService.FindAllEnabledNodeGrants:input_type -> pb.FindAllEnabledNodeGrantsRequest + 12, // 9: pb.NodeGrantService.FindEnabledGrant:input_type -> pb.FindEnabledGrantRequest + 1, // 10: pb.NodeGrantService.createNodeGrant:output_type -> pb.CreateNodeGrantResponse + 3, // 11: pb.NodeGrantService.updateNodeGrant:output_type -> pb.UpdateNodeGrantResponse + 5, // 12: pb.NodeGrantService.disableNodeGrant:output_type -> pb.DisableNodeGrantResponse + 7, // 13: pb.NodeGrantService.countAllEnabledNodeGrants:output_type -> pb.CountAllEnabledNodeGrantsResponse + 9, // 14: pb.NodeGrantService.ListEnabledNodeGrants:output_type -> pb.ListEnabledNodeGrantsResponse + 11, // 15: pb.NodeGrantService.FindAllEnabledNodeGrants:output_type -> pb.FindAllEnabledNodeGrantsResponse + 13, // 16: pb.NodeGrantService.FindEnabledGrant:output_type -> pb.FindEnabledGrantResponse + 10, // [10:17] is the sub-list for method output_type + 3, // [3:10] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name } func init() { file_service_node_grant_proto_init() } @@ -853,6 +1070,54 @@ func file_service_node_grant_proto_init() { return nil } } + file_service_node_grant_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FindAllEnabledNodeGrantsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_node_grant_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FindAllEnabledNodeGrantsResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_node_grant_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FindEnabledGrantRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_node_grant_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FindEnabledGrantResponse); 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{ @@ -860,7 +1125,7 @@ func file_service_node_grant_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_service_node_grant_proto_rawDesc, NumEnums: 0, - NumMessages: 10, + NumMessages: 14, NumExtensions: 0, NumServices: 1, }, @@ -894,8 +1159,12 @@ type NodeGrantServiceClient interface { DisableNodeGrant(ctx context.Context, in *DisableNodeGrantRequest, opts ...grpc.CallOption) (*DisableNodeGrantResponse, error) // 计算认证的数量 CountAllEnabledNodeGrants(ctx context.Context, in *CountAllEnabledNodeGrantsRequest, opts ...grpc.CallOption) (*CountAllEnabledNodeGrantsResponse, error) - // 列出所有认证 + // 列出单页认证 ListEnabledNodeGrants(ctx context.Context, in *ListEnabledNodeGrantsRequest, opts ...grpc.CallOption) (*ListEnabledNodeGrantsResponse, error) + // 列出所有认证 + FindAllEnabledNodeGrants(ctx context.Context, in *FindAllEnabledNodeGrantsRequest, opts ...grpc.CallOption) (*FindAllEnabledNodeGrantsResponse, error) + // 获取单个认证信息 + FindEnabledGrant(ctx context.Context, in *FindEnabledGrantRequest, opts ...grpc.CallOption) (*FindEnabledGrantResponse, error) } type nodeGrantServiceClient struct { @@ -951,6 +1220,24 @@ func (c *nodeGrantServiceClient) ListEnabledNodeGrants(ctx context.Context, in * return out, nil } +func (c *nodeGrantServiceClient) FindAllEnabledNodeGrants(ctx context.Context, in *FindAllEnabledNodeGrantsRequest, opts ...grpc.CallOption) (*FindAllEnabledNodeGrantsResponse, error) { + out := new(FindAllEnabledNodeGrantsResponse) + err := c.cc.Invoke(ctx, "/pb.NodeGrantService/FindAllEnabledNodeGrants", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *nodeGrantServiceClient) FindEnabledGrant(ctx context.Context, in *FindEnabledGrantRequest, opts ...grpc.CallOption) (*FindEnabledGrantResponse, error) { + out := new(FindEnabledGrantResponse) + err := c.cc.Invoke(ctx, "/pb.NodeGrantService/FindEnabledGrant", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // NodeGrantServiceServer is the server API for NodeGrantService service. type NodeGrantServiceServer interface { // 创建认证 @@ -961,8 +1248,12 @@ type NodeGrantServiceServer interface { DisableNodeGrant(context.Context, *DisableNodeGrantRequest) (*DisableNodeGrantResponse, error) // 计算认证的数量 CountAllEnabledNodeGrants(context.Context, *CountAllEnabledNodeGrantsRequest) (*CountAllEnabledNodeGrantsResponse, error) - // 列出所有认证 + // 列出单页认证 ListEnabledNodeGrants(context.Context, *ListEnabledNodeGrantsRequest) (*ListEnabledNodeGrantsResponse, error) + // 列出所有认证 + FindAllEnabledNodeGrants(context.Context, *FindAllEnabledNodeGrantsRequest) (*FindAllEnabledNodeGrantsResponse, error) + // 获取单个认证信息 + FindEnabledGrant(context.Context, *FindEnabledGrantRequest) (*FindEnabledGrantResponse, error) } // UnimplementedNodeGrantServiceServer can be embedded to have forward compatible implementations. @@ -984,6 +1275,12 @@ func (*UnimplementedNodeGrantServiceServer) CountAllEnabledNodeGrants(context.Co func (*UnimplementedNodeGrantServiceServer) ListEnabledNodeGrants(context.Context, *ListEnabledNodeGrantsRequest) (*ListEnabledNodeGrantsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ListEnabledNodeGrants not implemented") } +func (*UnimplementedNodeGrantServiceServer) FindAllEnabledNodeGrants(context.Context, *FindAllEnabledNodeGrantsRequest) (*FindAllEnabledNodeGrantsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method FindAllEnabledNodeGrants not implemented") +} +func (*UnimplementedNodeGrantServiceServer) FindEnabledGrant(context.Context, *FindEnabledGrantRequest) (*FindEnabledGrantResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method FindEnabledGrant not implemented") +} func RegisterNodeGrantServiceServer(s *grpc.Server, srv NodeGrantServiceServer) { s.RegisterService(&_NodeGrantService_serviceDesc, srv) @@ -1079,6 +1376,42 @@ func _NodeGrantService_ListEnabledNodeGrants_Handler(srv interface{}, ctx contex return interceptor(ctx, in, info, handler) } +func _NodeGrantService_FindAllEnabledNodeGrants_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(FindAllEnabledNodeGrantsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(NodeGrantServiceServer).FindAllEnabledNodeGrants(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pb.NodeGrantService/FindAllEnabledNodeGrants", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(NodeGrantServiceServer).FindAllEnabledNodeGrants(ctx, req.(*FindAllEnabledNodeGrantsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _NodeGrantService_FindEnabledGrant_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(FindEnabledGrantRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(NodeGrantServiceServer).FindEnabledGrant(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pb.NodeGrantService/FindEnabledGrant", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(NodeGrantServiceServer).FindEnabledGrant(ctx, req.(*FindEnabledGrantRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _NodeGrantService_serviceDesc = grpc.ServiceDesc{ ServiceName: "pb.NodeGrantService", HandlerType: (*NodeGrantServiceServer)(nil), @@ -1103,6 +1436,14 @@ var _NodeGrantService_serviceDesc = grpc.ServiceDesc{ MethodName: "ListEnabledNodeGrants", Handler: _NodeGrantService_ListEnabledNodeGrants_Handler, }, + { + MethodName: "FindAllEnabledNodeGrants", + Handler: _NodeGrantService_FindAllEnabledNodeGrants_Handler, + }, + { + MethodName: "FindEnabledGrant", + Handler: _NodeGrantService_FindEnabledGrant_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "service_node_grant.proto", diff --git a/internal/rpc/protos/model_node.proto b/internal/rpc/protos/model_node.proto index 58932cb1..6bd4d9c3 100644 --- a/internal/rpc/protos/model_node.proto +++ b/internal/rpc/protos/model_node.proto @@ -4,10 +4,12 @@ option go_package = "./pb"; package pb; import "model_node_cluster.proto"; +import "model_node_login.proto"; message Node { int64 id = 1; string name = 2; NodeCluster cluster = 32; + NodeLogin login = 33; } \ No newline at end of file diff --git a/internal/rpc/protos/model_node_grant.proto b/internal/rpc/protos/model_node_grant.proto index bf377d1a..6bddffca 100644 --- a/internal/rpc/protos/model_node_grant.proto +++ b/internal/rpc/protos/model_node_grant.proto @@ -7,9 +7,10 @@ message NodeGrant { int64 id = 1; string name = 2; string method = 3; - string password = 4; - bool su = 5; - string privateKey = 6; - string description = 7; - int64 nodeId = 8; + string username = 4; + string password = 5; + bool su = 6; + string privateKey = 7; + string description = 8; + int64 nodeId = 9; } \ No newline at end of file diff --git a/internal/rpc/protos/model_node_login.proto b/internal/rpc/protos/model_node_login.proto new file mode 100644 index 00000000..3ad28698 --- /dev/null +++ b/internal/rpc/protos/model_node_login.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; +option go_package = "./pb"; + +package pb; + +message NodeLogin { + int64 id = 1; + string name = 2; + string type = 3; + bytes params = 4; +} \ No newline at end of file diff --git a/internal/rpc/protos/service_node.proto b/internal/rpc/protos/service_node.proto index 26c797ab..c3719fec 100644 --- a/internal/rpc/protos/service_node.proto +++ b/internal/rpc/protos/service_node.proto @@ -3,6 +3,7 @@ option go_package = "./pb"; package pb; import "model_node.proto"; +import "model_node_login.proto"; service NodeService { // 创建节点 @@ -13,12 +14,22 @@ service NodeService { // 列出单页节点 rpc listEnabledNodes (ListEnabledNodesRequest) returns (ListEnabledNodesResponse); + + // 禁用节点 + rpc disableNode (DisableNodeRequest) returns (DisableNodeResponse); + + // 修改节点 + rpc updateNode(UpdateNodeRequest) returns (UpdateNodeResponse); + + // 查看单个节点 + rpc findEnabledNode(FindEnabledNodeRequest) returns (FindEnabledNodeResponse); } // 创建节点 message CreateNodeRequest { string name = 1; int64 clusterId = 2; + NodeLogin Login = 3; } message CreateNodeResponse { @@ -43,3 +54,33 @@ message ListEnabledNodesRequest { message ListEnabledNodesResponse { repeated Node nodes = 1; } + +// 禁用节点 +message DisableNodeRequest { + int64 nodeId = 1; +} + +message DisableNodeResponse { + +} + +// 修改节点 +message UpdateNodeRequest { + int64 nodeId = 1; + string name = 2; + int64 clusterId = 3; + NodeLogin Login = 4; +} + +message UpdateNodeResponse { + +} + +// 查找节点 +message FindEnabledNodeRequest { + int64 nodeId = 1; +} + +message FindEnabledNodeResponse { + Node node = 1; +} \ No newline at end of file diff --git a/internal/rpc/protos/service_node_grant.proto b/internal/rpc/protos/service_node_grant.proto index eb9158b1..6a2d3c27 100644 --- a/internal/rpc/protos/service_node_grant.proto +++ b/internal/rpc/protos/service_node_grant.proto @@ -17,8 +17,14 @@ service NodeGrantService { // 计算认证的数量 rpc countAllEnabledNodeGrants (CountAllEnabledNodeGrantsRequest) returns (CountAllEnabledNodeGrantsResponse); - // 列出所有认证 + // 列出单页认证 rpc ListEnabledNodeGrants (ListEnabledNodeGrantsRequest) returns (ListEnabledNodeGrantsResponse); + + // 列出所有认证 + rpc FindAllEnabledNodeGrants(FindAllEnabledNodeGrantsRequest) returns (FindAllEnabledNodeGrantsResponse); + + // 获取单个认证信息 + rpc FindEnabledGrant(FindEnabledGrantRequest) returns (FindEnabledGrantResponse); } // 创建节点认证 @@ -70,7 +76,7 @@ message CountAllEnabledNodeGrantsResponse { int64 count = 1; } -// 列出所有认证 +// 列出单页认证 message ListEnabledNodeGrantsRequest { int64 offset = 1; int64 size = 2; @@ -78,4 +84,22 @@ message ListEnabledNodeGrantsRequest { message ListEnabledNodeGrantsResponse { repeated NodeGrant grants = 1; +} + +// 获取所有认证信息 +message FindAllEnabledNodeGrantsRequest { + +} + +message FindAllEnabledNodeGrantsResponse { + repeated NodeGrant grants = 1; +} + +// 获取认证信息 +message FindEnabledGrantRequest { + int64 grantId = 1; +} + +message FindEnabledGrantResponse { + NodeGrant grant = 1; } \ No newline at end of file diff --git a/internal/rpc/services/service_node.go b/internal/rpc/services/service_node.go index 209b4ae5..943a40fe 100644 --- a/internal/rpc/services/service_node.go +++ b/internal/rpc/services/service_node.go @@ -16,17 +16,26 @@ func (this *NodeService) CreateNode(ctx context.Context, req *pb.CreateNodeReque return nil, err } - nodeId, err := models.SharedNodeDAO.CreateNode(req.Name, int(req.ClusterId)) + nodeId, err := models.SharedNodeDAO.CreateNode(req.Name, req.ClusterId) if err != nil { return nil, err } + // 增加认证相关 + if req.Login != nil { + _, err = models.SharedNodeLoginDAO.CreateNodeLogin(nodeId, req.Login.Name, req.Login.Type, req.Login.Params) + if err != nil { + return nil, err + } + } + return &pb.CreateNodeResponse{ - NodeId: int64(nodeId), + NodeId: nodeId, }, nil } func (this *NodeService) CountAllEnabledNodes(ctx context.Context, req *pb.CountAllEnabledNodesRequest) (*pb.CountAllEnabledNodesResponse, error) { + _ = req _, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin) if err != nil { return nil, err @@ -70,3 +79,99 @@ func (this *NodeService) ListEnabledNodes(ctx context.Context, req *pb.ListEnabl Nodes: result, }, nil } + +// 禁用节点 +func (this *NodeService) DisableNode(ctx context.Context, req *pb.DisableNodeRequest) (*pb.DisableNodeResponse, error) { + _, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin) + if err != nil { + return nil, err + } + + err = models.SharedNodeDAO.DisableNode(req.NodeId) + if err != nil { + return nil, err + } + + return &pb.DisableNodeResponse{}, nil +} + +// 修改节点 +func (this *NodeService) UpdateNode(ctx context.Context, req *pb.UpdateNodeRequest) (*pb.UpdateNodeResponse, error) { + _, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin) + if err != nil { + return nil, err + } + + err = models.SharedNodeDAO.UpdateNode(req.NodeId, req.Name, req.ClusterId) + if err != nil { + return nil, err + } + + if req.Login == nil { + err = models.SharedNodeLoginDAO.DisableNodeLogins(req.NodeId) + if err != nil { + return nil, err + } + } else { + if req.Login.Id > 0 { + err = models.SharedNodeLoginDAO.UpdateNodeLogin(req.Login.Id, req.Login.Name, req.Login.Type, req.Login.Params) + if err != nil { + return nil, err + } + } else { + _, err = models.SharedNodeLoginDAO.CreateNodeLogin(req.NodeId, req.Login.Name, req.Login.Type, req.Login.Params) + if err != nil { + return nil, err + } + } + } + + return &pb.UpdateNodeResponse{}, nil +} + +// 列出单个节点 +func (this *NodeService) FindEnabledNode(ctx context.Context, req *pb.FindEnabledNodeRequest) (*pb.FindEnabledNodeResponse, error) { + _, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin) + if err != nil { + return nil, err + } + + node, err := models.SharedNodeDAO.FindEnabledNode(req.NodeId) + if err != nil { + return nil, err + } + if node == nil { + return &pb.FindEnabledNodeResponse{Node: nil}, nil + } + + // 集群信息 + clusterName, err := models.SharedNodeClusterDAO.FindNodeClusterName(int64(node.ClusterId)) + if err != nil { + return nil, err + } + + // 认证信息 + login, err := models.SharedNodeLoginDAO.FindEnabledNodeLoginWithNodeId(req.NodeId) + if err != nil { + return nil, err + } + var respLogin *pb.NodeLogin = nil + if login != nil { + respLogin = &pb.NodeLogin{ + Id: int64(login.Id), + Name: login.Name, + Type: login.Type, + Params: []byte(login.Params), + } + } + + return &pb.FindEnabledNodeResponse{Node: &pb.Node{ + Id: int64(node.Id), + Name: node.Name, + Cluster: &pb.NodeCluster{ + Id: int64(node.ClusterId), + Name: clusterName, + }, + Login: respLogin, + }}, nil +} diff --git a/internal/rpc/services/service_node_grant.go b/internal/rpc/services/service_node_grant.go index 9f656276..e1d7748b 100644 --- a/internal/rpc/services/service_node_grant.go +++ b/internal/rpc/services/service_node_grant.go @@ -87,3 +87,56 @@ func (this *NodeGrantService) ListEnabledNodeGrants(ctx context.Context, req *pb return &pb.ListEnabledNodeGrantsResponse{Grants: result}, nil } + +// 列出所有认证信息 +func (this *NodeGrantService) FindAllEnabledNodeGrants(ctx context.Context, req *pb.FindAllEnabledNodeGrantsRequest) (*pb.FindAllEnabledNodeGrantsResponse, error) { + _, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin) + if err != nil { + return nil, err + } + grants, err := models.SharedNodeGrantDAO.FindAllEnabledGrants() + if err != nil { + return nil, err + } + result := []*pb.NodeGrant{} + for _, grant := range grants { + result = append(result, &pb.NodeGrant{ + Id: int64(grant.Id), + Name: grant.Name, + Method: grant.Method, + Password: grant.Password, + Su: grant.Su == 1, + PrivateKey: grant.PrivateKey, + Description: grant.Description, + NodeId: int64(grant.NodeId), + }) + } + + return &pb.FindAllEnabledNodeGrantsResponse{Grants: result}, nil +} + +func (this *NodeGrantService) FindEnabledGrant(ctx context.Context, req *pb.FindEnabledGrantRequest) (*pb.FindEnabledGrantResponse, error) { + _, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin) + if err != nil { + return nil, err + } + + grant, err := models.SharedNodeGrantDAO.FindEnabledNodeGrant(req.GrantId) + if err != nil { + return nil, err + } + if grant == nil { + return &pb.FindEnabledGrantResponse{}, nil + } + return &pb.FindEnabledGrantResponse{Grant: &pb.NodeGrant{ + Id: int64(grant.Id), + Name: grant.Name, + Method: grant.Method, + Username: grant.Username, + Password: grant.Password, + Su: grant.Su == 1, + PrivateKey: grant.PrivateKey, + Description: grant.Description, + NodeId: int64(grant.NodeId), + }}, nil +}