实现在域名解析中使用EdgeDNS

This commit is contained in:
刘祥超
2021-06-02 18:13:48 +08:00
parent fe6c610d56
commit ef5630ba4a
28 changed files with 731 additions and 174 deletions

View File

@@ -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
}