mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2026-04-04 03:55:19 +08:00
实现在域名解析中使用EdgeDNS
This commit is contained in:
@@ -2,6 +2,7 @@ package authority
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
teaconst "github.com/TeaOSLab/EdgeAPI/internal/const"
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
"github.com/iwind/TeaGo/Tea"
|
||||
"github.com/iwind/TeaGo/dbs"
|
||||
@@ -27,6 +28,9 @@ var SharedAuthorityKeyDAO *AuthorityKeyDAO
|
||||
func init() {
|
||||
dbs.OnReady(func() {
|
||||
SharedAuthorityKeyDAO = NewAuthorityKeyDAO()
|
||||
|
||||
// 初始化IsPlus值
|
||||
_, _ = SharedAuthorityKeyDAO.IsPlus(nil)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -73,7 +77,14 @@ func (this *AuthorityKeyDAO) ReadKey(tx *dbs.Tx) (key *AuthorityKey, err error)
|
||||
if one == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return one.(*AuthorityKey), nil
|
||||
key = one.(*AuthorityKey)
|
||||
|
||||
// 顺便更新相关变量
|
||||
if key.DayTo >= timeutil.Format("Y-m-d") {
|
||||
teaconst.IsPlus = true
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ResetKey 重置Key
|
||||
@@ -92,5 +103,6 @@ func (this *AuthorityKeyDAO) IsPlus(tx *dbs.Tx) (bool, error) {
|
||||
if key == nil {
|
||||
return false, nil
|
||||
}
|
||||
return key.DayTo >= timeutil.Format("Y-m-d"), nil
|
||||
teaconst.IsPlus = key.DayTo >= timeutil.Format("Y-m-d")
|
||||
return teaconst.IsPlus, nil
|
||||
}
|
||||
|
||||
@@ -7,17 +7,17 @@ import (
|
||||
)
|
||||
|
||||
func TestAuthorityKeyDAO_UpdateValue(t *testing.T) {
|
||||
err := NewAuthorityKeyDAO().UpdateValue(nil, "12345678")
|
||||
err := NewAuthorityKeyDAO().UpdateKey(nil, "12345678", "", "", "", []string{}, "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Logf("ok")
|
||||
t.Log("ok")
|
||||
}
|
||||
|
||||
func TestAuthorityKeyDAO_ReadValue(t *testing.T) {
|
||||
value, err := NewAuthorityKeyDAO().ReadValue(nil)
|
||||
value, err := NewAuthorityKeyDAO().ReadKey(nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Logf(value)
|
||||
t.Log(value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user