文件恢复

This commit is contained in:
robin
2026-03-04 19:14:57 +08:00
parent 54e808a85d
commit 30a1b4fa5e
4 changed files with 631 additions and 0 deletions

View File

@@ -0,0 +1,345 @@
package pb
import (
"fmt"
"google.golang.org/protobuf/encoding/protowire"
"google.golang.org/protobuf/proto"
)
// CountAllUpgradeHTTPDNSNodesWithClusterIdRequest 计算需要升级的HTTPDNS节点数量
type CountAllUpgradeHTTPDNSNodesWithClusterIdRequest struct {
ClusterId int64 `protobuf:"varint,1,opt,name=clusterId,proto3" json:"clusterId,omitempty"`
}
func (x *CountAllUpgradeHTTPDNSNodesWithClusterIdRequest) Reset() { *x = CountAllUpgradeHTTPDNSNodesWithClusterIdRequest{} }
func (x *CountAllUpgradeHTTPDNSNodesWithClusterIdRequest) String() string { return fmt.Sprintf("%+v", *x) }
func (x *CountAllUpgradeHTTPDNSNodesWithClusterIdRequest) ProtoMessage() {}
func (x *CountAllUpgradeHTTPDNSNodesWithClusterIdRequest) GetClusterId() int64 {
if x != nil {
return x.ClusterId
}
return 0
}
func (x *CountAllUpgradeHTTPDNSNodesWithClusterIdRequest) Marshal() ([]byte, error) {
var b []byte
if x.ClusterId != 0 {
b = protowire.AppendTag(b, 1, protowire.VarintType)
b = protowire.AppendVarint(b, uint64(x.ClusterId))
}
return b, nil
}
func (x *CountAllUpgradeHTTPDNSNodesWithClusterIdRequest) Unmarshal(data []byte) error {
for len(data) > 0 {
num, typ, n := protowire.ConsumeTag(data)
if n < 0 {
return fmt.Errorf("invalid tag")
}
data = data[n:]
switch num {
case 1:
if typ == protowire.VarintType {
v, n := protowire.ConsumeVarint(data)
if n < 0 {
return fmt.Errorf("invalid varint")
}
x.ClusterId = int64(v)
data = data[n:]
}
default:
n := protowire.ConsumeFieldValue(num, typ, data)
if n < 0 {
return fmt.Errorf("invalid field value")
}
data = data[n:]
}
}
return nil
}
// FindAllUpgradeHTTPDNSNodesWithClusterIdRequest 列出所有需要升级的HTTPDNS节点
type FindAllUpgradeHTTPDNSNodesWithClusterIdRequest struct {
ClusterId int64 `protobuf:"varint,1,opt,name=clusterId,proto3" json:"clusterId,omitempty"`
}
func (x *FindAllUpgradeHTTPDNSNodesWithClusterIdRequest) Reset() { *x = FindAllUpgradeHTTPDNSNodesWithClusterIdRequest{} }
func (x *FindAllUpgradeHTTPDNSNodesWithClusterIdRequest) String() string { return fmt.Sprintf("%+v", *x) }
func (x *FindAllUpgradeHTTPDNSNodesWithClusterIdRequest) ProtoMessage() {}
func (x *FindAllUpgradeHTTPDNSNodesWithClusterIdRequest) GetClusterId() int64 {
if x != nil {
return x.ClusterId
}
return 0
}
func (x *FindAllUpgradeHTTPDNSNodesWithClusterIdRequest) Marshal() ([]byte, error) {
var b []byte
if x.ClusterId != 0 {
b = protowire.AppendTag(b, 1, protowire.VarintType)
b = protowire.AppendVarint(b, uint64(x.ClusterId))
}
return b, nil
}
func (x *FindAllUpgradeHTTPDNSNodesWithClusterIdRequest) Unmarshal(data []byte) error {
for len(data) > 0 {
num, typ, n := protowire.ConsumeTag(data)
if n < 0 {
return fmt.Errorf("invalid tag")
}
data = data[n:]
switch num {
case 1:
if typ == protowire.VarintType {
v, n := protowire.ConsumeVarint(data)
if n < 0 {
return fmt.Errorf("invalid varint")
}
x.ClusterId = int64(v)
data = data[n:]
}
default:
n := protowire.ConsumeFieldValue(num, typ, data)
if n < 0 {
return fmt.Errorf("invalid field value")
}
data = data[n:]
}
}
return nil
}
// FindAllUpgradeHTTPDNSNodesWithClusterIdResponse_HTTPDNSNodeUpgrade 单个待升级节点信息
type FindAllUpgradeHTTPDNSNodesWithClusterIdResponse_HTTPDNSNodeUpgrade struct {
Node *HTTPDNSNode `protobuf:"bytes,1,opt,name=node,proto3" json:"node,omitempty"`
Os string `protobuf:"bytes,2,opt,name=os,proto3" json:"os,omitempty"`
Arch string `protobuf:"bytes,3,opt,name=arch,proto3" json:"arch,omitempty"`
OldVersion string `protobuf:"bytes,4,opt,name=oldVersion,proto3" json:"oldVersion,omitempty"`
NewVersion string `protobuf:"bytes,5,opt,name=newVersion,proto3" json:"newVersion,omitempty"`
}
func (x *FindAllUpgradeHTTPDNSNodesWithClusterIdResponse_HTTPDNSNodeUpgrade) Reset() {
*x = FindAllUpgradeHTTPDNSNodesWithClusterIdResponse_HTTPDNSNodeUpgrade{}
}
func (x *FindAllUpgradeHTTPDNSNodesWithClusterIdResponse_HTTPDNSNodeUpgrade) String() string {
return fmt.Sprintf("%+v", *x)
}
func (x *FindAllUpgradeHTTPDNSNodesWithClusterIdResponse_HTTPDNSNodeUpgrade) ProtoMessage() {}
func (x *FindAllUpgradeHTTPDNSNodesWithClusterIdResponse_HTTPDNSNodeUpgrade) Marshal() ([]byte, error) {
var b []byte
if x.Node != nil {
nodeData, err := proto.Marshal(x.Node)
if err != nil {
return nil, err
}
b = protowire.AppendTag(b, 1, protowire.BytesType)
b = protowire.AppendBytes(b, nodeData)
}
if x.Os != "" {
b = protowire.AppendTag(b, 2, protowire.BytesType)
b = protowire.AppendString(b, x.Os)
}
if x.Arch != "" {
b = protowire.AppendTag(b, 3, protowire.BytesType)
b = protowire.AppendString(b, x.Arch)
}
if x.OldVersion != "" {
b = protowire.AppendTag(b, 4, protowire.BytesType)
b = protowire.AppendString(b, x.OldVersion)
}
if x.NewVersion != "" {
b = protowire.AppendTag(b, 5, protowire.BytesType)
b = protowire.AppendString(b, x.NewVersion)
}
return b, nil
}
func (x *FindAllUpgradeHTTPDNSNodesWithClusterIdResponse_HTTPDNSNodeUpgrade) Unmarshal(data []byte) error {
for len(data) > 0 {
num, typ, n := protowire.ConsumeTag(data)
if n < 0 {
return fmt.Errorf("invalid tag")
}
data = data[n:]
switch num {
case 1:
if typ == protowire.BytesType {
v, n := protowire.ConsumeBytes(data)
if n < 0 {
return fmt.Errorf("invalid bytes")
}
x.Node = &HTTPDNSNode{}
if err := proto.Unmarshal(v, x.Node); err != nil {
return err
}
data = data[n:]
}
case 2:
if typ == protowire.BytesType {
v, n := protowire.ConsumeString(data)
if n < 0 {
return fmt.Errorf("invalid string")
}
x.Os = v
data = data[n:]
}
case 3:
if typ == protowire.BytesType {
v, n := protowire.ConsumeString(data)
if n < 0 {
return fmt.Errorf("invalid string")
}
x.Arch = v
data = data[n:]
}
case 4:
if typ == protowire.BytesType {
v, n := protowire.ConsumeString(data)
if n < 0 {
return fmt.Errorf("invalid string")
}
x.OldVersion = v
data = data[n:]
}
case 5:
if typ == protowire.BytesType {
v, n := protowire.ConsumeString(data)
if n < 0 {
return fmt.Errorf("invalid string")
}
x.NewVersion = v
data = data[n:]
}
default:
n := protowire.ConsumeFieldValue(num, typ, data)
if n < 0 {
return fmt.Errorf("invalid field value")
}
data = data[n:]
}
}
return nil
}
// FindAllUpgradeHTTPDNSNodesWithClusterIdResponse 列出所有需要升级的HTTPDNS节点
type FindAllUpgradeHTTPDNSNodesWithClusterIdResponse struct {
Nodes []*FindAllUpgradeHTTPDNSNodesWithClusterIdResponse_HTTPDNSNodeUpgrade `protobuf:"bytes,1,rep,name=nodes,proto3" json:"nodes,omitempty"`
}
func (x *FindAllUpgradeHTTPDNSNodesWithClusterIdResponse) Reset() {
*x = FindAllUpgradeHTTPDNSNodesWithClusterIdResponse{}
}
func (x *FindAllUpgradeHTTPDNSNodesWithClusterIdResponse) String() string {
return fmt.Sprintf("%+v", *x)
}
func (x *FindAllUpgradeHTTPDNSNodesWithClusterIdResponse) ProtoMessage() {}
func (x *FindAllUpgradeHTTPDNSNodesWithClusterIdResponse) GetNodes() []*FindAllUpgradeHTTPDNSNodesWithClusterIdResponse_HTTPDNSNodeUpgrade {
if x != nil {
return x.Nodes
}
return nil
}
func (x *FindAllUpgradeHTTPDNSNodesWithClusterIdResponse) Marshal() ([]byte, error) {
var b []byte
for _, node := range x.Nodes {
nodeData, err := node.Marshal()
if err != nil {
return nil, err
}
b = protowire.AppendTag(b, 1, protowire.BytesType)
b = protowire.AppendBytes(b, nodeData)
}
return b, nil
}
func (x *FindAllUpgradeHTTPDNSNodesWithClusterIdResponse) Unmarshal(data []byte) error {
for len(data) > 0 {
num, typ, n := protowire.ConsumeTag(data)
if n < 0 {
return fmt.Errorf("invalid tag")
}
data = data[n:]
switch num {
case 1:
if typ == protowire.BytesType {
v, n := protowire.ConsumeBytes(data)
if n < 0 {
return fmt.Errorf("invalid bytes")
}
node := &FindAllUpgradeHTTPDNSNodesWithClusterIdResponse_HTTPDNSNodeUpgrade{}
if err := node.Unmarshal(v); err != nil {
return err
}
x.Nodes = append(x.Nodes, node)
data = data[n:]
}
default:
n := protowire.ConsumeFieldValue(num, typ, data)
if n < 0 {
return fmt.Errorf("invalid field value")
}
data = data[n:]
}
}
return nil
}
// UpgradeHTTPDNSNodeRequest 升级单个HTTPDNS节点
type UpgradeHTTPDNSNodeRequest struct {
NodeId int64 `protobuf:"varint,1,opt,name=nodeId,proto3" json:"nodeId,omitempty"`
}
func (x *UpgradeHTTPDNSNodeRequest) Reset() { *x = UpgradeHTTPDNSNodeRequest{} }
func (x *UpgradeHTTPDNSNodeRequest) String() string { return fmt.Sprintf("%+v", *x) }
func (x *UpgradeHTTPDNSNodeRequest) ProtoMessage() {}
func (x *UpgradeHTTPDNSNodeRequest) GetNodeId() int64 {
if x != nil {
return x.NodeId
}
return 0
}
func (x *UpgradeHTTPDNSNodeRequest) Marshal() ([]byte, error) {
var b []byte
if x.NodeId != 0 {
b = protowire.AppendTag(b, 1, protowire.VarintType)
b = protowire.AppendVarint(b, uint64(x.NodeId))
}
return b, nil
}
func (x *UpgradeHTTPDNSNodeRequest) Unmarshal(data []byte) error {
for len(data) > 0 {
num, typ, n := protowire.ConsumeTag(data)
if n < 0 {
return fmt.Errorf("invalid tag")
}
data = data[n:]
switch num {
case 1:
if typ == protowire.VarintType {
v, n := protowire.ConsumeVarint(data)
if n < 0 {
return fmt.Errorf("invalid varint")
}
x.NodeId = int64(v)
data = data[n:]
}
default:
n := protowire.ConsumeFieldValue(num, typ, data)
if n < 0 {
return fmt.Errorf("invalid field value")
}
data = data[n:]
}
}
return nil
}

