mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-03 12:20:27 +08:00
[域名服务]实现基本的线路配置
This commit is contained in:
15
pkg/dnsconfigs/route_ranges.go
Normal file
15
pkg/dnsconfigs/route_ranges.go
Normal file
@@ -0,0 +1,15 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
|
||||
package dnsconfigs
|
||||
|
||||
type RouteRangeType = string
|
||||
|
||||
const (
|
||||
RouteRangeTypeIP RouteRangeType = "ipRange"
|
||||
)
|
||||
|
||||
// RouteRangeIPRange IP范围配置
|
||||
type RouteRangeIPRange struct {
|
||||
IPFrom string `json:"ipFrom"`
|
||||
IPTo string `json:"ipTo"`
|
||||
}
|
||||
@@ -31,9 +31,12 @@ type NSRoute struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
IsOn bool `protobuf:"varint,2,opt,name=isOn,proto3" json:"isOn,omitempty"`
|
||||
Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
IsOn bool `protobuf:"varint,2,opt,name=isOn,proto3" json:"isOn,omitempty"`
|
||||
Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
|
||||
RangesJSON []byte `protobuf:"bytes,4,opt,name=rangesJSON,proto3" json:"rangesJSON,omitempty"`
|
||||
NsCluster *NSCluster `protobuf:"bytes,30,opt,name=nsCluster,proto3" json:"nsCluster,omitempty"`
|
||||
NsDomain *NSDomain `protobuf:"bytes,31,opt,name=nsDomain,proto3" json:"nsDomain,omitempty"`
|
||||
}
|
||||
|
||||
func (x *NSRoute) Reset() {
|
||||
@@ -89,17 +92,49 @@ func (x *NSRoute) GetName() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *NSRoute) GetRangesJSON() []byte {
|
||||
if x != nil {
|
||||
return x.RangesJSON
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *NSRoute) GetNsCluster() *NSCluster {
|
||||
if x != nil {
|
||||
return x.NsCluster
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *NSRoute) GetNsDomain() *NSDomain {
|
||||
if x != nil {
|
||||
return x.NsDomain
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_models_model_ns_route_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_models_model_ns_route_proto_rawDesc = []byte{
|
||||
0x0a, 0x1b, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x6e,
|
||||
0x73, 0x5f, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70,
|
||||
0x62, 0x22, 0x41, 0x0a, 0x07, 0x4e, 0x53, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02,
|
||||
0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04,
|
||||
0x69, 0x73, 0x4f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x69, 0x73, 0x4f, 0x6e,
|
||||
0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
|
||||
0x6e, 0x61, 0x6d, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x33,
|
||||
0x62, 0x1a, 0x1d, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f,
|
||||
0x6e, 0x73, 0x5f, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x1a, 0x1c, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x6e,
|
||||
0x73, 0x5f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb8,
|
||||
0x01, 0x0a, 0x07, 0x4e, 0x53, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x73,
|
||||
0x4f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x69, 0x73, 0x4f, 0x6e, 0x12, 0x12,
|
||||
0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61,
|
||||
0x6d, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x4a, 0x53, 0x4f, 0x4e,
|
||||
0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x4a, 0x53,
|
||||
0x4f, 0x4e, 0x12, 0x2b, 0x0a, 0x09, 0x6e, 0x73, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x18,
|
||||
0x1e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x70, 0x62, 0x2e, 0x4e, 0x53, 0x43, 0x6c, 0x75,
|
||||
0x73, 0x74, 0x65, 0x72, 0x52, 0x09, 0x6e, 0x73, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x12,
|
||||
0x28, 0x0a, 0x08, 0x6e, 0x73, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x1f, 0x20, 0x01, 0x28,
|
||||
0x0b, 0x32, 0x0c, 0x2e, 0x70, 0x62, 0x2e, 0x4e, 0x53, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52,
|
||||
0x08, 0x6e, 0x73, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70,
|
||||
0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -116,14 +151,18 @@ func file_models_model_ns_route_proto_rawDescGZIP() []byte {
|
||||
|
||||
var file_models_model_ns_route_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_models_model_ns_route_proto_goTypes = []interface{}{
|
||||
(*NSRoute)(nil), // 0: pb.NSRoute
|
||||
(*NSRoute)(nil), // 0: pb.NSRoute
|
||||
(*NSCluster)(nil), // 1: pb.NSCluster
|
||||
(*NSDomain)(nil), // 2: pb.NSDomain
|
||||
}
|
||||
var file_models_model_ns_route_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
|
||||
1, // 0: pb.NSRoute.nsCluster:type_name -> pb.NSCluster
|
||||
2, // 1: pb.NSRoute.nsDomain:type_name -> pb.NSDomain
|
||||
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_models_model_ns_route_proto_init() }
|
||||
@@ -131,6 +170,8 @@ func file_models_model_ns_route_proto_init() {
|
||||
if File_models_model_ns_route_proto != nil {
|
||||
return
|
||||
}
|
||||
file_models_model_ns_cluster_proto_init()
|
||||
file_models_model_ns_domain_proto_init()
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_models_model_ns_route_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*NSRoute); i {
|
||||
|
||||
1069
pkg/rpc/pb/service_ns_route.pb.go
Normal file
1069
pkg/rpc/pb/service_ns_route.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
@@ -3,9 +3,16 @@ option go_package = "./pb";
|
||||
|
||||
package pb;
|
||||
|
||||
import "models/model_ns_cluster.proto";
|
||||
import "models/model_ns_domain.proto";
|
||||
|
||||
// 线路
|
||||
message NSRoute {
|
||||
int64 id = 1;
|
||||
bool isOn = 2;
|
||||
string name = 3;
|
||||
bytes rangesJSON = 4;
|
||||
|
||||
NSCluster nsCluster = 30;
|
||||
NSDomain nsDomain = 31;
|
||||
}
|
||||
78
pkg/rpc/protos/service_ns_route.proto
Normal file
78
pkg/rpc/protos/service_ns_route.proto
Normal file
@@ -0,0 +1,78 @@
|
||||
syntax = "proto3";
|
||||
option go_package = "./pb";
|
||||
|
||||
package pb;
|
||||
|
||||
import "models/model_ns_route.proto";
|
||||
import "models/rpc_messages.proto";
|
||||
|
||||
// 线路相关服务
|
||||
service NSRouteService {
|
||||
// 创建线路
|
||||
rpc createNSRoute (CreateNSRouteRequest) returns (CreateNSRouteResponse);
|
||||
|
||||
// 修改线路
|
||||
rpc updateNSRoute (UpdateNSRouteRequest) returns (RPCSuccess);
|
||||
|
||||
// 删除线路
|
||||
rpc deleteNSRoute (DeleteNSRouteRequest) returns (RPCSuccess);
|
||||
|
||||
// 获取单个路线信息
|
||||
rpc findEnabledNSRoute (FindEnabledNSRouteRequest) returns (FindEnabledNSRouteResponse);
|
||||
|
||||
// 读取所有线路
|
||||
rpc findAllEnabledNSRoutes (FindAllEnabledNSRoutesRequest) returns (FindAllEnabledNSRoutesResponse);
|
||||
|
||||
// 设置线路排序
|
||||
rpc updateNSRouteOrders (UpdateNSRouteOrdersRequest) returns (RPCSuccess);
|
||||
}
|
||||
|
||||
// 创建线路
|
||||
message CreateNSRouteRequest {
|
||||
int64 nsClusterId = 1;
|
||||
int64 nsDomainId = 2;
|
||||
int64 userId = 3;
|
||||
string name = 4;
|
||||
bytes rangesJSON = 5;
|
||||
}
|
||||
|
||||
message CreateNSRouteResponse {
|
||||
int64 nsRouteId = 1;
|
||||
}
|
||||
|
||||
// 修改线路
|
||||
message UpdateNSRouteRequest {
|
||||
int64 nsRouteId = 1;
|
||||
string name = 2;
|
||||
bytes rangesJSON = 3;
|
||||
}
|
||||
|
||||
// 删除线路
|
||||
message DeleteNSRouteRequest {
|
||||
int64 nsRouteId = 1;
|
||||
}
|
||||
|
||||
// 获取单个路线信息
|
||||
message FindEnabledNSRouteRequest {
|
||||
int64 nsRouteId = 1;
|
||||
}
|
||||
|
||||
message FindEnabledNSRouteResponse {
|
||||
NSRoute nsRoute = 1;
|
||||
}
|
||||
|
||||
// 读取所有线路
|
||||
message FindAllEnabledNSRoutesRequest {
|
||||
int64 nsClusterId = 1;
|
||||
int64 nsDomainId = 2;
|
||||
int64 userId = 3;
|
||||
}
|
||||
|
||||
message FindAllEnabledNSRoutesResponse {
|
||||
repeated NSRoute nsRoutes = 1;
|
||||
}
|
||||
|
||||
// 设置线路排序
|
||||
message UpdateNSRouteOrdersRequest {
|
||||
repeated int64 nsRouteIds = 1;
|
||||
}
|
||||
Reference in New Issue
Block a user