mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-03 23:20:26 +08:00
智能 DNS实现健康检查
This commit is contained in:
33
internal/db/models/nameservers/ns_domain_dao.go
Normal file
33
internal/db/models/nameservers/ns_domain_dao.go
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
package nameservers
|
||||||
|
|
||||||
|
import (
|
||||||
|
_ "github.com/go-sql-driver/mysql"
|
||||||
|
"github.com/iwind/TeaGo/Tea"
|
||||||
|
"github.com/iwind/TeaGo/dbs"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
NSDomainStateEnabled = 1 // 已启用
|
||||||
|
NSDomainStateDisabled = 0 // 已禁用
|
||||||
|
)
|
||||||
|
|
||||||
|
type NSDomainDAO dbs.DAO
|
||||||
|
|
||||||
|
func NewNSDomainDAO() *NSDomainDAO {
|
||||||
|
return dbs.NewDAO(&NSDomainDAO{
|
||||||
|
DAOObject: dbs.DAOObject{
|
||||||
|
DB: Tea.Env,
|
||||||
|
Table: "edgeNSDomains",
|
||||||
|
Model: new(NSDomain),
|
||||||
|
PkName: "id",
|
||||||
|
},
|
||||||
|
}).(*NSDomainDAO)
|
||||||
|
}
|
||||||
|
|
||||||
|
var SharedNSDomainDAO *NSDomainDAO
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
dbs.OnReady(func() {
|
||||||
|
SharedNSDomainDAO = NewNSDomainDAO()
|
||||||
|
})
|
||||||
|
}
|
||||||
6
internal/db/models/nameservers/ns_domain_dao_test.go
Normal file
6
internal/db/models/nameservers/ns_domain_dao_test.go
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
package nameservers_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
_ "github.com/go-sql-driver/mysql"
|
||||||
|
_ "github.com/iwind/TeaGo/bootstrap"
|
||||||
|
)
|
||||||
@@ -4,35 +4,37 @@ import "github.com/iwind/TeaGo/dbs"
|
|||||||
|
|
||||||
// NSDomain DNS域名
|
// NSDomain DNS域名
|
||||||
type NSDomain struct {
|
type NSDomain struct {
|
||||||
Id uint64 `field:"id"` // ID
|
Id uint64 `field:"id"` // ID
|
||||||
ClusterId uint32 `field:"clusterId"` // 集群ID
|
ClusterId uint32 `field:"clusterId"` // 集群ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
IsOn bool `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Name string `field:"name"` // 域名
|
Name string `field:"name"` // 域名
|
||||||
GroupIds dbs.JSON `field:"groupIds"` // 分组ID
|
GroupIds dbs.JSON `field:"groupIds"` // 分组ID
|
||||||
Tsig dbs.JSON `field:"tsig"` // TSIG配置
|
Tsig dbs.JSON `field:"tsig"` // TSIG配置
|
||||||
VerifyTXT string `field:"verifyTXT"` // 验证用的TXT
|
VerifyTXT string `field:"verifyTXT"` // 验证用的TXT
|
||||||
VerifyExpiresAt uint64 `field:"verifyExpiresAt"` // 验证TXT过期时间
|
VerifyExpiresAt uint64 `field:"verifyExpiresAt"` // 验证TXT过期时间
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
RecordsHealthCheck dbs.JSON `field:"recordsHealthCheck"` // 记录健康检查设置
|
||||||
Version uint64 `field:"version"` // 版本号
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
Status string `field:"status"` // 状态:none|verified
|
Version uint64 `field:"version"` // 版本号
|
||||||
State uint8 `field:"state"` // 状态
|
Status string `field:"status"` // 状态:none|verified
|
||||||
|
State uint8 `field:"state"` // 状态
|
||||||
}
|
}
|
||||||
|
|
||||||
type NSDomainOperator struct {
|
type NSDomainOperator struct {
|
||||||
Id any // ID
|
Id any // ID
|
||||||
ClusterId any // 集群ID
|
ClusterId any // 集群ID
|
||||||
UserId any // 用户ID
|
UserId any // 用户ID
|
||||||
IsOn any // 是否启用
|
IsOn any // 是否启用
|
||||||
Name any // 域名
|
Name any // 域名
|
||||||
GroupIds any // 分组ID
|
GroupIds any // 分组ID
|
||||||
Tsig any // TSIG配置
|
Tsig any // TSIG配置
|
||||||
VerifyTXT any // 验证用的TXT
|
VerifyTXT any // 验证用的TXT
|
||||||
VerifyExpiresAt any // 验证TXT过期时间
|
VerifyExpiresAt any // 验证TXT过期时间
|
||||||
CreatedAt any // 创建时间
|
RecordsHealthCheck any // 记录健康检查设置
|
||||||
Version any // 版本号
|
CreatedAt any // 创建时间
|
||||||
Status any // 状态:none|verified
|
Version any // 版本号
|
||||||
State any // 状态
|
Status any // 状态:none|verified
|
||||||
|
State any // 状态
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewNSDomainOperator() *NSDomainOperator {
|
func NewNSDomainOperator() *NSDomainOperator {
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ type NSRecord struct {
|
|||||||
Ttl uint32 `field:"ttl"` // TTL(秒)
|
Ttl uint32 `field:"ttl"` // TTL(秒)
|
||||||
Weight uint32 `field:"weight"` // 权重
|
Weight uint32 `field:"weight"` // 权重
|
||||||
RouteIds dbs.JSON `field:"routeIds"` // 线路
|
RouteIds dbs.JSON `field:"routeIds"` // 线路
|
||||||
|
HealthCheck dbs.JSON `field:"healthCheck"` // 健康检查配置
|
||||||
|
CountUp uint32 `field:"countUp"` // 连续上线次数
|
||||||
|
CountDown uint32 `field:"countDown"` // 连续离线次数
|
||||||
|
IsUp bool `field:"isUp"` // 是否在线
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
Version uint64 `field:"version"` // 版本号
|
Version uint64 `field:"version"` // 版本号
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
@@ -42,6 +46,10 @@ type NSRecordOperator struct {
|
|||||||
Ttl any // TTL(秒)
|
Ttl any // TTL(秒)
|
||||||
Weight any // 权重
|
Weight any // 权重
|
||||||
RouteIds any // 线路
|
RouteIds any // 线路
|
||||||
|
HealthCheck any // 健康检查配置
|
||||||
|
CountUp any // 连续上线次数
|
||||||
|
CountDown any // 连续离线次数
|
||||||
|
IsUp any // 是否在线
|
||||||
CreatedAt any // 创建时间
|
CreatedAt any // 创建时间
|
||||||
Version any // 版本号
|
Version any // 版本号
|
||||||
State any // 状态
|
State any // 状态
|
||||||
|
|||||||
Reference in New Issue
Block a user