Compare commits
85 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ff8aecbea | ||
|
|
e6cae84764 | ||
|
|
2d2d2931f1 | ||
|
|
69ad5e7d1f | ||
|
|
97abc6aeb9 | ||
|
|
8cf37dd37c | ||
|
|
e11d091ac5 | ||
|
|
e952dfcedd | ||
|
|
2565d5cab2 | ||
|
|
e4e66c74bc | ||
|
|
6607c41823 | ||
|
|
43570f20b5 | ||
|
|
9ea7a93206 | ||
|
|
dec4922fe5 | ||
|
|
ef1f95b347 | ||
|
|
7317312f68 | ||
|
|
2965e8df65 | ||
|
|
4fdcc7fae9 | ||
|
|
6be8f7539d | ||
|
|
a6de65fe39 | ||
|
|
fc5dae5a8e | ||
|
|
db69454d32 | ||
|
|
c824335b0e | ||
|
|
1f1ce11078 | ||
|
|
0ec1571d37 | ||
|
|
407e8b52a5 | ||
|
|
1be13a151d | ||
|
|
4d9d417d7a | ||
|
|
aaff8f0c4a | ||
|
|
8c064daf3f | ||
|
|
b0b3dae147 | ||
|
|
2ea2be43d3 | ||
|
|
81f7364e93 | ||
|
|
c530869530 | ||
|
|
586ccd90ec | ||
|
|
ece237c49f | ||
|
|
11da5ca98c | ||
|
|
276a68bda6 | ||
|
|
fba89d197a | ||
|
|
b3259e2489 | ||
|
|
880704dda0 | ||
|
|
d5e92e9c09 | ||
|
|
df2f5692bd | ||
|
|
dacc99b8b6 | ||
|
|
0e8ade3b61 | ||
|
|
fe2d8f6261 | ||
|
|
927381039b | ||
|
|
6b95947acb | ||
|
|
b05e53ce58 | ||
|
|
a2546582f2 | ||
|
|
a023b3401e | ||
|
|
07142e9872 | ||
|
|
f5fea6c34d | ||
|
|
5eb0fb3422 | ||
|
|
fa915e7c35 | ||
|
|
2b7905d31c | ||
|
|
9cbbf37add | ||
|
|
642a0c3b0d | ||
|
|
ff47a19250 | ||
|
|
1fc1a3fbe3 | ||
|
|
996172bd69 | ||
|
|
df038314ef | ||
|
|
67881c2e34 | ||
|
|
9c691a17b2 | ||
|
|
54df86a4a2 | ||
|
|
70aff759d7 | ||
|
|
d903cc6e3b | ||
|
|
c520271ab5 | ||
|
|
f6936224d9 | ||
|
|
283984a6a6 | ||
|
|
c4fc09f72a | ||
|
|
efdbabfa04 | ||
|
|
a43af333fd | ||
|
|
1f5894ff82 | ||
|
|
79b4054e31 | ||
|
|
376d7d0c78 | ||
|
|
c8b85330ed | ||
|
|
c65dffee13 | ||
|
|
275320ad9b | ||
|
|
f71cdf9065 | ||
|
|
8e0a239de9 | ||
|
|
ed2b95bc3f | ||
|
|
2e23ee4c66 | ||
|
|
58def52e30 | ||
|
|
aea5ef3b68 |
@@ -54,7 +54,7 @@
|
||||
* [管理平台](https://github.com/TeaOSLab/EdgeAdmin)
|
||||
|
||||
## 联系我们
|
||||
有什么问题和建议都可以加入QQ群 `659832182` 或者 [Telegram群](https://t.me/+5kVCMGxQhZxiODY9) 。
|
||||
有什么问题和建议都可以加入 [Telegram群](https://t.me/+5kVCMGxQhZxiODY9)
|
||||
|
||||
## 企业版
|
||||
* [GoEdge企业版](https://goedge.cn/commercial) - 功能更强大的CDN系统
|
||||
|
||||
@@ -1 +1 @@
|
||||
这个目录下我们列举了所有需要公开声明的第三方License,如果有遗漏,烦请告知 iwind.liu@gmail.com。再次感谢这些开源软件项目和贡献人员!
|
||||
这个目录下我们列举了所有需要公开声明的第三方License,如果有遗漏,烦请告知 goedge.cdn@gmail.com。再次感谢这些开源软件项目和贡献人员!
|
||||
@@ -1,7 +1,7 @@
|
||||
FROM alpine:latest
|
||||
LABEL maintainer="iwind.liu@gmail.com"
|
||||
LABEL maintainer="goedge.cdn@gmail.com"
|
||||
ENV TZ "Asia/Shanghai"
|
||||
ENV VERSION 1.0.1
|
||||
ENV VERSION 1.1.0
|
||||
ENV ROOT_DIR /usr/local/goedge
|
||||
ENV TAR_FILE edge-admin-linux-amd64-plus-v${VERSION}.zip
|
||||
ENV TAR_URL "https://dl.goedge.cn/edge/v${VERSION}/edge-admin-linux-amd64-plus-v${VERSION}.zip"
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package teaconst
|
||||
|
||||
const (
|
||||
Version = "1.0.4"
|
||||
Version = "1.2.0"
|
||||
|
||||
APINodeVersion = "1.0.4"
|
||||
APINodeVersion = "1.2.0"
|
||||
|
||||
ProductName = "Edge Admin"
|
||||
ProcessName = "edge-admin"
|
||||
|
||||
@@ -51,3 +51,19 @@ func IsConnError(err error) bool {
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// IsUnimplementedError 检查是否为未实现错误
|
||||
func IsUnimplementedError(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
statusErr, ok := status.FromError(err)
|
||||
if ok {
|
||||
if statusErr.Code() == codes.Unimplemented {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ func (this *CheckUpdatesTask) Loop() error {
|
||||
var vMap = maps.NewMap(version)
|
||||
if vMap.GetString("code") == "admin" {
|
||||
var latestVersion = vMap.GetString("version")
|
||||
if stringutil.VersionCompare(teaconst.Version, latestVersion) < 0 {
|
||||
if stringutil.VersionCompare(teaconst.Version, latestVersion) < 0 && (len(config.IgnoredVersion) == 0 || stringutil.VersionCompare(latestVersion, config.IgnoredVersion) > 0) {
|
||||
teaconst.NewVersionCode = latestVersion
|
||||
teaconst.NewVersionDownloadURL = dlHost + vMap.GetString("url")
|
||||
return nil
|
||||
|
||||
56
internal/utils/taskutils/concurrent.go
Normal file
56
internal/utils/taskutils/concurrent.go
Normal file
@@ -0,0 +1,56 @@
|
||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package taskutils
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"reflect"
|
||||
"sync"
|
||||
)
|
||||
|
||||
func RunConcurrent(tasks any, concurrent int, f func(task any)) error {
|
||||
if tasks == nil {
|
||||
return nil
|
||||
}
|
||||
var tasksValue = reflect.ValueOf(tasks)
|
||||
if tasksValue.Type().Kind() != reflect.Slice {
|
||||
return errors.New("ony works for slice")
|
||||
}
|
||||
|
||||
var countTasks = tasksValue.Len()
|
||||
if countTasks == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
if concurrent <= 0 {
|
||||
concurrent = 8
|
||||
}
|
||||
if concurrent > countTasks {
|
||||
concurrent = countTasks
|
||||
}
|
||||
|
||||
var taskChan = make(chan any, countTasks)
|
||||
for i := 0; i < countTasks; i++ {
|
||||
taskChan <- tasksValue.Index(i).Interface()
|
||||
}
|
||||
|
||||
var wg = &sync.WaitGroup{}
|
||||
wg.Add(concurrent)
|
||||
for i := 0; i < concurrent; i++ {
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
for {
|
||||
select {
|
||||
case task := <-taskChan:
|
||||
f(task)
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
return nil
|
||||
}
|
||||
17
internal/utils/taskutils/concurrent_test.go
Normal file
17
internal/utils/taskutils/concurrent_test.go
Normal file
@@ -0,0 +1,17 @@
|
||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package taskutils_test
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/utils/taskutils"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRunConcurrent(t *testing.T) {
|
||||
err := taskutils.RunConcurrent([]string{"a", "b", "c", "d", "e"}, 3, func(task any) {
|
||||
t.Log("run", task)
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
@@ -2,37 +2,49 @@ package actionutils
|
||||
|
||||
import (
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
type TabItem struct {
|
||||
Name string `json:"name"`
|
||||
SubName string `json:"subName"`
|
||||
URL string `json:"url"`
|
||||
Icon string `json:"icon"`
|
||||
IsActive bool `json:"isActive"`
|
||||
IsRight bool `json:"isRight"`
|
||||
IsTitle bool `json:"isTitle"`
|
||||
IsDisabled bool `json:"isDisabled"`
|
||||
}
|
||||
|
||||
// Tabbar Tabbar定义
|
||||
type Tabbar struct {
|
||||
items []maps.Map
|
||||
items []*TabItem
|
||||
}
|
||||
|
||||
// NewTabbar 获取新对象
|
||||
func NewTabbar() *Tabbar {
|
||||
return &Tabbar{
|
||||
items: []maps.Map{},
|
||||
items: []*TabItem{},
|
||||
}
|
||||
}
|
||||
|
||||
// Add 添加菜单项
|
||||
func (this *Tabbar) Add(name string, subName string, url string, icon string, active bool) maps.Map {
|
||||
m := maps.Map{
|
||||
"name": name,
|
||||
"subName": subName,
|
||||
"url": url,
|
||||
"icon": icon,
|
||||
"active": active,
|
||||
"right": false,
|
||||
func (this *Tabbar) Add(name string, subName string, url string, icon string, active bool) *TabItem {
|
||||
var m = &TabItem{
|
||||
Name: name,
|
||||
SubName: subName,
|
||||
URL: url,
|
||||
Icon: icon,
|
||||
IsActive: active,
|
||||
IsRight: false,
|
||||
IsTitle: false,
|
||||
IsDisabled: false,
|
||||
}
|
||||
this.items = append(this.items, m)
|
||||
return m
|
||||
}
|
||||
|
||||
// Items 取得所有的Items
|
||||
func (this *Tabbar) Items() []maps.Map {
|
||||
func (this *Tabbar) Items() []*TabItem {
|
||||
return this.items
|
||||
}
|
||||
|
||||
|
||||
@@ -24,10 +24,19 @@ import (
|
||||
|
||||
// Fail 提示服务器错误信息
|
||||
func Fail(action actions.ActionWrapper, err error) {
|
||||
if err != nil {
|
||||
logs.Println("[" + reflect.TypeOf(action).String() + "]" + findStack(err.Error()))
|
||||
if err == nil {
|
||||
err = errors.New("unknown error")
|
||||
}
|
||||
action.Object().Fail(teaconst.ErrServer + "(" + err.Error() + ")")
|
||||
|
||||
logs.Println("[" + reflect.TypeOf(action).String() + "]" + findStack(err.Error()))
|
||||
|
||||
_, _, isLocalAPI, issuesHTML := parseAPIErr(action, err)
|
||||
if isLocalAPI && len(issuesHTML) > 0 {
|
||||
action.Object().Fail(teaconst.ErrServer + "(" + err.Error() + ";最近一次错误提示:" + issuesHTML + ")")
|
||||
} else {
|
||||
action.Object().Fail(teaconst.ErrServer + "(" + err.Error() + ")")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// FailPage 提示页面错误信息
|
||||
@@ -38,67 +47,11 @@ func FailPage(action actions.ActionWrapper, err error) {
|
||||
|
||||
logs.Println("[" + reflect.TypeOf(action).String() + "]" + findStack(err.Error()))
|
||||
|
||||
// 当前API终端地址
|
||||
var apiEndpoints = []string{}
|
||||
apiConfig, apiConfigErr := configs.LoadAPIConfig()
|
||||
if apiConfigErr == nil && apiConfig != nil {
|
||||
apiEndpoints = append(apiEndpoints, apiConfig.RPC.Endpoints...)
|
||||
}
|
||||
|
||||
var isRPCConnError bool
|
||||
err, isRPCConnError = rpcerrors.HumanError(err, apiEndpoints, Tea.ConfigFile("api.yaml"))
|
||||
var apiNodeIsStarting = false
|
||||
var apiNodeProgress = ""
|
||||
if isRPCConnError {
|
||||
// API节点是否正在启动
|
||||
var sock = gosock.NewTmpSock("edge-api")
|
||||
reply, err := sock.SendTimeout(&gosock.Command{
|
||||
Code: "starting",
|
||||
Params: nil,
|
||||
}, 1*time.Second)
|
||||
if err == nil && reply != nil {
|
||||
var params = maps.NewMap(reply.Params)
|
||||
if params.GetBool("isStarting") {
|
||||
apiNodeIsStarting = true
|
||||
|
||||
var progressMap = params.GetMap("progress")
|
||||
apiNodeProgress = progressMap.GetString("description")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
action.Object().ResponseWriter.WriteHeader(http.StatusInternalServerError)
|
||||
if len(action.Object().Request.Header.Get("X-Requested-With")) > 0 {
|
||||
action.Object().WriteString(teaconst.ErrServer)
|
||||
} else {
|
||||
// 本地的一些错误提示
|
||||
var isLocalAPI = false
|
||||
if isRPCConnError {
|
||||
host, _, hostErr := net.SplitHostPort(action.Object().Request.Host)
|
||||
if hostErr == nil {
|
||||
for _, endpoint := range apiEndpoints {
|
||||
if strings.HasPrefix(endpoint, "http://"+host) || strings.HasPrefix(endpoint, "https://"+host) || strings.HasPrefix(endpoint, host) {
|
||||
isLocalAPI = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var issuesHTML = ""
|
||||
if isLocalAPI {
|
||||
// 读取本地API节点的issues
|
||||
issuesData, issuesErr := os.ReadFile(Tea.Root + "/edge-api/logs/issues.log")
|
||||
if issuesErr == nil {
|
||||
var issueMaps = []maps.Map{}
|
||||
issuesErr = json.Unmarshal(issuesData, &issueMaps)
|
||||
if issuesErr == nil && len(issueMaps) > 0 {
|
||||
var issueMap = issueMaps[0]
|
||||
issuesHTML = "本地API节点启动错误:" + issueMap.GetString("message") + ",处理建议:" + issueMap.GetString("suggestion")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
apiNodeIsStarting, apiNodeProgress, _, issuesHTML := parseAPIErr(action, err)
|
||||
var html = `<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
@@ -187,3 +140,61 @@ func findStack(err string) string {
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// 分析API节点的错误信息
|
||||
func parseAPIErr(action actions.ActionWrapper, err error) (apiNodeIsStarting bool, apiNodeProgress string, isLocalAPI bool, issuesHTML string) {
|
||||
// 当前API终端地址
|
||||
var apiEndpoints = []string{}
|
||||
apiConfig, apiConfigErr := configs.LoadAPIConfig()
|
||||
if apiConfigErr == nil && apiConfig != nil {
|
||||
apiEndpoints = append(apiEndpoints, apiConfig.RPC.Endpoints...)
|
||||
}
|
||||
|
||||
var isRPCConnError bool
|
||||
err, isRPCConnError = rpcerrors.HumanError(err, apiEndpoints, Tea.ConfigFile("api.yaml"))
|
||||
if isRPCConnError {
|
||||
// API节点是否正在启动
|
||||
var sock = gosock.NewTmpSock("edge-api")
|
||||
reply, err := sock.SendTimeout(&gosock.Command{
|
||||
Code: "starting",
|
||||
Params: nil,
|
||||
}, 1*time.Second)
|
||||
if err == nil && reply != nil {
|
||||
var params = maps.NewMap(reply.Params)
|
||||
if params.GetBool("isStarting") {
|
||||
apiNodeIsStarting = true
|
||||
|
||||
var progressMap = params.GetMap("progress")
|
||||
apiNodeProgress = progressMap.GetString("description")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 本地的一些错误提示
|
||||
if isRPCConnError {
|
||||
host, _, hostErr := net.SplitHostPort(action.Object().Request.Host)
|
||||
if hostErr == nil {
|
||||
for _, endpoint := range apiEndpoints {
|
||||
if strings.HasPrefix(endpoint, "http://"+host) || strings.HasPrefix(endpoint, "https://"+host) || strings.HasPrefix(endpoint, host) {
|
||||
isLocalAPI = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if isLocalAPI {
|
||||
// 读取本地API节点的issues
|
||||
issuesData, issuesErr := os.ReadFile(Tea.Root + "/edge-api/logs/issues.log")
|
||||
if issuesErr == nil {
|
||||
var issueMaps = []maps.Map{}
|
||||
issuesErr = json.Unmarshal(issuesData, &issueMaps)
|
||||
if issuesErr == nil && len(issueMaps) > 0 {
|
||||
var issueMap = issueMaps[0]
|
||||
issuesHTML = "本地API节点启动错误:" + issueMap.GetString("message") + ",处理建议:" + issueMap.GetString("suggestion")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -39,6 +39,17 @@ func (this *CreateBatchAction) RunGet(params struct {
|
||||
}
|
||||
this.Data["leftMenuItems"] = leftMenuItems
|
||||
|
||||
// 限额
|
||||
maxNodes, leftNodes, err := this.findNodesQuota()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
this.Data["quota"] = maps.Map{
|
||||
"maxNodes": maxNodes,
|
||||
"leftNodes": leftNodes,
|
||||
}
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
//go:build !plus
|
||||
|
||||
package cluster
|
||||
|
||||
func (this *CreateBatchAction) findNodesQuota() (maxNodes int32, leftNodes int32, err error) {
|
||||
return
|
||||
}
|
||||
@@ -30,6 +30,11 @@ func (this *CreateNodeAction) Init() {
|
||||
func (this *CreateNodeAction) RunGet(params struct {
|
||||
ClusterId int64
|
||||
}) {
|
||||
if params.ClusterId <= 0 {
|
||||
this.RedirectURL("/clusters")
|
||||
return
|
||||
}
|
||||
|
||||
var leftMenuItems = []maps.Map{
|
||||
{
|
||||
"name": "单个创建",
|
||||
@@ -92,6 +97,17 @@ func (this *CreateNodeAction) RunGet(params struct {
|
||||
// 安装文件下载
|
||||
this.Data["installerFiles"] = clusterutils.ListInstallerFiles()
|
||||
|
||||
// 限额
|
||||
maxNodes, leftNodes, err := this.findNodesQuota()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
this.Data["quota"] = maps.Map{
|
||||
"maxNodes": maxNodes,
|
||||
"leftNodes": leftNodes,
|
||||
}
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
//go:build !plus
|
||||
|
||||
package cluster
|
||||
|
||||
func (this *CreateNodeAction) findNodesQuota() (maxNodes int32, leftNodes int32, err error) {
|
||||
return
|
||||
}
|
||||
@@ -20,6 +20,7 @@ func init() {
|
||||
Helper(helpers.NewUserMustAuth(configloaders.AdminModuleCodeNode)).
|
||||
Helper(clusters.NewClusterHelper()).
|
||||
Data("teaMenu", "clusters").
|
||||
Data("teaSubMenu", "cluster").
|
||||
Prefix("/clusters/cluster").
|
||||
Get("", new(IndexAction)).
|
||||
Get("/nodes", new(NodesAction)).
|
||||
|
||||
@@ -187,6 +187,8 @@ func (this *DetailAction) RunGet(params struct {
|
||||
"route": route.Name,
|
||||
"value": addr.Ip,
|
||||
"clusterName": cluster.Name,
|
||||
"isBackup": dnsInfo.IsBackupForCluster || dnsInfo.IsBackupForGroup,
|
||||
"isOffline": dnsInfo.IsOffline,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -343,25 +345,29 @@ func (this *DetailAction) RunGet(params struct {
|
||||
}
|
||||
|
||||
this.Data["node"] = maps.Map{
|
||||
"id": node.Id,
|
||||
"name": node.Name,
|
||||
"ipAddresses": ipAddressMaps,
|
||||
"cluster": clusterMap,
|
||||
"secondaryClusters": secondaryClustersMaps,
|
||||
"login": loginMap,
|
||||
"installDir": node.InstallDir,
|
||||
"isInstalled": node.IsInstalled,
|
||||
"uniqueId": node.UniqueId,
|
||||
"secret": node.Secret,
|
||||
"maxCPU": node.MaxCPU,
|
||||
"isOn": node.IsOn,
|
||||
"records": recordMaps,
|
||||
"routes": routeMaps,
|
||||
"level": node.Level,
|
||||
"levelInfo": nodeconfigs.FindNodeLevel(int(node.Level)),
|
||||
"lnAddrs": lnAddrs,
|
||||
"enableIPLists": node.EnableIPLists,
|
||||
"apiNodeAddrs": apiNodeAddrStrings,
|
||||
"id": node.Id,
|
||||
"name": node.Name,
|
||||
"ipAddresses": ipAddressMaps,
|
||||
"cluster": clusterMap,
|
||||
"secondaryClusters": secondaryClustersMaps,
|
||||
"login": loginMap,
|
||||
"installDir": node.InstallDir,
|
||||
"isInstalled": node.IsInstalled,
|
||||
"uniqueId": node.UniqueId,
|
||||
"secret": node.Secret,
|
||||
"maxCPU": node.MaxCPU,
|
||||
"isOn": node.IsOn,
|
||||
"records": recordMaps,
|
||||
"routes": routeMaps,
|
||||
"level": node.Level,
|
||||
"levelInfo": nodeconfigs.FindNodeLevel(int(node.Level)),
|
||||
"lnAddrs": lnAddrs,
|
||||
"enableIPLists": node.EnableIPLists,
|
||||
"apiNodeAddrs": apiNodeAddrStrings,
|
||||
"offlineDay": node.OfflineDay,
|
||||
"isOffline": len(node.OfflineDay) > 0 && node.OfflineDay < timeutil.Format("Ymd"),
|
||||
"isBackupForCluster": node.IsBackupForCluster,
|
||||
"isBackupForGroup": node.IsBackupForGroup,
|
||||
|
||||
"status": maps.Map{
|
||||
"isActive": status.IsActive,
|
||||
|
||||
@@ -209,6 +209,8 @@ func (this *NodesAction) RunGet(params struct {
|
||||
"isInstalled": node.IsInstalled,
|
||||
"isOn": node.IsOn,
|
||||
"isUp": node.IsUp,
|
||||
"isBackup": node.IsBackupForCluster || node.IsBackupForGroup,
|
||||
"offlineDay": node.OfflineDay,
|
||||
"installStatus": maps.Map{
|
||||
"isRunning": node.InstallStatus.IsRunning,
|
||||
"isFinished": node.InstallStatus.IsFinished,
|
||||
|
||||
@@ -64,6 +64,7 @@ p { color: grey; }
|
||||
</body>
|
||||
</html>`
|
||||
}
|
||||
|
||||
this.Data["httpAllDomainMismatchActionContentHTML"] = httpAllDomainMismatchActionContentHTML
|
||||
|
||||
this.Show()
|
||||
@@ -77,8 +78,12 @@ func (this *IndexAction) RunPost(params struct {
|
||||
HttpAllAllowMismatchDomainsJSON []byte
|
||||
HttpAllAllowNodeIP bool
|
||||
HttpAllDefaultDomain string
|
||||
HttpAllNodeIPPageHTML string
|
||||
HttpAllNodeIPShowPage bool
|
||||
HttpAllForceLnRequest bool
|
||||
|
||||
HttpAllSupportsLowVersionHTTP bool
|
||||
HttpAllSupportsLowVersionHTTP bool
|
||||
HttpAllMatchCertFromAllServers bool
|
||||
|
||||
HttpAccessLogEnableRequestHeaders bool
|
||||
HttpAccessLogEnableResponseHeaders bool
|
||||
@@ -135,9 +140,13 @@ func (this *IndexAction) RunPost(params struct {
|
||||
config.HTTPAll.AllowMismatchDomains = allowMismatchDomains
|
||||
config.HTTPAll.AllowNodeIP = params.HttpAllAllowNodeIP
|
||||
config.HTTPAll.DefaultDomain = params.HttpAllDefaultDomain
|
||||
config.HTTPAll.NodeIPShowPage = params.HttpAllNodeIPShowPage
|
||||
config.HTTPAll.NodeIPPageHTML = params.HttpAllNodeIPPageHTML
|
||||
|
||||
// HTTP All
|
||||
config.HTTPAll.SupportsLowVersionHTTP = params.HttpAllSupportsLowVersionHTTP
|
||||
config.HTTPAll.MatchCertFromAllServers = params.HttpAllMatchCertFromAllServers
|
||||
config.HTTPAll.ForceLnRequest = params.HttpAllForceLnRequest
|
||||
|
||||
// 访问日志
|
||||
config.HTTPAccessLog.EnableRequestHeaders = params.HttpAccessLogEnableRequestHeaders
|
||||
|
||||
@@ -15,7 +15,17 @@ func (this *RunPopupAction) Init() {
|
||||
this.Nav("", "", "")
|
||||
}
|
||||
|
||||
func (this *RunPopupAction) RunGet(params struct{}) {
|
||||
func (this *RunPopupAction) RunGet(params struct {
|
||||
ClusterId int64
|
||||
}) {
|
||||
// 检查是否已部署服务
|
||||
countServersResp, err := this.RPC().ServerRPC().CountAllEnabledServersWithNodeClusterId(this.AdminContext(), &pb.CountAllEnabledServersWithNodeClusterIdRequest{NodeClusterId: params.ClusterId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
this.Data["hasServers"] = countServersResp.Count > 0
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ func init() {
|
||||
Helper(helpers.NewUserMustAuth(configloaders.AdminModuleCodeNode)).
|
||||
Helper(clusters.NewClusterHelper()).
|
||||
Prefix("/clusters/cluster/settings").
|
||||
Data("teaSubMenu", "cluster").
|
||||
GetPost("", new(IndexAction)).
|
||||
|
||||
// 健康检查
|
||||
|
||||
@@ -29,9 +29,9 @@ func (this *ClusterHelper) BeforeAction(actionPtr actions.ActionWrapper) (goNext
|
||||
|
||||
action.Data["teaMenu"] = "clusters"
|
||||
|
||||
selectedTabbar := action.Data.GetString("mainTab")
|
||||
clusterId := action.ParamInt64("clusterId")
|
||||
clusterIdString := strconv.FormatInt(clusterId, 10)
|
||||
var selectedTabbar = action.Data.GetString("mainTab")
|
||||
var clusterId = action.ParamInt64("clusterId")
|
||||
var clusterIdString = strconv.FormatInt(clusterId, 10)
|
||||
action.Data["clusterId"] = clusterId
|
||||
|
||||
if clusterId > 0 {
|
||||
@@ -57,14 +57,45 @@ func (this *ClusterHelper) BeforeAction(actionPtr actions.ActionWrapper) (goNext
|
||||
return
|
||||
}
|
||||
|
||||
var nodeId = action.ParamInt64("nodeId")
|
||||
var isInCluster = nodeId <= 0
|
||||
|
||||
var tabbar = actionutils.NewTabbar()
|
||||
tabbar.Add("集群列表", "", "/clusters", "", false)
|
||||
if teaconst.IsPlus {
|
||||
tabbar.Add("集群看板", "", "/clusters/cluster/boards?clusterId="+clusterIdString, "chart line area", selectedTabbar == "board")
|
||||
{
|
||||
var url = "/clusters"
|
||||
if !isInCluster {
|
||||
url = "/clusters/cluster/nodes?clusterId=" + clusterIdString
|
||||
}
|
||||
tabbar.Add("", "", url, "arrow left", false)
|
||||
}
|
||||
{
|
||||
var url = "/clusters/cluster?clusterId=" + clusterIdString
|
||||
if !isInCluster {
|
||||
url = "/clusters/cluster/nodes?clusterId=" + clusterIdString
|
||||
}
|
||||
|
||||
var item = tabbar.Add(cluster.Name, "", url, "angle right", true)
|
||||
item.IsTitle = true
|
||||
}
|
||||
if teaconst.IsPlus {
|
||||
{
|
||||
var item = tabbar.Add("集群看板", "", "/clusters/cluster/boards?clusterId="+clusterIdString, "chart line area", selectedTabbar == "board")
|
||||
item.IsDisabled = !isInCluster
|
||||
}
|
||||
}
|
||||
{
|
||||
var item = tabbar.Add("节点列表", "", "/clusters/cluster/nodes?clusterId="+clusterIdString, "server", selectedTabbar == "node")
|
||||
item.IsDisabled = !isInCluster
|
||||
}
|
||||
|
||||
{
|
||||
var item = tabbar.Add("集群设置", "", "/clusters/cluster/settings?clusterId="+clusterIdString, "setting", selectedTabbar == "setting")
|
||||
item.IsDisabled = !isInCluster
|
||||
}
|
||||
{
|
||||
var item = tabbar.Add("删除集群", "", "/clusters/cluster/delete?clusterId="+clusterIdString, "trash", selectedTabbar == "delete")
|
||||
item.IsDisabled = !isInCluster
|
||||
}
|
||||
tabbar.Add("集群节点", "", "/clusters/cluster/nodes?clusterId="+clusterIdString, "server", selectedTabbar == "node")
|
||||
tabbar.Add("集群设置", "", "/clusters/cluster/settings?clusterId="+clusterIdString, "setting", selectedTabbar == "setting")
|
||||
tabbar.Add("删除集群", "", "/clusters/cluster/delete?clusterId="+clusterIdString, "trash", selectedTabbar == "delete")
|
||||
actionutils.SetTabbar(action, tabbar)
|
||||
|
||||
// 左侧菜单
|
||||
@@ -97,14 +128,39 @@ func (this *ClusterHelper) createSettingMenu(cluster *pb.NodeCluster, info *pb.F
|
||||
"isActive": selectedItem == "basic",
|
||||
"isOn": true,
|
||||
})
|
||||
|
||||
items = append(items, maps.Map{
|
||||
"name": "缓存设置",
|
||||
"name": "DNS设置",
|
||||
"url": "/clusters/cluster/settings/dns?clusterId=" + clusterId,
|
||||
"isActive": selectedItem == "dns",
|
||||
"isOn": cluster.DnsDomainId > 0 || len(cluster.DnsName) > 0,
|
||||
})
|
||||
items = append(items, maps.Map{
|
||||
"name": "健康检查",
|
||||
"url": "/clusters/cluster/settings/health?clusterId=" + clusterId,
|
||||
"isActive": selectedItem == "health",
|
||||
"isOn": info != nil && info.HealthCheckIsOn,
|
||||
})
|
||||
|
||||
items = append(items, maps.Map{
|
||||
"name": "-",
|
||||
})
|
||||
|
||||
items = append(items, maps.Map{
|
||||
"name": "网站设置",
|
||||
"url": "/clusters/cluster/settings/global-server-config?clusterId=" + clusterId,
|
||||
"isActive": selectedItem == "globalServerConfig",
|
||||
"isOn": true,
|
||||
})
|
||||
|
||||
items = append(items, maps.Map{
|
||||
"name": "缓存策略",
|
||||
"url": "/clusters/cluster/settings/cache?clusterId=" + clusterId,
|
||||
"isActive": selectedItem == "cache",
|
||||
"isOn": cluster.HttpCachePolicyId > 0,
|
||||
})
|
||||
items = append(items, maps.Map{
|
||||
"name": "WAF设置",
|
||||
"name": "WAF策略",
|
||||
"url": "/clusters/cluster/settings/waf?clusterId=" + clusterId,
|
||||
"isActive": selectedItem == "waf",
|
||||
"isOn": cluster.HttpFirewallPolicyId > 0,
|
||||
@@ -132,20 +188,6 @@ func (this *ClusterHelper) createSettingMenu(cluster *pb.NodeCluster, info *pb.F
|
||||
"isActive": false,
|
||||
})
|
||||
|
||||
items = append(items, maps.Map{
|
||||
"name": "DNS设置",
|
||||
"url": "/clusters/cluster/settings/dns?clusterId=" + clusterId,
|
||||
"isActive": selectedItem == "dns",
|
||||
"isOn": cluster.DnsDomainId > 0 || len(cluster.DnsName) > 0,
|
||||
})
|
||||
|
||||
items = append(items, maps.Map{
|
||||
"name": "健康检查",
|
||||
"url": "/clusters/cluster/settings/health?clusterId=" + clusterId,
|
||||
"isActive": selectedItem == "health",
|
||||
"isOn": info != nil && info.HealthCheckIsOn,
|
||||
})
|
||||
|
||||
items = append(items, maps.Map{
|
||||
"name": "DDoS防护",
|
||||
"url": "/clusters/cluster/settings/ddos-protection?clusterId=" + clusterId,
|
||||
@@ -153,13 +195,6 @@ func (this *ClusterHelper) createSettingMenu(cluster *pb.NodeCluster, info *pb.F
|
||||
"isOn": info != nil && info.HasDDoSProtection,
|
||||
})
|
||||
|
||||
items = append(items, maps.Map{
|
||||
"name": "服务设置",
|
||||
"url": "/clusters/cluster/settings/global-server-config?clusterId=" + clusterId,
|
||||
"isActive": selectedItem == "globalServerConfig",
|
||||
"isOn": true,
|
||||
})
|
||||
|
||||
items = append(items, maps.Map{
|
||||
"name": "-",
|
||||
})
|
||||
|
||||
52
internal/web/actions/default/clusters/createNode.go
Normal file
52
internal/web/actions/default/clusters/createNode.go
Normal file
@@ -0,0 +1,52 @@
|
||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package clusters
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/types"
|
||||
)
|
||||
|
||||
type CreateNodeAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *CreateNodeAction) Init() {
|
||||
this.Nav("", "cluster", "createNode")
|
||||
}
|
||||
|
||||
func (this *CreateNodeAction) RunGet(params struct{}) {
|
||||
// 集群总数
|
||||
totalClustersResp, err := this.RPC().NodeClusterRPC().CountAllEnabledNodeClusters(this.AdminContext(), &pb.CountAllEnabledNodeClustersRequest{})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
this.Data["totalNodeClusters"] = totalClustersResp.Count
|
||||
|
||||
// 节点总数
|
||||
totalNodesResp, err := this.RPC().NodeRPC().CountAllEnabledNodes(this.AdminContext(), &pb.CountAllEnabledNodesRequest{})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
this.Data["totalNodes"] = totalNodesResp.Count
|
||||
|
||||
// 如果只有一个默认集群,那么直接跳转到集群
|
||||
clustersResp, err := this.RPC().NodeClusterRPC().ListEnabledNodeClusters(this.AdminContext(), &pb.ListEnabledNodeClustersRequest{
|
||||
Offset: 0,
|
||||
Size: 2,
|
||||
Keyword: "",
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
if len(clustersResp.NodeClusters) == 1 {
|
||||
this.RedirectURL("/clusters/cluster/createNode?clusterId=" + types.String(clustersResp.NodeClusters[0].Id))
|
||||
return
|
||||
}
|
||||
|
||||
this.Show()
|
||||
}
|
||||
@@ -13,9 +13,11 @@ func init() {
|
||||
Helper(helpers.NewUserMustAuth(configloaders.AdminModuleCodeNode)).
|
||||
Helper(clusterutils.NewClustersHelper()).
|
||||
Data("teaMenu", "clusters").
|
||||
Data("teaSubMenu", "cluster").
|
||||
Prefix("/clusters").
|
||||
Get("", new(IndexAction)).
|
||||
GetPost("/create", new(CreateAction)).
|
||||
GetPost("/createNode", new(CreateNodeAction)).
|
||||
Post("/pin", new(PinAction)).
|
||||
Get("/nodes", new(NodesAction)).
|
||||
|
||||
|
||||
@@ -211,6 +211,8 @@ func (this *NodesAction) RunGet(params struct {
|
||||
"isInstalled": node.IsInstalled,
|
||||
"isOn": node.IsOn,
|
||||
"isUp": node.IsUp,
|
||||
"isBackup": node.IsBackupForCluster || node.IsBackupForGroup,
|
||||
"offlineDay": node.OfflineDay,
|
||||
"installStatus": maps.Map{
|
||||
"isRunning": node.InstallStatus.IsRunning,
|
||||
"isFinished": node.InstallStatus.IsFinished,
|
||||
@@ -222,9 +224,9 @@ func (this *NodesAction) RunGet(params struct {
|
||||
"updatedAt": status.UpdatedAt,
|
||||
"hostname": status.Hostname,
|
||||
"cpuUsage": status.CPUUsage,
|
||||
"cpuUsageText": numberutils.FormatFloat2(status.CPUUsage * 100) + "%",
|
||||
"cpuUsageText": numberutils.FormatFloat2(status.CPUUsage*100) + "%",
|
||||
"memUsage": status.MemoryUsage,
|
||||
"memUsageText": numberutils.FormatFloat2(status.MemoryUsage * 100) + "%",
|
||||
"memUsageText": numberutils.FormatFloat2(status.MemoryUsage*100) + "%",
|
||||
"trafficInBytes": status.TrafficInBytes,
|
||||
"trafficOutBytes": status.TrafficOutBytes,
|
||||
"load1m": numberutils.PadFloatZero(numberutils.FormatFloat2(status.Load1m), 2),
|
||||
|
||||
@@ -136,6 +136,8 @@ func (this *ClusterAction) RunGet(params struct {
|
||||
"clusterId": node.NodeClusterId,
|
||||
"isResolved": isResolved,
|
||||
"isInstalled": isInstalled,
|
||||
"isBackup": node.IsBackupForCluster || node.IsBackupForGroup,
|
||||
"isOffline": node.IsOffline,
|
||||
})
|
||||
}
|
||||
} else {
|
||||
@@ -171,6 +173,8 @@ func (this *ClusterAction) RunGet(params struct {
|
||||
"clusterId": node.NodeClusterId,
|
||||
"isResolved": isResolved,
|
||||
"isInstalled": isInstalled,
|
||||
"isBackup": node.IsBackupForCluster || node.IsBackupForGroup,
|
||||
"isOffline": node.IsOffline,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ func init() {
|
||||
Helper(helpers.NewUserMustAuth(configloaders.AdminModuleCodeDNS)).
|
||||
Helper(new(Helper)).
|
||||
Prefix("/dns").
|
||||
Data("teaSubMenu", "cluster").
|
||||
Get("", new(IndexAction)).
|
||||
GetPost("/updateClusterPopup", new(UpdateClusterPopupAction)).
|
||||
Post("/providerOptions", new(ProviderOptionsAction)).
|
||||
|
||||
@@ -13,15 +13,19 @@ import (
|
||||
adminserverutils "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/server/admin-server-utils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/iplibrary"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/lists"
|
||||
"github.com/iwind/TeaGo/types"
|
||||
stringutil "github.com/iwind/TeaGo/utils/string"
|
||||
"net"
|
||||
"time"
|
||||
)
|
||||
|
||||
const regionDenyMessage = "当前软件系统暂时不为你所在的区域提供服务。"
|
||||
|
||||
type IndexAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
@@ -36,6 +40,11 @@ func (this *IndexAction) RunGet(params struct {
|
||||
|
||||
Auth *helpers.UserShouldAuth
|
||||
}) {
|
||||
if !this.checkRegion() {
|
||||
this.WriteString(regionDenyMessage)
|
||||
return
|
||||
}
|
||||
|
||||
// 是否自动从HTTP跳转到HTTPS
|
||||
if this.Request.TLS == nil {
|
||||
httpsPort, _ := adminserverutils.ReadServerHTTPS()
|
||||
@@ -50,8 +59,11 @@ func (this *IndexAction) RunGet(params struct {
|
||||
newHost += ":" + types.String(httpsPort)
|
||||
}
|
||||
|
||||
this.RedirectURL("https://" + newHost + this.Request.RequestURI)
|
||||
return
|
||||
// 如果没有前端反向代理,则跳转
|
||||
if len(this.Request.Header.Get("X-Forwarded-For")) == 0 && len(this.Request.Header.Get("X-Real-Ip")) == 0 {
|
||||
this.RedirectURL("https://" + newHost + this.Request.RequestURI)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,6 +134,11 @@ func (this *IndexAction) RunPost(params struct {
|
||||
Auth *helpers.UserShouldAuth
|
||||
CSRF *actionutils.CSRF
|
||||
}) {
|
||||
if !this.checkRegion() {
|
||||
this.Fail(regionDenyMessage)
|
||||
return
|
||||
}
|
||||
|
||||
params.Must.
|
||||
Field("username", params.Username).
|
||||
Require("请输入用户名").
|
||||
@@ -213,3 +230,13 @@ func (this *IndexAction) RunPost(params struct {
|
||||
|
||||
this.Success()
|
||||
}
|
||||
|
||||
// 检查登录区域
|
||||
func (this *IndexAction) checkRegion() bool {
|
||||
var ip = this.RequestRemoteIP()
|
||||
var result = iplibrary.LookupIP(ip)
|
||||
if result != nil && result.IsOk() && result.CountryId() > 0 && lists.ContainsInt64([]int64{9, 10}, result.CountryId()) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
"github.com/iwind/TeaGo/types"
|
||||
"net/url"
|
||||
"regexp"
|
||||
@@ -27,6 +28,8 @@ func (this *AddOriginPopupAction) RunGet(params struct {
|
||||
}) {
|
||||
this.Data["serverType"] = params.ServerType
|
||||
|
||||
this.getOSSHook()
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
@@ -40,50 +43,93 @@ func (this *AddOriginPopupAction) RunPost(params struct {
|
||||
|
||||
Must *actions.Must
|
||||
}) {
|
||||
params.Must.
|
||||
Field("addr", params.Addr).
|
||||
Require("请输入源站地址")
|
||||
|
||||
var addr = params.Addr
|
||||
|
||||
// 是否是完整的地址
|
||||
if (params.Protocol == "http" || params.Protocol == "https") && regexp.MustCompile(`^(http|https)://`).MatchString(addr) {
|
||||
u, err := url.Parse(addr)
|
||||
if err == nil {
|
||||
addr = u.Host
|
||||
}
|
||||
ossConfig, goNext, err := this.postOSSHook(params.Protocol)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
if !goNext {
|
||||
return
|
||||
}
|
||||
|
||||
addr = regexp.MustCompile(`\s+`).ReplaceAllString(addr, "")
|
||||
var portIndex = strings.LastIndex(addr, ":")
|
||||
if portIndex < 0 {
|
||||
if params.Protocol == "http" {
|
||||
addr += ":80"
|
||||
} else if params.Protocol == "https" {
|
||||
addr += ":443"
|
||||
} else {
|
||||
this.Fail("地址中需要带有端口")
|
||||
}
|
||||
portIndex = strings.LastIndex(addr, ":")
|
||||
// 初始化
|
||||
var pbAddr = &pb.NetworkAddress{
|
||||
Protocol: params.Protocol,
|
||||
}
|
||||
var host = addr[:portIndex]
|
||||
var port = addr[portIndex+1:]
|
||||
var addrConfig = &serverconfigs.NetworkAddressConfig{
|
||||
Protocol: serverconfigs.Protocol(params.Protocol),
|
||||
}
|
||||
var ossJSON []byte
|
||||
|
||||
// 检查端口号
|
||||
if port == "0" {
|
||||
this.Fail("端口号不能为0")
|
||||
}
|
||||
if !configutils.HasVariables(port) {
|
||||
// 必须是整数
|
||||
if !regexp.MustCompile(`^\d+$`).MatchString(port) {
|
||||
this.Fail("端口号只能为整数")
|
||||
if ossConfig != nil { // OSS
|
||||
ossJSON, err = json.Marshal(ossConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var portInt = types.Int(port)
|
||||
if portInt == 0 {
|
||||
err = ossConfig.Init()
|
||||
if err != nil {
|
||||
this.Fail("校验OSS配置时出错:" + err.Error())
|
||||
return
|
||||
}
|
||||
} else { // 普通源站
|
||||
params.Must.
|
||||
Field("addr", params.Addr).
|
||||
Require("请输入源站地址")
|
||||
|
||||
var addr = params.Addr
|
||||
|
||||
// 是否是完整的地址
|
||||
if (params.Protocol == "http" || params.Protocol == "https") && regexp.MustCompile(`^(http|https)://`).MatchString(addr) {
|
||||
u, err := url.Parse(addr)
|
||||
if err == nil {
|
||||
addr = u.Host
|
||||
}
|
||||
}
|
||||
|
||||
addr = regexp.MustCompile(`\s+`).ReplaceAllString(addr, "")
|
||||
var portIndex = strings.LastIndex(addr, ":")
|
||||
if portIndex < 0 {
|
||||
if params.Protocol == "http" {
|
||||
addr += ":80"
|
||||
} else if params.Protocol == "https" {
|
||||
addr += ":443"
|
||||
} else {
|
||||
this.Fail("地址中需要带有端口")
|
||||
}
|
||||
portIndex = strings.LastIndex(addr, ":")
|
||||
}
|
||||
var host = addr[:portIndex]
|
||||
var port = addr[portIndex+1:]
|
||||
|
||||
// 检查端口号
|
||||
if port == "0" {
|
||||
this.Fail("端口号不能为0")
|
||||
}
|
||||
if portInt > 65535 {
|
||||
this.Fail("端口号不能大于65535")
|
||||
if !configutils.HasVariables(port) {
|
||||
// 必须是整数
|
||||
if !regexp.MustCompile(`^\d+$`).MatchString(port) {
|
||||
this.Fail("端口号只能为整数")
|
||||
}
|
||||
var portInt = types.Int(port)
|
||||
if portInt == 0 {
|
||||
this.Fail("端口号不能为0")
|
||||
}
|
||||
if portInt > 65535 {
|
||||
this.Fail("端口号不能大于65535")
|
||||
}
|
||||
}
|
||||
|
||||
pbAddr = &pb.NetworkAddress{
|
||||
Protocol: params.Protocol,
|
||||
Host: host,
|
||||
PortRange: port,
|
||||
}
|
||||
|
||||
addrConfig = &serverconfigs.NetworkAddressConfig{
|
||||
Protocol: serverconfigs.Protocol(params.Protocol),
|
||||
Host: host,
|
||||
PortRange: port,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,12 +149,9 @@ func (this *AddOriginPopupAction) RunPost(params struct {
|
||||
}
|
||||
|
||||
resp, err := this.RPC().OriginRPC().CreateOrigin(this.AdminContext(), &pb.CreateOriginRequest{
|
||||
Name: "",
|
||||
Addr: &pb.NetworkAddress{
|
||||
Protocol: params.Protocol,
|
||||
Host: host,
|
||||
PortRange: port,
|
||||
},
|
||||
Name: "",
|
||||
Addr: pbAddr,
|
||||
OssJSON: ossJSON,
|
||||
Description: "",
|
||||
Weight: 10,
|
||||
IsOn: true,
|
||||
@@ -124,14 +167,16 @@ func (this *AddOriginPopupAction) RunPost(params struct {
|
||||
var origin = &serverconfigs.OriginConfig{
|
||||
Id: resp.OriginId,
|
||||
IsOn: true,
|
||||
Addr: &serverconfigs.NetworkAddressConfig{
|
||||
Protocol: serverconfigs.Protocol(params.Protocol),
|
||||
Host: host,
|
||||
PortRange: port,
|
||||
},
|
||||
Addr: addrConfig,
|
||||
OSS: ossConfig,
|
||||
}
|
||||
|
||||
this.Data["origin"] = origin
|
||||
this.Data["origin"] = maps.Map{
|
||||
"id": resp.OriginId,
|
||||
"isOn": true,
|
||||
"addr": addrConfig,
|
||||
"addrSummary": origin.AddrSummary(),
|
||||
}
|
||||
|
||||
// 创建日志
|
||||
defer this.CreateLog(oplogs.LevelInfo, "创建源站 %d", resp.OriginId)
|
||||
|
||||
20
internal/web/actions/default/servers/addOriginPopup_ext.go
Normal file
20
internal/web/actions/default/servers/addOriginPopup_ext.go
Normal file
@@ -0,0 +1,20 @@
|
||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
//go:build !plus
|
||||
|
||||
package servers
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/ossconfigs"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
func (this *AddOriginPopupAction) getOSSHook() {
|
||||
this.Data["ossTypes"] = []maps.Map{}
|
||||
this.Data["ossBucketParams"] = []maps.Map{}
|
||||
this.Data["ossForm"] = ""
|
||||
}
|
||||
|
||||
func (this *AddOriginPopupAction) postOSSHook(protocol string) (config *ossconfigs.OSSConfig, goNext bool, err error) {
|
||||
goNext = true
|
||||
return
|
||||
}
|
||||
@@ -238,7 +238,8 @@ func (this *CreateAction) RunPost(params struct {
|
||||
}
|
||||
|
||||
sslPolicyIdResp, err := this.RPC().SSLPolicyRPC().CreateSSLPolicy(this.AdminContext(), &pb.CreateSSLPolicyRequest{
|
||||
Http2Enabled: false, // 默认值
|
||||
Http2Enabled: false, // 默认值
|
||||
Http3Enabled: false,
|
||||
MinVersion: "TLS 1.1", // 默认值
|
||||
SslCertsJSON: certRefsJSON,
|
||||
HstsJSON: nil,
|
||||
@@ -387,7 +388,7 @@ func (this *CreateAction) RunPost(params struct {
|
||||
AdminId: this.AdminId(),
|
||||
Type: params.ServerType,
|
||||
Name: params.Name,
|
||||
ServerNamesJSON: params.ServerNames,
|
||||
ServerNamesJSON: params.ServerNames,
|
||||
Description: params.Description,
|
||||
NodeClusterId: clusterId,
|
||||
IncludeNodesJSON: includeNodesJSON,
|
||||
|
||||
@@ -42,7 +42,7 @@ func (this *CreatePopupAction) RunPost(params struct {
|
||||
}
|
||||
|
||||
// 创建日志
|
||||
defer this.CreateLog(oplogs.LevelInfo, "创建服务分组 %d", createResp.ServerGroupId)
|
||||
defer this.CreateLog(oplogs.LevelInfo, "创建网站分组 %d", createResp.ServerGroupId)
|
||||
|
||||
this.Success()
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ func (this *DeleteAction) RunPost(params struct {
|
||||
GroupId int64
|
||||
}) {
|
||||
// 创建日志
|
||||
defer this.CreateLog(oplogs.LevelInfo, "删除代理服务分组 %d", params.GroupId)
|
||||
defer this.CreateLog(oplogs.LevelInfo, "删除代理网站分组 %d", params.GroupId)
|
||||
|
||||
// 检查是否正在使用
|
||||
countResp, err := this.RPC().ServerRPC().CountAllEnabledServersWithServerGroupId(this.AdminContext(), &pb.CountAllEnabledServersWithServerGroupIdRequest{ServerGroupId: params.GroupId})
|
||||
|
||||
@@ -59,7 +59,8 @@ func (this *IndexAction) RunGet(params struct {
|
||||
var m = maps.Map{
|
||||
"id": originConfig.Id,
|
||||
"weight": originConfig.Weight,
|
||||
"addr": originConfig.Addr.Protocol.String() + "://" + originConfig.Addr.Host + ":" + originConfig.Addr.PortRange,
|
||||
"addr": originConfig.AddrSummary(),
|
||||
"isOSS": originConfig.IsOSS(),
|
||||
"name": originConfig.Name,
|
||||
"isOn": originConfig.IsOn,
|
||||
"domains": originConfig.Domains,
|
||||
@@ -76,7 +77,8 @@ func (this *IndexAction) RunGet(params struct {
|
||||
var m = maps.Map{
|
||||
"id": originConfig.Id,
|
||||
"weight": originConfig.Weight,
|
||||
"addr": originConfig.Addr.Protocol.String() + "://" + originConfig.Addr.Host + ":" + originConfig.Addr.PortRange,
|
||||
"addr": originConfig.AddrSummary(),
|
||||
"isOSS": originConfig.IsOSS(),
|
||||
"name": originConfig.Name,
|
||||
"isOn": originConfig.IsOn,
|
||||
"domains": originConfig.Domains,
|
||||
|
||||
@@ -59,7 +59,8 @@ func (this *IndexAction) RunGet(params struct {
|
||||
m := maps.Map{
|
||||
"id": originConfig.Id,
|
||||
"weight": originConfig.Weight,
|
||||
"addr": originConfig.Addr.Protocol.String() + "://" + originConfig.Addr.Host + ":" + originConfig.Addr.PortRange,
|
||||
"addr": originConfig.AddrSummary(),
|
||||
"isOSS": originConfig.IsOSS(),
|
||||
"name": originConfig.Name,
|
||||
"isOn": originConfig.IsOn,
|
||||
"domains": originConfig.Domains,
|
||||
@@ -76,7 +77,8 @@ func (this *IndexAction) RunGet(params struct {
|
||||
m := maps.Map{
|
||||
"id": originConfig.Id,
|
||||
"weight": originConfig.Weight,
|
||||
"addr": originConfig.Addr.Protocol.String() + "://" + originConfig.Addr.Host + ":" + originConfig.Addr.PortRange,
|
||||
"addr": originConfig.AddrSummary(),
|
||||
"isOSS": originConfig.IsOSS(),
|
||||
"name": originConfig.Name,
|
||||
"isOn": originConfig.IsOn,
|
||||
"domains": originConfig.Domains,
|
||||
|
||||
@@ -59,7 +59,8 @@ func (this *IndexAction) RunGet(params struct {
|
||||
var m = maps.Map{
|
||||
"id": originConfig.Id,
|
||||
"weight": originConfig.Weight,
|
||||
"addr": originConfig.Addr.Protocol.String() + "://" + originConfig.Addr.Host + ":" + originConfig.Addr.PortRange,
|
||||
"addr": originConfig.AddrSummary(),
|
||||
"isOSS": originConfig.IsOSS(),
|
||||
"name": originConfig.Name,
|
||||
"isOn": originConfig.IsOn,
|
||||
"domains": originConfig.Domains,
|
||||
@@ -76,7 +77,8 @@ func (this *IndexAction) RunGet(params struct {
|
||||
var m = maps.Map{
|
||||
"id": originConfig.Id,
|
||||
"weight": originConfig.Weight,
|
||||
"addr": originConfig.Addr.Protocol.String() + "://" + originConfig.Addr.Host + ":" + originConfig.Addr.PortRange,
|
||||
"addr": originConfig.AddrSummary(),
|
||||
"isOSS": originConfig.IsOSS(),
|
||||
"name": originConfig.Name,
|
||||
"isOn": originConfig.IsOn,
|
||||
"domains": originConfig.Domains,
|
||||
|
||||
@@ -41,7 +41,7 @@ func (this *UpdateAction) RunPost(params struct {
|
||||
Must *actions.Must
|
||||
}) {
|
||||
// 创建日志
|
||||
defer this.CreateLog(oplogs.LevelInfo, "修改代理服务分组 %d", params.GroupId)
|
||||
defer this.CreateLog(oplogs.LevelInfo, "修改网站分组 %d", params.GroupId)
|
||||
|
||||
params.Must.
|
||||
Field("name", params.Name).
|
||||
|
||||
@@ -14,7 +14,7 @@ func (this *SortAction) RunPost(params struct {
|
||||
GroupIds []int64
|
||||
}) {
|
||||
// 创建日志
|
||||
defer this.CreateLog(oplogs.LevelInfo, "修改服务分组排序")
|
||||
defer this.CreateLog(oplogs.LevelInfo, "修改网站分组排序")
|
||||
|
||||
_, err := this.RPC().ServerGroupRPC().UpdateServerGroupOrders(this.AdminContext(), &pb.UpdateServerGroupOrdersRequest{ServerGroupIds: params.GroupIds})
|
||||
if err != nil {
|
||||
|
||||
@@ -21,6 +21,7 @@ func (this *IndexAction) Init() {
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct {
|
||||
Ip string
|
||||
Keyword string
|
||||
GlobalOnly bool
|
||||
Unread bool
|
||||
@@ -40,6 +41,7 @@ func (this *IndexAction) RunGet(params struct {
|
||||
Unread: true,
|
||||
EventLevel: params.EventLevel,
|
||||
ListType: params.ListType,
|
||||
Ip: params.Ip,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
@@ -53,6 +55,7 @@ func (this *IndexAction) RunGet(params struct {
|
||||
Unread: params.Unread,
|
||||
EventLevel: params.EventLevel,
|
||||
ListType: params.ListType,
|
||||
Ip: params.Ip,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
@@ -68,6 +71,7 @@ func (this *IndexAction) RunGet(params struct {
|
||||
Unread: params.Unread,
|
||||
EventLevel: params.EventLevel,
|
||||
ListType: params.ListType,
|
||||
Ip: params.Ip,
|
||||
Offset: page.Offset,
|
||||
Size: page.Size,
|
||||
})
|
||||
|
||||
@@ -45,14 +45,14 @@ func (this *CreateDeletePopupAction) RunPost(params struct {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
policyConfig := &shared.HTTPHeaderPolicy{}
|
||||
var policyConfig = &shared.HTTPHeaderPolicy{}
|
||||
err = json.Unmarshal(policyConfigResp.HttpHeaderPolicyJSON, policyConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
deleteHeaders := policyConfig.DeleteHeaders
|
||||
var deleteHeaders = policyConfig.DeleteHeaders
|
||||
deleteHeaders = append(deleteHeaders, params.Name)
|
||||
_, err = this.RPC().HTTPHeaderPolicyRPC().UpdateHTTPHeaderPolicyDeletingHeaders(this.AdminContext(), &pb.UpdateHTTPHeaderPolicyDeletingHeadersRequest{
|
||||
HttpHeaderPolicyId: params.HeaderPolicyId,
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package headers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
)
|
||||
|
||||
type CreateNonStandardPopupAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *CreateNonStandardPopupAction) Init() {
|
||||
this.Nav("", "", "")
|
||||
}
|
||||
|
||||
func (this *CreateNonStandardPopupAction) RunGet(params struct {
|
||||
HeaderPolicyId int64
|
||||
Type string
|
||||
}) {
|
||||
this.Data["headerPolicyId"] = params.HeaderPolicyId
|
||||
this.Data["type"] = params.Type
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *CreateNonStandardPopupAction) RunPost(params struct {
|
||||
HeaderPolicyId int64
|
||||
Name string
|
||||
|
||||
Must *actions.Must
|
||||
}) {
|
||||
// 日志
|
||||
defer this.CreateLog(oplogs.LevelInfo, "添加非标的Header HeaderPolicyId: %d, Name: %s", params.HeaderPolicyId, params.Name)
|
||||
|
||||
params.Must.
|
||||
Field("name", params.Name).
|
||||
Require("名称不能为空")
|
||||
|
||||
policyConfigResp, err := this.RPC().HTTPHeaderPolicyRPC().FindEnabledHTTPHeaderPolicyConfig(this.AdminContext(), &pb.FindEnabledHTTPHeaderPolicyConfigRequest{HttpHeaderPolicyId: params.HeaderPolicyId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var policyConfig = &shared.HTTPHeaderPolicy{}
|
||||
err = json.Unmarshal(policyConfigResp.HttpHeaderPolicyJSON, policyConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
var nonStandardHeaders = policyConfig.NonStandardHeaders
|
||||
nonStandardHeaders = append(nonStandardHeaders, params.Name)
|
||||
_, err = this.RPC().HTTPHeaderPolicyRPC().UpdateHTTPHeaderPolicyNonStandardHeaders(this.AdminContext(), &pb.UpdateHTTPHeaderPolicyNonStandardHeadersRequest{
|
||||
HttpHeaderPolicyId: params.HeaderPolicyId,
|
||||
HeaderNames: nonStandardHeaders,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
@@ -17,22 +17,22 @@ func (this *DeleteDeletingHeaderAction) RunPost(params struct {
|
||||
HeaderName string
|
||||
}) {
|
||||
// 日志
|
||||
defer this.CreateLog(oplogs.LevelInfo, "删除需要删除的请求Header,HeaderPolicyId:%d, HeaderName:%s", params.HeaderPolicyId, params.HeaderName)
|
||||
defer this.CreateLog(oplogs.LevelInfo, "删除需要删除的Header,HeaderPolicyId:%d, HeaderName:%s", params.HeaderPolicyId, params.HeaderName)
|
||||
|
||||
policyConfigResp, err := this.RPC().HTTPHeaderPolicyRPC().FindEnabledHTTPHeaderPolicyConfig(this.AdminContext(), &pb.FindEnabledHTTPHeaderPolicyConfigRequest{HttpHeaderPolicyId: params.HeaderPolicyId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
policyConfigJSON := policyConfigResp.HttpHeaderPolicyJSON
|
||||
policyConfig := &shared.HTTPHeaderPolicy{}
|
||||
var policyConfigJSON = policyConfigResp.HttpHeaderPolicyJSON
|
||||
var policyConfig = &shared.HTTPHeaderPolicy{}
|
||||
err = json.Unmarshal(policyConfigJSON, policyConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
headerNames := []string{}
|
||||
var headerNames = []string{}
|
||||
for _, h := range policyConfig.DeleteHeaders {
|
||||
if h == params.HeaderName {
|
||||
continue
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package headers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||
)
|
||||
|
||||
type DeleteNonStandardHeaderAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *DeleteNonStandardHeaderAction) RunPost(params struct {
|
||||
HeaderPolicyId int64
|
||||
HeaderName string
|
||||
}) {
|
||||
// 日志
|
||||
defer this.CreateLog(oplogs.LevelInfo, "删除需要非标的Header,HeaderPolicyId:%d, HeaderName:%s", params.HeaderPolicyId, params.HeaderName)
|
||||
|
||||
policyConfigResp, err := this.RPC().HTTPHeaderPolicyRPC().FindEnabledHTTPHeaderPolicyConfig(this.AdminContext(), &pb.FindEnabledHTTPHeaderPolicyConfigRequest{HttpHeaderPolicyId: params.HeaderPolicyId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var policyConfigJSON = policyConfigResp.HttpHeaderPolicyJSON
|
||||
var policyConfig = &shared.HTTPHeaderPolicy{}
|
||||
err = json.Unmarshal(policyConfigJSON, policyConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
var headerNames = []string{}
|
||||
for _, h := range policyConfig.NonStandardHeaders {
|
||||
if h == params.HeaderName {
|
||||
continue
|
||||
}
|
||||
headerNames = append(headerNames, h)
|
||||
}
|
||||
_, err = this.RPC().HTTPHeaderPolicyRPC().UpdateHTTPHeaderPolicyNonStandardHeaders(this.AdminContext(), &pb.UpdateHTTPHeaderPolicyNonStandardHeadersRequest{
|
||||
HttpHeaderPolicyId: params.HeaderPolicyId,
|
||||
HeaderNames: headerNames,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
@@ -18,6 +18,8 @@ func init() {
|
||||
GetPost("/updateSetPopup", new(UpdateSetPopupAction)).
|
||||
GetPost("/createDeletePopup", new(CreateDeletePopupAction)).
|
||||
Post("/deleteDeletingHeader", new(DeleteDeletingHeaderAction)).
|
||||
GetPost("/createNonStandardPopup", new(CreateNonStandardPopupAction)).
|
||||
Post("/deleteNonStandardHeader", new(DeleteNonStandardHeaderAction)).
|
||||
Post("/delete", new(DeleteAction)).
|
||||
GetPost("/updateCORSPopup", new(UpdateCORSPopupAction)).
|
||||
EndAll()
|
||||
|
||||
@@ -49,7 +49,7 @@ func (this *UpdateCORSPopupAction) RunPost(params struct {
|
||||
Must *actions.Must
|
||||
CSRF *actionutils.CSRF
|
||||
}) {
|
||||
var config = &shared.HTTPCORSHeaderConfig{}
|
||||
var config = shared.NewHTTPCORSHeaderConfig()
|
||||
err := json.Unmarshal(params.CorsJSON, config)
|
||||
if err != nil {
|
||||
this.Fail("配置校验失败:" + err.Error())
|
||||
|
||||
@@ -85,11 +85,23 @@ func (this *IndexAction) RunGet(params struct {
|
||||
}
|
||||
}
|
||||
|
||||
// 当前集群是否支持HTTP/3
|
||||
if server.NodeCluster == nil {
|
||||
this.ErrorPage(errors.New("no node cluster for the server"))
|
||||
return
|
||||
}
|
||||
supportsHTTP3, err := this.checkSupportsHTTP3(server.NodeCluster.Id)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Data["serverType"] = server.Type
|
||||
this.Data["httpsConfig"] = maps.Map{
|
||||
"isOn": httpsConfig.IsOn,
|
||||
"addresses": httpsConfig.Listen,
|
||||
"sslPolicy": sslPolicy,
|
||||
"isOn": httpsConfig.IsOn,
|
||||
"addresses": httpsConfig.Listen,
|
||||
"sslPolicy": sslPolicy,
|
||||
"supportsHTTP3": supportsHTTP3,
|
||||
}
|
||||
|
||||
this.Show()
|
||||
@@ -175,6 +187,7 @@ func (this *IndexAction) RunPost(params struct {
|
||||
_, err := this.RPC().SSLPolicyRPC().UpdateSSLPolicy(this.AdminContext(), &pb.UpdateSSLPolicyRequest{
|
||||
SslPolicyId: sslPolicyId,
|
||||
Http2Enabled: sslPolicy.HTTP2Enabled,
|
||||
Http3Enabled: sslPolicy.HTTP3Enabled,
|
||||
MinVersion: sslPolicy.MinVersion,
|
||||
SslCertsJSON: certsJSON,
|
||||
HstsJSON: hstsJSON,
|
||||
@@ -191,6 +204,7 @@ func (this *IndexAction) RunPost(params struct {
|
||||
} else {
|
||||
resp, err := this.RPC().SSLPolicyRPC().CreateSSLPolicy(this.AdminContext(), &pb.CreateSSLPolicyRequest{
|
||||
Http2Enabled: sslPolicy.HTTP2Enabled,
|
||||
Http3Enabled: sslPolicy.HTTP3Enabled,
|
||||
MinVersion: sslPolicy.MinVersion,
|
||||
SslCertsJSON: certsJSON,
|
||||
HstsJSON: hstsJSON,
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
//go:build !plus
|
||||
|
||||
package https
|
||||
|
||||
func (this *IndexAction) checkSupportsHTTP3(clusterId int64) (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
@@ -38,6 +38,7 @@ func (this *IndexAction) RunGet(params struct {
|
||||
AllowEmpty: true,
|
||||
AllowSameDomain: true,
|
||||
AllowDomains: nil,
|
||||
CheckOrigin: true,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,8 @@ func (this *IndexAction) RunGet(params struct {
|
||||
var m = maps.Map{
|
||||
"id": originConfig.Id,
|
||||
"weight": originConfig.Weight,
|
||||
"addr": originConfig.Addr.Protocol.String() + "://" + originConfig.Addr.Host + ":" + originConfig.Addr.PortRange,
|
||||
"addr": originConfig.AddrSummary(),
|
||||
"isOSS": originConfig.IsOSS(),
|
||||
"name": originConfig.Name,
|
||||
"isOn": originConfig.IsOn,
|
||||
"domains": originConfig.Domains,
|
||||
@@ -77,7 +78,8 @@ func (this *IndexAction) RunGet(params struct {
|
||||
var m = maps.Map{
|
||||
"id": originConfig.Id,
|
||||
"weight": originConfig.Weight,
|
||||
"addr": originConfig.Addr.Protocol.String() + "://" + originConfig.Addr.Host + ":" + originConfig.Addr.PortRange,
|
||||
"addr": originConfig.AddrSummary(),
|
||||
"isOSS": originConfig.IsOSS(),
|
||||
"name": originConfig.Name,
|
||||
"isOn": originConfig.IsOn,
|
||||
"domains": originConfig.Domains,
|
||||
|
||||
@@ -47,6 +47,9 @@ func (this *AddPopupAction) RunGet(params struct {
|
||||
// 是否为HTTP
|
||||
this.Data["isHTTP"] = serverType == "httpProxy" || serverType == "httpWeb"
|
||||
|
||||
// OSS
|
||||
this.getOSSHook()
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
@@ -76,104 +79,142 @@ func (this *AddPopupAction) RunPost(params struct {
|
||||
|
||||
Must *actions.Must
|
||||
}) {
|
||||
params.Must.
|
||||
Field("addr", params.Addr).
|
||||
Require("请输入源站地址")
|
||||
|
||||
var addr = params.Addr
|
||||
|
||||
// 是否是完整的地址
|
||||
if (params.Protocol == "http" || params.Protocol == "https") && regexp.MustCompile(`^(http|https)://`).MatchString(addr) {
|
||||
u, err := url.Parse(addr)
|
||||
if err == nil {
|
||||
addr = u.Host
|
||||
}
|
||||
}
|
||||
|
||||
addr = strings.ReplaceAll(addr, ":", ":")
|
||||
addr = regexp.MustCompile(`\s+`).ReplaceAllString(addr, "")
|
||||
var portIndex = strings.LastIndex(addr, ":")
|
||||
if portIndex < 0 {
|
||||
if params.Protocol == "http" {
|
||||
addr += ":80"
|
||||
} else if params.Protocol == "https" {
|
||||
addr += ":443"
|
||||
} else {
|
||||
this.FailField("addr", "源站地址中需要带有端口")
|
||||
}
|
||||
portIndex = strings.LastIndex(addr, ":")
|
||||
}
|
||||
var host = addr[:portIndex]
|
||||
var port = addr[portIndex+1:]
|
||||
|
||||
// 检查端口号
|
||||
if port == "0" {
|
||||
this.FailField("addr", "源站端口号不能为0")
|
||||
}
|
||||
if !configutils.HasVariables(port) {
|
||||
// 必须是整数
|
||||
if !regexp.MustCompile(`^\d+$`).MatchString(port) {
|
||||
this.FailField("addr", "源站端口号只能为整数")
|
||||
}
|
||||
var portInt = types.Int(port)
|
||||
if portInt == 0 {
|
||||
this.FailField("addr", "源站端口号不能为0")
|
||||
}
|
||||
if portInt > 65535 {
|
||||
this.FailField("addr", "源站端口号不能大于65535")
|
||||
}
|
||||
}
|
||||
|
||||
connTimeoutJSON, err := (&shared.TimeDuration{
|
||||
Count: int64(params.ConnTimeout),
|
||||
Unit: shared.TimeDurationUnitSecond,
|
||||
}).AsJSON()
|
||||
ossConfig, goNext, err := this.postOSSHook(params.Protocol)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
readTimeoutJSON, err := (&shared.TimeDuration{
|
||||
Count: int64(params.ReadTimeout),
|
||||
Unit: shared.TimeDurationUnitSecond,
|
||||
}).AsJSON()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
if !goNext {
|
||||
return
|
||||
}
|
||||
|
||||
idleTimeoutJSON, err := (&shared.TimeDuration{
|
||||
Count: int64(params.IdleTimeout),
|
||||
Unit: shared.TimeDurationUnitSecond,
|
||||
}).AsJSON()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
// 初始化
|
||||
var pbAddr = &pb.NetworkAddress{
|
||||
Protocol: params.Protocol,
|
||||
}
|
||||
var connTimeoutJSON []byte
|
||||
var readTimeoutJSON []byte
|
||||
var idleTimeoutJSON []byte
|
||||
var certRefJSON []byte
|
||||
|
||||
// 证书
|
||||
var certIds = []int64{}
|
||||
if len(params.CertIdsJSON) > 0 {
|
||||
err = json.Unmarshal(params.CertIdsJSON, &certIds)
|
||||
var ossJSON []byte = nil
|
||||
if ossConfig != nil { // OSS
|
||||
ossJSON, err = json.Marshal(ossConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
var certRefJSON []byte
|
||||
if len(certIds) > 0 {
|
||||
var certId = certIds[0]
|
||||
if certId > 0 {
|
||||
var certRef = &sslconfigs.SSLCertRef{
|
||||
IsOn: true,
|
||||
CertId: certId,
|
||||
err = ossConfig.Init()
|
||||
if err != nil {
|
||||
this.Fail("校验OSS配置时出错:" + err.Error())
|
||||
return
|
||||
}
|
||||
} else { // 普通源站
|
||||
params.Must.
|
||||
Field("addr", params.Addr).
|
||||
Require("请输入源站地址")
|
||||
|
||||
var addr = params.Addr
|
||||
|
||||
// 是否是完整的地址
|
||||
if (params.Protocol == "http" || params.Protocol == "https") && regexp.MustCompile(`^(http|https)://`).MatchString(addr) {
|
||||
u, err := url.Parse(addr)
|
||||
if err == nil {
|
||||
addr = u.Host
|
||||
}
|
||||
certRefJSON, err = json.Marshal(certRef)
|
||||
}
|
||||
|
||||
addr = strings.ReplaceAll(addr, ":", ":")
|
||||
addr = regexp.MustCompile(`\s+`).ReplaceAllString(addr, "")
|
||||
var portIndex = strings.LastIndex(addr, ":")
|
||||
if portIndex < 0 {
|
||||
if params.Protocol == "http" {
|
||||
addr += ":80"
|
||||
} else if params.Protocol == "https" {
|
||||
addr += ":443"
|
||||
} else {
|
||||
this.FailField("addr", "源站地址中需要带有端口")
|
||||
}
|
||||
portIndex = strings.LastIndex(addr, ":")
|
||||
}
|
||||
var host = addr[:portIndex]
|
||||
var port = addr[portIndex+1:]
|
||||
|
||||
// 检查端口号
|
||||
if port == "0" {
|
||||
this.FailField("addr", "源站端口号不能为0")
|
||||
}
|
||||
if !configutils.HasVariables(port) {
|
||||
// 必须是整数
|
||||
if !regexp.MustCompile(`^\d+$`).MatchString(port) {
|
||||
this.FailField("addr", "源站端口号只能为整数")
|
||||
}
|
||||
var portInt = types.Int(port)
|
||||
if portInt == 0 {
|
||||
this.FailField("addr", "源站端口号不能为0")
|
||||
}
|
||||
if portInt > 65535 {
|
||||
this.FailField("addr", "源站端口号不能大于65535")
|
||||
}
|
||||
}
|
||||
|
||||
connTimeoutJSON, err = (&shared.TimeDuration{
|
||||
Count: int64(params.ConnTimeout),
|
||||
Unit: shared.TimeDurationUnitSecond,
|
||||
}).AsJSON()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
readTimeoutJSON, err = (&shared.TimeDuration{
|
||||
Count: int64(params.ReadTimeout),
|
||||
Unit: shared.TimeDurationUnitSecond,
|
||||
}).AsJSON()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
idleTimeoutJSON, err = (&shared.TimeDuration{
|
||||
Count: int64(params.IdleTimeout),
|
||||
Unit: shared.TimeDurationUnitSecond,
|
||||
}).AsJSON()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
// 证书
|
||||
var certIds = []int64{}
|
||||
if len(params.CertIdsJSON) > 0 {
|
||||
err = json.Unmarshal(params.CertIdsJSON, &certIds)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if len(certIds) > 0 {
|
||||
var certId = certIds[0]
|
||||
if certId > 0 {
|
||||
var certRef = &sslconfigs.SSLCertRef{
|
||||
IsOn: true,
|
||||
CertId: certId,
|
||||
}
|
||||
certRefJSON, err = json.Marshal(certRef)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pbAddr = &pb.NetworkAddress{
|
||||
Protocol: params.Protocol,
|
||||
Host: host,
|
||||
PortRange: port,
|
||||
}
|
||||
}
|
||||
|
||||
// 专属域名
|
||||
@@ -192,12 +233,9 @@ func (this *AddPopupAction) RunPost(params struct {
|
||||
}
|
||||
|
||||
createResp, err := this.RPC().OriginRPC().CreateOrigin(this.AdminContext(), &pb.CreateOriginRequest{
|
||||
Name: params.Name,
|
||||
Addr: &pb.NetworkAddress{
|
||||
Protocol: params.Protocol,
|
||||
Host: host,
|
||||
PortRange: port,
|
||||
},
|
||||
Name: params.Name,
|
||||
Addr: pbAddr,
|
||||
OssJSON: ossJSON,
|
||||
Description: params.Description,
|
||||
Weight: params.Weight,
|
||||
IsOn: params.IsOn,
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
//go:build !plus
|
||||
|
||||
package origins
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/ossconfigs"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
func (this *AddPopupAction) getOSSHook() {
|
||||
this.Data["ossTypes"] = []maps.Map{}
|
||||
this.Data["ossBucketParams"] = []maps.Map{}
|
||||
this.Data["ossForm"] = ""
|
||||
}
|
||||
|
||||
func (this *AddPopupAction) postOSSHook(protocol string) (config *ossconfigs.OSSConfig, goNext bool, err error) {
|
||||
goNext = true
|
||||
return
|
||||
}
|
||||
@@ -94,10 +94,14 @@ func (this *UpdatePopupAction) RunGet(params struct {
|
||||
config.Cert.KeyData = nil
|
||||
}
|
||||
|
||||
var addr = ""
|
||||
if len(config.Addr.Host) > 0 && len(config.Addr.PortRange) > 0 {
|
||||
addr = config.Addr.Host + ":" + config.Addr.PortRange
|
||||
}
|
||||
this.Data["origin"] = maps.Map{
|
||||
"id": config.Id,
|
||||
"protocol": config.Addr.Protocol,
|
||||
"addr": config.Addr.Host + ":" + config.Addr.PortRange,
|
||||
"addr": addr,
|
||||
"weight": config.Weight,
|
||||
"name": config.Name,
|
||||
"description": config.Description,
|
||||
@@ -111,8 +115,12 @@ func (this *UpdatePopupAction) RunGet(params struct {
|
||||
"domains": config.Domains,
|
||||
"host": config.RequestHost,
|
||||
"followPort": config.FollowPort,
|
||||
"oss": config.OSS,
|
||||
}
|
||||
|
||||
// OSS
|
||||
this.getOSSHook()
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
@@ -143,103 +151,144 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
||||
|
||||
Must *actions.Must
|
||||
}) {
|
||||
params.Must.
|
||||
Field("addr", params.Addr).
|
||||
Require("请输入源站地址")
|
||||
|
||||
var addr = params.Addr
|
||||
|
||||
// 是否是完整的地址
|
||||
if (params.Protocol == "http" || params.Protocol == "https") && regexp.MustCompile(`^(http|https)://`).MatchString(addr) {
|
||||
u, err := url.Parse(addr)
|
||||
if err == nil {
|
||||
addr = u.Host
|
||||
}
|
||||
}
|
||||
|
||||
addr = strings.ReplaceAll(addr, ":", ":")
|
||||
addr = regexp.MustCompile(`\s+`).ReplaceAllString(addr, "")
|
||||
portIndex := strings.LastIndex(addr, ":")
|
||||
if portIndex < 0 {
|
||||
if params.Protocol == "http" {
|
||||
addr += ":80"
|
||||
} else if params.Protocol == "https" {
|
||||
addr += ":443"
|
||||
} else {
|
||||
this.FailField("addr", "源站地址中需要带有端口")
|
||||
}
|
||||
portIndex = strings.LastIndex(addr, ":")
|
||||
}
|
||||
var host = addr[:portIndex]
|
||||
var port = addr[portIndex+1:]
|
||||
// 检查端口号
|
||||
if port == "0" {
|
||||
this.FailField("addr", "源站端口号不能为0")
|
||||
}
|
||||
if !configutils.HasVariables(port) {
|
||||
// 必须是整数
|
||||
if !regexp.MustCompile(`^\d+$`).MatchString(port) {
|
||||
this.FailField("addr", "源站端口号只能为整数")
|
||||
}
|
||||
var portInt = types.Int(port)
|
||||
if portInt == 0 {
|
||||
this.FailField("addr", "源站端口号不能为0")
|
||||
}
|
||||
if portInt > 65535 {
|
||||
this.FailField("addr", "源站端口号不能大于65535")
|
||||
}
|
||||
}
|
||||
|
||||
connTimeoutJSON, err := (&shared.TimeDuration{
|
||||
Count: int64(params.ConnTimeout),
|
||||
Unit: shared.TimeDurationUnitSecond,
|
||||
}).AsJSON()
|
||||
ossConfig, goNext, err := this.postOSSHook(params.Protocol)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
readTimeoutJSON, err := (&shared.TimeDuration{
|
||||
Count: int64(params.ReadTimeout),
|
||||
Unit: shared.TimeDurationUnitSecond,
|
||||
}).AsJSON()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
if !goNext {
|
||||
return
|
||||
}
|
||||
|
||||
idleTimeoutJSON, err := (&shared.TimeDuration{
|
||||
Count: int64(params.IdleTimeout),
|
||||
Unit: shared.TimeDurationUnitSecond,
|
||||
}).AsJSON()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
var ossJSON []byte = nil
|
||||
var connTimeoutJSON []byte
|
||||
var readTimeoutJSON []byte
|
||||
var idleTimeoutJSON []byte
|
||||
var certRefJSON []byte
|
||||
var pbAddr = &pb.NetworkAddress{
|
||||
Protocol: params.Protocol,
|
||||
}
|
||||
|
||||
// 证书
|
||||
var certIds = []int64{}
|
||||
if len(params.CertIdsJSON) > 0 {
|
||||
err = json.Unmarshal(params.CertIdsJSON, &certIds)
|
||||
if ossConfig != nil { // OSS
|
||||
ossJSON, err = json.Marshal(ossConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
var certRefJSON []byte
|
||||
if len(certIds) > 0 {
|
||||
var certId = certIds[0]
|
||||
if certId > 0 {
|
||||
var certRef = &sslconfigs.SSLCertRef{
|
||||
IsOn: true,
|
||||
CertId: certId,
|
||||
err = ossConfig.Init()
|
||||
if err != nil {
|
||||
this.Fail("校验OSS配置时出错:" + err.Error())
|
||||
return
|
||||
}
|
||||
} else { // 普通源站
|
||||
params.Must.
|
||||
Field("addr", params.Addr).
|
||||
Require("请输入源站地址")
|
||||
|
||||
var addr = params.Addr
|
||||
|
||||
// 是否是完整的地址
|
||||
if (params.Protocol == "http" || params.Protocol == "https") && regexp.MustCompile(`^(http|https)://`).MatchString(addr) {
|
||||
u, err := url.Parse(addr)
|
||||
if err == nil {
|
||||
addr = u.Host
|
||||
}
|
||||
certRefJSON, err = json.Marshal(certRef)
|
||||
}
|
||||
|
||||
addr = strings.ReplaceAll(addr, ":", ":")
|
||||
addr = regexp.MustCompile(`\s+`).ReplaceAllString(addr, "")
|
||||
portIndex := strings.LastIndex(addr, ":")
|
||||
if portIndex < 0 {
|
||||
if params.Protocol == "http" {
|
||||
addr += ":80"
|
||||
} else if params.Protocol == "https" {
|
||||
addr += ":443"
|
||||
} else {
|
||||
this.FailField("addr", "源站地址中需要带有端口")
|
||||
}
|
||||
portIndex = strings.LastIndex(addr, ":")
|
||||
}
|
||||
var host = addr[:portIndex]
|
||||
var port = addr[portIndex+1:]
|
||||
// 检查端口号
|
||||
if port == "0" {
|
||||
this.FailField("addr", "源站端口号不能为0")
|
||||
return
|
||||
}
|
||||
if !configutils.HasVariables(port) {
|
||||
// 必须是整数
|
||||
if !regexp.MustCompile(`^\d+$`).MatchString(port) {
|
||||
this.FailField("addr", "源站端口号只能为整数")
|
||||
return
|
||||
}
|
||||
var portInt = types.Int(port)
|
||||
if portInt == 0 {
|
||||
this.FailField("addr", "源站端口号不能为0")
|
||||
return
|
||||
}
|
||||
if portInt > 65535 {
|
||||
this.FailField("addr", "源站端口号不能大于65535")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
pbAddr = &pb.NetworkAddress{
|
||||
Protocol: params.Protocol,
|
||||
Host: host,
|
||||
PortRange: port,
|
||||
}
|
||||
|
||||
connTimeoutJSON, err = (&shared.TimeDuration{
|
||||
Count: int64(params.ConnTimeout),
|
||||
Unit: shared.TimeDurationUnitSecond,
|
||||
}).AsJSON()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
readTimeoutJSON, err = (&shared.TimeDuration{
|
||||
Count: int64(params.ReadTimeout),
|
||||
Unit: shared.TimeDurationUnitSecond,
|
||||
}).AsJSON()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
idleTimeoutJSON, err = (&shared.TimeDuration{
|
||||
Count: int64(params.IdleTimeout),
|
||||
Unit: shared.TimeDurationUnitSecond,
|
||||
}).AsJSON()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
// 证书
|
||||
var certIds = []int64{}
|
||||
if len(params.CertIdsJSON) > 0 {
|
||||
err = json.Unmarshal(params.CertIdsJSON, &certIds)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if len(certIds) > 0 {
|
||||
var certId = certIds[0]
|
||||
if certId > 0 {
|
||||
var certRef = &sslconfigs.SSLCertRef{
|
||||
IsOn: true,
|
||||
CertId: certId,
|
||||
}
|
||||
certRefJSON, err = json.Marshal(certRef)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 专属域名
|
||||
@@ -258,13 +307,10 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
||||
}
|
||||
|
||||
_, err = this.RPC().OriginRPC().UpdateOrigin(this.AdminContext(), &pb.UpdateOriginRequest{
|
||||
OriginId: params.OriginId,
|
||||
Name: params.Name,
|
||||
Addr: &pb.NetworkAddress{
|
||||
Protocol: params.Protocol,
|
||||
Host: host,
|
||||
PortRange: port,
|
||||
},
|
||||
OriginId: params.OriginId,
|
||||
Name: params.Name,
|
||||
Addr: pbAddr,
|
||||
OssJSON: ossJSON,
|
||||
Description: params.Description,
|
||||
Weight: params.Weight,
|
||||
IsOn: params.IsOn,
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
//go:build !plus
|
||||
|
||||
package origins
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/ossconfigs"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
func (this *UpdatePopupAction) getOSSHook() {
|
||||
this.Data["ossTypes"] = []maps.Map{}
|
||||
this.Data["ossBucketParams"] = []maps.Map{}
|
||||
this.Data["ossForm"] = ""
|
||||
}
|
||||
|
||||
func (this *UpdatePopupAction) postOSSHook(protocol string) (config *ossconfigs.OSSConfig, goNext bool, err error) {
|
||||
goNext = true
|
||||
return
|
||||
}
|
||||
@@ -40,6 +40,7 @@ func (this *IndexAction) RunGet(params struct {
|
||||
AllowEmpty: true,
|
||||
AllowSameDomain: true,
|
||||
AllowDomains: nil,
|
||||
CheckOrigin: true,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,8 @@ func (this *IndexAction) RunGet(params struct {
|
||||
var m = maps.Map{
|
||||
"id": originConfig.Id,
|
||||
"weight": originConfig.Weight,
|
||||
"addr": originConfig.Addr.Protocol.String() + "://" + originConfig.Addr.Host + ":" + originConfig.Addr.PortRange,
|
||||
"addr": originConfig.AddrSummary(),
|
||||
"isOSS": originConfig.IsOSS(),
|
||||
"name": originConfig.Name,
|
||||
"isOn": originConfig.IsOn,
|
||||
"domains": originConfig.Domains,
|
||||
@@ -104,7 +105,8 @@ func (this *IndexAction) RunGet(params struct {
|
||||
var m = maps.Map{
|
||||
"id": originConfig.Id,
|
||||
"weight": originConfig.Weight,
|
||||
"addr": originConfig.Addr.Protocol.String() + "://" + originConfig.Addr.Host + ":" + originConfig.Addr.PortRange,
|
||||
"addr": originConfig.AddrSummary(),
|
||||
"isOSS": originConfig.IsOSS(),
|
||||
"name": originConfig.Name,
|
||||
"isOn": originConfig.IsOn,
|
||||
"domains": originConfig.Domains,
|
||||
|
||||
@@ -128,6 +128,7 @@ func (this *IndexAction) RunPost(params struct {
|
||||
_, err := this.RPC().SSLPolicyRPC().UpdateSSLPolicy(this.AdminContext(), &pb.UpdateSSLPolicyRequest{
|
||||
SslPolicyId: sslPolicyId,
|
||||
Http2Enabled: sslPolicy.HTTP2Enabled,
|
||||
Http3Enabled: sslPolicy.HTTP3Enabled,
|
||||
MinVersion: sslPolicy.MinVersion,
|
||||
SslCertsJSON: certsJSON,
|
||||
HstsJSON: hstsJSON,
|
||||
@@ -144,6 +145,7 @@ func (this *IndexAction) RunPost(params struct {
|
||||
} else {
|
||||
resp, err := this.RPC().SSLPolicyRPC().CreateSSLPolicy(this.AdminContext(), &pb.CreateSSLPolicyRequest{
|
||||
Http2Enabled: sslPolicy.HTTP2Enabled,
|
||||
Http3Enabled: sslPolicy.HTTP3Enabled,
|
||||
MinVersion: sslPolicy.MinVersion,
|
||||
SslCertsJSON: certsJSON,
|
||||
HstsJSON: hstsJSON,
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/lists"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
@@ -41,7 +42,7 @@ func (this *CountriesAction) RunGet(params struct {
|
||||
this.NotFound("firewallPolicy", params.FirewallPolicyId)
|
||||
return
|
||||
}
|
||||
selectedCountryIds := []int64{}
|
||||
var selectedCountryIds = []int64{}
|
||||
if policyConfig.Inbound != nil && policyConfig.Inbound.Region != nil {
|
||||
selectedCountryIds = policyConfig.Inbound.Region.DenyCountryIds
|
||||
}
|
||||
@@ -51,7 +52,7 @@ func (this *CountriesAction) RunGet(params struct {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
countryMaps := []maps.Map{}
|
||||
var countryMaps = []maps.Map{}
|
||||
for _, country := range countriesResp.RegionCountries {
|
||||
countryMaps = append(countryMaps, maps.Map{
|
||||
"id": country.Id,
|
||||
@@ -62,6 +63,18 @@ func (this *CountriesAction) RunGet(params struct {
|
||||
}
|
||||
this.Data["countries"] = countryMaps
|
||||
|
||||
// except & only URL Patterns
|
||||
this.Data["exceptURLPatterns"] = []*shared.URLPattern{}
|
||||
this.Data["onlyURLPatterns"] = []*shared.URLPattern{}
|
||||
if policyConfig.Inbound != nil && policyConfig.Inbound.Region != nil {
|
||||
if len(policyConfig.Inbound.Region.CountryExceptURLPatterns) > 0 {
|
||||
this.Data["exceptURLPatterns"] = policyConfig.Inbound.Region.CountryExceptURLPatterns
|
||||
}
|
||||
if len(policyConfig.Inbound.Region.CountryOnlyURLPatterns) > 0 {
|
||||
this.Data["onlyURLPatterns"] = policyConfig.Inbound.Region.CountryOnlyURLPatterns
|
||||
}
|
||||
}
|
||||
|
||||
// WAF是否启用
|
||||
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithServerId(this.AdminContext(), params.ServerId)
|
||||
if err != nil {
|
||||
@@ -77,6 +90,9 @@ func (this *CountriesAction) RunPost(params struct {
|
||||
FirewallPolicyId int64
|
||||
CountryIds []int64
|
||||
|
||||
ExceptURLPatternsJSON []byte
|
||||
OnlyURLPatternsJSON []byte
|
||||
|
||||
Must *actions.Must
|
||||
}) {
|
||||
// 日志
|
||||
@@ -102,6 +118,34 @@ func (this *CountriesAction) RunPost(params struct {
|
||||
}
|
||||
policyConfig.Inbound.Region.DenyCountryIds = params.CountryIds
|
||||
|
||||
// 例外URL
|
||||
var exceptURLPatterns = []*shared.URLPattern{}
|
||||
if len(params.ExceptURLPatternsJSON) > 0 {
|
||||
err = json.Unmarshal(params.ExceptURLPatternsJSON, &exceptURLPatterns)
|
||||
if err != nil {
|
||||
this.Fail("校验例外URL参数失败:" + err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
policyConfig.Inbound.Region.CountryExceptURLPatterns = exceptURLPatterns
|
||||
|
||||
// 限制URL
|
||||
var onlyURLPatterns = []*shared.URLPattern{}
|
||||
if len(params.OnlyURLPatternsJSON) > 0 {
|
||||
err = json.Unmarshal(params.OnlyURLPatternsJSON, &onlyURLPatterns)
|
||||
if err != nil {
|
||||
this.Fail("校验限制URL参数失败:" + err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
policyConfig.Inbound.Region.CountryOnlyURLPatterns = onlyURLPatterns
|
||||
|
||||
err = policyConfig.Init()
|
||||
if err != nil {
|
||||
this.Fail("配置校验失败:" + err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
inboundJSON, err := json.Marshal(policyConfig.Inbound)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/lists"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
@@ -41,7 +42,7 @@ func (this *ProvincesAction) RunGet(params struct {
|
||||
this.NotFound("firewallPolicy", params.FirewallPolicyId)
|
||||
return
|
||||
}
|
||||
selectedProvinceIds := []int64{}
|
||||
var selectedProvinceIds = []int64{}
|
||||
if policyConfig.Inbound != nil && policyConfig.Inbound.Region != nil {
|
||||
selectedProvinceIds = policyConfig.Inbound.Region.DenyProvinceIds
|
||||
}
|
||||
@@ -53,7 +54,7 @@ func (this *ProvincesAction) RunGet(params struct {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
provinceMaps := []maps.Map{}
|
||||
var provinceMaps = []maps.Map{}
|
||||
for _, province := range provincesResp.RegionProvinces {
|
||||
provinceMaps = append(provinceMaps, maps.Map{
|
||||
"id": province.Id,
|
||||
@@ -63,6 +64,18 @@ func (this *ProvincesAction) RunGet(params struct {
|
||||
}
|
||||
this.Data["provinces"] = provinceMaps
|
||||
|
||||
// except & only URL Patterns
|
||||
this.Data["exceptURLPatterns"] = []*shared.URLPattern{}
|
||||
this.Data["onlyURLPatterns"] = []*shared.URLPattern{}
|
||||
if policyConfig.Inbound != nil && policyConfig.Inbound.Region != nil {
|
||||
if len(policyConfig.Inbound.Region.ProvinceExceptURLPatterns) > 0 {
|
||||
this.Data["exceptURLPatterns"] = policyConfig.Inbound.Region.ProvinceExceptURLPatterns
|
||||
}
|
||||
if len(policyConfig.Inbound.Region.ProvinceOnlyURLPatterns) > 0 {
|
||||
this.Data["onlyURLPatterns"] = policyConfig.Inbound.Region.ProvinceOnlyURLPatterns
|
||||
}
|
||||
}
|
||||
|
||||
// WAF是否启用
|
||||
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithServerId(this.AdminContext(), params.ServerId)
|
||||
if err != nil {
|
||||
@@ -78,6 +91,9 @@ func (this *ProvincesAction) RunPost(params struct {
|
||||
FirewallPolicyId int64
|
||||
ProvinceIds []int64
|
||||
|
||||
ExceptURLPatternsJSON []byte
|
||||
OnlyURLPatternsJSON []byte
|
||||
|
||||
Must *actions.Must
|
||||
}) {
|
||||
// 日志
|
||||
@@ -103,6 +119,34 @@ func (this *ProvincesAction) RunPost(params struct {
|
||||
}
|
||||
policyConfig.Inbound.Region.DenyProvinceIds = params.ProvinceIds
|
||||
|
||||
// 例外URL
|
||||
var exceptURLPatterns = []*shared.URLPattern{}
|
||||
if len(params.ExceptURLPatternsJSON) > 0 {
|
||||
err = json.Unmarshal(params.ExceptURLPatternsJSON, &exceptURLPatterns)
|
||||
if err != nil {
|
||||
this.Fail("校验例外URL参数失败:" + err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
policyConfig.Inbound.Region.ProvinceExceptURLPatterns = exceptURLPatterns
|
||||
|
||||
// 限制URL
|
||||
var onlyURLPatterns = []*shared.URLPattern{}
|
||||
if len(params.OnlyURLPatternsJSON) > 0 {
|
||||
err = json.Unmarshal(params.OnlyURLPatternsJSON, &onlyURLPatterns)
|
||||
if err != nil {
|
||||
this.Fail("校验限制URL参数失败:" + err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
policyConfig.Inbound.Region.ProvinceOnlyURLPatterns = onlyURLPatterns
|
||||
|
||||
err = policyConfig.Init()
|
||||
if err != nil {
|
||||
this.Fail("配置校验失败:" + err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
inboundJSON, err := json.Marshal(policyConfig.Inbound)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
|
||||
@@ -106,8 +106,13 @@ func (this *ServerHelper) createLeftMenu(action *actions.ActionObject) {
|
||||
|
||||
// TABBAR
|
||||
selectedTabbar, _ := action.Data["mainTab"]
|
||||
tabbar := actionutils.NewTabbar()
|
||||
tabbar.Add("网站列表", "", "/servers", "", false)
|
||||
var tabbar = actionutils.NewTabbar()
|
||||
tabbar.Add("", "", "/servers", "left arrow", false)
|
||||
if len(serverConfig.Name) > 0 {
|
||||
var item = tabbar.Add(serverConfig.Name, "", "/servers/server?serverId="+serverIdString, "angle right", true)
|
||||
item.IsTitle = true
|
||||
}
|
||||
|
||||
if teaconst.IsPlus {
|
||||
tabbar.Add("看板", "", "/servers/server/boards?serverId="+serverIdString, "dashboard", selectedTabbar == "board")
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package api
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/api/node"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/api/node"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/settingutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||
"github.com/iwind/TeaGo"
|
||||
@@ -14,7 +14,7 @@ func init() {
|
||||
Helper(helpers.NewUserMustAuth(configloaders.AdminModuleCodeSetting)).
|
||||
Helper(NewHelper()).
|
||||
Helper(settingutils.NewAdvancedHelper("apiNodes")).
|
||||
Prefix("/api").
|
||||
Prefix("/settings/api").
|
||||
Get("", new(IndexAction)).
|
||||
Get("/methodStats", new(MethodStatsAction)).
|
||||
GetPost("/node/createPopup", new(node.CreatePopupAction)).
|
||||
@@ -12,7 +12,7 @@ func init() {
|
||||
server.
|
||||
Helper(helpers.NewUserMustAuth(configloaders.AdminModuleCodeSetting)).
|
||||
Helper(settingutils.NewAdvancedHelper("apiNodes")).
|
||||
Prefix("/api/node").
|
||||
Prefix("/settings/api/node").
|
||||
|
||||
// 这里不受Helper的约束
|
||||
GetPost("/createAddrPopup", new(CreateAddrPopupAction)).
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
"sort"
|
||||
)
|
||||
|
||||
type CleanAction struct {
|
||||
@@ -16,11 +17,20 @@ func (this *CleanAction) Init() {
|
||||
this.Nav("", "", "clean")
|
||||
}
|
||||
|
||||
func (this *CleanAction) RunGet(params struct{}) {
|
||||
func (this *CleanAction) RunGet(params struct {
|
||||
OrderTable string
|
||||
OrderSize string
|
||||
}) {
|
||||
this.Data["orderTable"] = params.OrderTable
|
||||
this.Data["orderSize"] = params.OrderSize
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *CleanAction) RunPost(params struct {
|
||||
OrderTable string
|
||||
OrderSize string
|
||||
|
||||
Must *actions.Must
|
||||
}) {
|
||||
tablesResp, err := this.RPC().DBRPC().FindAllDBTables(this.AdminContext(), &pb.FindAllDBTablesRequest{})
|
||||
@@ -28,9 +38,33 @@ func (this *CleanAction) RunPost(params struct {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var tables = tablesResp.DbTables
|
||||
|
||||
tableMaps := []maps.Map{}
|
||||
for _, table := range tablesResp.DbTables {
|
||||
// 排序
|
||||
switch params.OrderTable {
|
||||
case "asc":
|
||||
sort.Slice(tables, func(i, j int) bool {
|
||||
return tables[i].Name < tables[j].Name
|
||||
})
|
||||
case "desc":
|
||||
sort.Slice(tables, func(i, j int) bool {
|
||||
return tables[i].Name > tables[j].Name
|
||||
})
|
||||
}
|
||||
|
||||
switch params.OrderSize {
|
||||
case "asc":
|
||||
sort.Slice(tables, func(i, j int) bool {
|
||||
return tables[i].DataLength+tables[i].IndexLength < tables[j].DataLength+tables[j].IndexLength
|
||||
})
|
||||
case "desc":
|
||||
sort.Slice(tables, func(i, j int) bool {
|
||||
return tables[i].DataLength+tables[i].IndexLength > tables[j].DataLength+tables[j].IndexLength
|
||||
})
|
||||
}
|
||||
|
||||
var tableMaps = []maps.Map{}
|
||||
for _, table := range tables {
|
||||
if !table.IsBaseTable || (!table.CanClean && !table.CanDelete) {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ func (this *AdvancedHelper) BeforeAction(actionPtr actions.ActionWrapper) (goNex
|
||||
var adminId = session.GetInt64("adminId")
|
||||
if configloaders.AllowModule(adminId, configloaders.AdminModuleCodeSetting) {
|
||||
tabbar.Add("数据库", "", "/settings/database", "", this.tab == "database")
|
||||
tabbar.Add("API节点", "", "/api", "", this.tab == "apiNodes")
|
||||
tabbar.Add("API节点", "", "/settings/api", "", this.tab == "apiNodes")
|
||||
tabbar.Add("日志数据库", "", "/db", "", this.tab == "dbNodes")
|
||||
tabbar.Add("迁移", "", "/settings/transfer", "", this.tab == "transfer")
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ func (this *Helper) BeforeAction(actionPtr actions.ActionWrapper) (goNext bool)
|
||||
|
||||
// 左侧菜单
|
||||
action.Data["teaMenu"] = "settings"
|
||||
action.Data["teaSubMenu"] = "basic"
|
||||
|
||||
// 标签栏
|
||||
var tabbar = actionutils.NewTabbar()
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package updates
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs"
|
||||
)
|
||||
|
||||
type IgnoreVersionAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *IgnoreVersionAction) RunPost(params struct {
|
||||
Version string
|
||||
}) {
|
||||
defer this.CreateLogInfo("忽略升级版本 %s", params.Version)
|
||||
|
||||
if len(params.Version) == 0 {
|
||||
this.Fail("请输入要忽略的版本号")
|
||||
return
|
||||
}
|
||||
|
||||
valueResp, err := this.RPC().SysSettingRPC().ReadSysSetting(this.AdminContext(), &pb.ReadSysSettingRequest{Code: systemconfigs.SettingCodeCheckUpdates})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var valueJSON = valueResp.ValueJSON
|
||||
var config = systemconfigs.NewCheckUpdatesConfig()
|
||||
if len(valueJSON) > 0 {
|
||||
err = json.Unmarshal(valueJSON, config)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
config.IgnoredVersion = params.Version
|
||||
configJSON, err := json.Marshal(config)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = this.RPC().SysSettingRPC().UpdateSysSetting(this.AdminContext(), &pb.UpdateSysSettingRequest{
|
||||
Code: systemconfigs.SettingCodeCheckUpdates,
|
||||
ValueJSON: configJSON,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
// 清除状态
|
||||
teaconst.NewVersionCode = ""
|
||||
|
||||
this.Success()
|
||||
}
|
||||
@@ -4,12 +4,12 @@ package updates
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
"github.com/iwind/TeaGo/types"
|
||||
stringutil "github.com/iwind/TeaGo/utils/string"
|
||||
"io"
|
||||
"net/http"
|
||||
@@ -25,8 +25,18 @@ func (this *IndexAction) Init() {
|
||||
this.Nav("", "updates", "")
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct{}) {
|
||||
func (this *IndexAction) RunGet(params struct {
|
||||
DoCheck bool
|
||||
}) {
|
||||
this.Data["version"] = teaconst.Version
|
||||
this.Data["doCheck"] = params.DoCheck
|
||||
|
||||
// 是否正在升级
|
||||
this.Data["isUpgrading"] = isUpgrading
|
||||
this.Data["upgradeProgress"] = fmt.Sprintf("%.2f", upgradeProgress * 100)
|
||||
if isUpgrading {
|
||||
this.Data["doCheck"] = false
|
||||
}
|
||||
|
||||
valueResp, err := this.RPC().SysSettingRPC().ReadSysSetting(this.AdminContext(), &pb.ReadSysSettingRequest{Code: systemconfigs.SettingCodeCheckUpdates})
|
||||
if err != nil {
|
||||
@@ -34,7 +44,7 @@ func (this *IndexAction) RunGet(params struct{}) {
|
||||
return
|
||||
}
|
||||
var valueJSON = valueResp.ValueJSON
|
||||
var config = &systemconfigs.CheckUpdatesConfig{AutoCheck: false}
|
||||
var config = systemconfigs.NewCheckUpdatesConfig()
|
||||
if len(valueJSON) > 0 {
|
||||
err = json.Unmarshal(valueJSON, config)
|
||||
if err != nil {
|
||||
@@ -49,6 +59,21 @@ func (this *IndexAction) RunGet(params struct{}) {
|
||||
|
||||
func (this *IndexAction) RunPost(params struct {
|
||||
}) {
|
||||
valueResp, err := this.RPC().SysSettingRPC().ReadSysSetting(this.AdminContext(), &pb.ReadSysSettingRequest{Code: systemconfigs.SettingCodeCheckUpdates})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var valueJSON = valueResp.ValueJSON
|
||||
var config = systemconfigs.NewCheckUpdatesConfig()
|
||||
if len(valueJSON) > 0 {
|
||||
err = json.Unmarshal(valueJSON, config)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
type Response struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
@@ -66,6 +91,7 @@ func (this *IndexAction) RunPost(params struct {
|
||||
"message": "读取更新信息失败:" + err.Error(),
|
||||
}
|
||||
this.Success()
|
||||
return
|
||||
}
|
||||
|
||||
defer func() {
|
||||
@@ -78,6 +104,7 @@ func (this *IndexAction) RunPost(params struct {
|
||||
"message": "读取更新信息失败:" + err.Error(),
|
||||
}
|
||||
this.Success()
|
||||
return
|
||||
}
|
||||
|
||||
var apiResponse = &Response{}
|
||||
@@ -88,6 +115,7 @@ func (this *IndexAction) RunPost(params struct {
|
||||
"message": "解析更新信息失败:" + err.Error(),
|
||||
}
|
||||
this.Success()
|
||||
return
|
||||
}
|
||||
|
||||
if apiResponse.Code != 200 {
|
||||
@@ -96,6 +124,7 @@ func (this *IndexAction) RunPost(params struct {
|
||||
"message": "解析更新信息失败:" + apiResponse.Message,
|
||||
}
|
||||
this.Success()
|
||||
return
|
||||
}
|
||||
|
||||
var m = maps.NewMap(apiResponse.Data)
|
||||
@@ -107,19 +136,30 @@ func (this *IndexAction) RunPost(params struct {
|
||||
if vMap.GetString("code") == "admin" {
|
||||
var latestVersion = vMap.GetString("version")
|
||||
if stringutil.VersionCompare(teaconst.Version, latestVersion) < 0 {
|
||||
// 是否已忽略
|
||||
if len(config.IgnoredVersion) > 0 && stringutil.VersionCompare(config.IgnoredVersion, latestVersion) >= 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
this.Data["result"] = maps.Map{
|
||||
"isOk": true,
|
||||
"message": "有最新的版本v" + types.String(latestVersion) + "可以更新",
|
||||
"hasNew": true,
|
||||
"dlURL": dlHost + vMap.GetString("url"),
|
||||
"isOk": true,
|
||||
"version": latestVersion,
|
||||
"message": "有最新的版本 v" + latestVersion + " 可以更新",
|
||||
"hasNew": true,
|
||||
"dlURL": dlHost + vMap.GetString("url"),
|
||||
"day": vMap.GetString("day"),
|
||||
"description": vMap.GetString("description"),
|
||||
"docURL": vMap.GetString("docURL"),
|
||||
}
|
||||
this.Success()
|
||||
return
|
||||
} else {
|
||||
this.Data["result"] = maps.Map{
|
||||
"isOk": true,
|
||||
"message": "你已安装最新版本,无需更新",
|
||||
}
|
||||
this.Success()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -127,7 +167,7 @@ func (this *IndexAction) RunPost(params struct {
|
||||
|
||||
this.Data["result"] = maps.Map{
|
||||
"isOk": false,
|
||||
"message": "找不到更新信息",
|
||||
"message": "没有发现更新的版本",
|
||||
}
|
||||
|
||||
this.Success()
|
||||
|
||||
@@ -15,6 +15,9 @@ func init() {
|
||||
Prefix("/settings/updates").
|
||||
GetPost("", new(IndexAction)).
|
||||
Post("/update", new(UpdateAction)).
|
||||
Post("/ignoreVersion", new(IgnoreVersionAction)).
|
||||
Post("/resetIgnoredVersion", new(ResetIgnoredVersionAction)).
|
||||
GetPost("/upgrade", new(UpgradeAction)).
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package updates
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs"
|
||||
)
|
||||
|
||||
type ResetIgnoredVersionAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *ResetIgnoredVersionAction) RunPost(params struct{}) {
|
||||
defer this.CreateLogInfo("重置忽略升级版本")
|
||||
|
||||
valueResp, err := this.RPC().SysSettingRPC().ReadSysSetting(this.AdminContext(), &pb.ReadSysSettingRequest{Code: systemconfigs.SettingCodeCheckUpdates})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var valueJSON = valueResp.ValueJSON
|
||||
var config = systemconfigs.NewCheckUpdatesConfig()
|
||||
if len(valueJSON) > 0 {
|
||||
err = json.Unmarshal(valueJSON, config)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
config.IgnoredVersion = ""
|
||||
configJSON, err := json.Marshal(config)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = this.RPC().SysSettingRPC().UpdateSysSetting(this.AdminContext(), &pb.UpdateSysSettingRequest{
|
||||
Code: systemconfigs.SettingCodeCheckUpdates,
|
||||
ValueJSON: configJSON,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
@@ -17,13 +17,16 @@ type UpdateAction struct {
|
||||
func (this *UpdateAction) RunPost(params struct {
|
||||
AutoCheck bool
|
||||
}) {
|
||||
defer this.CreateLogInfo("修改检查更新设置")
|
||||
|
||||
// 读取当前设置
|
||||
valueResp, err := this.RPC().SysSettingRPC().ReadSysSetting(this.AdminContext(), &pb.ReadSysSettingRequest{Code: systemconfigs.SettingCodeCheckUpdates})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var valueJSON = valueResp.ValueJSON
|
||||
var config = &systemconfigs.CheckUpdatesConfig{AutoCheck: false}
|
||||
var config = systemconfigs.NewCheckUpdatesConfig()
|
||||
if len(valueJSON) > 0 {
|
||||
err = json.Unmarshal(valueJSON, config)
|
||||
if err != nil {
|
||||
@@ -40,6 +43,7 @@ func (this *UpdateAction) RunPost(params struct {
|
||||
return
|
||||
}
|
||||
|
||||
// 修改设置
|
||||
_, err = this.RPC().SysSettingRPC().UpdateSysSetting(this.AdminContext(), &pb.UpdateSysSettingRequest{
|
||||
Code: systemconfigs.SettingCodeCheckUpdates,
|
||||
ValueJSON: configJSON,
|
||||
|
||||
73
internal/web/actions/default/settings/updates/upgrade.go
Normal file
73
internal/web/actions/default/settings/updates/upgrade.go
Normal file
@@ -0,0 +1,73 @@
|
||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package updates
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"os"
|
||||
"os/exec"
|
||||
"time"
|
||||
)
|
||||
|
||||
var upgradeProgress float32
|
||||
var isUpgrading = false
|
||||
|
||||
type UpgradeAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *UpgradeAction) RunGet(params struct {
|
||||
}) {
|
||||
this.Data["isUpgrading"] = isUpgrading
|
||||
this.Data["upgradeProgress"] = fmt.Sprintf("%.2f", upgradeProgress*100)
|
||||
this.Success()
|
||||
}
|
||||
|
||||
func (this *UpgradeAction) RunPost(params struct {
|
||||
Url string
|
||||
}) {
|
||||
if isUpgrading {
|
||||
this.Success()
|
||||
return
|
||||
}
|
||||
|
||||
isUpgrading = true
|
||||
upgradeProgress = 0
|
||||
|
||||
defer func() {
|
||||
isUpgrading = false
|
||||
}()
|
||||
|
||||
var manager = utils.NewUpgradeManager("admin", params.Url)
|
||||
var ticker = time.NewTicker(1 * time.Second)
|
||||
go func() {
|
||||
for range ticker.C {
|
||||
if manager.IsDownloading() {
|
||||
var progress = manager.Progress()
|
||||
if progress >= 0 {
|
||||
upgradeProgress = progress
|
||||
}
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
err := manager.Start()
|
||||
if err != nil {
|
||||
this.Fail("下载失败:" + err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// restart
|
||||
exe, _ := os.Executable()
|
||||
if len(exe) > 0 {
|
||||
go func() {
|
||||
var cmd = exec.Command(exe, "restart")
|
||||
_ = cmd.Run()
|
||||
}()
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
@@ -80,12 +80,14 @@ func (this *IndexAction) RunPost(params struct {
|
||||
config.RPC.Endpoints = []string{endpoint}
|
||||
client, err := rpc.NewRPCClient(config, false)
|
||||
if err != nil {
|
||||
this.Fail("无法连接到API节点地址'" + endpoint + "':" + err.Error())
|
||||
actionutils.Fail(this, err)
|
||||
return
|
||||
}
|
||||
_, err = client.APINodeRPC().FindCurrentAPINodeVersion(client.Context(0), &pb.FindCurrentAPINodeVersionRequest{})
|
||||
if err != nil {
|
||||
_ = client.Close()
|
||||
this.Fail("无法连接到API节点地址'" + endpoint + "':" + err.Error())
|
||||
actionutils.Fail(this, err)
|
||||
return
|
||||
}
|
||||
_ = client.Close()
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ func (this *MySQLInstaller) InstallFromFile(xzFilePath string, targetDir string)
|
||||
} else { // yum
|
||||
yumExe, err := exec.LookPath("yum")
|
||||
if err == nil && len(yumExe) > 0 {
|
||||
for _, lib := range []string{"libaio", "ncurses-libs", "ncurses-compat-libs"} {
|
||||
for _, lib := range []string{"libaio", "ncurses-libs", "ncurses-compat-libs", "numactl-libs"} {
|
||||
var cmd = utils.NewCmd("yum", "-y", "install", lib)
|
||||
_ = cmd.Run()
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
@@ -34,7 +34,7 @@ func FindAllMenuMaps(nodeLogsType string, countUnreadNodeLogs int64, countUnread
|
||||
"code": "cert",
|
||||
},
|
||||
{
|
||||
"name": "服务分组",
|
||||
"name": "网站分组",
|
||||
"url": "/servers/groups",
|
||||
"code": "group",
|
||||
},
|
||||
@@ -90,34 +90,44 @@ func FindAllMenuMaps(nodeLogsType string, countUnreadNodeLogs int64, countUnread
|
||||
"code": "clusters",
|
||||
"module": configloaders.AdminModuleCodeNode,
|
||||
"name": "边缘节点",
|
||||
"subtitle": "集群列表",
|
||||
"subtitle": "",
|
||||
"icon": "cloud",
|
||||
"subItems": []maps.Map{
|
||||
{
|
||||
"name": "运行日志",
|
||||
"name": "集群列表",
|
||||
"url": "/clusters",
|
||||
"code": "cluster",
|
||||
},
|
||||
{
|
||||
"name": "节点日志",
|
||||
"url": "/clusters/logs?type=" + nodeLogsType,
|
||||
"code": "log",
|
||||
"badge": countUnreadNodeLogs,
|
||||
},
|
||||
{
|
||||
"name": "SSH认证",
|
||||
"url": "/clusters/grants",
|
||||
"code": "grant",
|
||||
},
|
||||
{
|
||||
"name": "区域设置",
|
||||
"url": "/clusters/regions",
|
||||
"code": "region",
|
||||
},
|
||||
{
|
||||
"name": "节点SSH",
|
||||
"url": "/clusters/grants",
|
||||
"code": "grant",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"code": "dns",
|
||||
"module": configloaders.AdminModuleCodeDNS,
|
||||
"name": "域名解析",
|
||||
"subtitle": "集群列表",
|
||||
"subtitle": "",
|
||||
"icon": "globe",
|
||||
"subItems": []maps.Map{
|
||||
{
|
||||
"name": "集群列表",
|
||||
"url": "/dns",
|
||||
"code": "cluster",
|
||||
},
|
||||
{
|
||||
"name": "DNS服务商",
|
||||
"url": "/dns/providers",
|
||||
@@ -140,7 +150,7 @@ func FindAllMenuMaps(nodeLogsType string, countUnreadNodeLogs int64, countUnread
|
||||
"code": "admins",
|
||||
"module": configloaders.AdminModuleCodeAdmin,
|
||||
"name": "系统用户",
|
||||
"subtitle": "用户列表",
|
||||
"subtitle": "",
|
||||
"icon": "user secret",
|
||||
},
|
||||
{
|
||||
@@ -153,9 +163,14 @@ func FindAllMenuMaps(nodeLogsType string, countUnreadNodeLogs int64, countUnread
|
||||
"code": "settings",
|
||||
"module": configloaders.AdminModuleCodeSetting,
|
||||
"name": "系统设置",
|
||||
"subtitle": "基本设置",
|
||||
"subtitle": "",
|
||||
"icon": "setting",
|
||||
"subItems": []maps.Map{
|
||||
{
|
||||
"name": "基础设置",
|
||||
"url": "/settings",
|
||||
"code": "basic",
|
||||
},
|
||||
{
|
||||
"name": "高级设置",
|
||||
"url": "/settings/advanced",
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/admins"
|
||||
|
||||
// API节点
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/api"
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/api/node"
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/api"
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/api/node"
|
||||
|
||||
// 节点集群
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters"
|
||||
|
||||
BIN
web/public/audios/alert.ogg
Normal file
BIN
web/public/audios/alert.ogg
Normal file
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -13,7 +13,7 @@ Vue.component("api-node-addresses-box", {
|
||||
// 添加IP地址
|
||||
addAddr: function () {
|
||||
let that = this;
|
||||
teaweb.popup("/api/node/createAddrPopup", {
|
||||
teaweb.popup("/settings/api/node/createAddrPopup", {
|
||||
height: "16em",
|
||||
callback: function (resp) {
|
||||
that.addrs.push(resp.data.addr);
|
||||
@@ -25,7 +25,7 @@ Vue.component("api-node-addresses-box", {
|
||||
updateAddr: function (index, addr) {
|
||||
let that = this;
|
||||
window.UPDATING_ADDR = addr
|
||||
teaweb.popup("/api/node/updateAddrPopup?addressId=", {
|
||||
teaweb.popup("/settings/api/node/updateAddrPopup?addressId=", {
|
||||
callback: function (resp) {
|
||||
Vue.set(that.addrs, index, resp.data.addr);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Vue.component("health-check-config-box", {
|
||||
props: ["v-health-check-config", "v-check-domain-url"],
|
||||
props: ["v-health-check-config", "v-check-domain-url", "v-is-plus"],
|
||||
data: function () {
|
||||
let healthCheckConfig = this.vHealthCheckConfig
|
||||
let urlProtocol = "http"
|
||||
@@ -69,6 +69,7 @@ Vue.component("health-check-config-box", {
|
||||
healthCheckConfig.countDown = 3
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
healthCheck: healthCheckConfig,
|
||||
advancedVisible: false,
|
||||
@@ -237,13 +238,13 @@ Vue.component("health-check-config-box", {
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>自动下线</td>
|
||||
<td>自动下线<span v-if="vIsPlus">IP</span></td>
|
||||
<td>
|
||||
<div class="ui checkbox">
|
||||
<input type="checkbox" value="1" v-model="healthCheck.autoDown"/>
|
||||
<label></label>
|
||||
</div>
|
||||
<p class="comment">选中后系统会根据健康检查的结果自动标记节点的上线/下线状态,并可能自动同步DNS设置。</p>
|
||||
<p class="comment">选中后系统会根据健康检查的结果自动标记<span v-if="vIsPlus">节点IP</span><span v-else>节点</span>的上线/下线状态,并可能自动同步DNS设置。<span v-if="!vIsPlus">注意:免费版的只能整体上下线整个节点,商业版的可以下线单个IP。</span></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-show="healthCheck.autoDown">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Vue.component("time-duration-box", {
|
||||
props: ["v-name", "v-value", "v-count", "v-unit"],
|
||||
props: ["name", "v-name", "v-value", "v-count", "v-unit"],
|
||||
mounted: function () {
|
||||
this.change()
|
||||
},
|
||||
@@ -14,9 +14,18 @@ Vue.component("time-duration-box", {
|
||||
if (typeof (v["count"]) != "number") {
|
||||
v["count"] = -1
|
||||
}
|
||||
|
||||
let realName = ""
|
||||
if (typeof this.name == "string" && this.name.length > 0) {
|
||||
realName = this.name
|
||||
} else if (typeof this.vName == "string" && this.vName.length > 0) {
|
||||
realName = this.vName
|
||||
}
|
||||
|
||||
return {
|
||||
duration: v,
|
||||
countString: (v.count >= 0) ? v.count.toString() : ""
|
||||
countString: (v.count >= 0) ? v.count.toString() : "",
|
||||
realName: realName
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -39,7 +48,7 @@ Vue.component("time-duration-box", {
|
||||
}
|
||||
},
|
||||
template: `<div class="ui fields inline" style="padding-bottom: 0; margin-bottom: 0">
|
||||
<input type="hidden" :name="vName" :value="JSON.stringify(duration)"/>
|
||||
<input type="hidden" :name="realName" :value="JSON.stringify(duration)"/>
|
||||
<div class="ui field">
|
||||
<input type="text" v-model="countString" maxlength="11" size="11" @keypress.enter.prevent="1"/>
|
||||
</div>
|
||||
|
||||
83
web/public/js/components/dns/dns-resolvers-config-box.js
Normal file
83
web/public/js/components/dns/dns-resolvers-config-box.js
Normal file
@@ -0,0 +1,83 @@
|
||||
Vue.component("dns-resolvers-config-box", {
|
||||
props: ["value", "name"],
|
||||
data: function () {
|
||||
let resolvers = this.value
|
||||
if (resolvers == null) {
|
||||
resolvers = []
|
||||
}
|
||||
|
||||
let name = this.name
|
||||
if (name == null || name.length == 0) {
|
||||
name = "dnsResolversJSON"
|
||||
}
|
||||
|
||||
return {
|
||||
formName: name,
|
||||
resolvers: resolvers,
|
||||
|
||||
host: "",
|
||||
|
||||
isAdding: false
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
add: function () {
|
||||
this.isAdding = true
|
||||
let that = this
|
||||
setTimeout(function () {
|
||||
that.$refs.hostRef.focus()
|
||||
})
|
||||
},
|
||||
confirm: function () {
|
||||
let host = this.host.trim()
|
||||
if (host.length == 0) {
|
||||
let that = this
|
||||
setTimeout(function () {
|
||||
that.$refs.hostRef.focus()
|
||||
})
|
||||
return
|
||||
}
|
||||
this.resolvers.push({
|
||||
host: host,
|
||||
port: 0, // TODO
|
||||
protocol: "" // TODO
|
||||
})
|
||||
this.cancel()
|
||||
},
|
||||
cancel: function () {
|
||||
this.isAdding = false
|
||||
this.host = ""
|
||||
this.port = 0
|
||||
this.protocol = ""
|
||||
},
|
||||
remove: function (index) {
|
||||
this.resolvers.$remove(index)
|
||||
}
|
||||
},
|
||||
template: `<div>
|
||||
<input type="hidden" :name="formName" :value="JSON.stringify(resolvers)"/>
|
||||
<div v-if="resolvers.length > 0">
|
||||
<div v-for="(resolver, index) in resolvers" class="ui label basic small">
|
||||
<span v-if="resolver.protocol.length > 0">{{resolver.protocol}}</span>{{resolver.host}}<span v-if="resolver.port > 0">:{{resolver.port}}</span>
|
||||
|
||||
<a href="" title="删除" @click.prevent="remove(index)"><i class="icon remove small"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="isAdding" style="margin-top: 1em">
|
||||
<div class="ui fields inline">
|
||||
<div class="ui field">
|
||||
<input type="text" placeholder="x.x.x.x" @keyup.enter="confirm" @keypress.enter.prevent="1" ref="hostRef" v-model="host"/>
|
||||
</div>
|
||||
<div class="ui field">
|
||||
<button class="ui button tiny" type="button" @click.prevent="confirm">确认</button>
|
||||
<a href="" @click.prevent="cancel" title="取消"><i class="icon remove small"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="!isAdding" style="margin-top: 1em">
|
||||
<button class="ui button tiny" type="button" @click.prevent="add">+</button>
|
||||
</div>
|
||||
</div>`
|
||||
})
|
||||
@@ -95,6 +95,16 @@ Vue.component("message-row", {
|
||||
<div v-if="message.type == 'serverNamesRequireAuditing'" style="margin-top: 0.8em">
|
||||
<a :href="'/servers/server/settings/serverNames?serverId=' + params.serverId" target="_top">去审核</a></a>
|
||||
</div>
|
||||
|
||||
<!-- 节点调度 -->
|
||||
<div v-if="message.type == 'NodeSchedule'" style="margin-top: 0.8em">
|
||||
<a :href="'/clusters/cluster/node/settings/schedule?clusterId=' + message.cluster.id + '&nodeId=' + message.node.id" target="_top">查看调度状态 »</a>
|
||||
</div>
|
||||
|
||||
<!-- 节点租期结束 -->
|
||||
<div v-if="message.type == 'NodeOfflineDay'" style="margin-top: 0.8em">
|
||||
<a :href="'/clusters/cluster/node/detail?clusterId=' + message.cluster.id + '&nodeId=' + message.node.id" target="_top">查看详情 »</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -141,8 +141,8 @@ Vue.component("http-cache-config-box", {
|
||||
</div>
|
||||
|
||||
<div v-show="isOn()" style="margin-top: 1em">
|
||||
<h4>缓存条件</h4>
|
||||
<http-cache-refs-config-box :v-cache-config="cacheConfig" :v-cache-refs="cacheConfig.cacheRefs" :v-web-id="vWebId"></http-cache-refs-config-box>
|
||||
<h4>缓存条件 <a href="" style="font-size: 0.8em" @click.prevent="$refs.cacheRefsConfigBoxRef.addRef(false)">[添加]</a> </h4>
|
||||
<http-cache-refs-config-box ref="cacheRefsConfigBoxRef" :v-cache-config="cacheConfig" :v-cache-refs="cacheConfig.cacheRefs" :v-web-id="vWebId"></http-cache-refs-config-box>
|
||||
</div>
|
||||
<div class="margin"></div>
|
||||
</div>`
|
||||
|
||||
@@ -30,6 +30,7 @@ Vue.component("http-cache-ref-box", {
|
||||
simpleCond: null, // 简单条件
|
||||
allowChunkedEncoding: true,
|
||||
allowPartialContent: true,
|
||||
forcePartialContent: false,
|
||||
enableIfNoneMatch: false,
|
||||
enableIfModifiedSince: false,
|
||||
isReverse: this.vIsReverse,
|
||||
@@ -174,13 +175,15 @@ Vue.component("http-cache-ref-box", {
|
||||
},
|
||||
template: `<tbody>
|
||||
<tr v-if="condCategory == 'simple'">
|
||||
<td class="title color-border">条件类型 *</td>
|
||||
<td class="title">条件类型 *</td>
|
||||
<td>
|
||||
<select class="ui dropdown auto-width" name="condType" v-model="condType" @change="changeCondType(condType, false)">
|
||||
<option value="url-extension">URL扩展名</option>
|
||||
<option value="url-prefix">URL前缀</option>
|
||||
<option value="url-extension">文件扩展名</option>
|
||||
<option value="url-eq-index">首页</option>
|
||||
<option value="url-all">全站</option>
|
||||
<option value="url-prefix">URL前缀</option>
|
||||
<option value="url-eq">URL完整路径</option>
|
||||
<option value="url-wildcard-match">URL通配符</option>
|
||||
<option value="url-regexp">URL正则匹配</option>
|
||||
<option value="params">参数匹配</option>
|
||||
</select>
|
||||
@@ -188,7 +191,7 @@ Vue.component("http-cache-ref-box", {
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="condCategory == 'simple'">
|
||||
<td class="color-border">{{condComponent.paramsTitle}} *</td>
|
||||
<td>{{condComponent.paramsTitle}} *</td>
|
||||
<td>
|
||||
<component :is="condComponent.component" :v-cond="ref.simpleCond" v-if="condComponent.type != 'params'"></component>
|
||||
<table class="ui table" v-if="condComponent.type == 'params'">
|
||||
@@ -197,7 +200,7 @@ Vue.component("http-cache-ref-box", {
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="condCategory == 'simple' && condComponent.caseInsensitive">
|
||||
<td class="color-border">不区分大小写</td>
|
||||
<td>不区分大小写</td>
|
||||
<td>
|
||||
<div class="ui checkbox">
|
||||
<input type="checkbox" name="condIsCaseInsensitive" value="1" v-model="condIsCaseInsensitive"/>
|
||||
@@ -220,19 +223,19 @@ Vue.component("http-cache-ref-box", {
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-show="!vIsReverse">
|
||||
<td class="color-border">缓存Key *</td>
|
||||
<td>
|
||||
<input type="text" v-model="ref.key" @input="changeKey(ref.key)"/>
|
||||
<p class="comment">用来区分不同缓存内容的唯一Key。<request-variables-describer ref="variablesDescriber"></request-variables-describer>。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-show="!vIsReverse">
|
||||
<td class="color-border">忽略URI参数</td>
|
||||
<td>忽略URI参数</td>
|
||||
<td>
|
||||
<checkbox v-model="keyIgnoreArgs"></checkbox>
|
||||
<p class="comment">选中后,表示缓存Key中不包含URI参数(即问号(?))后面的内容。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-show="!vIsReverse">
|
||||
<td>缓存Key *</td>
|
||||
<td>
|
||||
<input type="text" v-model="ref.key" @input="changeKey(ref.key)"/>
|
||||
<p class="comment">用来区分不同缓存内容的唯一Key。<request-variables-describer ref="variablesDescriber"></request-variables-describer>。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-show="!vIsReverse">
|
||||
<td colspan="2"><more-options-indicator @change="changeOptionsVisible"></more-options-indicator></td>
|
||||
</tr>
|
||||
@@ -277,6 +280,13 @@ Vue.component("http-cache-ref-box", {
|
||||
<p class="comment">选中后,支持缓存源站返回的某个区间的内容,该内容通过<code-label>206 Partial Content</code-label>状态码返回。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-show="moreOptionsVisible && !vIsReverse && ref.allowPartialContent">
|
||||
<td>强制返回区间内容</td>
|
||||
<td>
|
||||
<checkbox name="forcePartialContent" value="1" v-model="ref.forcePartialContent"></checkbox>
|
||||
<p class="comment">选中后,表示无论客户端是否发送<code-label>Range</code-label>报头,都会优先尝试返回已缓存的区间内容;如果你的应用有不支持区间内容的客户端(比如有些下载软件不支持<code-label>206 Partial Content</code-label>),请务必关闭此功能。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-show="moreOptionsVisible && !vIsReverse">
|
||||
<td>状态码列表</td>
|
||||
<td>
|
||||
|
||||
@@ -214,7 +214,7 @@ Vue.component("http-cache-refs-config-box", {
|
||||
</table>
|
||||
<p class="comment" v-if="refs.length > 1">所有条件匹配顺序为从上到下,可以拖动左侧的<i class="icon bars"></i>排序。服务设置的优先级比全局缓存策略设置的优先级要高。</p>
|
||||
|
||||
<button class="ui button tiny" @click.prevent="addRef(false)" type="button">+添加缓存条件</button> <a href="" @click.prevent="addRef(true)">+添加不缓存条件</a>
|
||||
<button class="ui button tiny" @click.prevent="addRef(false)" type="button">+添加缓存条件</button> <a href="" @click.prevent="addRef(true)" style="font-size: 0.8em">+添加不缓存条件</a>
|
||||
</div>
|
||||
<div class="margin"></div>
|
||||
</div>`
|
||||
|
||||
@@ -276,6 +276,36 @@ Vue.component("http-cond-url-eq-index", {
|
||||
</div>`
|
||||
})
|
||||
|
||||
// 全站
|
||||
Vue.component("http-cond-url-all", {
|
||||
props: ["v-cond"],
|
||||
data: function () {
|
||||
let cond = {
|
||||
isRequest: true,
|
||||
param: "${requestPath}",
|
||||
operator: "prefix",
|
||||
value: "/",
|
||||
isCaseInsensitive: false
|
||||
}
|
||||
if (this.vCond != null && typeof this.vCond.value == "string") {
|
||||
cond.value = this.vCond.value
|
||||
}
|
||||
return {
|
||||
cond: cond
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
changeCaseInsensitive: function (isCaseInsensitive) {
|
||||
this.cond.isCaseInsensitive = isCaseInsensitive
|
||||
}
|
||||
},
|
||||
template: `<div>
|
||||
<input type="hidden" name="condJSON" :value="JSON.stringify(cond)"/>
|
||||
<input type="text" v-model="cond.value" disabled="disabled" style="background: #eee"/>
|
||||
<p class="comment">支持全站所有URL。</p>
|
||||
</div>`
|
||||
})
|
||||
|
||||
// URL精准匹配
|
||||
Vue.component("http-cond-url-eq", {
|
||||
props: ["v-cond"],
|
||||
@@ -408,6 +438,38 @@ Vue.component("http-cond-url-not-regexp", {
|
||||
</div>`
|
||||
})
|
||||
|
||||
// URL通配符
|
||||
Vue.component("http-cond-url-wildcard-match", {
|
||||
props: ["v-cond"],
|
||||
mounted: function () {
|
||||
this.$refs.valueInput.focus()
|
||||
},
|
||||
data: function () {
|
||||
let cond = {
|
||||
isRequest: true,
|
||||
param: "${requestPath}",
|
||||
operator: "wildcard match",
|
||||
value: "",
|
||||
isCaseInsensitive: false
|
||||
}
|
||||
if (this.vCond != null && typeof this.vCond.value == "string") {
|
||||
cond.value = this.vCond.value
|
||||
}
|
||||
return {
|
||||
cond: cond
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
changeCaseInsensitive: function (isCaseInsensitive) {
|
||||
this.cond.isCaseInsensitive = isCaseInsensitive
|
||||
}
|
||||
},
|
||||
template: `<div>
|
||||
<input type="hidden" name="condJSON" :value="JSON.stringify(cond)"/>
|
||||
<input type="text" v-model="cond.value" ref="valueInput"/>
|
||||
<p class="comment">匹配URL的通配符,用星号(<code-label>*</code-label>)表示任意字符,比如(<code-label>/images/*.png</code-label>、<code-label>/static/*</code-label>,不需要带域名。</p>
|
||||
</div>`
|
||||
})
|
||||
|
||||
// User-Agent正则匹配
|
||||
Vue.component("http-cond-user-agent-regexp", {
|
||||
|
||||
@@ -11,23 +11,110 @@ Vue.component("http-cors-header-config-box", {
|
||||
exposeHeaders: [],
|
||||
maxAge: 0,
|
||||
requestHeaders: [],
|
||||
requestMethod: ""
|
||||
requestMethod: "",
|
||||
optionsMethodOnly: false
|
||||
}
|
||||
}
|
||||
if (config.allowMethods == null) {
|
||||
config.allowMethods = []
|
||||
}
|
||||
if (config.exposeHeaders == null) {
|
||||
config.exposeHeaders = []
|
||||
}
|
||||
|
||||
let maxAgeSecondsString = config.maxAge.toString()
|
||||
if (maxAgeSecondsString == "0") {
|
||||
maxAgeSecondsString = ""
|
||||
}
|
||||
|
||||
return {
|
||||
config: config
|
||||
config: config,
|
||||
|
||||
maxAgeSecondsString: maxAgeSecondsString,
|
||||
|
||||
moreOptionsVisible: false
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
maxAgeSecondsString: function (v) {
|
||||
let seconds = parseInt(v)
|
||||
if (isNaN(seconds)) {
|
||||
seconds = 0
|
||||
}
|
||||
this.config.maxAge = seconds
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
changeMoreOptions: function (visible) {
|
||||
this.moreOptionsVisible = visible
|
||||
},
|
||||
addDefaultAllowMethods: function () {
|
||||
let that = this
|
||||
let defaultMethods = ["PUT", "GET", "POST", "DELETE", "HEAD", "OPTIONS", "PATCH"]
|
||||
defaultMethods.forEach(function (method) {
|
||||
if (!that.config.allowMethods.$contains(method)) {
|
||||
that.config.allowMethods.push(method)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
template: `<div>
|
||||
<input type="hidden" name="corsJSON" :value="JSON.stringify(config)"/>
|
||||
<table class="ui table definition selectable">
|
||||
<tr>
|
||||
<td class="title">启用CORS自适应跨域</td>
|
||||
<td>
|
||||
<checkbox v-model="config.isOn"></checkbox>
|
||||
</td>
|
||||
</tr>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="title">启用CORS自适应跨域</td>
|
||||
<td>
|
||||
<checkbox v-model="config.isOn"></checkbox>
|
||||
<p class="comment">启用后,自动在响应Header中增加对应的<code-label>Access-Control-*</code-label>相关内容。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody v-show="config.isOn">
|
||||
<tr>
|
||||
<td colspan="2"><more-options-indicator @change="changeMoreOptions"></more-options-indicator></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody v-show="config.isOn && moreOptionsVisible">
|
||||
<tr>
|
||||
<td>允许的请求方法列表</td>
|
||||
<td>
|
||||
<http-methods-box :v-methods="config.allowMethods"></http-methods-box>
|
||||
<p class="comment"><a href="" @click.prevent="addDefaultAllowMethods">[添加默认]</a>。<code-label>Access-Control-Allow-Methods</code-label>值设置。所访问资源允许使用的方法列表,不设置则表示默认为<code-label>PUT</code-label>、<code-label>GET</code-label>、<code-label>POST</code-label>、<code-label>DELETE</code-label>、<code-label>HEAD</code-label>、<code-label>OPTIONS</code-label>、<code-label>PATCH</code-label>。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>预检结果缓存时间</td>
|
||||
<td>
|
||||
<div class="ui input right labeled">
|
||||
<input type="text" style="width: 6em" maxlength="6" v-model="maxAgeSecondsString"/>
|
||||
<span class="ui label">秒</span>
|
||||
</div>
|
||||
<p class="comment"><code-label>Access-Control-Max-Age</code-label>值设置。预检结果缓存时间,0或者不填表示使用浏览器默认设置。注意每个浏览器有不同的缓存时间上限。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>允许服务器暴露的Header</td>
|
||||
<td>
|
||||
<values-box :v-values="config.exposeHeaders"></values-box>
|
||||
<p class="comment"><code-label>Access-Control-Expose-Headers</code-label>值设置。允许服务器暴露的Header,请注意Header的大小写。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>实际请求方法</td>
|
||||
<td>
|
||||
<input type="text" v-model="config.requestMethod"/>
|
||||
<p class="comment"><code-label>Access-Control-Request-Method</code-label>值设置。实际请求服务器时使用的方法,比如<code-label>POST</code-label>。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>仅OPTIONS有效</td>
|
||||
<td>
|
||||
<checkbox v-model="config.optionsMethodOnly"></checkbox>
|
||||
<p class="comment">选中后,表示当前CORS设置仅在OPTIONS方法请求时有效。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="margin"></div>
|
||||
</div>`
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user