mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-11 18:30:24 +08:00
增加DNS服务商账号管理
This commit is contained in:
205
pkg/rpc/pb/model_dns_provider.pb.go
Normal file
205
pkg/rpc/pb/model_dns_provider.pb.go
Normal file
@@ -0,0 +1,205 @@
|
|||||||
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// protoc-gen-go v1.25.0
|
||||||
|
// protoc v3.12.3
|
||||||
|
// source: model_dns_provider.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 DNSProvider 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"`
|
||||||
|
TypeName string `protobuf:"bytes,4,opt,name=typeName,proto3" json:"typeName,omitempty"`
|
||||||
|
ApiParamsJSON []byte `protobuf:"bytes,5,opt,name=apiParamsJSON,proto3" json:"apiParamsJSON,omitempty"`
|
||||||
|
RoutesJSON []byte `protobuf:"bytes,6,opt,name=routesJSON,proto3" json:"routesJSON,omitempty"`
|
||||||
|
DataUpdatedAt int64 `protobuf:"varint,7,opt,name=dataUpdatedAt,proto3" json:"dataUpdatedAt,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *DNSProvider) Reset() {
|
||||||
|
*x = DNSProvider{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_model_dns_provider_proto_msgTypes[0]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *DNSProvider) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*DNSProvider) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *DNSProvider) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_model_dns_provider_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 DNSProvider.ProtoReflect.Descriptor instead.
|
||||||
|
func (*DNSProvider) Descriptor() ([]byte, []int) {
|
||||||
|
return file_model_dns_provider_proto_rawDescGZIP(), []int{0}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *DNSProvider) GetId() int64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Id
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *DNSProvider) GetName() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Name
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *DNSProvider) GetType() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Type
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *DNSProvider) GetTypeName() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.TypeName
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *DNSProvider) GetApiParamsJSON() []byte {
|
||||||
|
if x != nil {
|
||||||
|
return x.ApiParamsJSON
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *DNSProvider) GetRoutesJSON() []byte {
|
||||||
|
if x != nil {
|
||||||
|
return x.RoutesJSON
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *DNSProvider) GetDataUpdatedAt() int64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.DataUpdatedAt
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
var File_model_dns_provider_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
|
var file_model_dns_provider_proto_rawDesc = []byte{
|
||||||
|
0x0a, 0x18, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x64, 0x6e, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x76,
|
||||||
|
0x69, 0x64, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x22, 0xcd,
|
||||||
|
0x01, 0x0a, 0x0b, 0x44, 0x4e, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 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, 0x1a, 0x0a, 0x08, 0x74, 0x79, 0x70, 0x65, 0x4e, 0x61,
|
||||||
|
0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x79, 0x70, 0x65, 0x4e, 0x61,
|
||||||
|
0x6d, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x61, 0x70, 0x69, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x4a,
|
||||||
|
0x53, 0x4f, 0x4e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0d, 0x61, 0x70, 0x69, 0x50, 0x61,
|
||||||
|
0x72, 0x61, 0x6d, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x1e, 0x0a, 0x0a, 0x72, 0x6f, 0x75, 0x74,
|
||||||
|
0x65, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x72, 0x6f,
|
||||||
|
0x75, 0x74, 0x65, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x24, 0x0a, 0x0d, 0x64, 0x61, 0x74, 0x61,
|
||||||
|
0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52,
|
||||||
|
0x0d, 0x64, 0x61, 0x74, 0x61, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x42, 0x06,
|
||||||
|
0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
file_model_dns_provider_proto_rawDescOnce sync.Once
|
||||||
|
file_model_dns_provider_proto_rawDescData = file_model_dns_provider_proto_rawDesc
|
||||||
|
)
|
||||||
|
|
||||||
|
func file_model_dns_provider_proto_rawDescGZIP() []byte {
|
||||||
|
file_model_dns_provider_proto_rawDescOnce.Do(func() {
|
||||||
|
file_model_dns_provider_proto_rawDescData = protoimpl.X.CompressGZIP(file_model_dns_provider_proto_rawDescData)
|
||||||
|
})
|
||||||
|
return file_model_dns_provider_proto_rawDescData
|
||||||
|
}
|
||||||
|
|
||||||
|
var file_model_dns_provider_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||||
|
var file_model_dns_provider_proto_goTypes = []interface{}{
|
||||||
|
(*DNSProvider)(nil), // 0: pb.DNSProvider
|
||||||
|
}
|
||||||
|
var file_model_dns_provider_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_dns_provider_proto_init() }
|
||||||
|
func file_model_dns_provider_proto_init() {
|
||||||
|
if File_model_dns_provider_proto != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !protoimpl.UnsafeEnabled {
|
||||||
|
file_model_dns_provider_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*DNSProvider); 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_dns_provider_proto_rawDesc,
|
||||||
|
NumEnums: 0,
|
||||||
|
NumMessages: 1,
|
||||||
|
NumExtensions: 0,
|
||||||
|
NumServices: 0,
|
||||||
|
},
|
||||||
|
GoTypes: file_model_dns_provider_proto_goTypes,
|
||||||
|
DependencyIndexes: file_model_dns_provider_proto_depIdxs,
|
||||||
|
MessageInfos: file_model_dns_provider_proto_msgTypes,
|
||||||
|
}.Build()
|
||||||
|
File_model_dns_provider_proto = out.File
|
||||||
|
file_model_dns_provider_proto_rawDesc = nil
|
||||||
|
file_model_dns_provider_proto_goTypes = nil
|
||||||
|
file_model_dns_provider_proto_depIdxs = nil
|
||||||
|
}
|
||||||
@@ -38,6 +38,7 @@ type Server struct {
|
|||||||
IncludeNodes []byte `protobuf:"bytes,5,opt,name=includeNodes,proto3" json:"includeNodes,omitempty"`
|
IncludeNodes []byte `protobuf:"bytes,5,opt,name=includeNodes,proto3" json:"includeNodes,omitempty"`
|
||||||
ExcludeNodes []byte `protobuf:"bytes,6,opt,name=excludeNodes,proto3" json:"excludeNodes,omitempty"`
|
ExcludeNodes []byte `protobuf:"bytes,6,opt,name=excludeNodes,proto3" json:"excludeNodes,omitempty"`
|
||||||
CreatedAt int64 `protobuf:"varint,7,opt,name=createdAt,proto3" json:"createdAt,omitempty"`
|
CreatedAt int64 `protobuf:"varint,7,opt,name=createdAt,proto3" json:"createdAt,omitempty"`
|
||||||
|
DnsName string `protobuf:"bytes,19,opt,name=dnsName,proto3" json:"dnsName,omitempty"`
|
||||||
// 配置相关
|
// 配置相关
|
||||||
Config []byte `protobuf:"bytes,17,opt,name=config,proto3" json:"config,omitempty"`
|
Config []byte `protobuf:"bytes,17,opt,name=config,proto3" json:"config,omitempty"`
|
||||||
ServerNamesJON []byte `protobuf:"bytes,8,opt,name=serverNamesJON,proto3" json:"serverNamesJON,omitempty"`
|
ServerNamesJON []byte `protobuf:"bytes,8,opt,name=serverNamesJON,proto3" json:"serverNamesJON,omitempty"`
|
||||||
@@ -141,6 +142,13 @@ func (x *Server) GetCreatedAt() int64 {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *Server) GetDnsName() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.DnsName
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func (x *Server) GetConfig() []byte {
|
func (x *Server) GetConfig() []byte {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Config
|
return x.Config
|
||||||
@@ -232,7 +240,7 @@ var file_model_server_proto_rawDesc = []byte{
|
|||||||
0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x1a, 0x18, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f,
|
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,
|
0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f,
|
||||||
0x74, 0x6f, 0x1a, 0x18, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72,
|
0x74, 0x6f, 0x1a, 0x18, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72,
|
||||||
0x5f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xd6, 0x04, 0x0a,
|
0x5f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xf0, 0x04, 0x0a,
|
||||||
0x06, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20,
|
0x06, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 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,
|
0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x73, 0x4f, 0x6e, 0x18,
|
||||||
0x12, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x69, 0x73, 0x4f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x74,
|
0x12, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x69, 0x73, 0x4f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x74,
|
||||||
@@ -246,32 +254,33 @@ var file_model_server_proto_rawDesc = []byte{
|
|||||||
0x6c, 0x75, 0x64, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52,
|
0x6c, 0x75, 0x64, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52,
|
||||||
0x0c, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x1c, 0x0a,
|
0x0c, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x1c, 0x0a,
|
||||||
0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03,
|
0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03,
|
||||||
0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x63,
|
0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x64,
|
||||||
0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x11, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x63, 0x6f, 0x6e,
|
0x6e, 0x73, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x13, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x64, 0x6e,
|
||||||
0x66, 0x69, 0x67, 0x12, 0x26, 0x0a, 0x0e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x4e, 0x61, 0x6d,
|
0x73, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18,
|
||||||
0x65, 0x73, 0x4a, 0x4f, 0x4e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x73, 0x65, 0x72,
|
0x11, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x26, 0x0a,
|
||||||
0x76, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x4a, 0x4f, 0x4e, 0x12, 0x1a, 0x0a, 0x08, 0x68,
|
0x0e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x4a, 0x4f, 0x4e, 0x18,
|
||||||
0x74, 0x74, 0x70, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x68,
|
0x08, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x4e, 0x61, 0x6d,
|
||||||
0x74, 0x74, 0x70, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x1c, 0x0a, 0x09, 0x68, 0x74, 0x74, 0x70, 0x73,
|
0x65, 0x73, 0x4a, 0x4f, 0x4e, 0x12, 0x1a, 0x0a, 0x08, 0x68, 0x74, 0x74, 0x70, 0x4a, 0x53, 0x4f,
|
||||||
0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x68, 0x74, 0x74, 0x70,
|
0x4e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x68, 0x74, 0x74, 0x70, 0x4a, 0x53, 0x4f,
|
||||||
0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x63, 0x70, 0x4a, 0x53, 0x4f, 0x4e,
|
0x4e, 0x12, 0x1c, 0x0a, 0x09, 0x68, 0x74, 0x74, 0x70, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x0a,
|
||||||
0x18, 0x0b, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x74, 0x63, 0x70, 0x4a, 0x53, 0x4f, 0x4e, 0x12,
|
0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x68, 0x74, 0x74, 0x70, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x12,
|
||||||
0x18, 0x0a, 0x07, 0x74, 0x6c, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0c,
|
0x18, 0x0a, 0x07, 0x74, 0x63, 0x70, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0c,
|
||||||
0x52, 0x07, 0x74, 0x6c, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x6e, 0x69,
|
0x52, 0x07, 0x74, 0x63, 0x70, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x6c, 0x73,
|
||||||
0x78, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x75, 0x6e, 0x69,
|
0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x74, 0x6c, 0x73, 0x4a,
|
||||||
0x78, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x18, 0x0a, 0x07, 0x75, 0x64, 0x70, 0x4a, 0x53, 0x4f, 0x4e,
|
0x53, 0x4f, 0x4e, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x6e, 0x69, 0x78, 0x4a, 0x53, 0x4f, 0x4e, 0x18,
|
||||||
0x18, 0x0e, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x75, 0x64, 0x70, 0x4a, 0x53, 0x4f, 0x4e, 0x12,
|
0x0d, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x75, 0x6e, 0x69, 0x78, 0x4a, 0x53, 0x4f, 0x4e, 0x12,
|
||||||
0x14, 0x0a, 0x05, 0x77, 0x65, 0x62, 0x49, 0x64, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05,
|
0x18, 0x0a, 0x07, 0x75, 0x64, 0x70, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0c,
|
||||||
0x77, 0x65, 0x62, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x10, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65,
|
0x52, 0x07, 0x75, 0x64, 0x70, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x14, 0x0a, 0x05, 0x77, 0x65, 0x62,
|
||||||
0x50, 0x72, 0x6f, 0x78, 0x79, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x10, 0x20, 0x01, 0x28, 0x0c, 0x52,
|
0x49, 0x64, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x77, 0x65, 0x62, 0x49, 0x64, 0x12,
|
||||||
0x10, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4a, 0x53, 0x4f,
|
0x2a, 0x0a, 0x10, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4a,
|
||||||
0x4e, 0x12, 0x29, 0x0a, 0x07, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x18, 0x1e, 0x20, 0x01,
|
0x53, 0x4f, 0x4e, 0x18, 0x10, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x10, 0x72, 0x65, 0x76, 0x65, 0x72,
|
||||||
0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73,
|
0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x29, 0x0a, 0x07, 0x63,
|
||||||
0x74, 0x65, 0x72, 0x52, 0x07, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x12, 0x27, 0x0a, 0x06,
|
0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x70,
|
||||||
0x67, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x18, 0x1f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x70,
|
0x62, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x07, 0x63,
|
||||||
0x62, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x06, 0x67,
|
0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x12, 0x27, 0x0a, 0x06, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x73,
|
||||||
0x72, 0x6f, 0x75, 0x70, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70,
|
0x18, 0x1f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x70, 0x62, 0x2e, 0x53, 0x65, 0x72, 0x76,
|
||||||
0x72, 0x6f, 0x74, 0x6f, 0x33,
|
0x65, 0x72, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x06, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x42,
|
||||||
|
0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
1362
pkg/rpc/pb/service_dns_provider.pb.go
Normal file
1362
pkg/rpc/pb/service_dns_provider.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
14
pkg/rpc/protos/model_dns_provider.proto
Normal file
14
pkg/rpc/protos/model_dns_provider.proto
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
option go_package = "./pb";
|
||||||
|
|
||||||
|
package pb;
|
||||||
|
|
||||||
|
message DNSProvider {
|
||||||
|
int64 id = 1;
|
||||||
|
string name = 2;
|
||||||
|
string type = 3;
|
||||||
|
string typeName = 4;
|
||||||
|
bytes apiParamsJSON = 5;
|
||||||
|
bytes routesJSON = 6;
|
||||||
|
int64 dataUpdatedAt = 7;
|
||||||
|
}
|
||||||
@@ -15,6 +15,7 @@ message Server {
|
|||||||
bytes includeNodes = 5;
|
bytes includeNodes = 5;
|
||||||
bytes excludeNodes = 6;
|
bytes excludeNodes = 6;
|
||||||
int64 createdAt = 7;
|
int64 createdAt = 7;
|
||||||
|
string dnsName = 19;
|
||||||
|
|
||||||
// 配置相关
|
// 配置相关
|
||||||
bytes config = 17;
|
bytes config = 17;
|
||||||
|
|||||||
98
pkg/rpc/protos/service_dns_provider.proto
Normal file
98
pkg/rpc/protos/service_dns_provider.proto
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
option go_package = "./pb";
|
||||||
|
|
||||||
|
package pb;
|
||||||
|
|
||||||
|
import "rpc_messages.proto";
|
||||||
|
import "model_dns_provider.proto";
|
||||||
|
|
||||||
|
// DNS服务商相关服务
|
||||||
|
service DNSProviderService {
|
||||||
|
// 创建服务商
|
||||||
|
rpc createDNSProvider (CreateDNSProviderRequest) returns (CreateDNSProviderResponse);
|
||||||
|
|
||||||
|
// 修改服务商
|
||||||
|
rpc updateDNSProvider (UpdateDNSProviderRequest) returns (RPCUpdateSuccess);
|
||||||
|
|
||||||
|
// 计算服务商数量
|
||||||
|
rpc countAllEnabledDNSProviders (CountAllEnabledDNSProvidersRequest) returns (CountAllEnabledDNSProvidersResponse);
|
||||||
|
|
||||||
|
// 列出单页服务商信息
|
||||||
|
rpc listEnabledDNSProviders (ListEnabledDNSProvidersRequest) returns (ListEnabledDNSProvidersResponse);
|
||||||
|
|
||||||
|
// 删除服务商
|
||||||
|
rpc deleteDNSProvider (DeleteDNSProviderRequest) returns (RPCDeleteSuccess);
|
||||||
|
|
||||||
|
// 查找单个服务商
|
||||||
|
rpc findEnabledDNSProvider (FindEnabledDNSProviderRequest) returns (FindEnabledDNSProviderResponse);
|
||||||
|
|
||||||
|
// 取得所有服务商类型
|
||||||
|
rpc findAllDNSProviderTypes (FindAllDNSProviderTypesRequest) returns (FindAllDNSProviderTypesResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建服务商
|
||||||
|
message CreateDNSProviderRequest {
|
||||||
|
string name = 1;
|
||||||
|
string type = 2;
|
||||||
|
bytes apiParamsJSON = 3;
|
||||||
|
bytes routesJSON = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message CreateDNSProviderResponse {
|
||||||
|
int64 dnsProviderId = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改服务商
|
||||||
|
message UpdateDNSProviderRequest {
|
||||||
|
int64 dnsProviderId = 1;
|
||||||
|
string name = 2;
|
||||||
|
bytes apiParamsJSON = 3;
|
||||||
|
bytes routesJSON = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算服务商数量
|
||||||
|
message CountAllEnabledDNSProvidersRequest {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
message CountAllEnabledDNSProvidersResponse {
|
||||||
|
int64 count = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 列出单页的服务商信息
|
||||||
|
message ListEnabledDNSProvidersRequest {
|
||||||
|
int64 offset = 1;
|
||||||
|
int64 size = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ListEnabledDNSProvidersResponse {
|
||||||
|
repeated DNSProvider dnsProviders = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除服务商
|
||||||
|
message DeleteDNSProviderRequest {
|
||||||
|
int64 dnsProviderId = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查找单个服务商
|
||||||
|
message FindEnabledDNSProviderRequest {
|
||||||
|
int64 dnsProviderId = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message FindEnabledDNSProviderResponse {
|
||||||
|
DNSProvider dnsProvider = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 取得所有服务商类型
|
||||||
|
message FindAllDNSProviderTypesRequest {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
message FindAllDNSProviderTypesResponse {
|
||||||
|
repeated DNSProviderType providerTypes = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message DNSProviderType {
|
||||||
|
string name = 1;
|
||||||
|
string code = 2;
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ import "model_node_cluster.proto";
|
|||||||
import "model_api_node.proto";
|
import "model_api_node.proto";
|
||||||
import "model_node.proto";
|
import "model_node.proto";
|
||||||
import "rpc_messages.proto";
|
import "rpc_messages.proto";
|
||||||
|
import "model_dns_provider.proto";
|
||||||
|
|
||||||
service NodeClusterService {
|
service NodeClusterService {
|
||||||
// 创建集群
|
// 创建集群
|
||||||
@@ -50,6 +51,12 @@ service NodeClusterService {
|
|||||||
|
|
||||||
// 查找使用某个认证的所有集群
|
// 查找使用某个认证的所有集群
|
||||||
rpc findAllEnabledNodeClustersWithGrantId (FindAllEnabledNodeClustersWithGrantIdRequest) returns (FindAllEnabledNodeClustersWithGrantIdResponse);
|
rpc findAllEnabledNodeClustersWithGrantId (FindAllEnabledNodeClustersWithGrantIdRequest) returns (FindAllEnabledNodeClustersWithGrantIdResponse);
|
||||||
|
|
||||||
|
// 查找集群的DNS配置
|
||||||
|
rpc findEnabledNodeClusterDNS (FindEnabledNodeClusterDNSRequest) returns (FindEnabledNodeClusterDNSResponse);
|
||||||
|
|
||||||
|
// 计算使用某个DNS服务商的集群数量
|
||||||
|
rpc countAllEnabledNodeClustersWithDNSProviderId (CountAllEnabledNodeClustersWithDNSProviderIdRequest) returns (CountAllEnabledNodeClustersWithDNSProviderIdResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取所有集群的信息
|
// 获取所有集群的信息
|
||||||
@@ -180,4 +187,24 @@ message FindAllEnabledNodeClustersWithGrantIdRequest {
|
|||||||
|
|
||||||
message FindAllEnabledNodeClustersWithGrantIdResponse {
|
message FindAllEnabledNodeClustersWithGrantIdResponse {
|
||||||
repeated NodeCluster clusters = 1;
|
repeated NodeCluster clusters = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查找集群的DNS配置
|
||||||
|
message FindEnabledNodeClusterDNSRequest {
|
||||||
|
int64 nodeClusterId = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message FindEnabledNodeClusterDNSResponse {
|
||||||
|
string name = 1;
|
||||||
|
string domain = 2;
|
||||||
|
DNSProvider provider = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算使用某个DNS服务商的集群数量
|
||||||
|
message CountAllEnabledNodeClustersWithDNSProviderIdRequest {
|
||||||
|
int64 dnsProviderId = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message CountAllEnabledNodeClustersWithDNSProviderIdResponse {
|
||||||
|
int64 count = 1;
|
||||||
}
|
}
|
||||||
101
pkg/serverconfigs/ipconfigs/action_http.go
Normal file
101
pkg/serverconfigs/ipconfigs/action_http.go
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
package ipconfigs
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TODO 支持自定义Header
|
||||||
|
type HTTPAction struct {
|
||||||
|
URL string `yaml:"url" json:"url"` // URL
|
||||||
|
Method string `yaml:"method" json:"method"` // 请求方法
|
||||||
|
ParamName string `yaml:"paramName" json:"paramsName"` // 参数名
|
||||||
|
Params map[string]string `yaml:"params" json:"params"` // 附加参数,在请求的时候一起提交
|
||||||
|
Timeout *shared.TimeDuration `yaml:"timeout" json:"timeout"` // 超时时间
|
||||||
|
Tries int `yaml:"tries" json:"tries"` // 失败尝试次数
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *HTTPAction) Node() string {
|
||||||
|
return "api"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *HTTPAction) Run(itemConfig *IPItemConfig) error {
|
||||||
|
if itemConfig == nil {
|
||||||
|
return errors.New("invalid ip item")
|
||||||
|
}
|
||||||
|
itemJSON, err := json.Marshal(itemConfig)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
method := this.Method
|
||||||
|
if len(method) == 0 {
|
||||||
|
method = http.MethodGet
|
||||||
|
}
|
||||||
|
|
||||||
|
var body io.Reader = nil
|
||||||
|
defaultParamName := "ip"
|
||||||
|
apiURL := this.URL
|
||||||
|
|
||||||
|
v := url.Values{}
|
||||||
|
for paramName, paramValue := range this.Params {
|
||||||
|
v[paramName] = []string{paramValue}
|
||||||
|
}
|
||||||
|
if len(this.ParamName) == 0 {
|
||||||
|
v[defaultParamName] = []string{string(itemJSON)}
|
||||||
|
} else {
|
||||||
|
v[this.ParamName] = []string{string(itemJSON)}
|
||||||
|
}
|
||||||
|
|
||||||
|
if method != http.MethodGet {
|
||||||
|
body = strings.NewReader(v.Encode())
|
||||||
|
} else {
|
||||||
|
if strings.Contains(apiURL, "?") {
|
||||||
|
apiURL += "&"
|
||||||
|
} else {
|
||||||
|
apiURL += "?"
|
||||||
|
}
|
||||||
|
apiURL += v.Encode()
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := http.NewRequest(method, apiURL, body)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if method == http.MethodPost {
|
||||||
|
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
}
|
||||||
|
|
||||||
|
client := &http.Client{}
|
||||||
|
if this.Timeout != nil {
|
||||||
|
timeout := this.Timeout.Duration()
|
||||||
|
if timeout > 0 {
|
||||||
|
client.Timeout = timeout
|
||||||
|
}
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
client.CloseIdleConnections()
|
||||||
|
}()
|
||||||
|
|
||||||
|
tries := this.Tries
|
||||||
|
if tries <= 0 {
|
||||||
|
tries = 1
|
||||||
|
}
|
||||||
|
for i := 0; i < tries; i++ {
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
if err == nil {
|
||||||
|
_ = resp.Body.Close()
|
||||||
|
return nil
|
||||||
|
} else if i == tries-1 {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
24
pkg/serverconfigs/ipconfigs/action_http_test.go
Normal file
24
pkg/serverconfigs/ipconfigs/action_http_test.go
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
package ipconfigs
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestHTTPAction_Run(t *testing.T) {
|
||||||
|
action := &HTTPAction{
|
||||||
|
URL: "http://127.0.0.1:1234/get?hello=world",
|
||||||
|
Method: http.MethodGet,
|
||||||
|
Params: map[string]string{"a": "b"},
|
||||||
|
ParamName: "IP",
|
||||||
|
}
|
||||||
|
err := action.Run(&IPItemConfig{
|
||||||
|
IPFrom: "192.168.1.100",
|
||||||
|
ExpiredAt: time.Now().Unix() + 3600,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Log("ok")
|
||||||
|
}
|
||||||
9
pkg/serverconfigs/ipconfigs/action_interface.go
Normal file
9
pkg/serverconfigs/ipconfigs/action_interface.go
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package ipconfigs
|
||||||
|
|
||||||
|
type ActionInterface interface {
|
||||||
|
// 运行节点
|
||||||
|
Node() string
|
||||||
|
|
||||||
|
// 执行对IP信息的处理
|
||||||
|
Run(itemConfig *IPItemConfig) error
|
||||||
|
}
|
||||||
60
pkg/serverconfigs/ipconfigs/action_ipset.go
Normal file
60
pkg/serverconfigs/ipconfigs/action_ipset.go
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
package ipconfigs
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os/exec"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type IPSetAction struct {
|
||||||
|
Exe string `yaml:"exe" json:"exe"` // 可执行文件位置
|
||||||
|
SetName string `yaml:"setName" json:"setName"` // 集合名称,多个集合使用同一个名称
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *IPSetAction) Node() string {
|
||||||
|
return "node"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *IPSetAction) Run(itemConfig *IPItemConfig) error {
|
||||||
|
exe := this.Exe
|
||||||
|
if len(exe) == 0 {
|
||||||
|
path, err := exec.LookPath("ipset")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
exe = path
|
||||||
|
}
|
||||||
|
|
||||||
|
var timeout int64 = 0
|
||||||
|
if itemConfig.ExpiredAt > 0 {
|
||||||
|
timeout = itemConfig.ExpiredAt - time.Now().Unix()
|
||||||
|
if timeout <= 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ip := itemConfig.IPFrom
|
||||||
|
if len(itemConfig.IPTo) > 0 {
|
||||||
|
ip += "-" + itemConfig.IPTo
|
||||||
|
}
|
||||||
|
|
||||||
|
switch itemConfig.Action {
|
||||||
|
case IPItemActionAdd:
|
||||||
|
cmd := exec.Command(exe, "add", this.SetName, ip, "timeout", strconv.FormatInt(timeout, 10))
|
||||||
|
_ = cmd.Run()
|
||||||
|
case IPItemActionUpdate:
|
||||||
|
{
|
||||||
|
cmd := exec.Command(exe, "del", this.SetName, ip, "timeout", strconv.FormatInt(timeout, 10))
|
||||||
|
_ = cmd.Run()
|
||||||
|
}
|
||||||
|
{
|
||||||
|
cmd := exec.Command(exe, "add", this.SetName, ip, "timeout", strconv.FormatInt(timeout, 10))
|
||||||
|
_ = cmd.Run()
|
||||||
|
}
|
||||||
|
case IPItemActionDelete:
|
||||||
|
cmd := exec.Command(exe, "del", this.SetName, ip, "timeout", strconv.FormatInt(timeout, 10))
|
||||||
|
_ = cmd.Run()
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
12
pkg/serverconfigs/ipconfigs/action_ipset_test.go
Normal file
12
pkg/serverconfigs/ipconfigs/action_ipset_test.go
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
package ipconfigs
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestIPSetAction_Run(t *testing.T) {
|
||||||
|
action := &IPSetAction{}
|
||||||
|
err := action.Run(&IPItemConfig{})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Log("ok")
|
||||||
|
}
|
||||||
9
pkg/serverconfigs/ipconfigs/actions.go
Normal file
9
pkg/serverconfigs/ipconfigs/actions.go
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package ipconfigs
|
||||||
|
|
||||||
|
type IPListAction = string
|
||||||
|
|
||||||
|
const (
|
||||||
|
IPListActionHTTP IPListAction = "http" // HTTP
|
||||||
|
IPListActionIPSet IPListAction = "ipset" // ipset
|
||||||
|
)
|
||||||
|
|
||||||
17
pkg/serverconfigs/ipconfigs/ip_item_config.go
Normal file
17
pkg/serverconfigs/ipconfigs/ip_item_config.go
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package ipconfigs
|
||||||
|
|
||||||
|
type IPItemAction = string
|
||||||
|
|
||||||
|
const (
|
||||||
|
IPItemActionAdd IPItemAction = "add"
|
||||||
|
IPItemActionUpdate IPItemAction = "update"
|
||||||
|
IPItemActionDelete IPItemAction = "delete"
|
||||||
|
)
|
||||||
|
|
||||||
|
type IPItemConfig struct {
|
||||||
|
Action IPItemAction `yaml:"action" json:"action"` // 对当前Item的操作
|
||||||
|
Id int64 `yaml:"id" json:"id"`
|
||||||
|
IPFrom string `yaml:"ipFrom" json:"ipFrom"`
|
||||||
|
IPTo string `yaml:"ipTo" json:"ipTo"`
|
||||||
|
ExpiredAt int64 `yaml:"expiredAt" json:"expiredAt"`
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user