feat: sync httpdns sdk/platform updates without large binaries
This commit is contained in:
@@ -7,9 +7,7 @@ import (
|
||||
"github.com/oschwald/geoip2-golang"
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
// MaxMindReader MaxMind GeoIP2 Reader
|
||||
@@ -19,6 +17,9 @@ type MaxMindReader struct {
|
||||
meta *Meta
|
||||
initialized bool
|
||||
mutex sync.RWMutex
|
||||
|
||||
// 临时文件路径,Destroy 时自动清理
|
||||
tmpFiles []string
|
||||
}
|
||||
|
||||
// NewMaxMindReader 创建 MaxMind Reader
|
||||
@@ -66,27 +67,9 @@ func NewMaxMindReaderFromBytes(cityDBData, asnDBData []byte) (*MaxMindReader, er
|
||||
return nil, fmt.Errorf("city database data is required")
|
||||
}
|
||||
|
||||
// 创建临时文件,使用更唯一的文件名避免冲突
|
||||
tmpDir := os.TempDir()
|
||||
pid := os.Getpid()
|
||||
// 使用时间戳增加唯一性,避免同一进程多次调用时的冲突
|
||||
timestamp := time.Now().UnixNano()
|
||||
cityTmpFile := filepath.Join(tmpDir, fmt.Sprintf("geolite2-city-%d-%d.mmdb", pid, timestamp))
|
||||
asnTmpFile := filepath.Join(tmpDir, fmt.Sprintf("geolite2-asn-%d-%d.mmdb", pid, timestamp))
|
||||
|
||||
// 如果临时文件已存在,先删除(可能是之前崩溃留下的)
|
||||
os.Remove(cityTmpFile)
|
||||
os.Remove(asnTmpFile)
|
||||
|
||||
// 写入 City 数据库到临时文件
|
||||
if err := os.WriteFile(cityTmpFile, cityDBData, 0644); err != nil {
|
||||
return nil, fmt.Errorf("write city database to temp file failed: %w", err)
|
||||
}
|
||||
|
||||
// 打开 City 数据库
|
||||
db, err := geoip2.Open(cityTmpFile)
|
||||
// 直接从内存字节加载,避免在 /tmp 持续生成 mmdb 临时文件。
|
||||
db, err := geoip2.FromBytes(cityDBData)
|
||||
if err != nil {
|
||||
os.Remove(cityTmpFile)
|
||||
return nil, fmt.Errorf("open MaxMind city database failed: %w", err)
|
||||
}
|
||||
|
||||
@@ -94,16 +77,11 @@ func NewMaxMindReaderFromBytes(cityDBData, asnDBData []byte) (*MaxMindReader, er
|
||||
db: db,
|
||||
}
|
||||
|
||||
// 写入并打开 ASN 数据库(可选)
|
||||
// 加载 ASN 数据库(可选)
|
||||
if len(asnDBData) > 0 {
|
||||
if err := os.WriteFile(asnTmpFile, asnDBData, 0644); err == nil {
|
||||
dbASN, err := geoip2.Open(asnTmpFile)
|
||||
if err == nil {
|
||||
reader.dbASN = dbASN
|
||||
} else {
|
||||
// ASN 数据库打开失败,清理临时文件但不影响主功能
|
||||
os.Remove(asnTmpFile)
|
||||
}
|
||||
dbASN, err := geoip2.FromBytes(asnDBData)
|
||||
if err == nil {
|
||||
reader.dbASN = dbASN
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +152,7 @@ func (this *MaxMindReader) Meta() *Meta {
|
||||
return this.meta
|
||||
}
|
||||
|
||||
// Destroy 销毁 Reader
|
||||
// Destroy 销毁 Reader 并清理临时文件
|
||||
func (this *MaxMindReader) Destroy() {
|
||||
this.mutex.Lock()
|
||||
defer this.mutex.Unlock()
|
||||
@@ -187,6 +165,10 @@ func (this *MaxMindReader) Destroy() {
|
||||
this.dbASN.Close()
|
||||
this.dbASN = nil
|
||||
}
|
||||
for _, f := range this.tmpFiles {
|
||||
os.Remove(f)
|
||||
}
|
||||
this.tmpFiles = nil
|
||||
this.initialized = false
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ type HTTPDNSCluster struct {
|
||||
UpdatedAt int64 `protobuf:"varint,11,opt,name=updatedAt,proto3" json:"updatedAt,omitempty"`
|
||||
AutoRemoteStart bool `protobuf:"varint,12,opt,name=autoRemoteStart,proto3" json:"autoRemoteStart,omitempty"`
|
||||
AccessLogIsOn bool `protobuf:"varint,13,opt,name=accessLogIsOn,proto3" json:"accessLogIsOn,omitempty"`
|
||||
TimeZone string `protobuf:"bytes,14,opt,name=timeZone,proto3" json:"timeZone,omitempty"`
|
||||
}
|
||||
|
||||
func (x *HTTPDNSCluster) Reset() {
|
||||
@@ -161,6 +162,13 @@ func (x *HTTPDNSCluster) GetAccessLogIsOn() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *HTTPDNSCluster) GetTimeZone() string {
|
||||
if x != nil {
|
||||
return x.TimeZone
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_models_model_httpdns_cluster_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_models_model_httpdns_cluster_proto_rawDesc = []byte{
|
||||
|
||||
@@ -35,6 +35,7 @@ type CreateHTTPDNSClusterRequest struct {
|
||||
IsDefault bool `protobuf:"varint,8,opt,name=isDefault,proto3" json:"isDefault,omitempty"`
|
||||
AutoRemoteStart bool `protobuf:"varint,9,opt,name=autoRemoteStart,proto3" json:"autoRemoteStart,omitempty"`
|
||||
AccessLogIsOn bool `protobuf:"varint,10,opt,name=accessLogIsOn,proto3" json:"accessLogIsOn,omitempty"`
|
||||
TimeZone string `protobuf:"bytes,11,opt,name=timeZone,proto3" json:"timeZone,omitempty"`
|
||||
}
|
||||
|
||||
func (x *CreateHTTPDNSClusterRequest) Reset() {
|
||||
@@ -137,6 +138,13 @@ func (x *CreateHTTPDNSClusterRequest) GetAccessLogIsOn() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *CreateHTTPDNSClusterRequest) GetTimeZone() string {
|
||||
if x != nil {
|
||||
return x.TimeZone
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type CreateHTTPDNSClusterResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
@@ -198,6 +206,7 @@ type UpdateHTTPDNSClusterRequest struct {
|
||||
IsDefault bool `protobuf:"varint,9,opt,name=isDefault,proto3" json:"isDefault,omitempty"`
|
||||
AutoRemoteStart bool `protobuf:"varint,10,opt,name=autoRemoteStart,proto3" json:"autoRemoteStart,omitempty"`
|
||||
AccessLogIsOn bool `protobuf:"varint,11,opt,name=accessLogIsOn,proto3" json:"accessLogIsOn,omitempty"`
|
||||
TimeZone string `protobuf:"bytes,12,opt,name=timeZone,proto3" json:"timeZone,omitempty"`
|
||||
}
|
||||
|
||||
func (x *UpdateHTTPDNSClusterRequest) Reset() {
|
||||
@@ -307,6 +316,13 @@ func (x *UpdateHTTPDNSClusterRequest) GetAccessLogIsOn() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *UpdateHTTPDNSClusterRequest) GetTimeZone() string {
|
||||
if x != nil {
|
||||
return x.TimeZone
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type DeleteHTTPDNSClusterRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
|
||||
@@ -27,7 +27,10 @@ const (
|
||||
HTTPDNSNodeService_UpdateHTTPDNSNodeStatus_FullMethodName = "/pb.HTTPDNSNodeService/updateHTTPDNSNodeStatus"
|
||||
HTTPDNSNodeService_UpdateHTTPDNSNodeLogin_FullMethodName = "/pb.HTTPDNSNodeService/updateHTTPDNSNodeLogin"
|
||||
HTTPDNSNodeService_CheckHTTPDNSNodeLatestVersion_FullMethodName = "/pb.HTTPDNSNodeService/checkHTTPDNSNodeLatestVersion"
|
||||
HTTPDNSNodeService_DownloadHTTPDNSNodeInstallationFile_FullMethodName = "/pb.HTTPDNSNodeService/downloadHTTPDNSNodeInstallationFile"
|
||||
HTTPDNSNodeService_DownloadHTTPDNSNodeInstallationFile_FullMethodName = "/pb.HTTPDNSNodeService/downloadHTTPDNSNodeInstallationFile"
|
||||
HTTPDNSNodeService_CountAllUpgradeHTTPDNSNodesWithClusterId_FullMethodName = "/pb.HTTPDNSNodeService/countAllUpgradeHTTPDNSNodesWithClusterId"
|
||||
HTTPDNSNodeService_FindAllUpgradeHTTPDNSNodesWithClusterId_FullMethodName = "/pb.HTTPDNSNodeService/findAllUpgradeHTTPDNSNodesWithClusterId"
|
||||
HTTPDNSNodeService_UpgradeHTTPDNSNode_FullMethodName = "/pb.HTTPDNSNodeService/upgradeHTTPDNSNode"
|
||||
)
|
||||
|
||||
// HTTPDNSNodeServiceClient is the client API for HTTPDNSNodeService service.
|
||||
@@ -46,6 +49,12 @@ type HTTPDNSNodeServiceClient interface {
|
||||
CheckHTTPDNSNodeLatestVersion(ctx context.Context, in *CheckHTTPDNSNodeLatestVersionRequest, opts ...grpc.CallOption) (*CheckHTTPDNSNodeLatestVersionResponse, error)
|
||||
// 下载最新HTTPDNS节点安装文件
|
||||
DownloadHTTPDNSNodeInstallationFile(ctx context.Context, in *DownloadHTTPDNSNodeInstallationFileRequest, opts ...grpc.CallOption) (*DownloadHTTPDNSNodeInstallationFileResponse, error)
|
||||
// 计算需要升级的HTTPDNS节点数量
|
||||
CountAllUpgradeHTTPDNSNodesWithClusterId(ctx context.Context, in *CountAllUpgradeHTTPDNSNodesWithClusterIdRequest, opts ...grpc.CallOption) (*RPCCountResponse, error)
|
||||
// 列出所有需要升级的HTTPDNS节点
|
||||
FindAllUpgradeHTTPDNSNodesWithClusterId(ctx context.Context, in *FindAllUpgradeHTTPDNSNodesWithClusterIdRequest, opts ...grpc.CallOption) (*FindAllUpgradeHTTPDNSNodesWithClusterIdResponse, error)
|
||||
// 升级单个HTTPDNS节点
|
||||
UpgradeHTTPDNSNode(ctx context.Context, in *UpgradeHTTPDNSNodeRequest, opts ...grpc.CallOption) (*RPCSuccess, error)
|
||||
}
|
||||
|
||||
type hTTPDNSNodeServiceClient struct {
|
||||
@@ -146,6 +155,36 @@ func (c *hTTPDNSNodeServiceClient) DownloadHTTPDNSNodeInstallationFile(ctx conte
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *hTTPDNSNodeServiceClient) CountAllUpgradeHTTPDNSNodesWithClusterId(ctx context.Context, in *CountAllUpgradeHTTPDNSNodesWithClusterIdRequest, opts ...grpc.CallOption) (*RPCCountResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(RPCCountResponse)
|
||||
err := c.cc.Invoke(ctx, HTTPDNSNodeService_CountAllUpgradeHTTPDNSNodesWithClusterId_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *hTTPDNSNodeServiceClient) FindAllUpgradeHTTPDNSNodesWithClusterId(ctx context.Context, in *FindAllUpgradeHTTPDNSNodesWithClusterIdRequest, opts ...grpc.CallOption) (*FindAllUpgradeHTTPDNSNodesWithClusterIdResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(FindAllUpgradeHTTPDNSNodesWithClusterIdResponse)
|
||||
err := c.cc.Invoke(ctx, HTTPDNSNodeService_FindAllUpgradeHTTPDNSNodesWithClusterId_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *hTTPDNSNodeServiceClient) UpgradeHTTPDNSNode(ctx context.Context, in *UpgradeHTTPDNSNodeRequest, opts ...grpc.CallOption) (*RPCSuccess, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(RPCSuccess)
|
||||
err := c.cc.Invoke(ctx, HTTPDNSNodeService_UpgradeHTTPDNSNode_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// HTTPDNSNodeServiceServer is the server API for HTTPDNSNodeService service.
|
||||
// All implementations must embed UnimplementedHTTPDNSNodeServiceServer
|
||||
// for forward compatibility.
|
||||
@@ -162,6 +201,12 @@ type HTTPDNSNodeServiceServer interface {
|
||||
CheckHTTPDNSNodeLatestVersion(context.Context, *CheckHTTPDNSNodeLatestVersionRequest) (*CheckHTTPDNSNodeLatestVersionResponse, error)
|
||||
// 下载最新HTTPDNS节点安装文件
|
||||
DownloadHTTPDNSNodeInstallationFile(context.Context, *DownloadHTTPDNSNodeInstallationFileRequest) (*DownloadHTTPDNSNodeInstallationFileResponse, error)
|
||||
// 计算需要升级的HTTPDNS节点数量
|
||||
CountAllUpgradeHTTPDNSNodesWithClusterId(context.Context, *CountAllUpgradeHTTPDNSNodesWithClusterIdRequest) (*RPCCountResponse, error)
|
||||
// 列出所有需要升级的HTTPDNS节点
|
||||
FindAllUpgradeHTTPDNSNodesWithClusterId(context.Context, *FindAllUpgradeHTTPDNSNodesWithClusterIdRequest) (*FindAllUpgradeHTTPDNSNodesWithClusterIdResponse, error)
|
||||
// 升级单个HTTPDNS节点
|
||||
UpgradeHTTPDNSNode(context.Context, *UpgradeHTTPDNSNodeRequest) (*RPCSuccess, error)
|
||||
mustEmbedUnimplementedHTTPDNSNodeServiceServer()
|
||||
}
|
||||
|
||||
@@ -199,6 +244,15 @@ func (UnimplementedHTTPDNSNodeServiceServer) CheckHTTPDNSNodeLatestVersion(conte
|
||||
func (UnimplementedHTTPDNSNodeServiceServer) DownloadHTTPDNSNodeInstallationFile(context.Context, *DownloadHTTPDNSNodeInstallationFileRequest) (*DownloadHTTPDNSNodeInstallationFileResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method DownloadHTTPDNSNodeInstallationFile not implemented")
|
||||
}
|
||||
func (UnimplementedHTTPDNSNodeServiceServer) CountAllUpgradeHTTPDNSNodesWithClusterId(context.Context, *CountAllUpgradeHTTPDNSNodesWithClusterIdRequest) (*RPCCountResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method CountAllUpgradeHTTPDNSNodesWithClusterId not implemented")
|
||||
}
|
||||
func (UnimplementedHTTPDNSNodeServiceServer) FindAllUpgradeHTTPDNSNodesWithClusterId(context.Context, *FindAllUpgradeHTTPDNSNodesWithClusterIdRequest) (*FindAllUpgradeHTTPDNSNodesWithClusterIdResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method FindAllUpgradeHTTPDNSNodesWithClusterId not implemented")
|
||||
}
|
||||
func (UnimplementedHTTPDNSNodeServiceServer) UpgradeHTTPDNSNode(context.Context, *UpgradeHTTPDNSNodeRequest) (*RPCSuccess, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method UpgradeHTTPDNSNode not implemented")
|
||||
}
|
||||
func (UnimplementedHTTPDNSNodeServiceServer) mustEmbedUnimplementedHTTPDNSNodeServiceServer() {}
|
||||
func (UnimplementedHTTPDNSNodeServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
@@ -382,6 +436,60 @@ func _HTTPDNSNodeService_DownloadHTTPDNSNodeInstallationFile_Handler(srv interfa
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _HTTPDNSNodeService_CountAllUpgradeHTTPDNSNodesWithClusterId_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CountAllUpgradeHTTPDNSNodesWithClusterIdRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(HTTPDNSNodeServiceServer).CountAllUpgradeHTTPDNSNodesWithClusterId(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HTTPDNSNodeService_CountAllUpgradeHTTPDNSNodesWithClusterId_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HTTPDNSNodeServiceServer).CountAllUpgradeHTTPDNSNodesWithClusterId(ctx, req.(*CountAllUpgradeHTTPDNSNodesWithClusterIdRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _HTTPDNSNodeService_FindAllUpgradeHTTPDNSNodesWithClusterId_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(FindAllUpgradeHTTPDNSNodesWithClusterIdRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(HTTPDNSNodeServiceServer).FindAllUpgradeHTTPDNSNodesWithClusterId(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HTTPDNSNodeService_FindAllUpgradeHTTPDNSNodesWithClusterId_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HTTPDNSNodeServiceServer).FindAllUpgradeHTTPDNSNodesWithClusterId(ctx, req.(*FindAllUpgradeHTTPDNSNodesWithClusterIdRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _HTTPDNSNodeService_UpgradeHTTPDNSNode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(UpgradeHTTPDNSNodeRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(HTTPDNSNodeServiceServer).UpgradeHTTPDNSNode(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HTTPDNSNodeService_UpgradeHTTPDNSNode_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HTTPDNSNodeServiceServer).UpgradeHTTPDNSNode(ctx, req.(*UpgradeHTTPDNSNodeRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// HTTPDNSNodeService_ServiceDesc is the grpc.ServiceDesc for HTTPDNSNodeService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
@@ -425,6 +533,18 @@ var HTTPDNSNodeService_ServiceDesc = grpc.ServiceDesc{
|
||||
MethodName: "downloadHTTPDNSNodeInstallationFile",
|
||||
Handler: _HTTPDNSNodeService_DownloadHTTPDNSNodeInstallationFile_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "countAllUpgradeHTTPDNSNodesWithClusterId",
|
||||
Handler: _HTTPDNSNodeService_CountAllUpgradeHTTPDNSNodesWithClusterId_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "findAllUpgradeHTTPDNSNodesWithClusterId",
|
||||
Handler: _HTTPDNSNodeService_FindAllUpgradeHTTPDNSNodesWithClusterId_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "upgradeHTTPDNSNode",
|
||||
Handler: _HTTPDNSNodeService_UpgradeHTTPDNSNode_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "service_httpdns_node.proto",
|
||||
|
||||
@@ -46,6 +46,8 @@ const (
|
||||
NSNodeService_UpdateNSNodeDDoSProtection_FullMethodName = "/pb.NSNodeService/updateNSNodeDDoSProtection"
|
||||
NSNodeService_FindNSNodeAPIConfig_FullMethodName = "/pb.NSNodeService/findNSNodeAPIConfig"
|
||||
NSNodeService_UpdateNSNodeAPIConfig_FullMethodName = "/pb.NSNodeService/updateNSNodeAPIConfig"
|
||||
NSNodeService_FindAllUpgradeNSNodesWithNSClusterId_FullMethodName = "/pb.NSNodeService/findAllUpgradeNSNodesWithNSClusterId"
|
||||
NSNodeService_UpgradeNSNode_FullMethodName = "/pb.NSNodeService/upgradeNSNode"
|
||||
)
|
||||
|
||||
// NSNodeServiceClient is the client API for NSNodeService service.
|
||||
@@ -108,6 +110,10 @@ type NSNodeServiceClient interface {
|
||||
FindNSNodeAPIConfig(ctx context.Context, in *FindNSNodeAPIConfigRequest, opts ...grpc.CallOption) (*FindNSNodeAPIConfigResponse, error)
|
||||
// 修改某个节点的API相关配置
|
||||
UpdateNSNodeAPIConfig(ctx context.Context, in *UpdateNSNodeAPIConfigRequest, opts ...grpc.CallOption) (*RPCSuccess, error)
|
||||
// 列出所有需要升级的NS节点
|
||||
FindAllUpgradeNSNodesWithNSClusterId(ctx context.Context, in *FindAllUpgradeNSNodesWithNSClusterIdRequest, opts ...grpc.CallOption) (*FindAllUpgradeNSNodesWithNSClusterIdResponse, error)
|
||||
// 升级单个NS节点
|
||||
UpgradeNSNode(ctx context.Context, in *UpgradeNSNodeRequest, opts ...grpc.CallOption) (*RPCSuccess, error)
|
||||
}
|
||||
|
||||
type nSNodeServiceClient struct {
|
||||
@@ -391,6 +397,26 @@ func (c *nSNodeServiceClient) UpdateNSNodeAPIConfig(ctx context.Context, in *Upd
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *nSNodeServiceClient) FindAllUpgradeNSNodesWithNSClusterId(ctx context.Context, in *FindAllUpgradeNSNodesWithNSClusterIdRequest, opts ...grpc.CallOption) (*FindAllUpgradeNSNodesWithNSClusterIdResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(FindAllUpgradeNSNodesWithNSClusterIdResponse)
|
||||
err := c.cc.Invoke(ctx, NSNodeService_FindAllUpgradeNSNodesWithNSClusterId_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *nSNodeServiceClient) UpgradeNSNode(ctx context.Context, in *UpgradeNSNodeRequest, opts ...grpc.CallOption) (*RPCSuccess, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(RPCSuccess)
|
||||
err := c.cc.Invoke(ctx, NSNodeService_UpgradeNSNode_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// NSNodeServiceServer is the server API for NSNodeService service.
|
||||
// All implementations should embed UnimplementedNSNodeServiceServer
|
||||
// for forward compatibility.
|
||||
@@ -451,6 +477,10 @@ type NSNodeServiceServer interface {
|
||||
FindNSNodeAPIConfig(context.Context, *FindNSNodeAPIConfigRequest) (*FindNSNodeAPIConfigResponse, error)
|
||||
// 修改某个节点的API相关配置
|
||||
UpdateNSNodeAPIConfig(context.Context, *UpdateNSNodeAPIConfigRequest) (*RPCSuccess, error)
|
||||
// 列出所有需要升级的NS节点
|
||||
FindAllUpgradeNSNodesWithNSClusterId(context.Context, *FindAllUpgradeNSNodesWithNSClusterIdRequest) (*FindAllUpgradeNSNodesWithNSClusterIdResponse, error)
|
||||
// 升级单个NS节点
|
||||
UpgradeNSNode(context.Context, *UpgradeNSNodeRequest) (*RPCSuccess, error)
|
||||
}
|
||||
|
||||
// UnimplementedNSNodeServiceServer should be embedded to have
|
||||
@@ -541,6 +571,12 @@ func (UnimplementedNSNodeServiceServer) FindNSNodeAPIConfig(context.Context, *Fi
|
||||
func (UnimplementedNSNodeServiceServer) UpdateNSNodeAPIConfig(context.Context, *UpdateNSNodeAPIConfigRequest) (*RPCSuccess, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UpdateNSNodeAPIConfig not implemented")
|
||||
}
|
||||
func (UnimplementedNSNodeServiceServer) FindAllUpgradeNSNodesWithNSClusterId(context.Context, *FindAllUpgradeNSNodesWithNSClusterIdRequest) (*FindAllUpgradeNSNodesWithNSClusterIdResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method FindAllUpgradeNSNodesWithNSClusterId not implemented")
|
||||
}
|
||||
func (UnimplementedNSNodeServiceServer) UpgradeNSNode(context.Context, *UpgradeNSNodeRequest) (*RPCSuccess, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UpgradeNSNode not implemented")
|
||||
}
|
||||
func (UnimplementedNSNodeServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeNSNodeServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
@@ -1036,6 +1072,42 @@ func _NSNodeService_UpdateNSNodeAPIConfig_Handler(srv interface{}, ctx context.C
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _NSNodeService_FindAllUpgradeNSNodesWithNSClusterId_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(FindAllUpgradeNSNodesWithNSClusterIdRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(NSNodeServiceServer).FindAllUpgradeNSNodesWithNSClusterId(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: NSNodeService_FindAllUpgradeNSNodesWithNSClusterId_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(NSNodeServiceServer).FindAllUpgradeNSNodesWithNSClusterId(ctx, req.(*FindAllUpgradeNSNodesWithNSClusterIdRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _NSNodeService_UpgradeNSNode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(UpgradeNSNodeRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(NSNodeServiceServer).UpgradeNSNode(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: NSNodeService_UpgradeNSNode_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(NSNodeServiceServer).UpgradeNSNode(ctx, req.(*UpgradeNSNodeRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// NSNodeService_ServiceDesc is the grpc.ServiceDesc for NSNodeService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
@@ -1147,6 +1219,14 @@ var NSNodeService_ServiceDesc = grpc.ServiceDesc{
|
||||
MethodName: "updateNSNodeAPIConfig",
|
||||
Handler: _NSNodeService_UpdateNSNodeAPIConfig_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "findAllUpgradeNSNodesWithNSClusterId",
|
||||
Handler: _NSNodeService_FindAllUpgradeNSNodesWithNSClusterId_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "upgradeNSNode",
|
||||
Handler: _NSNodeService_UpgradeNSNode_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
|
||||
@@ -17,4 +17,5 @@ message HTTPDNSCluster {
|
||||
int64 updatedAt = 11;
|
||||
bool autoRemoteStart = 12;
|
||||
bool accessLogIsOn = 13;
|
||||
string timeZone = 14;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ message CreateHTTPDNSClusterRequest {
|
||||
bool isDefault = 8;
|
||||
bool autoRemoteStart = 9;
|
||||
bool accessLogIsOn = 10;
|
||||
string timeZone = 11;
|
||||
}
|
||||
|
||||
message CreateHTTPDNSClusterResponse {
|
||||
@@ -47,6 +48,7 @@ message UpdateHTTPDNSClusterRequest {
|
||||
bool isDefault = 9;
|
||||
bool autoRemoteStart = 10;
|
||||
bool accessLogIsOn = 11;
|
||||
string timeZone = 12;
|
||||
}
|
||||
|
||||
message DeleteHTTPDNSClusterRequest {
|
||||
|
||||
@@ -22,6 +22,15 @@ service HTTPDNSNodeService {
|
||||
|
||||
// 下载最新HTTPDNS节点安装文件
|
||||
rpc downloadHTTPDNSNodeInstallationFile (DownloadHTTPDNSNodeInstallationFileRequest) returns (DownloadHTTPDNSNodeInstallationFileResponse);
|
||||
|
||||
// 计算需要升级的HTTPDNS节点数量
|
||||
rpc countAllUpgradeHTTPDNSNodesWithClusterId (CountAllUpgradeHTTPDNSNodesWithClusterIdRequest) returns (RPCCountResponse);
|
||||
|
||||
// 列出所有需要升级的HTTPDNS节点
|
||||
rpc findAllUpgradeHTTPDNSNodesWithClusterId (FindAllUpgradeHTTPDNSNodesWithClusterIdRequest) returns (FindAllUpgradeHTTPDNSNodesWithClusterIdResponse);
|
||||
|
||||
// 升级单个HTTPDNS节点
|
||||
rpc upgradeHTTPDNSNode (UpgradeHTTPDNSNodeRequest) returns (RPCSuccess);
|
||||
}
|
||||
|
||||
message CreateHTTPDNSNodeRequest {
|
||||
@@ -103,3 +112,30 @@ message DownloadHTTPDNSNodeInstallationFileResponse {
|
||||
string version = 4;
|
||||
string filename = 5;
|
||||
}
|
||||
|
||||
// 计算需要升级的HTTPDNS节点数量
|
||||
message CountAllUpgradeHTTPDNSNodesWithClusterIdRequest {
|
||||
int64 clusterId = 1;
|
||||
}
|
||||
|
||||
// 列出所有需要升级的HTTPDNS节点
|
||||
message FindAllUpgradeHTTPDNSNodesWithClusterIdRequest {
|
||||
int64 clusterId = 1;
|
||||
}
|
||||
|
||||
message FindAllUpgradeHTTPDNSNodesWithClusterIdResponse {
|
||||
repeated HTTPDNSNodeUpgrade nodes = 1;
|
||||
|
||||
message HTTPDNSNodeUpgrade {
|
||||
HTTPDNSNode node = 1;
|
||||
string os = 2;
|
||||
string arch = 3;
|
||||
string oldVersion = 4;
|
||||
string newVersion = 5;
|
||||
}
|
||||
}
|
||||
|
||||
// 升级单个HTTPDNS节点
|
||||
message UpgradeHTTPDNSNodeRequest {
|
||||
int64 nodeId = 1;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,12 @@ service NSNodeService {
|
||||
// 计算需要升级的NS节点数量
|
||||
rpc countAllUpgradeNSNodesWithNSClusterId (CountAllUpgradeNSNodesWithNSClusterIdRequest) returns (RPCCountResponse);
|
||||
|
||||
// 列出所有需要升级的NS节点
|
||||
rpc findAllUpgradeNSNodesWithNSClusterId (FindAllUpgradeNSNodesWithNSClusterIdRequest) returns (FindAllUpgradeNSNodesWithNSClusterIdResponse);
|
||||
|
||||
// 升级单个NS节点
|
||||
rpc upgradeNSNode (UpgradeNSNodeRequest) returns (RPCSuccess);
|
||||
|
||||
// 创建NS节点
|
||||
rpc createNSNode (CreateNSNodeRequest) returns (CreateNSNodeResponse);
|
||||
|
||||
@@ -316,4 +322,26 @@ message FindNSNodeAPIConfigResponse {
|
||||
message UpdateNSNodeAPIConfigRequest {
|
||||
int64 nsNodeId = 1;
|
||||
bytes apiNodeAddrsJSON = 2;
|
||||
}
|
||||
|
||||
// 列出所有需要升级的NS节点
|
||||
message FindAllUpgradeNSNodesWithNSClusterIdRequest {
|
||||
int64 nsClusterId = 1;
|
||||
}
|
||||
|
||||
message FindAllUpgradeNSNodesWithNSClusterIdResponse {
|
||||
repeated NSNodeUpgrade nodes = 1;
|
||||
|
||||
message NSNodeUpgrade {
|
||||
NSNode nsNode = 1;
|
||||
string os = 2;
|
||||
string arch = 3;
|
||||
string oldVersion = 4;
|
||||
string newVersion = 5;
|
||||
}
|
||||
}
|
||||
|
||||
// 升级单个NS节点
|
||||
message UpgradeNSNodeRequest {
|
||||
int64 nsNodeId = 1;
|
||||
}
|
||||
@@ -17,4 +17,5 @@ const (
|
||||
SettingCodeStandaloneInstanceInitialized SettingCode = "standaloneInstanceInitialized" // 单体实例初始化状态
|
||||
|
||||
SettingCodeHTTPDNSDefaultBackupClusterId SettingCode = "httpdnsDefaultBackupClusterId" // HTTPDNS默认备用集群ID
|
||||
SettingCodeUpgradeConfig SettingCode = "upgradeConfig" // 升级设置
|
||||
)
|
||||
|
||||
@@ -58,7 +58,7 @@ func (this *UserFeature) ToPB() *pb.UserFeature {
|
||||
func FindAllUserFeatures() []*UserFeature {
|
||||
return []*UserFeature{
|
||||
{
|
||||
Name: "记录访问日志",
|
||||
Name: "访问日志记录",
|
||||
Code: UserFeatureCodeServerAccessLog,
|
||||
Description: "用户可以开启服务的访问日志。",
|
||||
SupportPlan: true,
|
||||
@@ -106,7 +106,7 @@ func FindAllUserFeatures() []*UserFeature {
|
||||
SupportPlan: false,
|
||||
},
|
||||
{
|
||||
Name: "开启WAF",
|
||||
Name: "WAF",
|
||||
Code: UserFeatureCodeServerWAF,
|
||||
Description: "用户可以开启WAF功能并可以设置黑白名单等。",
|
||||
SupportPlan: true,
|
||||
@@ -136,7 +136,7 @@ func FindAllUserFeatures() []*UserFeature {
|
||||
SupportPlan: true,
|
||||
},
|
||||
{
|
||||
Name: "页面优化",
|
||||
Name: "页面动态加密",
|
||||
Code: UserFeatureCodeServerOptimization,
|
||||
Description: "用户可以开启页面优化功能。",
|
||||
SupportPlan: true,
|
||||
|
||||
Reference in New Issue
Block a user