View File

@@ -0,0 +1,274 @@
package pb
import (
"fmt"
"google.golang.org/protobuf/encoding/protowire"
"google.golang.org/protobuf/proto"
)
// FindAllUpgradeNSNodesWithNSClusterIdRequest 列出所有需要升级的NS节点
type FindAllUpgradeNSNodesWithNSClusterIdRequest struct {
NsClusterId int64 `protobuf:"varint,1,opt,name=nsClusterId,proto3" json:"nsClusterId,omitempty"`
}
func (x *FindAllUpgradeNSNodesWithNSClusterIdRequest) Reset() { *x = FindAllUpgradeNSNodesWithNSClusterIdRequest{} }
func (x *FindAllUpgradeNSNodesWithNSClusterIdRequest) String() string { return fmt.Sprintf("%+v", *x) }
func (x *FindAllUpgradeNSNodesWithNSClusterIdRequest) ProtoMessage() {}
func (x *FindAllUpgradeNSNodesWithNSClusterIdRequest) GetNsClusterId() int64 {
if x != nil {
return x.NsClusterId
}
return 0
}
func (x *FindAllUpgradeNSNodesWithNSClusterIdRequest) Marshal() ([]byte, error) {
var b []byte
if x.NsClusterId != 0 {
b = protowire.AppendTag(b, 1, protowire.VarintType)
b = protowire.AppendVarint(b, uint64(x.NsClusterId))
}
return b, nil
}
func (x *FindAllUpgradeNSNodesWithNSClusterIdRequest) Unmarshal(data []byte) error {
for len(data) > 0 {
num, typ, n := protowire.ConsumeTag(data)
if n < 0 {
return fmt.Errorf("invalid tag")
}
data = data[n:]
switch num {
case 1:
if typ == protowire.VarintType {
v, n := protowire.ConsumeVarint(data)
if n < 0 {
return fmt.Errorf("invalid varint")
}
x.NsClusterId = int64(v)
data = data[n:]
}
default:
n := protowire.ConsumeFieldValue(num, typ, data)
if n < 0 {
return fmt.Errorf("invalid field value")
}
data = data[n:]
}
}
return nil
}
// FindAllUpgradeNSNodesWithNSClusterIdResponse_NSNodeUpgrade 单个待升级NS节点信息
type FindAllUpgradeNSNodesWithNSClusterIdResponse_NSNodeUpgrade struct {
NsNode *NSNode `protobuf:"bytes,1,opt,name=nsNode,proto3" json:"nsNode,omitempty"`
Os string `protobuf:"bytes,2,opt,name=os,proto3" json:"os,omitempty"`
Arch string `protobuf:"bytes,3,opt,name=arch,proto3" json:"arch,omitempty"`
OldVersion string `protobuf:"bytes,4,opt,name=oldVersion,proto3" json:"oldVersion,omitempty"`
NewVersion string `protobuf:"bytes,5,opt,name=newVersion,proto3" json:"newVersion,omitempty"`
}
func (x *FindAllUpgradeNSNodesWithNSClusterIdResponse_NSNodeUpgrade) Reset() {
*x = FindAllUpgradeNSNodesWithNSClusterIdResponse_NSNodeUpgrade{}
}
func (x *FindAllUpgradeNSNodesWithNSClusterIdResponse_NSNodeUpgrade) String() string {
return fmt.Sprintf("%+v", *x)
}
func (x *FindAllUpgradeNSNodesWithNSClusterIdResponse_NSNodeUpgrade) ProtoMessage() {}
func (x *FindAllUpgradeNSNodesWithNSClusterIdResponse_NSNodeUpgrade) Marshal() ([]byte, error) {
var b []byte
if x.NsNode != nil {
nodeData, err := proto.Marshal(x.NsNode)
if err != nil {
return nil, err
}
b = protowire.AppendTag(b, 1, protowire.BytesType)
b = protowire.AppendBytes(b, nodeData)
}
if x.Os != "" {
b = protowire.AppendTag(b, 2, protowire.BytesType)
b = protowire.AppendString(b, x.Os)
}
if x.Arch != "" {
b = protowire.AppendTag(b, 3, protowire.BytesType)
b = protowire.AppendString(b, x.Arch)
}
if x.OldVersion != "" {
b = protowire.AppendTag(b, 4, protowire.BytesType)
b = protowire.AppendString(b, x.OldVersion)
}
if x.NewVersion != "" {
b = protowire.AppendTag(b, 5, protowire.BytesType)
b = protowire.AppendString(b, x.NewVersion)
}
return b, nil
}
func (x *FindAllUpgradeNSNodesWithNSClusterIdResponse_NSNodeUpgrade) Unmarshal(data []byte) error {
for len(data) > 0 {
num, typ, n := protowire.ConsumeTag(data)
if n < 0 {
return fmt.Errorf("invalid tag")
}
data = data[n:]
switch num {
case 1:
if typ == protowire.BytesType {
v, n := protowire.ConsumeBytes(data)
if n < 0 {
return fmt.Errorf("invalid bytes")
}
x.NsNode = &NSNode{}
if err := proto.Unmarshal(v, x.NsNode); err != nil {
return err
}
data = data[n:]
}
case 2, 3, 4, 5:
if typ == protowire.BytesType {
v, n := protowire.ConsumeString(data)
if n < 0 {
return fmt.Errorf("invalid string")
}
switch num {
case 2:
x.Os = v
case 3:
x.Arch = v
case 4:
x.OldVersion = v
case 5:
x.NewVersion = v
}
data = data[n:]
}
default:
n := protowire.ConsumeFieldValue(num, typ, data)
if n < 0 {
return fmt.Errorf("invalid field value")
}
data = data[n:]
}
}
return nil
}
// FindAllUpgradeNSNodesWithNSClusterIdResponse 列出所有需要升级的NS节点
type FindAllUpgradeNSNodesWithNSClusterIdResponse struct {
Nodes []*FindAllUpgradeNSNodesWithNSClusterIdResponse_NSNodeUpgrade `protobuf:"bytes,1,rep,name=nodes,proto3" json:"nodes,omitempty"`
}
func (x *FindAllUpgradeNSNodesWithNSClusterIdResponse) Reset() {
*x = FindAllUpgradeNSNodesWithNSClusterIdResponse{}
}
func (x *FindAllUpgradeNSNodesWithNSClusterIdResponse) String() string {
return fmt.Sprintf("%+v", *x)
}
func (x *FindAllUpgradeNSNodesWithNSClusterIdResponse) ProtoMessage() {}
func (x *FindAllUpgradeNSNodesWithNSClusterIdResponse) GetNodes() []*FindAllUpgradeNSNodesWithNSClusterIdResponse_NSNodeUpgrade {
if x != nil {
return x.Nodes
}
return nil
}
func (x *FindAllUpgradeNSNodesWithNSClusterIdResponse) Marshal() ([]byte, error) {
var b []byte
for _, node := range x.Nodes {
nodeData, err := node.Marshal()
if err != nil {
return nil, err
}
b = protowire.AppendTag(b, 1, protowire.BytesType)
b = protowire.AppendBytes(b, nodeData)
}
return b, nil
}
func (x *FindAllUpgradeNSNodesWithNSClusterIdResponse) Unmarshal(data []byte) error {
for len(data) > 0 {
num, typ, n := protowire.ConsumeTag(data)
if n < 0 {
return fmt.Errorf("invalid tag")
}
data = data[n:]
switch num {
case 1:
if typ == protowire.BytesType {
v, n := protowire.ConsumeBytes(data)
if n < 0 {
return fmt.Errorf("invalid bytes")
}
node := &FindAllUpgradeNSNodesWithNSClusterIdResponse_NSNodeUpgrade{}
if err := node.Unmarshal(v); err != nil {
return err
}
x.Nodes = append(x.Nodes, node)
data = data[n:]
}
default:
n := protowire.ConsumeFieldValue(num, typ, data)
if n < 0 {
return fmt.Errorf("invalid field value")
}
data = data[n:]
}
}
return nil
}
// UpgradeNSNodeRequest 升级单个NS节点
type UpgradeNSNodeRequest struct {
NsNodeId int64 `protobuf:"varint,1,opt,name=nsNodeId,proto3" json:"nsNodeId,omitempty"`
}
func (x *UpgradeNSNodeRequest) Reset() { *x = UpgradeNSNodeRequest{} }
func (x *UpgradeNSNodeRequest) String() string { return fmt.Sprintf("%+v", *x) }
func (x *UpgradeNSNodeRequest) ProtoMessage() {}
func (x *UpgradeNSNodeRequest) GetNsNodeId() int64 {
if x != nil {
return x.NsNodeId
}
return 0
}
func (x *UpgradeNSNodeRequest) Marshal() ([]byte, error) {
var b []byte
if x.NsNodeId != 0 {
b = protowire.AppendTag(b, 1, protowire.VarintType)
b = protowire.AppendVarint(b, uint64(x.NsNodeId))
}
return b, nil
}
func (x *UpgradeNSNodeRequest) Unmarshal(data []byte) error {
for len(data) > 0 {
num, typ, n := protowire.ConsumeTag(data)
if n < 0 {
return fmt.Errorf("invalid tag")
}
data = data[n:]
switch num {
case 1:
if typ == protowire.VarintType {
v, n := protowire.ConsumeVarint(data)
if n < 0 {
return fmt.Errorf("invalid varint")
}
x.NsNodeId = int64(v)
data = data[n:]
}
default:
n := protowire.ConsumeFieldValue(num, typ, data)
if n < 0 {
return fmt.Errorf("invalid field value")
}
data = data[n:]
}
}
return nil
}

View File

@@ -0,0 +1,12 @@
package systemconfigs
// UpgradeConfig 升级设置
type UpgradeConfig struct {
AutoUpgrade bool `json:"autoUpgrade"` // 是否开启自动升级控制EdgeNode、EdgeDNS、EdgeHTTPDNS三个模块
}
func NewUpgradeConfig() *UpgradeConfig {
return &UpgradeConfig{
AutoUpgrade: false,
}
}