This commit is contained in:
GoEdgeLab
2024-07-27 15:42:58 +08:00
parent 7279dc873f
commit d7d0c8fbfe
490 changed files with 2158 additions and 738 deletions

View File

@@ -3,11 +3,6 @@ package apps
import (
"errors"
"fmt"
teaconst "github.com/TeaOSLab/EdgeAdmin/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/EdgeAdmin/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/EdgeAdmin/internal/goman"
"github.com/TeaOSLab/EdgeAdmin/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/EdgeAdmin/internal/goman"
"github.com/TeaOSLab/EdgeAdmin/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,8 +1,9 @@
package configloaders
import (
"github.com/iwind/TeaGo/logs"
"testing"
"github.com/iwind/TeaGo/logs"
)
func TestLoadAdminModuleMapping(t *testing.T) {

View File

@@ -2,6 +2,9 @@ package configloaders
import (
"encoding/json"
"reflect"
"time"
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
"github.com/TeaOSLab/EdgeCommon/pkg/langs"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
@@ -9,8 +12,6 @@ import (
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs"
"github.com/iwind/TeaGo/logs"
"reflect"
"time"
)
var sharedAdminUIConfig *systemconfigs.AdminUIConfig = nil

View File

@@ -1,9 +1,10 @@
package configloaders
import (
_ "github.com/iwind/TeaGo/bootstrap"
"testing"
"time"
_ "github.com/iwind/TeaGo/bootstrap"
)
func TestLoadUIConfig(t *testing.T) {

View File

@@ -2,11 +2,12 @@ package configloaders
import (
"encoding/json"
"reflect"
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs"
"github.com/iwind/TeaGo/logs"
"reflect"
)
var sharedLogConfig *systemconfigs.LogConfig = nil

View File

@@ -2,12 +2,13 @@ package configloaders
import (
"encoding/json"
"reflect"
"github.com/TeaOSLab/EdgeAdmin/internal/events"
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs"
"github.com/iwind/TeaGo/logs"
"reflect"
)
const (

View File

@@ -1,9 +1,10 @@
package configloaders
import (
_ "github.com/iwind/TeaGo/bootstrap"
"testing"
"time"
_ "github.com/iwind/TeaGo/bootstrap"
)
func TestLoadSecurityConfig(t *testing.T) {

View File

@@ -2,11 +2,12 @@ package configs
import (
"errors"
"os"
"path/filepath"
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
"github.com/iwind/TeaGo/Tea"
"gopkg.in/yaml.v3"
"os"
"path/filepath"
)
const ConfigFileName = "api_admin.yaml"

View File

@@ -1,9 +1,10 @@
package configs
import (
"testing"
_ "github.com/iwind/TeaGo/bootstrap"
"gopkg.in/yaml.v3"
"testing"
)
func TestLoadAPIConfig(t *testing.T) {

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 {
@@ -22,7 +23,7 @@ type SimpleDBConfig struct {
func (this *SimpleDBConfig) GenerateOldConfig(targetFile string) 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,9 +1,9 @@
package teaconst
const (
Version = "1.3.9"
Version = "1.4.1"
APINodeVersion = "1.3.9"
APINodeVersion = "1.4.1"
ProductName = "Edge Admin"
ProcessName = "edge-admin"
@@ -16,5 +16,5 @@ const (
SessionAdminId = "adminId"
SystemdServiceName = "edge-admin"
UpdatesURL = "https://goedge.cn/api/boot/versions?os=${os}&arch=${arch}&version=${version}"
UpdatesURL = "https://goedge.cloud/api/boot/versions?os=${os}&arch=${arch}&version=${version}"
)

View File

@@ -4,10 +4,11 @@ import (
"crypto/sha256"
"encoding/base64"
"fmt"
"github.com/TeaOSLab/EdgeAdmin/internal/configs"
"github.com/iwind/TeaGo/types"
"strconv"
"time"
"github.com/TeaOSLab/EdgeAdmin/internal/configs"
"github.com/iwind/TeaGo/types"
)
// Generate 生成Token

View File

@@ -6,6 +6,10 @@ import (
"bytes"
"encoding/json"
"fmt"
"io"
"os"
"path/filepath"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/conds/condutils"
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
@@ -15,9 +19,6 @@ import (
"github.com/iwind/TeaGo/files"
"github.com/iwind/TeaGo/logs"
"github.com/iwind/TeaGo/maps"
"io"
"os"
"path/filepath"
)
func Generate() error {
@@ -39,8 +40,11 @@ func generateComponentsJSFile() error {
} else {
webRoot = Tea.Root + "/web/public/js/components/"
}
var f = files.NewFile(webRoot)
gitDir, gDirFound := os.LookupEnv("GithubDIR")
if gDirFound {
webRoot = gitDir + "/EdgeAdmin/web/public/js/components/"
}
f := files.NewFile(webRoot)
f.Range(func(file *files.File) {
if !file.IsFile() {
return
@@ -156,7 +160,12 @@ func generateComponentsJSFile() error {
buffer.Write([]byte{';', '\n', '\n'})
}
fp, err := os.OpenFile(filepath.Clean(Tea.PublicFile("/js/components.src.js")), os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0777)
pubPath := Tea.PublicFile("/js/components.src.js")
if gDirFound {
pubPath = gitDir + "/EdgeAdmin/web/public/js/components.src.js"
}
fp, err := os.OpenFile(filepath.Clean(pubPath), os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0777)
if err != nil {
return err
}

View File

@@ -3,6 +3,16 @@ package nodes
import (
"errors"
"fmt"
"log"
"net"
"os"
"os/exec"
"os/signal"
"path/filepath"
"strings"
"syscall"
"time"
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
"github.com/TeaOSLab/EdgeAdmin/internal/configs"
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
@@ -18,15 +28,6 @@ import (
"github.com/iwind/TeaGo/types"
"github.com/iwind/gosock/pkg/gosock"
"gopkg.in/yaml.v3"
"log"
"net"
"os"
"os/exec"
"os/signal"
"path/filepath"
"strings"
"syscall"
"time"
)
var SharedAdminNode *AdminNode = nil

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 nodes
@@ -13,6 +13,6 @@ func (this *AdminNode) startIPLibrary() {
logs.Println("[NODE]initializing ip library ...")
err := iplibrary.InitDefault()
if err != nil {
logs.Println("[NODE]initialize ip library failed: "+err.Error())
logs.Println("[NODE]initialize ip library failed: " + err.Error())
}
}

View File

@@ -1,16 +1,17 @@
// 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 .
package nodes
import (
"encoding/json"
"strings"
"time"
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
"github.com/TeaOSLab/EdgeAdmin/internal/ttlcache"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/logs"
"strings"
"time"
)
// SessionManager SESSION管理

View File

@@ -6,6 +6,12 @@ import (
"encoding/base64"
"errors"
"fmt"
"net"
"net/url"
"strings"
"sync"
"time"
"github.com/TeaOSLab/EdgeAdmin/internal/configs"
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
"github.com/TeaOSLab/EdgeAdmin/internal/encrypt"
@@ -22,11 +28,6 @@ import (
"google.golang.org/grpc/encoding/gzip"
"google.golang.org/grpc/keepalive"
"google.golang.org/grpc/metadata"
"net"
"net/url"
"strings"
"sync"
"time"
)
// RPCClient RPC客户端

View File

@@ -1,12 +1,13 @@
package rpc
import (
"testing"
"time"
"github.com/TeaOSLab/EdgeAdmin/internal/configs"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
_ "github.com/iwind/TeaGo/bootstrap"
stringutil "github.com/iwind/TeaGo/utils/string"
"testing"
"time"
)
func TestRPCClient_NodeRPC(t *testing.T) {

View File

@@ -1,11 +1,12 @@
package rpc
import (
"strings"
"sync"
"github.com/TeaOSLab/EdgeAdmin/internal/configs"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"strings"
"sync"
)
var sharedRPC *RPCClient = nil

View File

@@ -6,6 +6,12 @@ import (
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"runtime"
"strings"
"time"
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
"github.com/TeaOSLab/EdgeAdmin/internal/events"
"github.com/TeaOSLab/EdgeAdmin/internal/goman"
@@ -15,11 +21,6 @@ import (
"github.com/iwind/TeaGo/logs"
"github.com/iwind/TeaGo/maps"
stringutil "github.com/iwind/TeaGo/utils/string"
"io"
"net/http"
"runtime"
"strings"
"time"
)
func init() {

View File

@@ -3,6 +3,12 @@ package tasks
import (
"context"
"crypto/tls"
"net/url"
"sort"
"strings"
"sync"
"time"
"github.com/TeaOSLab/EdgeAdmin/internal/configs"
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
"github.com/TeaOSLab/EdgeAdmin/internal/events"
@@ -15,11 +21,6 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
"net/url"
"sort"
"strings"
"sync"
"time"
)
func init() {

View File

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

View File

@@ -1,6 +1,8 @@
package tasks
import (
"time"
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
"github.com/TeaOSLab/EdgeAdmin/internal/events"
"github.com/TeaOSLab/EdgeAdmin/internal/goman"
@@ -12,7 +14,6 @@ import (
_ "github.com/iwind/TeaGo/bootstrap"
"github.com/iwind/TeaGo/lists"
"github.com/iwind/TeaGo/logs"
"time"
)
func init() {

View File

@@ -1,8 +1,9 @@
package ttlcache
import (
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
"time"
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
)
var DefaultCache = NewCache()

View File

@@ -1,11 +1,12 @@
package ttlcache
import (
"github.com/iwind/TeaGo/rands"
"runtime"
"strconv"
"testing"
"time"
"github.com/iwind/TeaGo/rands"
)
func TestNewCache(t *testing.T) {
@@ -68,7 +69,7 @@ func TestCache_Read(t *testing.T) {
total := 0
for _, piece := range cache.pieces {
//t.Log(len(piece.m), "keys")
// t.Log(len(piece.m), "keys")
total += len(piece.m)
}
t.Log(total, "total keys")

View File

@@ -1,9 +1,10 @@
package ttlcache
import (
"github.com/iwind/TeaGo/types"
"sync"
"time"
"github.com/iwind/TeaGo/types"
)
type Piece struct {
@@ -16,7 +17,7 @@ func NewPiece(maxItems int) *Piece {
return &Piece{m: map[uint64]*Item{}, maxItems: maxItems}
}
func (this *Piece) Add(key uint64, item *Item) () {
func (this *Piece) Add(key uint64, item *Item) {
this.locker.Lock()
if len(this.m) >= this.maxItems {
this.locker.Unlock()

View File

@@ -1,9 +1,10 @@
package ttlcache
import (
"github.com/iwind/TeaGo/rands"
"testing"
"time"
"github.com/iwind/TeaGo/rands"
)
func TestPiece_Add(t *testing.T) {

View File

@@ -1,10 +1,11 @@
package apinodeutils
import (
"regexp"
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/files"
stringutil "github.com/iwind/TeaGo/utils/string"
"regexp"
)
// DeployManager 节点部署文件管理器

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 .
package apinodeutils

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 .
package apinodeutils
@@ -8,16 +8,17 @@ import (
"crypto/md5"
"errors"
"fmt"
"io"
"os"
"path/filepath"
"runtime"
"github.com/TeaOSLab/EdgeAdmin/internal/configs"
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/types"
stringutil "github.com/iwind/TeaGo/utils/string"
"io"
"os"
"path/filepath"
"runtime"
)
type Progress struct {

View File

@@ -1,12 +1,13 @@
// 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 .
package apinodeutils_test
import (
"github.com/TeaOSLab/EdgeAdmin/internal/utils/apinodeutils"
_ "github.com/iwind/TeaGo/bootstrap"
"runtime"
"testing"
"github.com/TeaOSLab/EdgeAdmin/internal/utils/apinodeutils"
_ "github.com/iwind/TeaGo/bootstrap"
)
func TestUpgrader_CanUpgrade(t *testing.T) {

View File

@@ -1,18 +1,19 @@
// 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 .
package apinodeutils
import (
"bytes"
"errors"
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
"github.com/iwind/TeaGo/Tea"
stringutil "github.com/iwind/TeaGo/utils/string"
"os"
"os/exec"
"regexp"
"runtime"
"strings"
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
"github.com/iwind/TeaGo/Tea"
stringutil "github.com/iwind/TeaGo/utils/string"
)
func CanUpgrade(apiVersion string, osName string, arch string) (canUpgrade bool, reason string) {

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 .
package dateutils

81
internal/utils/dns.go Normal file
View File

@@ -0,0 +1,81 @@
package utils
import (
"context"
"net"
"regexp"
"sync"
"time"
dig "github.com/TeaOSLab/EdgeCommon/pkg/utils"
"golang.org/x/net/idna"
)
func stringInSlice(str string, slice []string) bool {
for _, s := range slice {
if s == str {
return true
}
}
return false
}
func DnsCheck(domains []string, nodeIps []string) map[string]bool {
var wg sync.WaitGroup
ipMap := &sync.Map{}
concurrent := 10
counter := make(chan struct{}, concurrent)
for _, domain := range domains {
counter <- struct{}{}
wg.Add(1)
go func(domain string) {
defer func() {
<-counter
wg.Done()
}()
// 中文域名转换
if !regexp.MustCompile(`^[a-zA-Z0-9-.]+$`).MatchString(domain) {
unicodeDomain, err := idna.ToASCII(domain)
if err == nil && len(unicodeDomain) > 0 {
domain = unicodeDomain
}
}
dnsIps, err := dig.DigTraceIP(domain)
if err != nil || len(dnsIps) < 1 {
ipMap.Store(domain, false)
} else {
var flag = false
for _, ip := range dnsIps{
flag = stringInSlice(ip, nodeIps)
if flag {
break
}
}
ipMap.Store(domain, flag)
}
}(domain)
}
wg.Wait()
resultMap := make(map[string]bool)
ipMap.Range(func(key, value interface{}) bool {
resultMap[key.(string)] = value.(bool)
return true
})
return resultMap
}
func LookupIPWithTimeout(domain string, timeoutMS int64) ([]string, error) {
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*time.Duration(timeoutMS))
defer cancel()
r := net.DefaultResolver
ips, err := r.LookupHost(ctx, domain)
if err != nil {
return nil, err
}
return ips, nil
}

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 .
package utils

View File

@@ -1,11 +1,12 @@
// 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 .
package utils_test
import (
"testing"
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
"github.com/iwind/TeaGo/assert"
"testing"
)
func TestValidateEmail(t *testing.T) {

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 .
package executils

View File

@@ -1,11 +1,12 @@
// 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 .
package executils_test
import (
executils "github.com/TeaOSLab/EdgeAdmin/internal/utils/exec"
"testing"
"time"
executils "github.com/TeaOSLab/EdgeAdmin/internal/utils/exec"
)
func TestNewTimeoutCmd_Sleep(t *testing.T) {

View File

@@ -1,14 +1,15 @@
// 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 linux
package executils
import (
"golang.org/x/sys/unix"
"io/fs"
"os"
"os/exec"
"syscall"
"golang.org/x/sys/unix"
)
// LookPath customize our LookPath() function, to work in broken $PATH environment variable

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 !linux
package executils

View File

@@ -1,13 +1,14 @@
// 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 .
package utils
import (
"os/exec"
"runtime"
executils "github.com/TeaOSLab/EdgeAdmin/internal/utils/exec"
"github.com/iwind/TeaGo/logs"
"github.com/iwind/TeaGo/types"
"os/exec"
"runtime"
)
func AddPortsToFirewall(ports []int) {

View File

@@ -3,10 +3,11 @@ package utils
import (
"bytes"
"errors"
"github.com/TeaOSLab/EdgeCommon/pkg/iputils"
"github.com/iwind/TeaGo/types"
"net"
"strings"
"github.com/TeaOSLab/EdgeCommon/pkg/iputils"
"github.com/iwind/TeaGo/types"
)
// ParseIPValue 解析IP值

View File

@@ -3,9 +3,10 @@
package utils_test
import (
"testing"
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
"github.com/iwind/TeaGo/assert"
"testing"
)
func TestJSONClone(t *testing.T) {
@@ -25,11 +26,10 @@ func TestJSONClone(t *testing.T) {
}
}
func TestJSONIsNull(t *testing.T) {
var a = assert.NewAssertion(t)
a.IsTrue(utils.JSONIsNull(nil))
a.IsTrue(utils.JSONIsNull([]byte{}))
a.IsTrue(utils.JSONIsNull([]byte("null")))
a.IsFalse(utils.JSONIsNull([]byte{1, 2, 3}))
}
}

View File

@@ -1,12 +1,13 @@
package utils
import (
"sync"
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
"github.com/iwind/TeaGo/lists"
"github.com/iwind/TeaGo/logs"
"github.com/miekg/dns"
"sync"
)
var sharedDNSClient *dns.Client

View File

@@ -3,8 +3,9 @@
package utils_test
import (
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
"testing"
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
)
func TestLookupCNAME(t *testing.T) {

View File

@@ -2,10 +2,11 @@ package numberutils
import (
"fmt"
"github.com/iwind/TeaGo/types"
"regexp"
"strconv"
"strings"
"github.com/iwind/TeaGo/types"
)
func FormatInt64(value int64) string {

View File

@@ -3,9 +3,10 @@
package numberutils_test
import (
"testing"
"github.com/TeaOSLab/EdgeAdmin/internal/utils/numberutils"
"github.com/iwind/TeaGo/assert"
"testing"
)
func TestFormatBytes(t *testing.T) {

View File

@@ -1,4 +1,4 @@
// 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 otputils

View File

@@ -1,10 +1,11 @@
// 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 otputils_test
import (
"github.com/TeaOSLab/EdgeAdmin/internal/utils/otputils"
"testing"
"github.com/TeaOSLab/EdgeAdmin/internal/utils/otputils"
)
func TestFixIssuer(t *testing.T) {

View File

@@ -1,14 +1,15 @@
package utils
import (
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/files"
"github.com/iwind/TeaGo/logs"
"log"
"os"
"path/filepath"
"runtime"
"sync"
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/files"
"github.com/iwind/TeaGo/logs"
)
// 服务管理器
@@ -42,7 +43,7 @@ func (this *ServiceManager) setup() {
_ = logFile.Delete()
}
//logger
// logger
fp, err := os.OpenFile(Tea.Root+"/logs/service.log", os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0666)
if err != nil {
logs.Error(err)

View File

@@ -4,13 +4,14 @@ package utils
import (
"errors"
"os"
"os/exec"
"regexp"
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
executils "github.com/TeaOSLab/EdgeAdmin/internal/utils/exec"
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/files"
"os"
"os/exec"
"regexp"
)
var systemdServiceFile = "/etc/systemd/system/edge-admin.service"

View File

@@ -1,8 +1,9 @@
package utils
import (
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
"testing"
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
)
func TestServiceManager_Log(t *testing.T) {

View File

@@ -4,12 +4,13 @@ package utils
import (
"fmt"
"os/exec"
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
"github.com/iwind/TeaGo/Tea"
"golang.org/x/sys/windows"
"golang.org/x/sys/windows/svc"
"golang.org/x/sys/windows/svc/mgr"
"os/exec"
)
// 安装服务

View File

@@ -3,9 +3,10 @@
package sizes_test
import (
"testing"
"github.com/TeaOSLab/EdgeAdmin/internal/utils/sizes"
"github.com/iwind/TeaGo/assert"
"testing"
)
func TestSizes(t *testing.T) {

View File

@@ -1,8 +1,9 @@
package utils
import (
"github.com/iwind/TeaGo/types"
"strings"
"github.com/iwind/TeaGo/types"
)
// FormatAddress format address

View File

@@ -1,10 +1,11 @@
// 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 .
package utils
import (
"github.com/iwind/TeaGo/lists"
"strings"
"github.com/iwind/TeaGo/lists"
)
func FilterNotEmpty(item string) bool {

View File

@@ -1,11 +1,12 @@
// 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 .
package utils_test
import (
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
"strings"
"testing"
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
)
func TestStringsStream_Filter(t *testing.T) {

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 .
package taskutils

View File

@@ -1,10 +1,11 @@
// 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 .
package taskutils_test
import (
"github.com/TeaOSLab/EdgeAdmin/internal/utils/taskutils"
"testing"
"github.com/TeaOSLab/EdgeAdmin/internal/utils/taskutils"
)
func TestRunConcurrent(t *testing.T) {

View File

@@ -1,12 +1,13 @@
// 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 .
package utils
import (
"errors"
"fmt"
"github.com/iwind/TeaGo/types"
"regexp"
"github.com/iwind/TeaGo/types"
)
// RangeTimes 计算时间点

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 .
package utils
@@ -8,12 +8,6 @@ import (
"encoding/json"
"errors"
"fmt"
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
executils "github.com/TeaOSLab/EdgeAdmin/internal/utils/exec"
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/maps"
"github.com/iwind/TeaGo/types"
stringutil "github.com/iwind/TeaGo/utils/string"
"io"
"net/http"
"os"
@@ -22,6 +16,13 @@ import (
"runtime"
"strings"
"time"
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
executils "github.com/TeaOSLab/EdgeAdmin/internal/utils/exec"
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/maps"
"github.com/iwind/TeaGo/types"
stringutil "github.com/iwind/TeaGo/utils/string"
)
type UpgradeFileWriter struct {

View File

@@ -1,11 +1,12 @@
// 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 .
package utils_test
import (
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
"testing"
"time"
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
)
func TestNewUpgradeManager(t *testing.T) {

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 gcc
package injectionutils

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 !gcc
package injectionutils

View File

@@ -1,16 +1,17 @@
// 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 gcc
package injectionutils_test
import (
"runtime"
"strings"
"testing"
"github.com/TeaOSLab/EdgeAdmin/internal/waf/injectionutils"
"github.com/iwind/TeaGo/assert"
"github.com/iwind/TeaGo/rands"
"github.com/iwind/TeaGo/types"
"runtime"
"strings"
"testing"
)
func TestDetectSQLInjection(t *testing.T) {

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 gcc
package injectionutils
@@ -11,11 +11,12 @@ package injectionutils
*/
import "C"
import (
"github.com/cespare/xxhash/v2"
"net/url"
"strconv"
"strings"
"unsafe"
"github.com/cespare/xxhash/v2"
)
const MaxCacheDataSize = 1 << 20

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 !gcc
package injectionutils

View File

@@ -1,13 +1,14 @@
// 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 gcc
package injectionutils_test
import (
"github.com/TeaOSLab/EdgeAdmin/internal/waf/injectionutils"
"github.com/iwind/TeaGo/assert"
"runtime"
"testing"
"github.com/TeaOSLab/EdgeAdmin/internal/waf/injectionutils"
"github.com/iwind/TeaGo/assert"
)
func TestDetectXSS(t *testing.T) {

View File

@@ -2,6 +2,7 @@ package actionutils
import (
"context"
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
"github.com/iwind/TeaGo/maps"
)

View File

@@ -1,9 +1,10 @@
package actionutils
import (
"net/http"
"github.com/TeaOSLab/EdgeAdmin/internal/csrf"
"github.com/iwind/TeaGo/actions"
"net/http"
)
type CSRF struct {

View File

@@ -2,10 +2,11 @@ package actionutils
import (
"fmt"
"github.com/iwind/TeaGo/actions"
"math"
"net/url"
"strings"
"github.com/iwind/TeaGo/actions"
)
type Page struct {

View File

@@ -4,6 +4,9 @@ import (
"context"
"errors"
"fmt"
"net/http"
"strconv"
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
@@ -16,8 +19,6 @@ import (
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/logs"
"github.com/iwind/TeaGo/maps"
"net/http"
"strconv"
)
type ParentAction struct {

View File

@@ -4,6 +4,15 @@ import (
"encoding/json"
"errors"
"fmt"
"net"
"net/http"
"os"
"path/filepath"
"reflect"
"runtime"
"strings"
"time"
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
"github.com/TeaOSLab/EdgeAdmin/internal/configs"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
@@ -13,14 +22,6 @@ import (
"github.com/iwind/TeaGo/logs"
"github.com/iwind/TeaGo/maps"
"github.com/iwind/gosock/pkg/gosock"
"net"
"net/http"
"os"
"path/filepath"
"reflect"
"runtime"
"strings"
"time"
)
// Fail 提示服务器错误信息

View File

@@ -2,6 +2,7 @@ package admins
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"

View File

@@ -2,6 +2,7 @@ package adminutils
import (
"errors"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/maps"

View File

@@ -2,6 +2,7 @@ package admins
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"

View File

@@ -2,6 +2,7 @@ package admins
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
"github.com/TeaOSLab/EdgeAdmin/internal/utils/otputils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"

View File

@@ -2,6 +2,7 @@ package admins
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"

View File

@@ -1,6 +1,10 @@
package cluster
import (
"net"
"strconv"
"strings"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
@@ -8,9 +12,6 @@ import (
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/lists"
"github.com/iwind/TeaGo/maps"
"net"
"strconv"
"strings"
)
type CreateBatchAction struct {

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 cluster

View File

@@ -2,6 +2,11 @@ package cluster
import (
"encoding/json"
"net"
"regexp"
"strconv"
"strings"
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/clusterutils"
@@ -11,10 +16,6 @@ import (
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/maps"
"net"
"regexp"
"strconv"
"strings"
)
// CreateNodeAction 创建节点
@@ -124,6 +125,8 @@ func (this *CreateNodeAction) RunPost(params struct {
DnsDomainId int64
DnsRoutesJSON []byte
SecondaryClusterIds []byte
Must *actions.Must
}) {
params.Must.
@@ -342,5 +345,30 @@ func (this *CreateNodeAction) RunPost(params struct {
}
}
var secondaryClusterIds = []int64{}
if len(params.SecondaryClusterIds) > 0 {
err := json.Unmarshal(params.SecondaryClusterIds, &secondaryClusterIds)
if err != nil {
this.ErrorPage(err)
return
}
}
_, err = this.RPC().NodeRPC().UpdateNode(this.AdminContext(), &pb.UpdateNodeRequest{
NodeId: nodeResp.Node.Id,
NodeGroupId: params.GroupId,
NodeRegionId: params.RegionId,
Name: nodeResp.Node.Name,
NodeClusterId: params.ClusterId,
SecondaryNodeClusterIds: secondaryClusterIds,
IsOn: true,
Level: nodeResp.Node.Level,
LnAddrs: nodeResp.Node.LnAddrs,
EnableIPLists: nodeResp.Node.EnableIPLists,
})
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}

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 cluster

View File

@@ -1,15 +1,16 @@
// 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 .
package cluster
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/types"
"io"
"net/http"
"os"
"regexp"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/types"
)
type DownloadInstallerAction struct {

View File

@@ -3,9 +3,10 @@
package cluster
import (
"strconv"
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"strconv"
)
type IndexAction struct {

View File

@@ -2,6 +2,7 @@ package cluster
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/maps"

View File

@@ -1,10 +1,11 @@
package cluster
import (
"strings"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/maps"
"strings"
)
type InstallNodesAction struct {

View File

@@ -2,6 +2,7 @@ package cluster
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"

View File

@@ -3,6 +3,8 @@ package node
import (
"encoding/json"
"fmt"
"time"
"github.com/TeaOSLab/EdgeAdmin/internal/utils/numberutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/grants/grantutils"
@@ -13,7 +15,6 @@ import (
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/iwind/TeaGo/maps"
timeutil "github.com/iwind/TeaGo/utils/time"
"time"
)
type DetailAction struct {

View File

@@ -2,10 +2,11 @@ package node
import (
"fmt"
"strconv"
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/node/nodeutils"
"strconv"
)
type IndexAction struct {

View File

@@ -2,6 +2,9 @@ package node
import (
"encoding/json"
"path/filepath"
"strings"
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/node/nodeutils"
@@ -12,8 +15,6 @@ import (
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/maps"
"path/filepath"
"strings"
)
// InstallAction 安装节点

View File

@@ -4,12 +4,13 @@ package nodeutils
import (
"errors"
"strconv"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/maps"
"github.com/iwind/TeaGo/types"
"strconv"
)
// InitNodeInfo 初始化节点信息
@@ -38,12 +39,13 @@ func InitNodeInfo(parentAction *actionutils.ParentAction, nodeId int64) (*pb.Nod
}
parentAction.Data["node"] = maps.Map{
"id": node.Id,
"name": node.Name,
"isOn": node.IsOn,
"isUp": node.IsUp,
"group": groupMap,
"level": node.Level,
"id": node.Id,
"name": node.Name,
"isOn": node.IsOn,
"isUp": node.IsUp,
"group": groupMap,
"level": node.Level,
"bypassMobile": node.BypassMobile,
}
var clusterId int64 = 0
if node.NodeCluster != nil {

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 nodeutils

View File

@@ -1,16 +1,16 @@
// 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 nodeutils_test
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/node/nodeutils"
_ "github.com/iwind/TeaGo/bootstrap"
"testing"
_ "github.com/iwind/TeaGo/bootstrap"
)
func TestInstallLocalNode(t *testing.T) {
err := nodeutils.InstallLocalNode()
if err != nil {
t.Fatal(err)
}
// err := nodeutils.InstallLocalNode()
// if err != nil {
// t.Fatal(err)
// }
}

View File

@@ -4,6 +4,7 @@ package cache
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/node/nodeutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"

View File

@@ -4,6 +4,8 @@ package ddosProtection
import (
"encoding/json"
"net"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/node/nodeutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
@@ -12,7 +14,6 @@ import (
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/ddosconfigs"
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/types"
"net"
)
type IndexAction struct {

View File

@@ -4,6 +4,7 @@ package dns
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/node/nodeutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"

View File

@@ -4,6 +4,9 @@ package ssh
import (
"encoding/json"
"net"
"regexp"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/node/nodeutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/grants/grantutils"
@@ -11,8 +14,6 @@ import (
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/maps"
"net"
"regexp"
)
type IndexAction struct {

View File

@@ -4,6 +4,7 @@ package system
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/node/nodeutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
@@ -35,6 +36,8 @@ func (this *IndexAction) RunGet(params struct {
// 获取节点信息
var nodeMap = this.Data["node"].(maps.Map)
nodeMap["maxCPU"] = node.MaxCPU
nodeMap["bypassMobileCheckbox"] = node.BypassMobile > 0
nodeMap["bypassMobile"] = node.BypassMobile
// DNS
dnsResolverResp, err := this.RPC().NodeRPC().FindNodeDNSResolver(this.AdminContext(), &pb.FindNodeDNSResolverRequest{NodeId: params.NodeId})
@@ -75,6 +78,8 @@ func (this *IndexAction) RunPost(params struct {
NodeId int64
MaxCPU int32
BypassMobile int32
DnsResolverJSON []byte
ApiNodeAddrsJSON []byte
@@ -98,6 +103,16 @@ func (this *IndexAction) RunPost(params struct {
return
}
// bypass 移动
_, err = this.RPC().NodeRPC().UpdateNodeBypassMobile(this.AdminContext(), &pb.UpdateNodeBypassMobile{
NodeId: params.NodeId,
BypassMobile: params.BypassMobile,
})
if err != nil {
this.ErrorPage(err)
return
}
// DNS解析设置
var dnsResolverConfig = nodeconfigs.DefaultDNSResolverConfig()
err = json.Unmarshal(params.DnsResolverJSON, dnsResolverConfig)

View File

@@ -1,4 +1,4 @@
// 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 node

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