This commit is contained in:
GoEdgeLab
2024-07-27 14:15:25 +08:00
parent be70925770
commit 5a17ae9d79
520 changed files with 2515 additions and 762 deletions

View File

@@ -5,14 +5,15 @@ import (
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
"io"
"log"
"testing"
"github.com/go-acme/lego/v4/certcrypto"
"github.com/go-acme/lego/v4/certificate"
"github.com/go-acme/lego/v4/challenge/dns01"
"github.com/go-acme/lego/v4/lego"
acmelog "github.com/go-acme/lego/v4/log"
"io"
"log"
"testing"
"github.com/go-acme/lego/v4/registration"
)

View File

@@ -2,15 +2,16 @@ package acme
import (
"fmt"
"os"
"strings"
"sync"
"time"
"github.com/TeaOSLab/EdgeAPI/internal/dnsclients"
"github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes"
"github.com/TeaOSLab/EdgeAPI/internal/errors"
"github.com/go-acme/lego/v4/challenge/dns01"
"github.com/iwind/TeaGo/lists"
"os"
"strings"
"sync"
"time"
)
type DNSProvider struct {

View File

@@ -1,4 +1,4 @@
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud .
//go:build !plus
package acme

View File

@@ -2,6 +2,9 @@ package acme
import (
"fmt"
"io"
"log"
teaconst "github.com/TeaOSLab/EdgeAPI/internal/const"
"github.com/TeaOSLab/EdgeAPI/internal/errors"
"github.com/go-acme/lego/v4/certcrypto"
@@ -10,8 +13,6 @@ import (
acmelog "github.com/go-acme/lego/v4/log"
"github.com/go-acme/lego/v4/registration"
"github.com/iwind/TeaGo/Tea"
"io"
"log"
)
type Request struct {

View File

@@ -2,13 +2,14 @@ package acme
import (
"encoding/json"
"testing"
"github.com/TeaOSLab/EdgeAPI/internal/dnsclients"
"github.com/go-acme/lego/v4/registration"
_ "github.com/go-sql-driver/mysql"
_ "github.com/iwind/TeaGo/bootstrap"
"github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/maps"
"testing"
)
func TestRequest_Run_DNS(t *testing.T) {

View File

@@ -3,6 +3,7 @@ package acme
import (
"crypto"
"encoding/json"
"github.com/go-acme/lego/v4/registration"
)

View File

@@ -3,11 +3,6 @@ package apps
import (
"errors"
"fmt"
teaconst "github.com/TeaOSLab/EdgeAPI/internal/const"
"github.com/iwind/TeaGo/logs"
"github.com/iwind/TeaGo/maps"
"github.com/iwind/TeaGo/types"
"github.com/iwind/gosock/pkg/gosock"
"os"
"os/exec"
"path/filepath"
@@ -15,6 +10,12 @@ import (
"strconv"
"strings"
"time"
teaconst "github.com/TeaOSLab/EdgeAPI/internal/const"
"github.com/iwind/TeaGo/logs"
"github.com/iwind/TeaGo/maps"
"github.com/iwind/TeaGo/types"
"github.com/iwind/gosock/pkg/gosock"
)
// AppCmd App命令帮助

View File

@@ -1,16 +1,17 @@
package apps
import (
"github.com/TeaOSLab/EdgeAPI/internal/goman"
"github.com/TeaOSLab/EdgeAPI/internal/utils/sizes"
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/files"
timeutil "github.com/iwind/TeaGo/utils/time"
"log"
"os"
"runtime"
"strconv"
"strings"
"github.com/TeaOSLab/EdgeAPI/internal/goman"
"github.com/TeaOSLab/EdgeAPI/internal/utils/sizes"
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/files"
timeutil "github.com/iwind/TeaGo/utils/time"
)
type LogWriter struct {

View File

@@ -1,11 +1,12 @@
package configs
import (
"os"
"path/filepath"
teaconst "github.com/TeaOSLab/EdgeAPI/internal/const"
"github.com/iwind/TeaGo/Tea"
"gopkg.in/yaml.v3"
"os"
"path/filepath"
)
var sharedAPIConfig *APIConfig = nil

View File

@@ -1,8 +1,9 @@
package configs
import (
_ "github.com/iwind/TeaGo/bootstrap"
"testing"
_ "github.com/iwind/TeaGo/bootstrap"
)
func TestSharedAPIConfig(t *testing.T) {

View File

@@ -1,13 +1,14 @@
// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud .
package configs
import (
"errors"
"os"
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/dbs"
"gopkg.in/yaml.v3"
"os"
)
func LoadDBConfig() (*dbs.Config, error) {

View File

@@ -1,14 +1,15 @@
// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud .
package configs
import (
"fmt"
"net/url"
"os"
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/dbs"
"gopkg.in/yaml.v3"
"net/url"
"os"
)
type SimpleDBConfig struct {
@@ -28,7 +29,7 @@ func ParseSimpleDBConfig(data []byte) (*SimpleDBConfig, error) {
func (this *SimpleDBConfig) GenerateOldConfig() error {
var dbConfig = &dbs.DBConfig{
Driver: "mysql",
Dsn: url.QueryEscape(this.User) + ":" + url.QueryEscape(this.Password) + "@tcp(" + this.Host + ")/" + url.PathEscape(this.Database) + "?charset=utf8mb4&timeout=30s&multiStatements=true",
Dsn: url.QueryEscape(this.User) + ":" + this.Password + "@tcp(" + this.Host + ")/" + url.PathEscape(this.Database) + "?charset=utf8mb4&timeout=30s&multiStatements=true",
Prefix: "edge",
}
dbConfig.Models.Package = "internal/db/models"

View File

@@ -1,7 +1,7 @@
package teaconst
const (
Version = "1.3.9"
Version = "1.4.1"
ProductName = "Edge API"
ProcessName = "edge-api"
@@ -17,5 +17,5 @@ const (
// 其他节点版本号,用来检测是否有需要升级的节点
NodeVersion = "1.3.9"
NodeVersion = "1.4.0"
)

View File

@@ -1,4 +1,4 @@
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud .
//go:build !plus
package teaconst

View File

@@ -5,11 +5,12 @@ package teaconst
import (
"crypto/sha1"
"fmt"
"github.com/iwind/TeaGo/rands"
"github.com/iwind/TeaGo/types"
"os"
"strings"
"time"
"github.com/iwind/TeaGo/rands"
"github.com/iwind/TeaGo/types"
)
var (

View File

@@ -3,13 +3,14 @@ package db
import (
"database/sql"
"database/sql/driver"
"testing"
"time"
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
_ "github.com/go-sql-driver/mysql"
"github.com/iwind/TeaGo/Tea"
_ "github.com/iwind/TeaGo/bootstrap"
"github.com/iwind/TeaGo/dbs"
"testing"
"time"
)
func TestDB_Env(t *testing.T) {

View File

@@ -4,6 +4,13 @@ import (
"bytes"
"context"
"encoding/json"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"net/http"
"strconv"
"strings"
"sync"
"time"
acmeutils "github.com/TeaOSLab/EdgeAPI/internal/acme"
teaconst "github.com/TeaOSLab/EdgeAPI/internal/const"
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
@@ -21,15 +28,21 @@ import (
"github.com/iwind/TeaGo/logs"
"github.com/iwind/TeaGo/maps"
"github.com/iwind/TeaGo/types"
"net/http"
"time"
)
const (
ACMETaskStateEnabled = 1 // 已启用
ACMETaskStateDisabled = 0 // 已禁用
ACMETaskStatusPending = 0
ACMETaskStatusDone = 1
ACMETaskStatusRunning = 2
ACMETaskStatusIssueFailed = 3
)
var runningTaskMap sync.Map
var serverBindMutex = &sync.Mutex{}
type ACMETaskDAO dbs.DAO
func NewACMETaskDAO() *ACMETaskDAO {
@@ -187,7 +200,7 @@ func (this *ACMETaskDAO) ListEnabledACMETasks(tx *dbs.Tx, userId int64, isAvaila
}
// CreateACMETask 创建任务
func (this *ACMETaskDAO) CreateACMETask(tx *dbs.Tx, adminId int64, userId int64, authType acmeutils.AuthType, acmeUserId int64, dnsProviderId int64, dnsDomain string, domains []string, autoRenew bool, authURL string) (int64, error) {
func (this *ACMETaskDAO) CreateACMETask(tx *dbs.Tx, adminId int64, userId int64, authType acmeutils.AuthType, acmeUserId int64, dnsProviderId int64, dnsDomain string, domains []string, autoRenew bool, authURL string, async bool) (int64, error) {
var op = NewACMETaskOperator()
op.AdminId = adminId
op.UserId = userId
@@ -210,6 +223,7 @@ func (this *ACMETaskDAO) CreateACMETask(tx *dbs.Tx, adminId int64, userId int64,
op.AuthURL = authURL
op.IsOn = true
op.State = ACMETaskStateEnabled
op.Async = async
err := this.Save(tx, op)
if err != nil {
return 0, err
@@ -281,7 +295,7 @@ func (this *ACMETaskDAO) UpdateACMETaskCert(tx *dbs.Tx, taskId int64, certId int
// RunTask 执行任务并记录日志
func (this *ACMETaskDAO) RunTask(tx *dbs.Tx, taskId int64) (isOk bool, errMsg string, resultCertId int64) {
isOk, errMsg, resultCertId = this.runTaskWithoutLog(tx, taskId)
isOk, errMsg, resultCertId = this.runTaskWithoutLog(tx, taskId, false)
// 记录日志
err := SharedACMETaskLogDAO.CreateACMETaskLog(tx, taskId, isOk, errMsg)
@@ -293,7 +307,7 @@ func (this *ACMETaskDAO) RunTask(tx *dbs.Tx, taskId int64) (isOk bool, errMsg st
}
// 执行任务但并不记录日志
func (this *ACMETaskDAO) runTaskWithoutLog(tx *dbs.Tx, taskId int64) (isOk bool, errMsg string, resultCertId int64) {
func (this *ACMETaskDAO) runTaskWithoutLog(tx *dbs.Tx, taskId int64, randomAcmeAccount bool) (isOk bool, errMsg string, resultCertId int64) {
task, err := this.FindEnabledACMETask(tx, taskId)
if err != nil {
errMsg = "查询任务信息时出错:" + err.Error()
@@ -308,6 +322,17 @@ func (this *ACMETaskDAO) runTaskWithoutLog(tx *dbs.Tx, taskId int64) (isOk bool,
return
}
if task.Status == ACMETaskStatusDone {
errMsg = "任务已完成"
return
}
// 设置执行中
err = this.UpdateStatus(tx, taskId, ACMETaskStatusRunning)
if err != nil {
logs.Error(err)
}
// ACME用户
user, err := SharedACMEUserDAO.FindEnabledACMEUser(tx, int64(task.AcmeUserId))
if err != nil {
@@ -323,6 +348,15 @@ func (this *ACMETaskDAO) runTaskWithoutLog(tx *dbs.Tx, taskId int64) (isOk bool,
if len(user.ProviderCode) == 0 {
user.ProviderCode = acmeutils.DefaultProviderCode
}
if randomAcmeAccount {
user, err = SharedACMEUserDAO.FindRandomACMEUserWithSameProvider(tx, user.ProviderCode)
if user == nil {
errMsg = "找不到ACME用户"
return
}
}
var acmeProvider = acmeutils.FindProviderWithCode(user.ProviderCode)
if acmeProvider == nil {
errMsg = "服务商已不可用"
@@ -515,3 +549,193 @@ func (this *ACMETaskDAO) runTaskWithoutLog(tx *dbs.Tx, taskId int64) (isOk bool,
isOk = true
return
}
// FindIssueACMETask 查找N小时内未执行的AcmeTask
func (this *ACMETaskDAO) FindIssueACMETask(tx *dbs.Tx, hour int, limit int64, excludeTasks []int64) (result []*ACMETask, err error) {
if len(excludeTasks) == 0 {
excludeTasks = append(excludeTasks, 0)
}
var strIDs []string
for _, id := range excludeTasks {
strIDs = append(strIDs, strconv.FormatInt(id, 10))
}
_, err = this.Query(tx).
Attr("isOn", true).
Attr("async", true).
State(ACMETaskStateEnabled).
Where("FROM_UNIXTIME(createdAt, '%Y-%m-%d %H:%i')>:hoursAgo AND certId=0 and id NOT IN ("+strings.Join(strIDs, ",")+")").
Param("hoursAgo", time.Now().UTC().Add(-time.Duration(hour)*time.Hour).Format("2006-01-02 15:04")).
Param("now", time.Now().Unix()).
Slice(&result).
AscPk().
Limit(limit).
FindAll()
return
}
// UpdateStatus 更新状态
func (this *ACMETaskDAO) UpdateStatus(tx *dbs.Tx, id int64, status int64) error {
_, err := this.Query(tx).
Pk(id).
Set("status", status).
Update()
return err
}
// RunTaskAndAutoBindServer 证书签发并绑定Server记录日志
func (this *ACMETaskDAO) RunTaskAndAutoBindServer(tx *dbs.Tx, taskId int64, domains []string) (isOk bool, errMsg string) {
_, ok := runningTaskMap.Load(taskId)
if ok {
return true, "" // 返回ok异步任务无需继续执行
}
isOk, errMsg, resultCertId := this.runTaskWithoutLog(tx, taskId, true)
// 记录日志
err := SharedACMETaskLogDAO.CreateACMETaskLog(tx, taskId, isOk, errMsg)
if err != nil {
logs.Error(err)
}
if !isOk {
// 设置签发失败
err = this.UpdateStatus(tx, taskId, ACMETaskStatusIssueFailed)
if err != nil {
logs.Error(err)
}
return
}
// 签发成功
err = this.UpdateStatus(tx, taskId, ACMETaskStatusDone)
if err != nil {
logs.Error(err)
}
newCert, err := models.SharedSSLCertDAO.FindEnabledSSLCert(tx, resultCertId)
if err != nil {
logs.Error(err)
return
}
type ServerInfo struct {
SSLPolicyId int64
CertIds []int64
UserId int64
TlsConfig *serverconfigs.HTTPSProtocolConfig
}
serverMap := map[int64]ServerInfo{}
domainChecked := map[string]bool{}
// 以下绑定cert到Server的逻辑加互斥锁避免大量证书绑定到同一个Server时sslCertIds数据覆盖以下绑定流程耗时不长
serverBindMutex.Lock()
defer serverBindMutex.Unlock()
// 获取域名需要绑定的SSLPolicy
for _, domain := range domains {
if _, ok := domainChecked[domain]; ok {
continue
}
servers, err := models.SharedServerDAO.FindUserServerByServerName(tx, domain)
if err != nil {
continue
}
for _, server := range servers {
var serverNames []string
err = json.Unmarshal(server.PlainServerNames, &serverNames)
if err != nil {
continue
}
for _, sn := range serverNames {
domainChecked[sn] = true
}
tlsConfig := server.DecodeHTTPS()
if tlsConfig == nil {
continue // 跳过其他有HTTPS的正常执行
}
if tlsConfig.SSLPolicyRef != nil {
sslPolicyConfig, err := models.SharedSSLPolicyDAO.ComposePolicyConfig(tx, tlsConfig.SSLPolicyRef.SSLPolicyId, false, nil, nil)
if err != nil {
continue
}
if sslPolicyConfig != nil {
var certIds []int64
for _, cert := range sslPolicyConfig.Certs {
// 新签发的证书如果包含所有旧证书的域名则不再绑定旧证书,并禁用旧证书避免触发续签
if utils.ListIsGreaterEqualThanOther(domains, cert.DNSNames) && cert.TimeEndAt < int64(newCert.TimeEndAt) {
err = models.SharedSSLCertDAO.DisableSSLCert(tx, cert.Id)
if err != nil {
logs.Error(err)
}
continue
}
certIds = append(certIds, cert.Id)
}
certIds = append(certIds, resultCertId)
serverMap[int64(server.Id)] = ServerInfo{
UserId: int64(server.UserId),
SSLPolicyId: sslPolicyConfig.Id,
CertIds: certIds,
TlsConfig: tlsConfig}
continue
}
}
serverMap[int64(server.Id)] = ServerInfo{CertIds: []int64{resultCertId}, TlsConfig: tlsConfig, UserId: int64(server.UserId)}
}
}
for serverId, serverInfo := range serverMap {
var certRefs []*sslconfigs.SSLCertRef
certExists := make(map[int64]bool)
for _, certId := range serverInfo.CertIds {
if !certExists[certId] {
certRefs = append(certRefs, &sslconfigs.SSLCertRef{
IsOn: true,
CertId: certId,
})
certExists[certId] = true
}
}
certRefsJSON, err := json.Marshal(certRefs)
if err != nil {
logs.Errorf("解析证书错误:%s", err.Error())
continue
}
if serverInfo.SSLPolicyId == 0 {
policyId, err := models.SharedSSLPolicyDAO.CreatePolicy(tx,
0, serverInfo.UserId, false, false,
"TLS 1.1", certRefsJSON,
nil, false, 0,
nil, false, nil)
if err != nil {
logs.Errorf("创建SSL策略错误%s", err.Error())
continue
}
httpsConfig := serverInfo.TlsConfig
httpsConfig.SSLPolicyRef = &sslconfigs.SSLPolicyRef{
IsOn: true,
SSLPolicyId: policyId,
}
httpsJSON, err := json.Marshal(httpsConfig)
if err != nil {
logs.Errorf("获取https信息错误%s", err.Error())
continue
}
err = models.SharedServerDAO.UpdateServerHTTPS(tx, serverId, httpsJSON)
} else {
policy, err := models.SharedSSLPolicyDAO.FindEnabledSSLPolicy(tx, serverInfo.SSLPolicyId)
if err != nil {
logs.Errorf("获取SSL策略错误%s", err.Error())
continue
}
err = models.SharedSSLPolicyDAO.UpdatePolicy(tx, serverInfo.SSLPolicyId, policy.Http2Enabled, policy.Http3Enabled,
policy.MinVersion, certRefsJSON, policy.Hsts, policy.OcspIsOn == 1, int32(policy.ClientAuthType), policy.ClientCACerts, policy.CipherSuitesIsOn == 1, nil)
if err != nil {
logs.Errorf("更新SSL策略错误%s", err.Error())
continue
}
}
}
return
}

View File

@@ -18,6 +18,8 @@ type ACMETask struct {
AutoRenew uint8 `field:"autoRenew"` // 是否自动更新
AuthType string `field:"authType"` // 认证类型
AuthURL string `field:"authURL"` // 认证URL
Async bool `field:"async"` // 是否异步
Status uint32 `field:"status"` // 任务状态
}
type ACMETaskOperator struct {
@@ -35,6 +37,8 @@ type ACMETaskOperator struct {
AutoRenew interface{} // 是否自动更新
AuthType interface{} // 认证类型
AuthURL interface{} // 认证URL
Async interface{} //是否异步
Status interface{} // 任务状态
}
func NewACMETaskOperator() *ACMETaskOperator {

View File

@@ -2,6 +2,7 @@ package acme
import (
"encoding/json"
"github.com/iwind/TeaGo/logs"
)

View File

@@ -11,6 +11,7 @@ import (
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/types"
mrand "math/rand"
)
const (
@@ -209,3 +210,17 @@ func (this *ACMEUserDAO) CheckACMEUser(tx *dbs.Tx, acmeUserId int64, adminId int
State(ACMEUserStateEnabled).
Exist()
}
func (this *ACMEUserDAO) FindRandomACMEUserWithSameProvider(tx *dbs.Tx, providerCode string) (*ACMEUser, error) {
results, err := this.Query(tx).
Attr("providerCode", providerCode).
Attr("userId", 0).
FindAll()
if results == nil {
return nil, err
}
if len(results) == 0 {
return nil, errors.New("no acme user found")
}
idx := mrand.Intn(len(results))
return results[idx].(*ACMEUser), err
}

View File

@@ -1,12 +1,13 @@
package models
import (
"time"
"github.com/TeaOSLab/EdgeAPI/internal/errors"
_ "github.com/go-sql-driver/mysql"
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/rands"
"time"
)
type APIAccessTokenDAO dbs.DAO

View File

@@ -3,6 +3,10 @@ package models
import (
"encoding/json"
"errors"
"net"
"strconv"
"strings"
"github.com/TeaOSLab/EdgeAPI/internal/configs"
"github.com/TeaOSLab/EdgeAPI/internal/remotelogs"
"github.com/TeaOSLab/EdgeAPI/internal/utils"
@@ -14,9 +18,6 @@ import (
"github.com/iwind/TeaGo/maps"
"github.com/iwind/TeaGo/rands"
"github.com/iwind/TeaGo/types"
"net"
"strconv"
"strings"
)
const (

View File

@@ -1,11 +1,12 @@
package models
import (
"runtime"
"testing"
"github.com/TeaOSLab/EdgeAPI/internal/utils"
_ "github.com/go-sql-driver/mysql"
"github.com/iwind/TeaGo/dbs"
"runtime"
"testing"
)
func TestAPINodeDAO_FindEnabledAPINodeIdWithAddr(t *testing.T) {

View File

@@ -3,6 +3,7 @@ package models
import (
"context"
"encoding/json"
"github.com/TeaOSLab/EdgeAPI/internal/utils"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/iwind/TeaGo/dbs"

View File

@@ -2,6 +2,7 @@ package authority
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
"github.com/TeaOSLab/EdgeAPI/internal/errors"
"github.com/TeaOSLab/EdgeAPI/internal/utils"

View File

@@ -1,10 +1,11 @@
package clients_test
import (
"testing"
"github.com/TeaOSLab/EdgeAPI/internal/db/models/clients"
_ "github.com/go-sql-driver/mysql"
_ "github.com/iwind/TeaGo/bootstrap"
"testing"
)
func TestClientAgentIPDAO_CreateIP(t *testing.T) {

View File

@@ -1,6 +1,8 @@
package clients
import (
"time"
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
"github.com/TeaOSLab/EdgeAPI/internal/goman"
"github.com/TeaOSLab/EdgeAPI/internal/remotelogs"
@@ -10,7 +12,6 @@ import (
"github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/rands"
timeutil "github.com/iwind/TeaGo/utils/time"
"time"
)
const (

View File

@@ -1,9 +1,10 @@
package clients_test
import (
"testing"
"github.com/TeaOSLab/EdgeAPI/internal/db/models/clients"
_ "github.com/go-sql-driver/mysql"
"testing"
)
func TestClientBrowserDAO_CreateBrowser(t *testing.T) {

View File

@@ -1,6 +1,8 @@
package clients
import (
"time"
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
"github.com/TeaOSLab/EdgeAPI/internal/goman"
"github.com/TeaOSLab/EdgeAPI/internal/remotelogs"
@@ -10,7 +12,6 @@ import (
"github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/rands"
timeutil "github.com/iwind/TeaGo/utils/time"
"time"
)
const (

View File

@@ -1,9 +1,10 @@
package clients_test
import (
"testing"
"github.com/TeaOSLab/EdgeAPI/internal/db/models/clients"
_ "github.com/go-sql-driver/mysql"
"testing"
)
func TestClientSystemDAO_CreateSystemIfNotExists(t *testing.T) {

View File

@@ -2,6 +2,8 @@ package models
import (
"encoding/base64"
"strings"
"github.com/TeaOSLab/EdgeAPI/internal/encrypt"
"github.com/TeaOSLab/EdgeAPI/internal/errors"
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
@@ -9,7 +11,6 @@ import (
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/types"
"strings"
)
const (

View File

@@ -1,8 +1,9 @@
package models
import (
_ "github.com/go-sql-driver/mysql"
"testing"
_ "github.com/go-sql-driver/mysql"
)
func TestDBNodeDAO_EncodePassword(t *testing.T) {

View File

@@ -2,6 +2,10 @@ package models
import (
"fmt"
"strconv"
"sync"
"time"
dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils"
"github.com/TeaOSLab/EdgeAPI/internal/goman"
"github.com/TeaOSLab/EdgeAPI/internal/remotelogs"
@@ -10,9 +14,6 @@ import (
"github.com/iwind/TeaGo/lists"
"github.com/iwind/TeaGo/rands"
timeutil "github.com/iwind/TeaGo/utils/time"
"strconv"
"sync"
"time"
)
var accessLogDBMapping = map[int64]*dbs.DB{} // dbNodeId => DB

View File

@@ -1,4 +1,4 @@
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud .
//go:build !plus
package models

View File

@@ -2,6 +2,7 @@ package models
import (
"fmt"
"github.com/iwind/TeaGo/dbs"
)

View File

@@ -2,6 +2,9 @@ package dns
import (
"encoding/json"
"strings"
"time"
"github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes"
"github.com/TeaOSLab/EdgeAPI/internal/errors"
"github.com/TeaOSLab/EdgeAPI/internal/utils"
@@ -10,8 +13,6 @@ import (
"github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/maps"
"github.com/iwind/TeaGo/types"
"strings"
"time"
)
const (

View File

@@ -1,9 +1,10 @@
package dns
import (
"testing"
_ "github.com/go-sql-driver/mysql"
"github.com/iwind/TeaGo/dbs"
"testing"
)
func TestDNSDomainDAO_ExistDomainRecord(t *testing.T) {

View File

@@ -2,6 +2,7 @@ package dns
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes"
)

View File

@@ -1,13 +1,14 @@
package dns
import (
"time"
dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils"
"github.com/TeaOSLab/EdgeAPI/internal/errors"
_ "github.com/go-sql-driver/mysql"
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/types"
"time"
)
const (

View File

@@ -2,6 +2,7 @@ package dns
import (
"encoding/json"
"github.com/iwind/TeaGo/maps"
)

View File

@@ -1,12 +1,13 @@
package dns
import (
"time"
"github.com/TeaOSLab/EdgeAPI/internal/errors"
_ "github.com/go-sql-driver/mysql"
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/maps"
"time"
)
type DNSTaskType = string

View File

@@ -1,12 +1,13 @@
package dns_test
import (
"testing"
"time"
"github.com/TeaOSLab/EdgeAPI/internal/db/models/dns"
_ "github.com/go-sql-driver/mysql"
_ "github.com/iwind/TeaGo/bootstrap"
"github.com/iwind/TeaGo/dbs"
"testing"
"time"
)
func TestDNSTaskDAO_CreateDNSTask(t *testing.T) {

View File

@@ -4,6 +4,7 @@ package dnsutils
import (
"fmt"
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
"github.com/TeaOSLab/EdgeAPI/internal/db/models/dns"
"github.com/TeaOSLab/EdgeAPI/internal/dnsclients"

View File

@@ -3,10 +3,11 @@
package dnsutils
import (
"testing"
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
"github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/logs"
"testing"
)
func TestNodeClusterDAO_CheckClusterDNS(t *testing.T) {

View File

@@ -2,6 +2,7 @@ package models
import (
"errors"
_ "github.com/go-sql-driver/mysql"
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/dbs"

View File

@@ -2,6 +2,10 @@ package models
import (
"encoding/json"
"strconv"
"strings"
"time"
dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils"
"github.com/TeaOSLab/EdgeAPI/internal/errors"
"github.com/TeaOSLab/EdgeAPI/internal/utils/ttlcache"
@@ -9,9 +13,6 @@ import (
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/types"
"strconv"
"strings"
"time"
)
const (

View File

@@ -2,6 +2,7 @@ package models
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAPI/internal/remotelogs"
)

View File

@@ -2,6 +2,7 @@ package models
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAPI/internal/remotelogs"
)

View File

@@ -3,6 +3,15 @@ package models
import (
"bytes"
"encoding/json"
"net"
"net/http"
"net/url"
"regexp"
"sort"
"strings"
"sync"
"time"
dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils"
"github.com/TeaOSLab/EdgeAPI/internal/errors"
"github.com/TeaOSLab/EdgeAPI/internal/goman"
@@ -22,14 +31,6 @@ import (
"github.com/iwind/TeaGo/types"
timeutil "github.com/iwind/TeaGo/utils/time"
"golang.org/x/net/idna"
"net"
"net/http"
"net/url"
"regexp"
"sort"
"strings"
"sync"
"time"
)
type HTTPAccessLogDAO dbs.DAO

View File

@@ -4,11 +4,12 @@ package models_test
import (
"encoding/json"
"testing"
"time"
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
"github.com/iwind/TeaGo/dbs"
timeutil "github.com/iwind/TeaGo/utils/time"
"testing"
"time"
)
func TestNewHTTPAccessLogManager(t *testing.T) {

View File

@@ -2,6 +2,7 @@ package models
import (
"encoding/json"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
)

View File

@@ -2,6 +2,7 @@ package models
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAPI/internal/errors"
"github.com/TeaOSLab/EdgeAPI/internal/utils"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"

View File

@@ -2,6 +2,7 @@ package models
import (
"encoding/json"
dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils"
"github.com/TeaOSLab/EdgeAPI/internal/errors"
"github.com/TeaOSLab/EdgeAPI/internal/utils"

View File

@@ -1,6 +1,8 @@
package models
import (
"time"
"github.com/TeaOSLab/EdgeAPI/internal/errors"
"github.com/TeaOSLab/EdgeAPI/internal/goman"
"github.com/TeaOSLab/EdgeAPI/internal/remotelogs"
@@ -10,7 +12,6 @@ import (
"github.com/iwind/TeaGo/rands"
"github.com/iwind/TeaGo/types"
timeutil "github.com/iwind/TeaGo/utils/time"
"time"
)
const (

View File

@@ -1,12 +1,13 @@
package models_test
import (
"testing"
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
_ "github.com/go-sql-driver/mysql"
_ "github.com/iwind/TeaGo/bootstrap"
"github.com/iwind/TeaGo/dbs"
timeutil "github.com/iwind/TeaGo/utils/time"
"testing"
)
func TestHTTPCacheTaskKeyDAO_CreateKey(t *testing.T) {

View File

@@ -2,6 +2,7 @@ package models
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAPI/internal/errors"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"

View File

@@ -2,6 +2,7 @@ package models
import (
"encoding/json"
dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils"
"github.com/TeaOSLab/EdgeAPI/internal/errors"
"github.com/TeaOSLab/EdgeAPI/internal/utils"

View File

@@ -1,9 +1,10 @@
package models
import (
"testing"
_ "github.com/go-sql-driver/mysql"
"github.com/iwind/TeaGo/dbs"
"testing"
)
func TestHTTPFirewallPolicyDAO_FindFirewallPolicyIdsContainsIPList(t *testing.T) {

View File

@@ -2,6 +2,7 @@ package models
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAPI/internal/errors"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
_ "github.com/go-sql-driver/mysql"

View File

@@ -1,9 +1,10 @@
package models
import (
"testing"
_ "github.com/go-sql-driver/mysql"
"github.com/iwind/TeaGo/dbs"
"testing"
)
func TestHTTPFirewallRuleGroupDAO_FindRuleGroupIdWithRuleSetId(t *testing.T) {

View File

@@ -2,6 +2,7 @@ package models
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAPI/internal/errors"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
_ "github.com/go-sql-driver/mysql"

View File

@@ -1,10 +1,11 @@
package models
import (
_ "github.com/go-sql-driver/mysql"
"github.com/iwind/TeaGo/dbs"
"testing"
"time"
_ "github.com/go-sql-driver/mysql"
"github.com/iwind/TeaGo/dbs"
)
func TestHTTPFirewallRuleSetDAO_FindRuleSetIdWithRuleId(t *testing.T) {

View File

@@ -3,6 +3,7 @@ package models
import (
"encoding/json"
"errors"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
_ "github.com/go-sql-driver/mysql"

View File

@@ -2,6 +2,7 @@ package models
import (
"encoding/json"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
)

View File

@@ -2,6 +2,7 @@ package models
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAPI/internal/errors"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
_ "github.com/go-sql-driver/mysql"

View File

@@ -1,9 +1,10 @@
package models
import (
"testing"
_ "github.com/go-sql-driver/mysql"
"github.com/iwind/TeaGo/dbs"
"testing"
)
func TestHTTPHeaderPolicyDAO_FindHeaderPolicyIdWithHeaderId(t *testing.T) {

View File

@@ -3,6 +3,7 @@ package models
import (
"encoding/json"
"errors"
"github.com/TeaOSLab/EdgeAPI/internal/utils"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"

View File

@@ -3,6 +3,7 @@ package models
import (
"encoding/json"
"errors"
"github.com/TeaOSLab/EdgeAPI/internal/utils"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"

View File

@@ -3,6 +3,7 @@ package models
import (
"encoding/json"
"errors"
"github.com/TeaOSLab/EdgeAPI/internal/utils"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"

View File

@@ -3,6 +3,7 @@ package models
import (
"encoding/json"
"errors"
teaconst "github.com/TeaOSLab/EdgeAPI/internal/const"
"github.com/TeaOSLab/EdgeAPI/internal/utils"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"

View File

@@ -1,9 +1,10 @@
package models
import (
"testing"
_ "github.com/go-sql-driver/mysql"
"github.com/iwind/TeaGo/dbs"
"testing"
)
func TestHTTPWebDAO_UpdateWebShutdown(t *testing.T) {

View File

@@ -3,6 +3,7 @@ package models
import (
"encoding/json"
"errors"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
_ "github.com/go-sql-driver/mysql"

View File

@@ -1,6 +1,10 @@
package models
import (
"net"
"strings"
"time"
dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils"
"github.com/TeaOSLab/EdgeAPI/internal/errors"
"github.com/TeaOSLab/EdgeAPI/internal/goman"
@@ -13,9 +17,6 @@ import (
"github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/lists"
"github.com/iwind/TeaGo/types"
"net"
"strings"
"time"
)
const (

View File

@@ -1,14 +1,15 @@
package models_test
import (
"testing"
"time"
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
_ "github.com/go-sql-driver/mysql"
"github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/rands"
"github.com/iwind/TeaGo/types"
"testing"
"time"
)
func TestIPItemDAO_NotifyClustersUpdate(t *testing.T) {

View File

@@ -4,6 +4,11 @@ import (
"encoding/json"
"errors"
"fmt"
"io"
"os"
"strings"
"time"
"github.com/TeaOSLab/EdgeAPI/internal/db/models/regions"
"github.com/TeaOSLab/EdgeAPI/internal/utils"
"github.com/TeaOSLab/EdgeCommon/pkg/iplibrary"
@@ -11,10 +16,6 @@ import (
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/types"
"io"
"os"
"strings"
"time"
)
const (

View File

@@ -1,11 +1,12 @@
package models_test
import (
"testing"
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
_ "github.com/go-sql-driver/mysql"
_ "github.com/iwind/TeaGo/bootstrap"
"github.com/iwind/TeaGo/dbs"
"testing"
)
func TestIPLibraryFileDAO_GenerateIPLibrary(t *testing.T) {

View File

@@ -1,6 +1,8 @@
package models
import (
"regexp"
dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils"
"github.com/TeaOSLab/EdgeAPI/internal/errors"
"github.com/TeaOSLab/EdgeAPI/internal/utils"
@@ -13,7 +15,6 @@ import (
"github.com/iwind/TeaGo/lists"
"github.com/iwind/TeaGo/maps"
"github.com/iwind/TeaGo/types"
"regexp"
)
const (

View File

@@ -2,10 +2,11 @@ package models
import (
"errors"
_ "github.com/go-sql-driver/mysql"
"github.com/iwind/TeaGo/dbs"
"runtime"
"testing"
_ "github.com/go-sql-driver/mysql"
"github.com/iwind/TeaGo/dbs"
)
func TestIPListDAO_IncreaseVersion(t *testing.T) {

View File

@@ -1,11 +1,12 @@
package models
import (
"time"
_ "github.com/go-sql-driver/mysql"
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/maps"
"time"
)
type LatestItemType = string

View File

@@ -2,6 +2,10 @@ package models
import (
"encoding/json"
"regexp"
"strings"
"time"
dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils"
"github.com/TeaOSLab/EdgeAPI/internal/errors"
"github.com/TeaOSLab/EdgeAPI/internal/utils"
@@ -11,9 +15,6 @@ import (
"github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/types"
timeutil "github.com/iwind/TeaGo/utils/time"
"regexp"
"strings"
"time"
)
type LogDAO dbs.DAO

View File

@@ -1,9 +1,10 @@
package models
import (
"testing"
_ "github.com/go-sql-driver/mysql"
"github.com/iwind/TeaGo/dbs"
"testing"
)
func TestLogDAO_SumLogsSize(t *testing.T) {

View File

@@ -3,12 +3,13 @@ package models
import (
"encoding/json"
"errors"
"time"
_ "github.com/go-sql-driver/mysql"
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/maps"
"github.com/iwind/TeaGo/types"
"time"
)
// TODO 定时清理过期的SESSION

View File

@@ -2,6 +2,9 @@ package models
import (
"errors"
"math/rand"
"time"
teaconst "github.com/TeaOSLab/EdgeAPI/internal/const"
"github.com/TeaOSLab/EdgeAPI/internal/goman"
"github.com/TeaOSLab/EdgeAPI/internal/remotelogs"
@@ -12,8 +15,6 @@ import (
"github.com/iwind/TeaGo/rands"
"github.com/iwind/TeaGo/types"
stringutil "github.com/iwind/TeaGo/utils/string"
"math/rand"
"time"
)
func init() {

View File

@@ -3,6 +3,8 @@ package models
import (
"crypto/md5"
"fmt"
"time"
"github.com/TeaOSLab/EdgeAPI/internal/errors"
"github.com/TeaOSLab/EdgeAPI/internal/utils"
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
@@ -11,7 +13,6 @@ import (
"github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/types"
timeutil "github.com/iwind/TeaGo/utils/time"
"time"
)
const (

View File

@@ -1,11 +1,12 @@
package models
import (
"testing"
"time"
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
_ "github.com/go-sql-driver/mysql"
"github.com/iwind/TeaGo/dbs"
"testing"
"time"
)
func TestMessageDAO_CreateClusterMessage(t *testing.T) {

View File

@@ -2,6 +2,7 @@ package models
import (
"encoding/json"
dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils"
"github.com/TeaOSLab/EdgeAPI/internal/errors"
"github.com/TeaOSLab/EdgeAPI/internal/utils"

View File

@@ -2,6 +2,7 @@ package models
import (
"encoding/json"
_ "github.com/go-sql-driver/mysql"
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/dbs"

View File

@@ -2,6 +2,8 @@ package models
import (
"encoding/json"
"regexp"
dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils"
"github.com/TeaOSLab/EdgeAPI/internal/errors"
"github.com/TeaOSLab/EdgeAPI/internal/utils"
@@ -10,7 +12,6 @@ import (
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/types"
"regexp"
)
const (

View File

@@ -1,10 +1,11 @@
package models
import (
"testing"
_ "github.com/go-sql-driver/mysql"
_ "github.com/iwind/TeaGo/bootstrap"
"github.com/iwind/TeaGo/dbs"
"testing"
)
func TestMessageRecipientDAO_FindAllEnabledAndOnRecipientIdsWithGroup(t *testing.T) {

View File

@@ -2,6 +2,7 @@ package models
import (
"encoding/json"
"github.com/iwind/TeaGo/logs"
)

View File

@@ -1,6 +1,8 @@
package models
import (
"time"
"github.com/TeaOSLab/EdgeAPI/internal/goman"
"github.com/TeaOSLab/EdgeAPI/internal/remotelogs"
_ "github.com/go-sql-driver/mysql"
@@ -8,7 +10,6 @@ import (
"github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/rands"
timeutil "github.com/iwind/TeaGo/utils/time"
"time"
)
const (

View File

@@ -1,4 +1,4 @@
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud .
//go:build !plus
package models

View File

@@ -1,11 +1,12 @@
package models_test
import (
"testing"
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
_ "github.com/go-sql-driver/mysql"
_ "github.com/iwind/TeaGo/bootstrap"
"github.com/iwind/TeaGo/dbs"
"testing"
)
func TestMessageTaskDAO_CleanExpiredMessageTasks(t *testing.T) {

View File

@@ -1,6 +1,8 @@
package models
import (
"time"
"github.com/TeaOSLab/EdgeAPI/internal/goman"
"github.com/TeaOSLab/EdgeAPI/internal/remotelogs"
_ "github.com/go-sql-driver/mysql"
@@ -8,7 +10,6 @@ import (
"github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/rands"
timeutil "github.com/iwind/TeaGo/utils/time"
"time"
)
type MessageTaskLogDAO dbs.DAO

View File

@@ -2,6 +2,7 @@ package models
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAPI/internal/errors"
_ "github.com/go-sql-driver/mysql"
"github.com/iwind/TeaGo/Tea"

View File

@@ -2,6 +2,10 @@ package models
import (
"encoding/json"
"sort"
"strings"
"sync"
"github.com/TeaOSLab/EdgeAPI/internal/errors"
"github.com/TeaOSLab/EdgeAPI/internal/utils"
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
@@ -10,9 +14,6 @@ import (
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/types"
"sort"
"strings"
"sync"
)
const (

View File

@@ -1,10 +1,11 @@
package models_test
import (
"testing"
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
_ "github.com/go-sql-driver/mysql"
_ "github.com/iwind/TeaGo/bootstrap"
"testing"
)
func TestMetricStatDAO_Clean(t *testing.T) {

View File

@@ -2,6 +2,14 @@ package models
import (
"encoding/json"
"regexp"
"sort"
"strconv"
"strings"
"sync"
"sync/atomic"
"time"
"github.com/TeaOSLab/EdgeAPI/internal/goman"
"github.com/TeaOSLab/EdgeAPI/internal/remotelogs"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
@@ -13,13 +21,6 @@ import (
"github.com/iwind/TeaGo/rands"
"github.com/iwind/TeaGo/types"
timeutil "github.com/iwind/TeaGo/utils/time"
"regexp"
"sort"
"strconv"
"strings"
"sync"
"sync/atomic"
"time"
)
type MetricStatDAO dbs.DAO

View File

@@ -1,6 +1,9 @@
package models_test
import (
"testing"
"time"
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
_ "github.com/go-sql-driver/mysql"
_ "github.com/iwind/TeaGo/bootstrap"
@@ -8,8 +11,6 @@ import (
"github.com/iwind/TeaGo/rands"
"github.com/iwind/TeaGo/types"
timeutil "github.com/iwind/TeaGo/utils/time"
"testing"
"time"
)
func TestNewMetricStatDAO_InsertMany(t *testing.T) {

View File

@@ -1,6 +1,9 @@
package models
import (
"sync"
"time"
"github.com/TeaOSLab/EdgeAPI/internal/goman"
"github.com/TeaOSLab/EdgeAPI/internal/remotelogs"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
@@ -11,8 +14,6 @@ import (
"github.com/iwind/TeaGo/rands"
"github.com/iwind/TeaGo/types"
timeutil "github.com/iwind/TeaGo/utils/time"
"sync"
"time"
)
type MetricSumStatDAO dbs.DAO

Some files were not shown because too many files have changed in this diff Show More