diff --git a/internal/web/actions/default/clusters/cluster/settings/health.go b/internal/web/actions/default/clusters/cluster/settings/health.go index d268c276..8b9df1ce 100644 --- a/internal/web/actions/default/clusters/cluster/settings/health.go +++ b/internal/web/actions/default/clusters/cluster/settings/health.go @@ -27,9 +27,9 @@ func (this *HealthAction) RunGet(params struct { return } var config *serverconfigs.HealthCheckConfig = nil - if len(configResp.HealthCheckConfig) > 0 { + if len(configResp.HealthCheckJSON) > 0 { config = &serverconfigs.HealthCheckConfig{} - err = json.Unmarshal(configResp.HealthCheckConfig, config) + err = json.Unmarshal(configResp.HealthCheckJSON, config) if err != nil { this.ErrorPage(err) return diff --git a/internal/web/actions/default/clusters/cluster/settings/init.go b/internal/web/actions/default/clusters/cluster/settings/init.go index b346293d..f0eb03f4 100644 --- a/internal/web/actions/default/clusters/cluster/settings/init.go +++ b/internal/web/actions/default/clusters/cluster/settings/init.go @@ -2,6 +2,7 @@ package settings import ( "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/settings/dns" + "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/settings/toa" clusters "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/clusterutils" "github.com/TeaOSLab/EdgeAdmin/internal/web/helpers" "github.com/iwind/TeaGo" @@ -18,7 +19,12 @@ func init() { GetPost("/healthRunPopup", new(HealthRunPopupAction)). // DNS - GetPost("/dns", new(dns.IndexAction)). + Prefix("/clusters/cluster/settings/dns"). + GetPost("", new(dns.IndexAction)). + + // TOA + Prefix("/clusters/cluster/settings/toa"). + GetPost("", new(toa.IndexAction)). EndAll() }) diff --git a/internal/web/actions/default/clusters/cluster/settings/toa/index.go b/internal/web/actions/default/clusters/cluster/settings/toa/index.go new file mode 100644 index 00000000..fad92b4d --- /dev/null +++ b/internal/web/actions/default/clusters/cluster/settings/toa/index.go @@ -0,0 +1,82 @@ +package toa + +import ( + "encoding/json" + "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" + "github.com/iwind/TeaGo/actions" +) + +type IndexAction struct { + actionutils.ParentAction +} + +func (this *IndexAction) Init() { + this.Nav("", "setting", "") + this.SecondMenu("toa") +} + +func (this *IndexAction) RunGet(params struct { + ClusterId int64 +}) { + toaResp, err := this.RPC().NodeClusterRPC().FindEnabledNodeClusterTOA(this.AdminContext(), &pb.FindEnabledNodeClusterTOARequest{NodeClusterId: params.ClusterId}) + if err != nil { + this.ErrorPage(err) + return + } + if len(toaResp.ToaJSON) == 0 { + this.Data["toa"] = nodeconfigs.DefaultTOAConfig() + } else { + config := &nodeconfigs.TOAConfig{} + err = json.Unmarshal(toaResp.ToaJSON, config) + if err != nil { + this.ErrorPage(err) + return + } + this.Data["toa"] = config + } + + this.Show() +} + +func (this *IndexAction) RunPost(params struct { + ClusterId int64 + IsOn bool + AutoSetup bool + OptionType uint8 + MinQueueId uint8 + MaxQueueId uint8 + + Must *actions.Must + CSRF *actionutils.CSRF +}) { + defer this.CreateLogInfo("修改集群 %d 的TOA设置", params.ClusterId) + + config := &nodeconfigs.TOAConfig{ + IsOn: params.IsOn, + Debug: false, // 暂时不允许打开调试 + OptionType: params.OptionType, + MinQueueId: params.MinQueueId, + MaxQueueId: params.MaxQueueId, + AutoSetup: params.AutoSetup, + } + + configJSON, err := json.Marshal(config) + if err != nil { + this.ErrorPage(err) + return + } + + _, err = this.RPC().NodeClusterRPC().UpdateNodeClusterTOA(this.AdminContext(), &pb.UpdateNodeClusterTOARequest{ + NodeClusterId: params.ClusterId, + ToaJSON: configJSON, + }) + + if err != nil { + this.ErrorPage(err) + return + } + + this.Success() +} diff --git a/internal/web/actions/default/clusters/clusterutils/cluster_helper.go b/internal/web/actions/default/clusters/clusterutils/cluster_helper.go index 9a0302f4..d946798e 100644 --- a/internal/web/actions/default/clusters/clusterutils/cluster_helper.go +++ b/internal/web/actions/default/clusters/clusterutils/cluster_helper.go @@ -87,5 +87,10 @@ func (this *ClusterHelper) createSettingMenu(clusterId string, selectedItem stri "url": "/clusters/cluster/settings/dns?clusterId=" + clusterId, "isActive": selectedItem == "dns", }) + items = append(items, maps.Map{ + "name": "TOA设置", + "url": "/clusters/cluster/settings/toa?clusterId=" + clusterId, + "isActive": selectedItem == "toa", + }) return } diff --git a/web/views/@default/clusters/cluster/settings/toa/index.html b/web/views/@default/clusters/cluster/settings/toa/index.html new file mode 100644 index 00000000..0601d01b --- /dev/null +++ b/web/views/@default/clusters/cluster/settings/toa/index.html @@ -0,0 +1,52 @@ +{$layout} +{$template "/left_menu"} + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
是否启用TOA + +

在启用之前,请确保当前集群下所有节点服务器已经安装TOA模块和libnetfilter_queue,并启用了IPTables。

+
是否自动配置 + +

TOA功能需要节点服务器安装并开启了IPTables,并将网络数据包转发到NFQueue中。如果选中了自动配置,则每次在启动时都会自动尝试配置IPTables规则。

+
选项类型数值 + +

用来作为附加的TCP OPTION值,通常是254(即0xfe)。

+
NFQueue队列开始ID + +

不能超过255。

+
NFQueue队列结束ID + +

不能超过255。

+
+ + +
+
\ No newline at end of file diff --git a/web/views/@default/clusters/cluster/settings/toa/index.js b/web/views/@default/clusters/cluster/settings/toa/index.js new file mode 100644 index 00000000..295a9aaf --- /dev/null +++ b/web/views/@default/clusters/cluster/settings/toa/index.js @@ -0,0 +1,3 @@ +Tea.context(function () { + this.success = NotifyReloadSuccess("保存成功") +}) \ No newline at end of file