mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-06 01:50:25 +08:00
优化代码
This commit is contained in:
@@ -58,7 +58,7 @@ func (this *StorageManager) Loop() error {
|
|||||||
}
|
}
|
||||||
var policyIds = []int64{}
|
var policyIds = []int64{}
|
||||||
for _, policy := range policies {
|
for _, policy := range policies {
|
||||||
if policy.IsOn == 1 {
|
if policy.IsOn {
|
||||||
policyIds = append(policyIds, int64(policy.Id))
|
policyIds = append(policyIds, int64(policy.Id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package acme
|
|||||||
// ACMEProviderAccount ACME提供商
|
// ACMEProviderAccount ACME提供商
|
||||||
type ACMEProviderAccount struct {
|
type ACMEProviderAccount struct {
|
||||||
Id uint64 `field:"id"` // ID
|
Id uint64 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
ProviderCode string `field:"providerCode"` // 代号
|
ProviderCode string `field:"providerCode"` // 代号
|
||||||
Error string `field:"error"` // 最后一条错误信息
|
Error string `field:"error"` // 最后一条错误信息
|
||||||
|
|||||||
@@ -271,7 +271,7 @@ func (this *ACMETaskDAO) runTaskWithoutLog(tx *dbs.Tx, taskId int64) (isOk bool,
|
|||||||
errMsg = "找不到要执行的任务"
|
errMsg = "找不到要执行的任务"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if task.IsOn != 1 {
|
if !task.IsOn {
|
||||||
errMsg = "任务没有启用"
|
errMsg = "任务没有启用"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -453,7 +453,7 @@ func (this *ACMETaskDAO) runTaskWithoutLog(tx *dbs.Tx, taskId int64) (isOk bool,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = models.SharedSSLCertDAO.UpdateCert(tx, resultCertId, cert.IsOn == 1, cert.Name, cert.Description, cert.ServerName, cert.IsCA == 1, certData, keyData, sslConfig.TimeBeginAt, sslConfig.TimeEndAt, sslConfig.DNSNames, sslConfig.CommonNames)
|
err = models.SharedSSLCertDAO.UpdateCert(tx, resultCertId, cert.IsOn, cert.Name, cert.Description, cert.ServerName, cert.IsCA == 1, certData, keyData, sslConfig.TimeBeginAt, sslConfig.TimeEndAt, sslConfig.DNSNames, sslConfig.CommonNames)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errMsg = "证书生成成功,但是修改数据库中的证书信息时出错:" + err.Error()
|
errMsg = "证书生成成功,但是修改数据库中的证书信息时出错:" + err.Error()
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ type ACMETask struct {
|
|||||||
Id uint64 `field:"id"` // ID
|
Id uint64 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
AcmeUserId uint32 `field:"acmeUserId"` // ACME用户ID
|
AcmeUserId uint32 `field:"acmeUserId"` // ACME用户ID
|
||||||
DnsDomain string `field:"dnsDomain"` // DNS主域名
|
DnsDomain string `field:"dnsDomain"` // DNS主域名
|
||||||
DnsProviderId uint64 `field:"dnsProviderId"` // DNS服务商
|
DnsProviderId uint64 `field:"dnsProviderId"` // DNS服务商
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import "github.com/iwind/TeaGo/dbs"
|
|||||||
// Admin 管理员
|
// Admin 管理员
|
||||||
type Admin struct {
|
type Admin struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Username string `field:"username"` // 用户名
|
Username string `field:"username"` // 用户名
|
||||||
Password string `field:"password"` // 密码
|
Password string `field:"password"` // 密码
|
||||||
Fullname string `field:"fullname"` // 全名
|
Fullname string `field:"fullname"` // 全名
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ package models
|
|||||||
|
|
||||||
import "github.com/iwind/TeaGo/dbs"
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// API节点
|
// APINode API节点
|
||||||
type APINode struct {
|
type APINode struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
ClusterId uint32 `field:"clusterId"` // 专用集群ID
|
ClusterId uint32 `field:"clusterId"` // 专用集群ID
|
||||||
UniqueId string `field:"uniqueId"` // 唯一ID
|
UniqueId string `field:"uniqueId"` // 唯一ID
|
||||||
Secret string `field:"secret"` // 密钥
|
Secret string `field:"secret"` // 密钥
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import "github.com/iwind/TeaGo/dbs"
|
|||||||
// AuthorityNode 监控节点
|
// AuthorityNode 监控节点
|
||||||
type AuthorityNode struct {
|
type AuthorityNode struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
UniqueId string `field:"uniqueId"` // 唯一ID
|
UniqueId string `field:"uniqueId"` // 唯一ID
|
||||||
Secret string `field:"secret"` // 密钥
|
Secret string `field:"secret"` // 密钥
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
// 数据库节点
|
// DBNode 数据库节点
|
||||||
type DBNode struct {
|
type DBNode struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Role string `field:"role"` // 数据库角色
|
Role string `field:"role"` // 数据库角色
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
Description string `field:"description"` // 描述
|
Description string `field:"description"` // 描述
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ type DNSDomain struct {
|
|||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
ProviderId uint32 `field:"providerId"` // 服务商ID
|
ProviderId uint32 `field:"providerId"` // 服务商ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否可用
|
IsOn bool `field:"isOn"` // 是否可用
|
||||||
Name string `field:"name"` // 域名
|
Name string `field:"name"` // 域名
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
DataUpdatedAt uint64 `field:"dataUpdatedAt"` // 数据更新时间
|
DataUpdatedAt uint64 `field:"dataUpdatedAt"` // 数据更新时间
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ type HTTPAccessLogPolicy struct {
|
|||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Type string `field:"type"` // 存储类型
|
Type string `field:"type"` // 存储类型
|
||||||
Options dbs.JSON `field:"options"` // 存储选项
|
Options dbs.JSON `field:"options"` // 存储选项
|
||||||
Conds dbs.JSON `field:"conds"` // 请求条件
|
Conds dbs.JSON `field:"conds"` // 请求条件
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ func (this *HTTPAuthPolicyDAO) ComposePolicyConfig(tx *dbs.Tx, policyId int64, c
|
|||||||
var config = &serverconfigs.HTTPAuthPolicy{
|
var config = &serverconfigs.HTTPAuthPolicy{
|
||||||
Id: int64(policy.Id),
|
Id: int64(policy.Id),
|
||||||
Name: policy.Name,
|
Name: policy.Name,
|
||||||
IsOn: policy.IsOn == 1,
|
IsOn: policy.IsOn,
|
||||||
Type: policy.Type,
|
Type: policy.Type,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ type HTTPAuthPolicy struct {
|
|||||||
Id uint64 `field:"id"` // ID
|
Id uint64 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
Type string `field:"type"` // 类型
|
Type string `field:"type"` // 类型
|
||||||
Params dbs.JSON `field:"params"` // 参数
|
Params dbs.JSON `field:"params"` // 参数
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ func (this *HTTPBrotliPolicyDAO) ComposeBrotliConfig(tx *dbs.Tx, policyId int64)
|
|||||||
|
|
||||||
config := &serverconfigs.HTTPBrotliCompressionConfig{}
|
config := &serverconfigs.HTTPBrotliCompressionConfig{}
|
||||||
config.Id = int64(policy.Id)
|
config.Id = int64(policy.Id)
|
||||||
config.IsOn = policy.IsOn == 1
|
config.IsOn = policy.IsOn
|
||||||
if IsNotNull(policy.MinLength) {
|
if IsNotNull(policy.MinLength) {
|
||||||
minLengthConfig := &shared.SizeCapacity{}
|
minLengthConfig := &shared.SizeCapacity{}
|
||||||
err = json.Unmarshal(policy.MinLength, minLengthConfig)
|
err = json.Unmarshal(policy.MinLength, minLengthConfig)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ type HTTPBrotliPolicy struct {
|
|||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Level uint32 `field:"level"` // 压缩级别
|
Level uint32 `field:"level"` // 压缩级别
|
||||||
MinLength dbs.JSON `field:"minLength"` // 可压缩最小值
|
MinLength dbs.JSON `field:"minLength"` // 可压缩最小值
|
||||||
MaxLength dbs.JSON `field:"maxLength"` // 可压缩最大值
|
MaxLength dbs.JSON `field:"maxLength"` // 可压缩最大值
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ func (this *HTTPCachePolicyDAO) ComposeCachePolicy(tx *dbs.Tx, policyId int64, c
|
|||||||
}
|
}
|
||||||
config := &serverconfigs.HTTPCachePolicy{}
|
config := &serverconfigs.HTTPCachePolicy{}
|
||||||
config.Id = int64(policy.Id)
|
config.Id = int64(policy.Id)
|
||||||
config.IsOn = policy.IsOn == 1
|
config.IsOn = policy.IsOn
|
||||||
config.Name = policy.Name
|
config.Name = policy.Name
|
||||||
config.Description = policy.Description
|
config.Description = policy.Description
|
||||||
config.SyncCompressionCache = policy.SyncCompressionCache == 1
|
config.SyncCompressionCache = policy.SyncCompressionCache == 1
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ type HTTPCachePolicy struct {
|
|||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
TemplateId uint32 `field:"templateId"` // 模版ID
|
TemplateId uint32 `field:"templateId"` // 模版ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
Capacity dbs.JSON `field:"capacity"` // 容量数据
|
Capacity dbs.JSON `field:"capacity"` // 容量数据
|
||||||
MaxKeys uint64 `field:"maxKeys"` // 最多Key值
|
MaxKeys uint64 `field:"maxKeys"` // 最多Key值
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ func (this *HTTPDeflatePolicyDAO) ComposeDeflateConfig(tx *dbs.Tx, policyId int6
|
|||||||
|
|
||||||
config := &serverconfigs.HTTPDeflateCompressionConfig{}
|
config := &serverconfigs.HTTPDeflateCompressionConfig{}
|
||||||
config.Id = int64(policy.Id)
|
config.Id = int64(policy.Id)
|
||||||
config.IsOn = policy.IsOn == 1
|
config.IsOn = policy.IsOn
|
||||||
if IsNotNull(policy.MinLength) {
|
if IsNotNull(policy.MinLength) {
|
||||||
minLengthConfig := &shared.SizeCapacity{}
|
minLengthConfig := &shared.SizeCapacity{}
|
||||||
err = json.Unmarshal(policy.MinLength, minLengthConfig)
|
err = json.Unmarshal(policy.MinLength, minLengthConfig)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ type HTTPDeflatePolicy struct {
|
|||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Level uint32 `field:"level"` // 压缩级别
|
Level uint32 `field:"level"` // 压缩级别
|
||||||
MinLength dbs.JSON `field:"minLength"` // 可压缩最小值
|
MinLength dbs.JSON `field:"minLength"` // 可压缩最小值
|
||||||
MaxLength dbs.JSON `field:"maxLength"` // 可压缩最大值
|
MaxLength dbs.JSON `field:"maxLength"` // 可压缩最大值
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ func (this *HTTPFastcgiDAO) ComposeFastcgiConfig(tx *dbs.Tx, fastcgiId int64) (*
|
|||||||
}
|
}
|
||||||
config := &serverconfigs.HTTPFastcgiConfig{}
|
config := &serverconfigs.HTTPFastcgiConfig{}
|
||||||
config.Id = int64(fastcgi.Id)
|
config.Id = int64(fastcgi.Id)
|
||||||
config.IsOn = fastcgi.IsOn == 1
|
config.IsOn = fastcgi.IsOn
|
||||||
config.Address = fastcgi.Address
|
config.Address = fastcgi.Address
|
||||||
|
|
||||||
if IsNotNull(fastcgi.Params) {
|
if IsNotNull(fastcgi.Params) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ type HTTPFastcgi struct {
|
|||||||
Id uint64 `field:"id"` // ID
|
Id uint64 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Address string `field:"address"` // 地址
|
Address string `field:"address"` // 地址
|
||||||
Params dbs.JSON `field:"params"` // 参数
|
Params dbs.JSON `field:"params"` // 参数
|
||||||
ReadTimeout dbs.JSON `field:"readTimeout"` // 读取超时
|
ReadTimeout dbs.JSON `field:"readTimeout"` // 读取超时
|
||||||
|
|||||||
@@ -366,7 +366,7 @@ func (this *HTTPFirewallPolicyDAO) ComposeFirewallPolicy(tx *dbs.Tx, policyId in
|
|||||||
|
|
||||||
config := &firewallconfigs.HTTPFirewallPolicy{}
|
config := &firewallconfigs.HTTPFirewallPolicy{}
|
||||||
config.Id = int64(policy.Id)
|
config.Id = int64(policy.Id)
|
||||||
config.IsOn = policy.IsOn == 1
|
config.IsOn = policy.IsOn
|
||||||
config.Name = policy.Name
|
config.Name = policy.Name
|
||||||
config.Description = policy.Description
|
config.Description = policy.Description
|
||||||
config.UseLocalFirewall = policy.UseLocalFirewall == 1
|
config.UseLocalFirewall = policy.UseLocalFirewall == 1
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ type HTTPFirewallPolicy struct {
|
|||||||
GroupId uint32 `field:"groupId"` // 服务分组ID
|
GroupId uint32 `field:"groupId"` // 服务分组ID
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
Description string `field:"description"` // 描述
|
Description string `field:"description"` // 描述
|
||||||
Inbound dbs.JSON `field:"inbound"` // 入站规则
|
Inbound dbs.JSON `field:"inbound"` // 入站规则
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ func (this *HTTPFirewallRuleDAO) ComposeFirewallRule(tx *dbs.Tx, ruleId int64) (
|
|||||||
}
|
}
|
||||||
config := &firewallconfigs.HTTPFirewallRule{}
|
config := &firewallconfigs.HTTPFirewallRule{}
|
||||||
config.Id = int64(rule.Id)
|
config.Id = int64(rule.Id)
|
||||||
config.IsOn = rule.IsOn == 1
|
config.IsOn = rule.IsOn
|
||||||
config.Param = rule.Param
|
config.Param = rule.Param
|
||||||
|
|
||||||
paramFilters := []*firewallconfigs.ParamFilter{}
|
paramFilters := []*firewallconfigs.ParamFilter{}
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ func (this *HTTPFirewallRuleGroupDAO) ComposeFirewallRuleGroup(tx *dbs.Tx, group
|
|||||||
}
|
}
|
||||||
config := &firewallconfigs.HTTPFirewallRuleGroup{}
|
config := &firewallconfigs.HTTPFirewallRuleGroup{}
|
||||||
config.Id = int64(group.Id)
|
config.Id = int64(group.Id)
|
||||||
config.IsOn = group.IsOn == 1
|
config.IsOn = group.IsOn
|
||||||
config.Name = group.Name
|
config.Name = group.Name
|
||||||
config.Description = group.Description
|
config.Description = group.Description
|
||||||
config.Code = group.Code
|
config.Code = group.Code
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import "github.com/iwind/TeaGo/dbs"
|
|||||||
// HTTPFirewallRuleGroup 防火墙规则分组
|
// HTTPFirewallRuleGroup 防火墙规则分组
|
||||||
type HTTPFirewallRuleGroup struct {
|
type HTTPFirewallRuleGroup struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
Description string `field:"description"` // 描述
|
Description string `field:"description"` // 描述
|
||||||
Code string `field:"code"` // 代号
|
Code string `field:"code"` // 代号
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import "github.com/iwind/TeaGo/dbs"
|
|||||||
// HTTPFirewallRule 防火墙规则
|
// HTTPFirewallRule 防火墙规则
|
||||||
type HTTPFirewallRule struct {
|
type HTTPFirewallRule struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Description string `field:"description"` // 说明
|
Description string `field:"description"` // 说明
|
||||||
Param string `field:"param"` // 参数
|
Param string `field:"param"` // 参数
|
||||||
ParamFilters dbs.JSON `field:"paramFilters"` // 处理器
|
ParamFilters dbs.JSON `field:"paramFilters"` // 处理器
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ func (this *HTTPFirewallRuleSetDAO) ComposeFirewallRuleSet(tx *dbs.Tx, setId int
|
|||||||
}
|
}
|
||||||
config := &firewallconfigs.HTTPFirewallRuleSet{}
|
config := &firewallconfigs.HTTPFirewallRuleSet{}
|
||||||
config.Id = int64(set.Id)
|
config.Id = int64(set.Id)
|
||||||
config.IsOn = set.IsOn == 1
|
config.IsOn = set.IsOn
|
||||||
config.Name = set.Name
|
config.Name = set.Name
|
||||||
config.Description = set.Description
|
config.Description = set.Description
|
||||||
config.Code = set.Code
|
config.Code = set.Code
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import "github.com/iwind/TeaGo/dbs"
|
|||||||
// HTTPFirewallRuleSet 防火墙规则集
|
// HTTPFirewallRuleSet 防火墙规则集
|
||||||
type HTTPFirewallRuleSet struct {
|
type HTTPFirewallRuleSet struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Code string `field:"code"` // 代号
|
Code string `field:"code"` // 代号
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
Description string `field:"description"` // 描述
|
Description string `field:"description"` // 描述
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ func (this *HTTPGzipDAO) ComposeGzipConfig(tx *dbs.Tx, gzipId int64) (*servercon
|
|||||||
|
|
||||||
config := &serverconfigs.HTTPGzipCompressionConfig{}
|
config := &serverconfigs.HTTPGzipCompressionConfig{}
|
||||||
config.Id = int64(gzip.Id)
|
config.Id = int64(gzip.Id)
|
||||||
config.IsOn = gzip.IsOn == 1
|
config.IsOn = gzip.IsOn
|
||||||
if IsNotNull(gzip.MinLength) {
|
if IsNotNull(gzip.MinLength) {
|
||||||
minLengthConfig := &shared.SizeCapacity{}
|
minLengthConfig := &shared.SizeCapacity{}
|
||||||
err = json.Unmarshal(gzip.MinLength, minLengthConfig)
|
err = json.Unmarshal(gzip.MinLength, minLengthConfig)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ type HTTPGzip struct {
|
|||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Level uint32 `field:"level"` // 压缩级别
|
Level uint32 `field:"level"` // 压缩级别
|
||||||
MinLength dbs.JSON `field:"minLength"` // 可压缩最小值
|
MinLength dbs.JSON `field:"minLength"` // 可压缩最小值
|
||||||
MaxLength dbs.JSON `field:"maxLength"` // 可压缩最大值
|
MaxLength dbs.JSON `field:"maxLength"` // 可压缩最大值
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ func (this *HTTPHeaderDAO) ComposeHeaderConfig(tx *dbs.Tx, headerId int64) (*sha
|
|||||||
|
|
||||||
config := &shared.HTTPHeaderConfig{}
|
config := &shared.HTTPHeaderConfig{}
|
||||||
config.Id = int64(header.Id)
|
config.Id = int64(header.Id)
|
||||||
config.IsOn = header.IsOn == 1
|
config.IsOn = header.IsOn
|
||||||
config.Name = header.Name
|
config.Name = header.Name
|
||||||
config.Value = header.Value
|
config.Value = header.Value
|
||||||
config.DisableRedirect = header.DisableRedirect == 1
|
config.DisableRedirect = header.DisableRedirect == 1
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ type HTTPHeader struct {
|
|||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
TemplateId uint32 `field:"templateId"` // 模版ID
|
TemplateId uint32 `field:"templateId"` // 模版ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
Value string `field:"value"` // 值
|
Value string `field:"value"` // 值
|
||||||
Order uint32 `field:"order"` // 排序
|
Order uint32 `field:"order"` // 排序
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ func (this *HTTPHeaderPolicyDAO) ComposeHeaderPolicyConfig(tx *dbs.Tx, headerPol
|
|||||||
|
|
||||||
config := &shared.HTTPHeaderPolicy{}
|
config := &shared.HTTPHeaderPolicy{}
|
||||||
config.Id = int64(policy.Id)
|
config.Id = int64(policy.Id)
|
||||||
config.IsOn = policy.IsOn == 1
|
config.IsOn = policy.IsOn
|
||||||
|
|
||||||
// SetHeaders
|
// SetHeaders
|
||||||
if IsNotNull(policy.SetHeaders) {
|
if IsNotNull(policy.SetHeaders) {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import "github.com/iwind/TeaGo/dbs"
|
|||||||
//
|
//
|
||||||
type HTTPHeaderPolicy struct {
|
type HTTPHeaderPolicy struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ func (this *HTTPLocationDAO) ComposeLocationConfig(tx *dbs.Tx, locationId int64,
|
|||||||
|
|
||||||
config := &serverconfigs.HTTPLocationConfig{}
|
config := &serverconfigs.HTTPLocationConfig{}
|
||||||
config.Id = int64(location.Id)
|
config.Id = int64(location.Id)
|
||||||
config.IsOn = location.IsOn == 1
|
config.IsOn = location.IsOn
|
||||||
config.Description = location.Description
|
config.Description = location.Description
|
||||||
config.Name = location.Name
|
config.Name = location.Name
|
||||||
config.Pattern = location.Pattern
|
config.Pattern = location.Pattern
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ type HTTPLocation struct {
|
|||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
Pattern string `field:"pattern"` // 匹配规则
|
Pattern string `field:"pattern"` // 匹配规则
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
Description string `field:"description"` // 描述
|
Description string `field:"description"` // 描述
|
||||||
WebId uint32 `field:"webId"` // Web配置ID
|
WebId uint32 `field:"webId"` // Web配置ID
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ func (this *HTTPPageDAO) ComposePageConfig(tx *dbs.Tx, pageId int64, cacheMap *u
|
|||||||
|
|
||||||
config := &serverconfigs.HTTPPageConfig{}
|
config := &serverconfigs.HTTPPageConfig{}
|
||||||
config.Id = int64(page.Id)
|
config.Id = int64(page.Id)
|
||||||
config.IsOn = page.IsOn == 1
|
config.IsOn = page.IsOn
|
||||||
config.NewStatus = int(page.NewStatus)
|
config.NewStatus = int(page.NewStatus)
|
||||||
config.URL = page.Url
|
config.URL = page.Url
|
||||||
config.Body = page.Body
|
config.Body = page.Body
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ type HTTPPage struct {
|
|||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
StatusList dbs.JSON `field:"statusList"` // 状态列表
|
StatusList dbs.JSON `field:"statusList"` // 状态列表
|
||||||
Url string `field:"url"` // 页面URL
|
Url string `field:"url"` // 页面URL
|
||||||
NewStatus int32 `field:"newStatus"` // 新状态码
|
NewStatus int32 `field:"newStatus"` // 新状态码
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ func (this *HTTPRewriteRuleDAO) ComposeRewriteRule(tx *dbs.Tx, rewriteRuleId int
|
|||||||
|
|
||||||
config := &serverconfigs.HTTPRewriteRule{}
|
config := &serverconfigs.HTTPRewriteRule{}
|
||||||
config.Id = int64(rule.Id)
|
config.Id = int64(rule.Id)
|
||||||
config.IsOn = rule.IsOn == 1
|
config.IsOn = rule.IsOn
|
||||||
config.Pattern = rule.Pattern
|
config.Pattern = rule.Pattern
|
||||||
config.Replace = rule.Replace
|
config.Replace = rule.Replace
|
||||||
config.Mode = rule.Mode
|
config.Mode = rule.Mode
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ type HTTPRewriteRule struct {
|
|||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
TemplateId uint32 `field:"templateId"` // 模版ID
|
TemplateId uint32 `field:"templateId"` // 模版ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
Pattern string `field:"pattern"` // 匹配规则
|
Pattern string `field:"pattern"` // 匹配规则
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
|
|||||||
|
|
||||||
config := &serverconfigs.HTTPWebConfig{}
|
config := &serverconfigs.HTTPWebConfig{}
|
||||||
config.Id = webId
|
config.Id = webId
|
||||||
config.IsOn = web.IsOn == 1
|
config.IsOn = web.IsOn
|
||||||
|
|
||||||
// root
|
// root
|
||||||
if IsNotNull(web.Root) {
|
if IsNotNull(web.Root) {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import "github.com/iwind/TeaGo/dbs"
|
|||||||
// HTTPWeb HTTP Web
|
// HTTPWeb HTTP Web
|
||||||
type HTTPWeb struct {
|
type HTTPWeb struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
TemplateId uint32 `field:"templateId"` // 模版ID
|
TemplateId uint32 `field:"templateId"` // 模版ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ func (this *HTTPWebsocketDAO) ComposeWebsocketConfig(tx *dbs.Tx, websocketId int
|
|||||||
}
|
}
|
||||||
config := &serverconfigs.HTTPWebsocketConfig{}
|
config := &serverconfigs.HTTPWebsocketConfig{}
|
||||||
config.Id = int64(websocket.Id)
|
config.Id = int64(websocket.Id)
|
||||||
config.IsOn = websocket.IsOn == 1
|
config.IsOn = websocket.IsOn
|
||||||
config.AllowAllOrigins = websocket.AllowAllOrigins == 1
|
config.AllowAllOrigins = websocket.AllowAllOrigins == 1
|
||||||
|
|
||||||
if IsNotNull(websocket.AllowedOrigins) {
|
if IsNotNull(websocket.AllowedOrigins) {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ type HTTPWebsocket struct {
|
|||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
HandshakeTimeout dbs.JSON `field:"handshakeTimeout"` // 握手超时时间
|
HandshakeTimeout dbs.JSON `field:"handshakeTimeout"` // 握手超时时间
|
||||||
AllowAllOrigins uint8 `field:"allowAllOrigins"` // 是否支持所有源
|
AllowAllOrigins uint8 `field:"allowAllOrigins"` // 是否支持所有源
|
||||||
AllowedOrigins dbs.JSON `field:"allowedOrigins"` // 支持的源域名列表
|
AllowedOrigins dbs.JSON `field:"allowedOrigins"` // 支持的源域名列表
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ var DefaultGlobalIPList = &IPList{
|
|||||||
IsGlobal: 1,
|
IsGlobal: 1,
|
||||||
Type: "black",
|
Type: "black",
|
||||||
State: IPListStateEnabled,
|
State: IPListStateEnabled,
|
||||||
IsOn: 1,
|
IsOn: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
type IPListDAO dbs.DAO
|
type IPListDAO dbs.DAO
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import "github.com/iwind/TeaGo/dbs"
|
|||||||
// IPList IP名单
|
// IPList IP名单
|
||||||
type IPList struct {
|
type IPList struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Type string `field:"type"` // 类型
|
Type string `field:"type"` // 类型
|
||||||
AdminId uint32 `field:"adminId"` // 用户ID
|
AdminId uint32 `field:"adminId"` // 用户ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ type Login struct {
|
|||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Type string `field:"type"` // 认证方式
|
Type string `field:"type"` // 认证方式
|
||||||
Params dbs.JSON `field:"params"` // 参数
|
Params dbs.JSON `field:"params"` // 参数
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import "github.com/iwind/TeaGo/dbs"
|
|||||||
type MessageMediaInstance struct {
|
type MessageMediaInstance struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
MediaType string `field:"mediaType"` // 媒介类型
|
MediaType string `field:"mediaType"` // 媒介类型
|
||||||
Params dbs.JSON `field:"params"` // 媒介参数
|
Params dbs.JSON `field:"params"` // 媒介参数
|
||||||
Description string `field:"description"` // 备注
|
Description string `field:"description"` // 备注
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
// 消息媒介
|
// MessageMedia 消息媒介
|
||||||
type MessageMedia struct {
|
type MessageMedia struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
Type string `field:"type"` // 类型
|
Type string `field:"type"` // 类型
|
||||||
Description string `field:"description"` // 描述
|
Description string `field:"description"` // 描述
|
||||||
UserDescription string `field:"userDescription"` // 用户描述
|
UserDescription string `field:"userDescription"` // 用户描述
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Order uint32 `field:"order"` // 排序
|
Order uint32 `field:"order"` // 排序
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
// 消息接收人分组
|
// MessageRecipientGroup 消息接收人分组
|
||||||
type MessageRecipientGroup struct {
|
type MessageRecipientGroup struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
Name string `field:"name"` // 分组名
|
Name string `field:"name"` // 分组名
|
||||||
Order uint32 `field:"order"` // 排序
|
Order uint32 `field:"order"` // 排序
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import "github.com/iwind/TeaGo/dbs"
|
|||||||
type MessageRecipient struct {
|
type MessageRecipient struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
InstanceId uint32 `field:"instanceId"` // 实例ID
|
InstanceId uint32 `field:"instanceId"` // 实例ID
|
||||||
User string `field:"user"` // 接收人信息
|
User string `field:"user"` // 接收人信息
|
||||||
GroupIds dbs.JSON `field:"groupIds"` // 分组ID
|
GroupIds dbs.JSON `field:"groupIds"` // 分组ID
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ type MetricChart struct {
|
|||||||
WidthDiv int32 `field:"widthDiv"` // 宽度划分
|
WidthDiv int32 `field:"widthDiv"` // 宽度划分
|
||||||
Params dbs.JSON `field:"params"` // 图形参数
|
Params dbs.JSON `field:"params"` // 图形参数
|
||||||
Order uint32 `field:"order"` // 排序
|
Order uint32 `field:"order"` // 排序
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
MaxItems uint32 `field:"maxItems"` // 最多条目
|
MaxItems uint32 `field:"maxItems"` // 最多条目
|
||||||
IgnoreEmptyKeys uint8 `field:"ignoreEmptyKeys"` // 忽略空的键值
|
IgnoreEmptyKeys uint8 `field:"ignoreEmptyKeys"` // 忽略空的键值
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ func (this *MetricItemDAO) UpdateItem(tx *dbs.Tx, itemId int64, name string, key
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 通知更新
|
// 通知更新
|
||||||
if versionChanged || (oldItem.IsOn == 0 && isOn) || (oldItem.IsOn == 1 && !isOn) || oldIsPublic != isPublic {
|
if versionChanged || (!oldItem.IsOn && isOn) || (oldItem.IsOn && !isOn) || oldIsPublic != isPublic {
|
||||||
err := this.NotifyUpdate(tx, itemId, isPublic || oldIsPublic)
|
err := this.NotifyUpdate(tx, itemId, isPublic || oldIsPublic)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -283,7 +283,7 @@ func (this *MetricItemDAO) ComposeItemConfig(tx *dbs.Tx, itemId int64) (*serverc
|
|||||||
var item = one.(*MetricItem)
|
var item = one.(*MetricItem)
|
||||||
var config = &serverconfigs.MetricItemConfig{
|
var config = &serverconfigs.MetricItemConfig{
|
||||||
Id: int64(item.Id),
|
Id: int64(item.Id),
|
||||||
IsOn: item.IsOn == 1,
|
IsOn: item.IsOn,
|
||||||
Period: types.Int(item.Period),
|
Period: types.Int(item.Period),
|
||||||
PeriodUnit: item.PeriodUnit,
|
PeriodUnit: item.PeriodUnit,
|
||||||
Category: item.Category,
|
Category: item.Category,
|
||||||
@@ -302,7 +302,7 @@ func (this *MetricItemDAO) ComposeItemConfigWithItem(item *MetricItem) *serverco
|
|||||||
}
|
}
|
||||||
var config = &serverconfigs.MetricItemConfig{
|
var config = &serverconfigs.MetricItemConfig{
|
||||||
Id: int64(item.Id),
|
Id: int64(item.Id),
|
||||||
IsOn: item.IsOn == 1,
|
IsOn: item.IsOn,
|
||||||
Period: types.Int(item.Period),
|
Period: types.Int(item.Period),
|
||||||
PeriodUnit: item.PeriodUnit,
|
PeriodUnit: item.PeriodUnit,
|
||||||
Category: item.Category,
|
Category: item.Category,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import "github.com/iwind/TeaGo/dbs"
|
|||||||
// MetricItem 指标定义
|
// MetricItem 指标定义
|
||||||
type MetricItem struct {
|
type MetricItem struct {
|
||||||
Id uint64 `field:"id"` // ID
|
Id uint64 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Code string `field:"code"` // 代号(用来区分是否内置)
|
Code string `field:"code"` // 代号(用来区分是否内置)
|
||||||
Category string `field:"category"` // 类型,比如http, tcp等
|
Category string `field:"category"` // 类型,比如http, tcp等
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ package models
|
|||||||
|
|
||||||
import "github.com/iwind/TeaGo/dbs"
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// 监控节点
|
// MonitorNode 监控节点
|
||||||
type MonitorNode struct {
|
type MonitorNode struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
UniqueId string `field:"uniqueId"` // 唯一ID
|
UniqueId string `field:"uniqueId"` // 唯一ID
|
||||||
Secret string `field:"secret"` // 密钥
|
Secret string `field:"secret"` // 密钥
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ type NSDomain struct {
|
|||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
ClusterId uint32 `field:"clusterId"` // 集群ID
|
ClusterId uint32 `field:"clusterId"` // 集群ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Name string `field:"name"` // 域名
|
Name string `field:"name"` // 域名
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
Version uint64 `field:"version"` // 版本
|
Version uint64 `field:"version"` // 版本
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package nameservers
|
|||||||
// NSKey 密钥管理
|
// NSKey 密钥管理
|
||||||
type NSKey struct {
|
type NSKey struct {
|
||||||
Id uint64 `field:"id"` // ID
|
Id uint64 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 状态
|
IsOn bool `field:"isOn"` // 状态
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
DomainId uint64 `field:"domainId"` // 域名ID
|
DomainId uint64 `field:"domainId"` // 域名ID
|
||||||
ZoneId uint64 `field:"zoneId"` // 子域ID
|
ZoneId uint64 `field:"zoneId"` // 子域ID
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import "github.com/iwind/TeaGo/dbs"
|
|||||||
type NSRecord struct {
|
type NSRecord struct {
|
||||||
Id uint64 `field:"id"` // ID
|
Id uint64 `field:"id"` // ID
|
||||||
DomainId uint32 `field:"domainId"` // 域名ID
|
DomainId uint32 `field:"domainId"` // 域名ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Description string `field:"description"` // 备注
|
Description string `field:"description"` // 备注
|
||||||
Name string `field:"name"` // 记录名
|
Name string `field:"name"` // 记录名
|
||||||
Type string `field:"type"` // 类型
|
Type string `field:"type"` // 类型
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ func (this *NSRouteDAO) FindEnabledRouteWithCode(tx *dbs.Tx, code string) (*NSRo
|
|||||||
|
|
||||||
return &NSRoute{
|
return &NSRoute{
|
||||||
Id: 0,
|
Id: 0,
|
||||||
IsOn: 1,
|
IsOn: true,
|
||||||
Name: route.Name,
|
Name: route.Name,
|
||||||
Code: route.Code,
|
Code: route.Code,
|
||||||
State: NSRouteStateEnabled,
|
State: NSRouteStateEnabled,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import "github.com/iwind/TeaGo/dbs"
|
|||||||
// NSRoute DNS线路
|
// NSRoute DNS线路
|
||||||
type NSRoute struct {
|
type NSRoute struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
ClusterId uint32 `field:"clusterId"` // 集群ID
|
ClusterId uint32 `field:"clusterId"` // 集群ID
|
||||||
DomainId uint32 `field:"domainId"` // 域名ID
|
DomainId uint32 `field:"domainId"` // 域名ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import "github.com/iwind/TeaGo/dbs"
|
|||||||
type NSZone struct {
|
type NSZone struct {
|
||||||
Id uint64 `field:"id"` // ID
|
Id uint64 `field:"id"` // ID
|
||||||
DomainId uint64 `field:"domainId"` // 域名ID
|
DomainId uint64 `field:"domainId"` // 域名ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Order uint32 `field:"order"` // 排序
|
Order uint32 `field:"order"` // 排序
|
||||||
Version uint64 `field:"version"` // 版本
|
Version uint64 `field:"version"` // 版本
|
||||||
Tsig dbs.JSON `field:"tsig"` // TSIG配置
|
Tsig dbs.JSON `field:"tsig"` // TSIG配置
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ func (this *NodeClusterDAO) FindAllAPINodeAddrsWithCluster(tx *dbs.Tx, clusterId
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, apiNode := range apiNodes {
|
for _, apiNode := range apiNodes {
|
||||||
if apiNode.IsOn != 1 {
|
if !apiNode.IsOn {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
addrs, err := apiNode.DecodeAccessAddrStrings()
|
addrs, err := apiNode.DecodeAccessAddrStrings()
|
||||||
@@ -288,7 +288,7 @@ func (this *NodeClusterDAO) FindAllAPINodeAddrsWithCluster(tx *dbs.Tx, clusterId
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if apiNode == nil || apiNode.IsOn != 1 {
|
if apiNode == nil || !apiNode.IsOn {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
addrs, err := apiNode.DecodeAccessAddrStrings()
|
addrs, err := apiNode.DecodeAccessAddrStrings()
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package models
|
|||||||
// NodeClusterMetricItem 集群使用的指标
|
// NodeClusterMetricItem 集群使用的指标
|
||||||
type NodeClusterMetricItem struct {
|
type NodeClusterMetricItem struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
ClusterId uint32 `field:"clusterId"` // 集群ID
|
ClusterId uint32 `field:"clusterId"` // 集群ID
|
||||||
ItemId uint64 `field:"itemId"` // 指标ID
|
ItemId uint64 `field:"itemId"` // 指标ID
|
||||||
State uint8 `field:"state"` // 是否启用
|
State uint8 `field:"state"` // 是否启用
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ type NodeCluster struct {
|
|||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
UseAllAPINodes uint8 `field:"useAllAPINodes"` // 是否使用所有API节点
|
UseAllAPINodes uint8 `field:"useAllAPINodes"` // 是否使用所有API节点
|
||||||
ApiNodes dbs.JSON `field:"apiNodes"` // 使用的API节点
|
ApiNodes dbs.JSON `field:"apiNodes"` // 使用的API节点
|
||||||
|
|||||||
@@ -736,7 +736,7 @@ func (this *NodeDAO) ComposeNodeConfig(tx *dbs.Tx, nodeId int64, cacheMap *utils
|
|||||||
Id: int64(node.Id),
|
Id: int64(node.Id),
|
||||||
NodeId: node.UniqueId,
|
NodeId: node.UniqueId,
|
||||||
Secret: node.Secret,
|
Secret: node.Secret,
|
||||||
IsOn: node.IsOn == 1,
|
IsOn: node.IsOn,
|
||||||
Servers: nil,
|
Servers: nil,
|
||||||
Version: int64(node.Version),
|
Version: int64(node.Version),
|
||||||
Name: node.Name,
|
Name: node.Name,
|
||||||
@@ -767,7 +767,7 @@ func (this *NodeDAO) ComposeNodeConfig(tx *dbs.Tx, nodeId int64, cacheMap *utils
|
|||||||
}
|
}
|
||||||
config.Servers = append(config.Servers, serverConfig)
|
config.Servers = append(config.Servers, serverConfig)
|
||||||
|
|
||||||
if server.IsOn == 1 && server.SupportCNAME == 1 {
|
if server.IsOn && server.SupportCNAME == 1 {
|
||||||
config.SupportCNAME = true
|
config.SupportCNAME = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ type NodeIPAddressLog struct {
|
|||||||
Description string `field:"description"` // 描述
|
Description string `field:"description"` // 描述
|
||||||
CreatedAt uint64 `field:"createdAt"` // 操作时间
|
CreatedAt uint64 `field:"createdAt"` // 操作时间
|
||||||
IsUp uint8 `field:"isUp"` // 是否在线
|
IsUp uint8 `field:"isUp"` // 是否在线
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
CanAccess uint8 `field:"canAccess"` // 是否可访问
|
CanAccess uint8 `field:"canAccess"` // 是否可访问
|
||||||
Day string `field:"day"` // YYYYMMDD,用来清理
|
Day string `field:"day"` // YYYYMMDD,用来清理
|
||||||
BackupIP string `field:"backupIP"` // 备用IP
|
BackupIP string `field:"backupIP"` // 备用IP
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ type NodeIPAddress struct {
|
|||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
Order uint32 `field:"order"` // 排序
|
Order uint32 `field:"order"` // 排序
|
||||||
CanAccess uint8 `field:"canAccess"` // 是否可以访问
|
CanAccess uint8 `field:"canAccess"` // 是否可以访问
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
IsUp uint8 `field:"isUp"` // 是否上线
|
IsUp uint8 `field:"isUp"` // 是否上线
|
||||||
IsHealthy uint8 `field:"isHealthy"` // 是否健康
|
IsHealthy uint8 `field:"isHealthy"` // 是否健康
|
||||||
Thresholds dbs.JSON `field:"thresholds"` // 上线阈值
|
Thresholds dbs.JSON `field:"thresholds"` // 上线阈值
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ type Node struct {
|
|||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
IsUp uint8 `field:"isUp"` // 是否在线
|
IsUp uint8 `field:"isUp"` // 是否在线
|
||||||
CountUp uint32 `field:"countUp"` // 连续在线次数
|
CountUp uint32 `field:"countUp"` // 连续在线次数
|
||||||
CountDown uint32 `field:"countDown"` // 连续下线次数
|
CountDown uint32 `field:"countDown"` // 连续下线次数
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package models
|
|||||||
// NodePriceItem 区域计费设置
|
// NodePriceItem 区域计费设置
|
||||||
type NodePriceItem struct {
|
type NodePriceItem struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Type string `field:"type"` // 类型:峰值|流量
|
Type string `field:"type"` // 类型:峰值|流量
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
BitsFrom uint64 `field:"bitsFrom"` // 起始值
|
BitsFrom uint64 `field:"bitsFrom"` // 起始值
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import "github.com/iwind/TeaGo/dbs"
|
|||||||
type NodeRegion struct {
|
type NodeRegion struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
Description string `field:"description"` // 描述
|
Description string `field:"description"` // 描述
|
||||||
Order uint32 `field:"order"` // 排序
|
Order uint32 `field:"order"` // 排序
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ type NodeThreshold struct {
|
|||||||
Role string `field:"role"` // 节点角色
|
Role string `field:"role"` // 节点角色
|
||||||
ClusterId uint32 `field:"clusterId"` // 集群ID
|
ClusterId uint32 `field:"clusterId"` // 集群ID
|
||||||
NodeId uint32 `field:"nodeId"` // 节点ID
|
NodeId uint32 `field:"nodeId"` // 节点ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Item string `field:"item"` // 监控项
|
Item string `field:"item"` // 监控项
|
||||||
Param string `field:"param"` // 参数
|
Param string `field:"param"` // 参数
|
||||||
Operator string `field:"operator"` // 操作符
|
Operator string `field:"operator"` // 操作符
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import "github.com/iwind/TeaGo/dbs"
|
|||||||
// NSCluster 域名服务器集群
|
// NSCluster 域名服务器集群
|
||||||
type NSCluster struct {
|
type NSCluster struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Name string `field:"name"` // 集群名
|
Name string `field:"name"` // 集群名
|
||||||
InstallDir string `field:"installDir"` // 安装目录
|
InstallDir string `field:"installDir"` // 安装目录
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ type NSNode struct {
|
|||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
ClusterId uint32 `field:"clusterId"` // 集群ID
|
ClusterId uint32 `field:"clusterId"` // 集群ID
|
||||||
Name string `field:"name"` // 节点名称
|
Name string `field:"name"` // 节点名称
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Status dbs.JSON `field:"status"` // 运行状态
|
Status dbs.JSON `field:"status"` // 运行状态
|
||||||
UniqueId string `field:"uniqueId"` // 节点ID
|
UniqueId string `field:"uniqueId"` // 节点ID
|
||||||
Secret string `field:"secret"` // 密钥
|
Secret string `field:"secret"` // 密钥
|
||||||
|
|||||||
@@ -292,7 +292,7 @@ func (this *OriginDAO) ComposeOriginConfig(tx *dbs.Tx, originId int64, cacheMap
|
|||||||
|
|
||||||
var config = &serverconfigs.OriginConfig{
|
var config = &serverconfigs.OriginConfig{
|
||||||
Id: int64(origin.Id),
|
Id: int64(origin.Id),
|
||||||
IsOn: origin.IsOn == 1,
|
IsOn: origin.IsOn,
|
||||||
Version: int(origin.Version),
|
Version: int(origin.Version),
|
||||||
Name: origin.Name,
|
Name: origin.Name,
|
||||||
Description: origin.Description,
|
Description: origin.Description,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ type Origin struct {
|
|||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
Version uint32 `field:"version"` // 版本
|
Version uint32 `field:"version"` // 版本
|
||||||
Addr dbs.JSON `field:"addr"` // 地址
|
Addr dbs.JSON `field:"addr"` // 地址
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import "github.com/iwind/TeaGo/dbs"
|
|||||||
// Plan 用户套餐
|
// Plan 用户套餐
|
||||||
type Plan struct {
|
type Plan struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Name string `field:"name"` // 套餐名
|
Name string `field:"name"` // 套餐名
|
||||||
ClusterId uint32 `field:"clusterId"` // 集群ID
|
ClusterId uint32 `field:"clusterId"` // 集群ID
|
||||||
TrafficLimit dbs.JSON `field:"trafficLimit"` // 流量限制
|
TrafficLimit dbs.JSON `field:"trafficLimit"` // 流量限制
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ type ReportNodeGroup struct {
|
|||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
}
|
}
|
||||||
|
|
||||||
type ReportNodeGroupOperator struct {
|
type ReportNodeGroupOperator struct {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ type ReportNode struct {
|
|||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
UniqueId string `field:"uniqueId"` // 唯一ID
|
UniqueId string `field:"uniqueId"` // 唯一ID
|
||||||
Secret string `field:"secret"` // 密钥
|
Secret string `field:"secret"` // 密钥
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
Location string `field:"location"` // 所在区域
|
Location string `field:"location"` // 所在区域
|
||||||
Isp string `field:"isp"` // 网络服务商
|
Isp string `field:"isp"` // 网络服务商
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ func (this *ReverseProxyDAO) ComposeReverseProxyConfig(tx *dbs.Tx, reverseProxyI
|
|||||||
|
|
||||||
config := &serverconfigs.ReverseProxyConfig{}
|
config := &serverconfigs.ReverseProxyConfig{}
|
||||||
config.Id = int64(reverseProxy.Id)
|
config.Id = int64(reverseProxy.Id)
|
||||||
config.IsOn = reverseProxy.IsOn == 1
|
config.IsOn = reverseProxy.IsOn
|
||||||
config.RequestHostType = types.Int8(reverseProxy.RequestHostType)
|
config.RequestHostType = types.Int8(reverseProxy.RequestHostType)
|
||||||
config.RequestHost = reverseProxy.RequestHost
|
config.RequestHost = reverseProxy.RequestHost
|
||||||
config.RequestURI = reverseProxy.RequestURI
|
config.RequestURI = reverseProxy.RequestURI
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ type ReverseProxy struct {
|
|||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
TemplateId uint32 `field:"templateId"` // 模版ID
|
TemplateId uint32 `field:"templateId"` // 模版ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Scheduling dbs.JSON `field:"scheduling"` // 调度算法
|
Scheduling dbs.JSON `field:"scheduling"` // 调度算法
|
||||||
PrimaryOrigins dbs.JSON `field:"primaryOrigins"` // 主要源站
|
PrimaryOrigins dbs.JSON `field:"primaryOrigins"` // 主要源站
|
||||||
BackupOrigins dbs.JSON `field:"backupOrigins"` // 备用源站
|
BackupOrigins dbs.JSON `field:"backupOrigins"` // 备用源站
|
||||||
|
|||||||
@@ -890,7 +890,7 @@ func (this *ServerDAO) ComposeServerConfig(tx *dbs.Tx, server *Server, cacheMap
|
|||||||
config.Id = int64(server.Id)
|
config.Id = int64(server.Id)
|
||||||
config.ClusterId = int64(server.ClusterId)
|
config.ClusterId = int64(server.ClusterId)
|
||||||
config.Type = server.Type
|
config.Type = server.Type
|
||||||
config.IsOn = server.IsOn == 1
|
config.IsOn = server.IsOn
|
||||||
config.Name = server.Name
|
config.Name = server.Name
|
||||||
config.Description = server.Description
|
config.Description = server.Description
|
||||||
|
|
||||||
@@ -1085,7 +1085,7 @@ func (this *ServerDAO) ComposeServerConfig(tx *dbs.Tx, server *Server, cacheMap
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if userPlan != nil && userPlan.IsOn == 1 {
|
if userPlan != nil && userPlan.IsOn {
|
||||||
if len(userPlan.DayTo) == 0 {
|
if len(userPlan.DayTo) == 0 {
|
||||||
userPlan.DayTo = DefaultUserPlanMaxDay
|
userPlan.DayTo = DefaultUserPlanMaxDay
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
package models
|
package models_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
|
||||||
"github.com/TeaOSLab/EdgeAPI/internal/utils"
|
"github.com/TeaOSLab/EdgeAPI/internal/utils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||||
@@ -16,7 +17,7 @@ import (
|
|||||||
func TestServerDAO_ComposeServerConfig(t *testing.T) {
|
func TestServerDAO_ComposeServerConfig(t *testing.T) {
|
||||||
dbs.NotifyReady()
|
dbs.NotifyReady()
|
||||||
var tx *dbs.Tx
|
var tx *dbs.Tx
|
||||||
config, err := SharedServerDAO.ComposeServerConfigWithServerId(tx, 1, false)
|
config, err := models.SharedServerDAO.ComposeServerConfigWithServerId(tx, 1, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -26,7 +27,7 @@ func TestServerDAO_ComposeServerConfig(t *testing.T) {
|
|||||||
func TestServerDAO_ComposeServerConfig_AliasServerNames(t *testing.T) {
|
func TestServerDAO_ComposeServerConfig_AliasServerNames(t *testing.T) {
|
||||||
dbs.NotifyReady()
|
dbs.NotifyReady()
|
||||||
var tx *dbs.Tx
|
var tx *dbs.Tx
|
||||||
config, err := SharedServerDAO.ComposeServerConfigWithServerId(tx, 14, false)
|
config, err := models.SharedServerDAO.ComposeServerConfigWithServerId(tx, 14, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -36,7 +37,7 @@ func TestServerDAO_ComposeServerConfig_AliasServerNames(t *testing.T) {
|
|||||||
func TestServerDAO_UpdateServerConfig(t *testing.T) {
|
func TestServerDAO_UpdateServerConfig(t *testing.T) {
|
||||||
dbs.NotifyReady()
|
dbs.NotifyReady()
|
||||||
var tx *dbs.Tx
|
var tx *dbs.Tx
|
||||||
config, err := SharedServerDAO.ComposeServerConfigWithServerId(tx, 1, false)
|
config, err := models.SharedServerDAO.ComposeServerConfigWithServerId(tx, 1, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -62,7 +63,7 @@ func TestNewServerDAO_md5(t *testing.T) {
|
|||||||
func TestServerDAO_genDNSName(t *testing.T) {
|
func TestServerDAO_genDNSName(t *testing.T) {
|
||||||
dbs.NotifyReady()
|
dbs.NotifyReady()
|
||||||
var tx *dbs.Tx
|
var tx *dbs.Tx
|
||||||
dnsName, err := SharedServerDAO.GenDNSName(tx)
|
dnsName, err := models.SharedServerDAO.GenDNSName(tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -72,7 +73,7 @@ func TestServerDAO_genDNSName(t *testing.T) {
|
|||||||
func TestServerDAO_FindAllServerDNSNamesWithDNSDomainId(t *testing.T) {
|
func TestServerDAO_FindAllServerDNSNamesWithDNSDomainId(t *testing.T) {
|
||||||
dbs.NotifyReady()
|
dbs.NotifyReady()
|
||||||
var tx *dbs.Tx
|
var tx *dbs.Tx
|
||||||
dnsNames, err := SharedServerDAO.FindAllServerDNSNamesWithDNSDomainId(tx, 2)
|
dnsNames, err := models.SharedServerDAO.FindAllServerDNSNamesWithDNSDomainId(tx, 2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -82,7 +83,7 @@ func TestServerDAO_FindAllServerDNSNamesWithDNSDomainId(t *testing.T) {
|
|||||||
func TestServerDAO_FindAllEnabledServerIdsWithSSLPolicyIds(t *testing.T) {
|
func TestServerDAO_FindAllEnabledServerIdsWithSSLPolicyIds(t *testing.T) {
|
||||||
dbs.NotifyReady()
|
dbs.NotifyReady()
|
||||||
var tx *dbs.Tx
|
var tx *dbs.Tx
|
||||||
serverIds, err := SharedServerDAO.FindAllEnabledServerIdsWithSSLPolicyIds(tx, []int64{14})
|
serverIds, err := models.SharedServerDAO.FindAllEnabledServerIdsWithSSLPolicyIds(tx, []int64{14})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -100,7 +101,7 @@ func TestServerDAO_CheckPortIsUsing(t *testing.T) {
|
|||||||
// t.Log("isUsing:", isUsing)
|
// t.Log("isUsing:", isUsing)
|
||||||
//}
|
//}
|
||||||
{
|
{
|
||||||
isUsing, err := SharedServerDAO.CheckPortIsUsing(tx, 18, "tcp", 3306, 0, "")
|
isUsing, err := models.SharedServerDAO.CheckPortIsUsing(tx, 18, "tcp", 3306, 0, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -113,7 +114,7 @@ func TestServerDAO_ExistServerNameInCluster(t *testing.T) {
|
|||||||
|
|
||||||
var tx *dbs.Tx
|
var tx *dbs.Tx
|
||||||
{
|
{
|
||||||
exist, err := SharedServerDAO.ExistServerNameInCluster(tx, 18, "hello.teaos.cn", 0)
|
exist, err := models.SharedServerDAO.ExistServerNameInCluster(tx, 18, "hello.teaos.cn", 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -121,7 +122,7 @@ func TestServerDAO_ExistServerNameInCluster(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
exist, err := SharedServerDAO.ExistServerNameInCluster(tx, 18, "cdn.teaos.cn", 0)
|
exist, err := models.SharedServerDAO.ExistServerNameInCluster(tx, 18, "cdn.teaos.cn", 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -129,7 +130,7 @@ func TestServerDAO_ExistServerNameInCluster(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
exist, err := SharedServerDAO.ExistServerNameInCluster(tx, 18, "cdn.teaos.cn", 23)
|
exist, err := models.SharedServerDAO.ExistServerNameInCluster(tx, 18, "cdn.teaos.cn", 23)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -141,7 +142,7 @@ func TestServerDAO_FindAllEnabledServersWithNode(t *testing.T) {
|
|||||||
dbs.NotifyReady()
|
dbs.NotifyReady()
|
||||||
|
|
||||||
var before = time.Now()
|
var before = time.Now()
|
||||||
servers, err := SharedServerDAO.FindAllEnabledServersWithNode(nil, 48)
|
servers, err := models.SharedServerDAO.FindAllEnabledServersWithNode(nil, 48)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -156,23 +157,23 @@ func TestServerDAO_FindAllEnabledServersWithNode_Cache(t *testing.T) {
|
|||||||
|
|
||||||
var cacheMap = utils.NewCacheMap()
|
var cacheMap = utils.NewCacheMap()
|
||||||
{
|
{
|
||||||
servers, err := SharedServerDAO.FindAllEnabledServersWithNode(nil, 48)
|
servers, err := models.SharedServerDAO.FindAllEnabledServersWithNode(nil, 48)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
for _, server := range servers {
|
for _, server := range servers {
|
||||||
_, _ = SharedServerDAO.ComposeServerConfig(nil, server, cacheMap, true)
|
_, _ = models.SharedServerDAO.ComposeServerConfig(nil, server, cacheMap, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var before = time.Now()
|
var before = time.Now()
|
||||||
{
|
{
|
||||||
servers, err := SharedServerDAO.FindAllEnabledServersWithNode(nil, 48)
|
servers, err := models.SharedServerDAO.FindAllEnabledServersWithNode(nil, 48)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
for _, server := range servers {
|
for _, server := range servers {
|
||||||
_, _ = SharedServerDAO.ComposeServerConfig(nil, server, cacheMap, true)
|
_, _ = models.SharedServerDAO.ComposeServerConfig(nil, server, cacheMap, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
t.Log(time.Since(before).Seconds()*1000, "ms")
|
t.Log(time.Since(before).Seconds()*1000, "ms")
|
||||||
@@ -180,7 +181,7 @@ func TestServerDAO_FindAllEnabledServersWithNode_Cache(t *testing.T) {
|
|||||||
|
|
||||||
func TestServerDAO_FindAllEnabledServersWithDomain(t *testing.T) {
|
func TestServerDAO_FindAllEnabledServersWithDomain(t *testing.T) {
|
||||||
for _, domain := range []string{"yun4s.cn", "teaos.cn", "teaos2.cn", "cdn.teaos.cn", "cdn100.teaos.cn"} {
|
for _, domain := range []string{"yun4s.cn", "teaos.cn", "teaos2.cn", "cdn.teaos.cn", "cdn100.teaos.cn"} {
|
||||||
servers, err := NewServerDAO().FindAllEnabledServersWithDomain(nil, domain)
|
servers, err := models.NewServerDAO().FindAllEnabledServersWithDomain(nil, domain)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -202,7 +203,7 @@ func TestServerDAO_UpdateServerTrafficLimitStatus(t *testing.T) {
|
|||||||
defer func() {
|
defer func() {
|
||||||
t.Log(time.Since(before).Seconds()*1000, "ms")
|
t.Log(time.Since(before).Seconds()*1000, "ms")
|
||||||
}()
|
}()
|
||||||
err := NewServerDAO().UpdateServerTrafficLimitStatus(tx, &serverconfigs.TrafficLimitConfig{
|
err := models.NewServerDAO().UpdateServerTrafficLimitStatus(tx, &serverconfigs.TrafficLimitConfig{
|
||||||
IsOn: true,
|
IsOn: true,
|
||||||
DailySize: &shared.SizeCapacity{Count: 1, Unit: "mb"},
|
DailySize: &shared.SizeCapacity{Count: 1, Unit: "mb"},
|
||||||
MonthlySize: &shared.SizeCapacity{Count: 10, Unit: "mb"},
|
MonthlySize: &shared.SizeCapacity{Count: 10, Unit: "mb"},
|
||||||
@@ -225,7 +226,7 @@ func TestServerDAO_CalculateServerTrafficLimitConfig(t *testing.T) {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
var cacheMap = utils.NewCacheMap()
|
var cacheMap = utils.NewCacheMap()
|
||||||
config, err := SharedServerDAO.CalculateServerTrafficLimitConfig(tx, 23, cacheMap)
|
config, err := models.SharedServerDAO.CalculateServerTrafficLimitConfig(tx, 23, cacheMap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -243,7 +244,7 @@ func TestServerDAO_CalculateServerTrafficLimitConfig_Cache(t *testing.T) {
|
|||||||
|
|
||||||
var cacheMap = utils.NewCacheMap()
|
var cacheMap = utils.NewCacheMap()
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
config, err := SharedServerDAO.CalculateServerTrafficLimitConfig(tx, 23, cacheMap)
|
config, err := models.SharedServerDAO.CalculateServerTrafficLimitConfig(tx, 23, cacheMap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -251,11 +252,35 @@ func TestServerDAO_CalculateServerTrafficLimitConfig_Cache(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestServerDAO_FindBytes(t *testing.T) {
|
||||||
|
col, err := models.NewServerDAO().Query(nil).
|
||||||
|
Result("http").
|
||||||
|
Pk(1).
|
||||||
|
FindBytesCol()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Log(string(col))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestServerDAO_FindBool(t *testing.T) {
|
||||||
|
one, err := models.NewServerDAO().Query(nil).
|
||||||
|
Result("isOn").
|
||||||
|
Pk(1).
|
||||||
|
Find()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if one != nil {
|
||||||
|
t.Log(one.(*models.Server).IsOn)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func BenchmarkServerDAO_CountAllEnabledServers(b *testing.B) {
|
func BenchmarkServerDAO_CountAllEnabledServers(b *testing.B) {
|
||||||
SharedServerDAO = NewServerDAO()
|
models.SharedServerDAO = models.NewServerDAO()
|
||||||
|
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
result, err := SharedServerDAO.CountAllEnabledServers(nil)
|
result, err := models.SharedServerDAO.CountAllEnabledServers(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatal(err)
|
b.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -312,7 +312,7 @@ func (this *ServerGroupDAO) ComposeGroupConfig(tx *dbs.Tx, groupId int64, cacheM
|
|||||||
var config = &serverconfigs.ServerGroupConfig{
|
var config = &serverconfigs.ServerGroupConfig{
|
||||||
Id: int64(group.Id),
|
Id: int64(group.Id),
|
||||||
Name: group.Name,
|
Name: group.Name,
|
||||||
IsOn: group.IsOn == 1,
|
IsOn: group.IsOn,
|
||||||
}
|
}
|
||||||
|
|
||||||
if IsNotNull(group.HttpReverseProxy) {
|
if IsNotNull(group.HttpReverseProxy) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ type ServerGroup struct {
|
|||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
Order uint32 `field:"order"` // 排序
|
Order uint32 `field:"order"` // 排序
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import "github.com/iwind/TeaGo/dbs"
|
|||||||
// Server 服务
|
// Server 服务
|
||||||
type Server struct {
|
type Server struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
Type string `field:"type"` // 服务类型
|
Type string `field:"type"` // 服务类型
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ type ServerStatBoard struct {
|
|||||||
Id uint64 `field:"id"` // ID
|
Id uint64 `field:"id"` // ID
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
ClusterId uint32 `field:"clusterId"` // 集群ID
|
ClusterId uint32 `field:"clusterId"` // 集群ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Order uint32 `field:"order"` // 排序
|
Order uint32 `field:"order"` // 排序
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ func (this *SSLCertDAO) ComposeCertConfig(tx *dbs.Tx, certId int64, cacheMap *ut
|
|||||||
|
|
||||||
config := &sslconfigs.SSLCertConfig{}
|
config := &sslconfigs.SSLCertConfig{}
|
||||||
config.Id = int64(cert.Id)
|
config.Id = int64(cert.Id)
|
||||||
config.IsOn = cert.IsOn == 1
|
config.IsOn = cert.IsOn
|
||||||
config.IsCA = cert.IsCA == 1
|
config.IsCA = cert.IsCA == 1
|
||||||
config.IsACME = cert.IsACME == 1
|
config.IsACME = cert.IsACME == 1
|
||||||
config.Name = cert.Name
|
config.Name = cert.Name
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ type SSLCert struct {
|
|||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
UpdatedAt uint64 `field:"updatedAt"` // 修改时间
|
UpdatedAt uint64 `field:"updatedAt"` // 修改时间
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Name string `field:"name"` // 证书名
|
Name string `field:"name"` // 证书名
|
||||||
Description string `field:"description"` // 描述
|
Description string `field:"description"` // 描述
|
||||||
CertData []byte `field:"certData"` // 证书内容
|
CertData []byte `field:"certData"` // 证书内容
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ func (this *SSLPolicyDAO) ComposePolicyConfig(tx *dbs.Tx, policyId int64, cacheM
|
|||||||
}
|
}
|
||||||
config := &sslconfigs.SSLPolicy{}
|
config := &sslconfigs.SSLPolicy{}
|
||||||
config.Id = int64(policy.Id)
|
config.Id = int64(policy.Id)
|
||||||
config.IsOn = policy.IsOn == 1
|
config.IsOn = policy.IsOn
|
||||||
config.ClientAuthType = int(policy.ClientAuthType)
|
config.ClientAuthType = int(policy.ClientAuthType)
|
||||||
config.HTTP2Enabled = policy.Http2Enabled == 1
|
config.HTTP2Enabled = policy.Http2Enabled == 1
|
||||||
config.MinVersion = policy.MinVersion
|
config.MinVersion = policy.MinVersion
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ type SSLPolicy struct {
|
|||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Certs dbs.JSON `field:"certs"` // 证书列表
|
Certs dbs.JSON `field:"certs"` // 证书列表
|
||||||
ClientCACerts dbs.JSON `field:"clientCACerts"` // 客户端证书
|
ClientCACerts dbs.JSON `field:"clientCACerts"` // 客户端证书
|
||||||
ClientAuthType uint32 `field:"clientAuthType"` // 客户端认证类型
|
ClientAuthType uint32 `field:"clientAuthType"` // 客户端认证类型
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
// 子用户
|
// SubUser 子用户
|
||||||
type SubUser struct {
|
type SubUser struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
UserId uint32 `field:"userId"` // 所属主用户ID
|
UserId uint32 `field:"userId"` // 所属主用户ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
Username string `field:"username"` // 用户名
|
Username string `field:"username"` // 用户名
|
||||||
Password string `field:"password"` // 密码
|
Password string `field:"password"` // 密码
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ type UserAccessKey struct {
|
|||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
SubUserId uint32 `field:"subUserId"` // 子用户ID
|
SubUserId uint32 `field:"subUserId"` // 子用户ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
UniqueId string `field:"uniqueId"` // 唯一的Key
|
UniqueId string `field:"uniqueId"` // 唯一的Key
|
||||||
Secret string `field:"secret"` // 密钥
|
Secret string `field:"secret"` // 密钥
|
||||||
Description string `field:"description"` // 备注
|
Description string `field:"description"` // 备注
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import "github.com/iwind/TeaGo/dbs"
|
|||||||
// User 用户
|
// User 用户
|
||||||
type User struct {
|
type User struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Username string `field:"username"` // 用户名
|
Username string `field:"username"` // 用户名
|
||||||
Password string `field:"password"` // 密码
|
Password string `field:"password"` // 密码
|
||||||
Fullname string `field:"fullname"` // 真实姓名
|
Fullname string `field:"fullname"` // 真实姓名
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ package models
|
|||||||
|
|
||||||
import "github.com/iwind/TeaGo/dbs"
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// 用户节点
|
// UserNode 用户节点
|
||||||
type UserNode struct {
|
type UserNode struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
UniqueId string `field:"uniqueId"` // 唯一ID
|
UniqueId string `field:"uniqueId"` // 唯一ID
|
||||||
Secret string `field:"secret"` // 密钥
|
Secret string `field:"secret"` // 密钥
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ type UserPlan struct {
|
|||||||
Id uint64 `field:"id"` // ID
|
Id uint64 `field:"id"` // ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
PlanId uint32 `field:"planId"` // 套餐ID
|
PlanId uint32 `field:"planId"` // 套餐ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
DayTo string `field:"dayTo"` // 结束日期
|
DayTo string `field:"dayTo"` // 结束日期
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ func (this *NSAccessLogService) ListNSAccessLogs(ctx context.Context, req *pb.Li
|
|||||||
if route != nil {
|
if route != nil {
|
||||||
a.NsRoutes = append(a.NsRoutes, &pb.NSRoute{
|
a.NsRoutes = append(a.NsRoutes, &pb.NSRoute{
|
||||||
Id: types.Int64(route.Id),
|
Id: types.Int64(route.Id),
|
||||||
IsOn: route.IsOn == 1,
|
IsOn: route.IsOn,
|
||||||
Name: route.Name,
|
Name: route.Name,
|
||||||
Code: routeCode,
|
Code: routeCode,
|
||||||
NsCluster: nil,
|
NsCluster: nil,
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ func (this *NSClusterService) FindEnabledNSCluster(ctx context.Context, req *pb.
|
|||||||
}
|
}
|
||||||
return &pb.FindEnabledNSClusterResponse{NsCluster: &pb.NSCluster{
|
return &pb.FindEnabledNSClusterResponse{NsCluster: &pb.NSCluster{
|
||||||
Id: int64(cluster.Id),
|
Id: int64(cluster.Id),
|
||||||
IsOn: cluster.IsOn == 1,
|
IsOn: cluster.IsOn,
|
||||||
Name: cluster.Name,
|
Name: cluster.Name,
|
||||||
InstallDir: cluster.InstallDir,
|
InstallDir: cluster.InstallDir,
|
||||||
}}, nil
|
}}, nil
|
||||||
@@ -147,7 +147,7 @@ func (this *NSClusterService) ListEnabledNSClusters(ctx context.Context, req *pb
|
|||||||
for _, cluster := range clusters {
|
for _, cluster := range clusters {
|
||||||
pbClusters = append(pbClusters, &pb.NSCluster{
|
pbClusters = append(pbClusters, &pb.NSCluster{
|
||||||
Id: int64(cluster.Id),
|
Id: int64(cluster.Id),
|
||||||
IsOn: cluster.IsOn == 1,
|
IsOn: cluster.IsOn,
|
||||||
Name: cluster.Name,
|
Name: cluster.Name,
|
||||||
InstallDir: cluster.InstallDir,
|
InstallDir: cluster.InstallDir,
|
||||||
})
|
})
|
||||||
@@ -170,7 +170,7 @@ func (this *NSClusterService) FindAllEnabledNSClusters(ctx context.Context, req
|
|||||||
for _, cluster := range clusters {
|
for _, cluster := range clusters {
|
||||||
pbClusters = append(pbClusters, &pb.NSCluster{
|
pbClusters = append(pbClusters, &pb.NSCluster{
|
||||||
Id: int64(cluster.Id),
|
Id: int64(cluster.Id),
|
||||||
IsOn: cluster.IsOn == 1,
|
IsOn: cluster.IsOn,
|
||||||
Name: cluster.Name,
|
Name: cluster.Name,
|
||||||
InstallDir: cluster.InstallDir,
|
InstallDir: cluster.InstallDir,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -108,12 +108,12 @@ func (this *NSDomainService) FindEnabledNSDomain(ctx context.Context, req *pb.Fi
|
|||||||
NsDomain: &pb.NSDomain{
|
NsDomain: &pb.NSDomain{
|
||||||
Id: int64(domain.Id),
|
Id: int64(domain.Id),
|
||||||
Name: domain.Name,
|
Name: domain.Name,
|
||||||
IsOn: domain.IsOn == 1,
|
IsOn: domain.IsOn,
|
||||||
TsigJSON: domain.Tsig,
|
TsigJSON: domain.Tsig,
|
||||||
CreatedAt: int64(domain.CreatedAt),
|
CreatedAt: int64(domain.CreatedAt),
|
||||||
NsCluster: &pb.NSCluster{
|
NsCluster: &pb.NSCluster{
|
||||||
Id: int64(cluster.Id),
|
Id: int64(cluster.Id),
|
||||||
IsOn: cluster.IsOn == 1,
|
IsOn: cluster.IsOn,
|
||||||
Name: cluster.Name,
|
Name: cluster.Name,
|
||||||
},
|
},
|
||||||
User: pbUser,
|
User: pbUser,
|
||||||
@@ -180,12 +180,12 @@ func (this *NSDomainService) ListEnabledNSDomains(ctx context.Context, req *pb.L
|
|||||||
pbDomains = append(pbDomains, &pb.NSDomain{
|
pbDomains = append(pbDomains, &pb.NSDomain{
|
||||||
Id: int64(domain.Id),
|
Id: int64(domain.Id),
|
||||||
Name: domain.Name,
|
Name: domain.Name,
|
||||||
IsOn: domain.IsOn == 1,
|
IsOn: domain.IsOn,
|
||||||
CreatedAt: int64(domain.CreatedAt),
|
CreatedAt: int64(domain.CreatedAt),
|
||||||
TsigJSON: domain.Tsig,
|
TsigJSON: domain.Tsig,
|
||||||
NsCluster: &pb.NSCluster{
|
NsCluster: &pb.NSCluster{
|
||||||
Id: int64(cluster.Id),
|
Id: int64(cluster.Id),
|
||||||
IsOn: cluster.IsOn == 1,
|
IsOn: cluster.IsOn,
|
||||||
Name: cluster.Name,
|
Name: cluster.Name,
|
||||||
},
|
},
|
||||||
User: pbUser,
|
User: pbUser,
|
||||||
@@ -217,7 +217,7 @@ func (this *NSDomainService) ListNSDomainsAfterVersion(ctx context.Context, req
|
|||||||
pbDomains = append(pbDomains, &pb.NSDomain{
|
pbDomains = append(pbDomains, &pb.NSDomain{
|
||||||
Id: int64(domain.Id),
|
Id: int64(domain.Id),
|
||||||
Name: domain.Name,
|
Name: domain.Name,
|
||||||
IsOn: domain.IsOn == 1,
|
IsOn: domain.IsOn,
|
||||||
IsDeleted: domain.State == nameservers.NSDomainStateDisabled,
|
IsDeleted: domain.State == nameservers.NSDomainStateDisabled,
|
||||||
Version: int64(domain.Version),
|
Version: int64(domain.Version),
|
||||||
TsigJSON: domain.Tsig,
|
TsigJSON: domain.Tsig,
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ func (this *NSKeyService) FindEnabledNSKey(ctx context.Context, req *pb.FindEnab
|
|||||||
return &pb.FindEnabledNSKeyResponse{
|
return &pb.FindEnabledNSKeyResponse{
|
||||||
NsKey: &pb.NSKey{
|
NsKey: &pb.NSKey{
|
||||||
Id: int64(key.Id),
|
Id: int64(key.Id),
|
||||||
IsOn: key.IsOn == 1,
|
IsOn: key.IsOn,
|
||||||
Name: key.Name,
|
Name: key.Name,
|
||||||
Algo: key.Algo,
|
Algo: key.Algo,
|
||||||
Secret: key.Secret,
|
Secret: key.Secret,
|
||||||
@@ -116,7 +116,7 @@ func (this *NSKeyService) ListEnabledNSKeys(ctx context.Context, req *pb.ListEna
|
|||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
pbKeys = append(pbKeys, &pb.NSKey{
|
pbKeys = append(pbKeys, &pb.NSKey{
|
||||||
Id: int64(key.Id),
|
Id: int64(key.Id),
|
||||||
IsOn: key.IsOn == 1,
|
IsOn: key.IsOn,
|
||||||
Name: key.Name,
|
Name: key.Name,
|
||||||
Algo: key.Algo,
|
Algo: key.Algo,
|
||||||
Secret: key.Secret,
|
Secret: key.Secret,
|
||||||
@@ -155,7 +155,7 @@ func (this *NSKeyService) ListNSKeysAfterVersion(ctx context.Context, req *pb.Li
|
|||||||
|
|
||||||
pbKeys = append(pbKeys, &pb.NSKey{
|
pbKeys = append(pbKeys, &pb.NSKey{
|
||||||
Id: int64(key.Id),
|
Id: int64(key.Id),
|
||||||
IsOn: key.IsOn == 1,
|
IsOn: key.IsOn,
|
||||||
Name: "",
|
Name: "",
|
||||||
Algo: key.Algo,
|
Algo: key.Algo,
|
||||||
Secret: key.Secret,
|
Secret: key.Secret,
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ func (this *NSNodeService) FindAllEnabledNSNodesWithNSClusterId(ctx context.Cont
|
|||||||
pbNodes = append(pbNodes, &pb.NSNode{
|
pbNodes = append(pbNodes, &pb.NSNode{
|
||||||
Id: int64(node.Id),
|
Id: int64(node.Id),
|
||||||
Name: node.Name,
|
Name: node.Name,
|
||||||
IsOn: node.IsOn == 1,
|
IsOn: node.IsOn,
|
||||||
UniqueId: node.UniqueId,
|
UniqueId: node.UniqueId,
|
||||||
Secret: node.Secret,
|
Secret: node.Secret,
|
||||||
IsInstalled: node.IsInstalled == 1,
|
IsInstalled: node.IsInstalled == 1,
|
||||||
@@ -120,7 +120,7 @@ func (this *NSNodeService) ListEnabledNSNodesMatch(ctx context.Context, req *pb.
|
|||||||
pbNodes = append(pbNodes, &pb.NSNode{
|
pbNodes = append(pbNodes, &pb.NSNode{
|
||||||
Id: int64(node.Id),
|
Id: int64(node.Id),
|
||||||
Name: node.Name,
|
Name: node.Name,
|
||||||
IsOn: node.IsOn == 1,
|
IsOn: node.IsOn,
|
||||||
UniqueId: node.UniqueId,
|
UniqueId: node.UniqueId,
|
||||||
Secret: node.Secret,
|
Secret: node.Secret,
|
||||||
IsActive: node.IsActive == 1,
|
IsActive: node.IsActive == 1,
|
||||||
@@ -276,7 +276,7 @@ func (this *NSNodeService) FindEnabledNSNode(ctx context.Context, req *pb.FindEn
|
|||||||
Name: clusterName,
|
Name: clusterName,
|
||||||
},
|
},
|
||||||
InstallStatus: installStatusResult,
|
InstallStatus: installStatusResult,
|
||||||
IsOn: node.IsOn == 1,
|
IsOn: node.IsOn,
|
||||||
IsActive: node.IsActive == 1,
|
IsActive: node.IsActive == 1,
|
||||||
NodeLogin: respLogin,
|
NodeLogin: respLogin,
|
||||||
}}, nil
|
}}, nil
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user