mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 16:00:24 +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"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
@@ -13,6 +13,7 @@ type NSDomain struct {
 | 
				
			|||||||
	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过期时间
 | 
				
			||||||
 | 
						RecordsHealthCheck dbs.JSON `field:"recordsHealthCheck"` // 记录健康检查设置
 | 
				
			||||||
	CreatedAt          uint64   `field:"createdAt"`          // 创建时间
 | 
						CreatedAt          uint64   `field:"createdAt"`          // 创建时间
 | 
				
			||||||
	Version            uint64   `field:"version"`            // 版本号
 | 
						Version            uint64   `field:"version"`            // 版本号
 | 
				
			||||||
	Status             string   `field:"status"`             // 状态:none|verified
 | 
						Status             string   `field:"status"`             // 状态:none|verified
 | 
				
			||||||
@@ -29,6 +30,7 @@ type NSDomainOperator struct {
 | 
				
			|||||||
	Tsig               any // TSIG配置
 | 
						Tsig               any // TSIG配置
 | 
				
			||||||
	VerifyTXT          any // 验证用的TXT
 | 
						VerifyTXT          any // 验证用的TXT
 | 
				
			||||||
	VerifyExpiresAt    any // 验证TXT过期时间
 | 
						VerifyExpiresAt    any // 验证TXT过期时间
 | 
				
			||||||
 | 
						RecordsHealthCheck any // 记录健康检查设置
 | 
				
			||||||
	CreatedAt          any // 创建时间
 | 
						CreatedAt          any // 创建时间
 | 
				
			||||||
	Version            any // 版本号
 | 
						Version            any // 版本号
 | 
				
			||||||
	Status             any // 状态:none|verified
 | 
						Status             any // 状态:none|verified
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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