mirror of
				https://github.com/TeaOSLab/EdgeCommon.git
				synced 2025-11-04 05:00:24 +08:00 
			
		
		
		
	实现基本的区域监控终端管理功能
This commit is contained in:
		@@ -6,7 +6,7 @@ type NSMessageCode = string
 | 
			
		||||
const (
 | 
			
		||||
	NSMessageCodeConnectedAPINode    NSMessageCode = "connectedAPINode"    // NS节点连接API节点成功
 | 
			
		||||
	NSMessageCodeCheckSystemdService NSMessageCode = "checkSystemdService" // 检查Systemd服务
 | 
			
		||||
	NSMessageCodeNewNodeTask         MessageCode   = "newNodeTask"         // 有新的节点任务产生
 | 
			
		||||
	NSMessageCodeNewNodeTask         NSMessageCode = "newNodeTask"         // 有新的节点任务产生
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// NSConnectedAPINodeMessage 连接API节点成功
 | 
			
		||||
 
 | 
			
		||||
@@ -14,4 +14,5 @@ const (
 | 
			
		||||
	NodeRoleNode      NodeRole = "node"
 | 
			
		||||
	NodeRoleCluster   NodeRole = "cluster"
 | 
			
		||||
	NodeRoleAuthority NodeRole = "authority"
 | 
			
		||||
	NodeRoleReport    NodeRole = "report"
 | 
			
		||||
)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										23
									
								
								pkg/reporterconfigs/messages.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								pkg/reporterconfigs/messages.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
			
		||||
package reporterconfigs
 | 
			
		||||
 | 
			
		||||
type MessageCode = string
 | 
			
		||||
 | 
			
		||||
// 节点相关消息
 | 
			
		||||
const (
 | 
			
		||||
	MessageCodeConnectedAPINode    MessageCode = "connectedAPINode"    // 节点连接API节点成功
 | 
			
		||||
	MessageCodeCheckSystemdService MessageCode = "checkSystemdService" // 检查Systemd服务
 | 
			
		||||
	MessageCodeNewNodeTask         MessageCode = "newNodeTask"         // 有新的节点任务产生
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// ConnectedAPINodeMessage 连接API节点成功
 | 
			
		||||
type ConnectedAPINodeMessage struct {
 | 
			
		||||
	APINodeId int64 `json:"apiNodeId"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CheckSystemdServiceMessage Systemd服务
 | 
			
		||||
type CheckSystemdServiceMessage struct {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NewNodeTaskMessage 有新的节点任务
 | 
			
		||||
type NewNodeTaskMessage struct {
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										11
									
								
								pkg/reporterconfigs/node_config.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								pkg/reporterconfigs/node_config.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
 | 
			
		||||
 | 
			
		||||
package reporterconfigs
 | 
			
		||||
 | 
			
		||||
type NodeConfig struct {
 | 
			
		||||
	Id int64 `json:"id"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *NodeConfig) Init() error {
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										16
									
								
								pkg/reporterconfigs/status.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								pkg/reporterconfigs/status.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,16 @@
 | 
			
		||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
 | 
			
		||||
 | 
			
		||||
package reporterconfigs
 | 
			
		||||
 | 
			
		||||
type Status struct {
 | 
			
		||||
	IP               string `json:"ip"`
 | 
			
		||||
	OS               string `json:"os"`
 | 
			
		||||
	OSName           string `json:"osName"`
 | 
			
		||||
	Username         string `json:"username"`
 | 
			
		||||
	BuildVersion     string `json:"buildVersion"`     // 编译版本
 | 
			
		||||
	BuildVersionCode uint32 `json:"buildVersionCode"` // 版本数字
 | 
			
		||||
	UpdatedAt        int64  `json:"updatedAt"`        // 更新时间
 | 
			
		||||
 | 
			
		||||
	Location string `json:"location"` // 从IP查询到的Location
 | 
			
		||||
	ISP      string `json:"isp"`      // 从IP查询到的ISP
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										233
									
								
								pkg/rpc/pb/model_report_node.pb.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										233
									
								
								pkg/rpc/pb/model_report_node.pb.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,233 @@
 | 
			
		||||
// Code generated by protoc-gen-go. DO NOT EDIT.
 | 
			
		||||
// versions:
 | 
			
		||||
// 	protoc-gen-go v1.25.0
 | 
			
		||||
// 	protoc        v3.12.3
 | 
			
		||||
// source: models/model_report_node.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 ReportNode struct {
 | 
			
		||||
	state         protoimpl.MessageState
 | 
			
		||||
	sizeCache     protoimpl.SizeCache
 | 
			
		||||
	unknownFields protoimpl.UnknownFields
 | 
			
		||||
 | 
			
		||||
	Id         int64    `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
 | 
			
		||||
	UniqueId   string   `protobuf:"bytes,2,opt,name=uniqueId,proto3" json:"uniqueId,omitempty"`
 | 
			
		||||
	Secret     string   `protobuf:"bytes,3,opt,name=secret,proto3" json:"secret,omitempty"`
 | 
			
		||||
	IsOn       bool     `protobuf:"varint,4,opt,name=isOn,proto3" json:"isOn,omitempty"`
 | 
			
		||||
	Name       string   `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"`
 | 
			
		||||
	Location   string   `protobuf:"bytes,6,opt,name=location,proto3" json:"location,omitempty"`
 | 
			
		||||
	Isp        string   `protobuf:"bytes,7,opt,name=isp,proto3" json:"isp,omitempty"`
 | 
			
		||||
	IsActive   bool     `protobuf:"varint,8,opt,name=isActive,proto3" json:"isActive,omitempty"`
 | 
			
		||||
	StatusJSON []byte   `protobuf:"bytes,9,opt,name=statusJSON,proto3" json:"statusJSON,omitempty"`
 | 
			
		||||
	AllowIPs   []string `protobuf:"bytes,10,rep,name=allowIPs,proto3" json:"allowIPs,omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (x *ReportNode) Reset() {
 | 
			
		||||
	*x = ReportNode{}
 | 
			
		||||
	if protoimpl.UnsafeEnabled {
 | 
			
		||||
		mi := &file_models_model_report_node_proto_msgTypes[0]
 | 
			
		||||
		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
 | 
			
		||||
		ms.StoreMessageInfo(mi)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (x *ReportNode) String() string {
 | 
			
		||||
	return protoimpl.X.MessageStringOf(x)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (*ReportNode) ProtoMessage() {}
 | 
			
		||||
 | 
			
		||||
func (x *ReportNode) ProtoReflect() protoreflect.Message {
 | 
			
		||||
	mi := &file_models_model_report_node_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 ReportNode.ProtoReflect.Descriptor instead.
 | 
			
		||||
func (*ReportNode) Descriptor() ([]byte, []int) {
 | 
			
		||||
	return file_models_model_report_node_proto_rawDescGZIP(), []int{0}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (x *ReportNode) GetId() int64 {
 | 
			
		||||
	if x != nil {
 | 
			
		||||
		return x.Id
 | 
			
		||||
	}
 | 
			
		||||
	return 0
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (x *ReportNode) GetUniqueId() string {
 | 
			
		||||
	if x != nil {
 | 
			
		||||
		return x.UniqueId
 | 
			
		||||
	}
 | 
			
		||||
	return ""
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (x *ReportNode) GetSecret() string {
 | 
			
		||||
	if x != nil {
 | 
			
		||||
		return x.Secret
 | 
			
		||||
	}
 | 
			
		||||
	return ""
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (x *ReportNode) GetIsOn() bool {
 | 
			
		||||
	if x != nil {
 | 
			
		||||
		return x.IsOn
 | 
			
		||||
	}
 | 
			
		||||
	return false
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (x *ReportNode) GetName() string {
 | 
			
		||||
	if x != nil {
 | 
			
		||||
		return x.Name
 | 
			
		||||
	}
 | 
			
		||||
	return ""
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (x *ReportNode) GetLocation() string {
 | 
			
		||||
	if x != nil {
 | 
			
		||||
		return x.Location
 | 
			
		||||
	}
 | 
			
		||||
	return ""
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (x *ReportNode) GetIsp() string {
 | 
			
		||||
	if x != nil {
 | 
			
		||||
		return x.Isp
 | 
			
		||||
	}
 | 
			
		||||
	return ""
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (x *ReportNode) GetIsActive() bool {
 | 
			
		||||
	if x != nil {
 | 
			
		||||
		return x.IsActive
 | 
			
		||||
	}
 | 
			
		||||
	return false
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (x *ReportNode) GetStatusJSON() []byte {
 | 
			
		||||
	if x != nil {
 | 
			
		||||
		return x.StatusJSON
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (x *ReportNode) GetAllowIPs() []string {
 | 
			
		||||
	if x != nil {
 | 
			
		||||
		return x.AllowIPs
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var File_models_model_report_node_proto protoreflect.FileDescriptor
 | 
			
		||||
 | 
			
		||||
var file_models_model_report_node_proto_rawDesc = []byte{
 | 
			
		||||
	0x0a, 0x1e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x72,
 | 
			
		||||
	0x65, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
 | 
			
		||||
	0x12, 0x02, 0x70, 0x62, 0x22, 0xfe, 0x01, 0x0a, 0x0a, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x4e,
 | 
			
		||||
	0x6f, 0x64, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52,
 | 
			
		||||
	0x02, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x49, 0x64, 0x18,
 | 
			
		||||
	0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x49, 0x64, 0x12,
 | 
			
		||||
	0x16, 0x0a, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52,
 | 
			
		||||
	0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x73, 0x4f, 0x6e, 0x18,
 | 
			
		||||
	0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x69, 0x73, 0x4f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e,
 | 
			
		||||
	0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12,
 | 
			
		||||
	0x1a, 0x0a, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28,
 | 
			
		||||
	0x09, 0x52, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x69,
 | 
			
		||||
	0x73, 0x70, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x69, 0x73, 0x70, 0x12, 0x1a, 0x0a,
 | 
			
		||||
	0x08, 0x69, 0x73, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52,
 | 
			
		||||
	0x08, 0x69, 0x73, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x74, 0x61,
 | 
			
		||||
	0x74, 0x75, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x73,
 | 
			
		||||
	0x74, 0x61, 0x74, 0x75, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x6c, 0x6c,
 | 
			
		||||
	0x6f, 0x77, 0x49, 0x50, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x61, 0x6c, 0x6c,
 | 
			
		||||
	0x6f, 0x77, 0x49, 0x50, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70,
 | 
			
		||||
	0x72, 0x6f, 0x74, 0x6f, 0x33,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	file_models_model_report_node_proto_rawDescOnce sync.Once
 | 
			
		||||
	file_models_model_report_node_proto_rawDescData = file_models_model_report_node_proto_rawDesc
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func file_models_model_report_node_proto_rawDescGZIP() []byte {
 | 
			
		||||
	file_models_model_report_node_proto_rawDescOnce.Do(func() {
 | 
			
		||||
		file_models_model_report_node_proto_rawDescData = protoimpl.X.CompressGZIP(file_models_model_report_node_proto_rawDescData)
 | 
			
		||||
	})
 | 
			
		||||
	return file_models_model_report_node_proto_rawDescData
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var file_models_model_report_node_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
 | 
			
		||||
var file_models_model_report_node_proto_goTypes = []interface{}{
 | 
			
		||||
	(*ReportNode)(nil), // 0: pb.ReportNode
 | 
			
		||||
}
 | 
			
		||||
var file_models_model_report_node_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_models_model_report_node_proto_init() }
 | 
			
		||||
func file_models_model_report_node_proto_init() {
 | 
			
		||||
	if File_models_model_report_node_proto != nil {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	if !protoimpl.UnsafeEnabled {
 | 
			
		||||
		file_models_model_report_node_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
 | 
			
		||||
			switch v := v.(*ReportNode); 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_models_model_report_node_proto_rawDesc,
 | 
			
		||||
			NumEnums:      0,
 | 
			
		||||
			NumMessages:   1,
 | 
			
		||||
			NumExtensions: 0,
 | 
			
		||||
			NumServices:   0,
 | 
			
		||||
		},
 | 
			
		||||
		GoTypes:           file_models_model_report_node_proto_goTypes,
 | 
			
		||||
		DependencyIndexes: file_models_model_report_node_proto_depIdxs,
 | 
			
		||||
		MessageInfos:      file_models_model_report_node_proto_msgTypes,
 | 
			
		||||
	}.Build()
 | 
			
		||||
	File_models_model_report_node_proto = out.File
 | 
			
		||||
	file_models_model_report_node_proto_rawDesc = nil
 | 
			
		||||
	file_models_model_report_node_proto_goTypes = nil
 | 
			
		||||
	file_models_model_report_node_proto_depIdxs = nil
 | 
			
		||||
}
 | 
			
		||||
@@ -989,7 +989,7 @@ func (x *UpdateNSNodeIsInstalledRequest) GetIsInstalled() bool {
 | 
			
		||||
	return false
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 更新认证状态
 | 
			
		||||
// 更新节点状态
 | 
			
		||||
type UpdateNSNodeStatusRequest struct {
 | 
			
		||||
	state         protoimpl.MessageState
 | 
			
		||||
	sizeCache     protoimpl.SizeCache
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1570
									
								
								pkg/rpc/pb/service_report_node.pb.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1570
									
								
								pkg/rpc/pb/service_report_node.pb.go
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										17
									
								
								pkg/rpc/protos/models/model_report_node.proto
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								pkg/rpc/protos/models/model_report_node.proto
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
			
		||||
syntax = "proto3";
 | 
			
		||||
option go_package = "./pb";
 | 
			
		||||
 | 
			
		||||
package pb;
 | 
			
		||||
 | 
			
		||||
message ReportNode {
 | 
			
		||||
	int64 id = 1;
 | 
			
		||||
	string uniqueId = 2;
 | 
			
		||||
	string secret = 3;
 | 
			
		||||
	bool isOn = 4;
 | 
			
		||||
	string name = 5;
 | 
			
		||||
	string location = 6;
 | 
			
		||||
	string isp = 7;
 | 
			
		||||
	bool isActive = 8;
 | 
			
		||||
	bytes statusJSON = 9;
 | 
			
		||||
	repeated string allowIPs = 10;
 | 
			
		||||
}
 | 
			
		||||
@@ -180,7 +180,7 @@ message UpdateNSNodeIsInstalledRequest {
 | 
			
		||||
	bool isInstalled = 2;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 更新认证状态
 | 
			
		||||
// 更新节点状态
 | 
			
		||||
message UpdateNSNodeStatusRequest {
 | 
			
		||||
	int64 nodeId = 1;
 | 
			
		||||
	bytes statusJSON = 2;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										115
									
								
								pkg/rpc/protos/service_report_node.proto
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										115
									
								
								pkg/rpc/protos/service_report_node.proto
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,115 @@
 | 
			
		||||
syntax = "proto3";
 | 
			
		||||
option go_package = "./pb";
 | 
			
		||||
 | 
			
		||||
package pb;
 | 
			
		||||
 | 
			
		||||
import "models/model_report_node.proto";
 | 
			
		||||
import "models/rpc_messages.proto";
 | 
			
		||||
 | 
			
		||||
// 监控终端服务
 | 
			
		||||
service ReportNodeService {
 | 
			
		||||
	// 添加终端
 | 
			
		||||
	rpc createReportNode(CreateReportNodeRequest) returns (CreateReportNodeResponse);
 | 
			
		||||
 | 
			
		||||
	// 删除终端
 | 
			
		||||
	rpc deleteReportNode(DeleteReportNodeRequest) returns (RPCSuccess);
 | 
			
		||||
 | 
			
		||||
	// 修改终端
 | 
			
		||||
	rpc updateReportNode(UpdateReportNodeRequest) returns (RPCSuccess);
 | 
			
		||||
 | 
			
		||||
	// 计算终端数量
 | 
			
		||||
	rpc countAllEnabledReportNodes(CountAllEnabledReportNodesRequest) returns (RPCCountResponse);
 | 
			
		||||
 | 
			
		||||
	// 列出单页终端
 | 
			
		||||
	rpc listEnabledReportNodes(ListEnabledReportNodesRequest) returns (ListEnabledReportNodesResponse);
 | 
			
		||||
 | 
			
		||||
	// 查找单个终端
 | 
			
		||||
	rpc findEnabledReportNode(FindEnabledReportNodeRequest) returns (FindEnabledReportNodeResponse);
 | 
			
		||||
 | 
			
		||||
	// 终端stream
 | 
			
		||||
	rpc reportNodeStream (stream ReportNodeStreamMessage) returns (stream ReportNodeStreamMessage);
 | 
			
		||||
 | 
			
		||||
	// 更新节点状态
 | 
			
		||||
	rpc updateReportNodeStatus (UpdateReportNodeStatusRequest) returns (RPCSuccess);
 | 
			
		||||
 | 
			
		||||
	// 获取当前节点信息
 | 
			
		||||
	rpc findCurrentReportNodeConfig (FindCurrentReportNodeConfigRequest) returns (FindCurrentReportNodeConfigResponse);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 添加终端
 | 
			
		||||
message CreateReportNodeRequest {
 | 
			
		||||
	string name = 1;
 | 
			
		||||
	string location = 2;
 | 
			
		||||
	string isp = 3;
 | 
			
		||||
	repeated string allowIPs = 4;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
message CreateReportNodeResponse {
 | 
			
		||||
	int64 reportNodeId = 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 删除终端
 | 
			
		||||
message DeleteReportNodeRequest {
 | 
			
		||||
	int64 reportNodeId = 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 修改终端
 | 
			
		||||
message UpdateReportNodeRequest{
 | 
			
		||||
	int64 reportNodeId = 1;
 | 
			
		||||
	string name = 2;
 | 
			
		||||
	string location = 3;
 | 
			
		||||
	string isp = 4;
 | 
			
		||||
	repeated string allowIPs = 5;
 | 
			
		||||
	bool isOn = 6;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 计算终端数量
 | 
			
		||||
message CountAllEnabledReportNodesRequest {
 | 
			
		||||
	string keyword = 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 列出单页终端
 | 
			
		||||
message ListEnabledReportNodesRequest {
 | 
			
		||||
	string keyword = 1;
 | 
			
		||||
	int64 offset = 2;
 | 
			
		||||
	int64 size = 3;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
message ListEnabledReportNodesResponse {
 | 
			
		||||
	repeated ReportNode reportNodes = 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 查找单个终端
 | 
			
		||||
message FindEnabledReportNodeRequest{
 | 
			
		||||
	int64 reportNodeId = 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
message FindEnabledReportNodeResponse {
 | 
			
		||||
	ReportNode reportNode = 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 终端stream
 | 
			
		||||
message ReportNodeStreamMessage {
 | 
			
		||||
	int64 reportNodeId = 1;
 | 
			
		||||
	int64 requestId = 2;
 | 
			
		||||
	int32 timeoutSeconds = 3;
 | 
			
		||||
	string code = 4;
 | 
			
		||||
	bytes dataJSON = 5;
 | 
			
		||||
	bool isOk = 6;
 | 
			
		||||
	string message = 7;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 更新节点状态
 | 
			
		||||
message UpdateReportNodeStatusRequest {
 | 
			
		||||
	bytes statusJSON = 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// 获取当前节点信息
 | 
			
		||||
message FindCurrentReportNodeConfigRequest {
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
message FindCurrentReportNodeConfigResponse {
 | 
			
		||||
	bytes reportNodeJSON = 1;
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user