Archived
[日志审计]增加删除、清理和别的一些设置
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
package configloaders
|
||||
|
||||
import "sync"
|
||||
|
||||
var locker sync.Mutex
|
||||
@@ -0,0 +1,83 @@
|
||||
package configloaders
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs"
|
||||
"github.com/iwind/TeaGo/logs"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
var sharedLogConfig *systemconfigs.LogConfig = nil
|
||||
|
||||
const (
|
||||
LogSettingName = "adminLogConfig"
|
||||
)
|
||||
|
||||
func LoadLogConfig() (*systemconfigs.LogConfig, error) {
|
||||
locker.Lock()
|
||||
defer locker.Unlock()
|
||||
|
||||
config, err := loadLogConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
v := reflect.Indirect(reflect.ValueOf(config)).Interface().(systemconfigs.LogConfig)
|
||||
return &v, nil
|
||||
}
|
||||
|
||||
func UpdateLogConfig(logConfig *systemconfigs.LogConfig) error {
|
||||
locker.Lock()
|
||||
defer locker.Unlock()
|
||||
|
||||
var rpcClient, err = rpc.SharedRPC()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
valueJSON, err := json.Marshal(logConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = rpcClient.SysSettingRPC().UpdateSysSetting(rpcClient.Context(0), &pb.UpdateSysSettingRequest{
|
||||
Code: LogSettingName,
|
||||
ValueJSON: valueJSON,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sharedLogConfig = logConfig
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func loadLogConfig() (*systemconfigs.LogConfig, error) {
|
||||
if sharedLogConfig != nil {
|
||||
return sharedLogConfig, nil
|
||||
}
|
||||
var rpcClient, err = rpc.SharedRPC()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := rpcClient.SysSettingRPC().ReadSysSetting(rpcClient.Context(0), &pb.ReadSysSettingRequest{
|
||||
Code: LogSettingName,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(resp.ValueJSON) == 0 {
|
||||
sharedLogConfig = systemconfigs.DefaultLogConfig()
|
||||
return sharedLogConfig, nil
|
||||
}
|
||||
|
||||
config := &systemconfigs.LogConfig{}
|
||||
err = json.Unmarshal(resp.ValueJSON, config)
|
||||
if err != nil {
|
||||
logs.Println("[LOG_MANAGER]" + err.Error())
|
||||
sharedLogConfig = systemconfigs.DefaultLogConfig()
|
||||
return sharedLogConfig, nil
|
||||
}
|
||||
sharedLogConfig = config
|
||||
return sharedLogConfig, nil
|
||||
}
|
||||
+10
-19
@@ -1,17 +1,15 @@
|
||||
package securitymanager
|
||||
package configloaders
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/events"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs"
|
||||
"github.com/iwind/TeaGo/logs"
|
||||
"reflect"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var locker sync.Mutex
|
||||
|
||||
const (
|
||||
SecuritySettingName = "adminSecurityConfig"
|
||||
|
||||
@@ -20,16 +18,9 @@ const (
|
||||
FrameSameOrigin = "SAMEORIGIN"
|
||||
)
|
||||
|
||||
var sharedSecurityConfig *SecurityConfig = nil
|
||||
var sharedSecurityConfig *systemconfigs.SecurityConfig = nil
|
||||
|
||||
type SecurityConfig struct {
|
||||
Frame string `json:"frame"`
|
||||
AllowCountryIds []int64 `json:"allowCountryIds"`
|
||||
AllowProvinceIds []int64 `json:"allowProvinceIds"`
|
||||
AllowLocal bool `json:"allowLocal"`
|
||||
}
|
||||
|
||||
func LoadSecurityConfig() (*SecurityConfig, error) {
|
||||
func LoadSecurityConfig() (*systemconfigs.SecurityConfig, error) {
|
||||
locker.Lock()
|
||||
defer locker.Unlock()
|
||||
|
||||
@@ -38,11 +29,11 @@ func LoadSecurityConfig() (*SecurityConfig, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
v := reflect.Indirect(reflect.ValueOf(config)).Interface().(SecurityConfig)
|
||||
v := reflect.Indirect(reflect.ValueOf(config)).Interface().(systemconfigs.SecurityConfig)
|
||||
return &v, nil
|
||||
}
|
||||
|
||||
func UpdateSecurityConfig(securityConfig *SecurityConfig) error {
|
||||
func UpdateSecurityConfig(securityConfig *systemconfigs.SecurityConfig) error {
|
||||
locker.Lock()
|
||||
defer locker.Unlock()
|
||||
|
||||
@@ -69,7 +60,7 @@ func UpdateSecurityConfig(securityConfig *SecurityConfig) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func loadSecurityConfig() (*SecurityConfig, error) {
|
||||
func loadSecurityConfig() (*systemconfigs.SecurityConfig, error) {
|
||||
if sharedSecurityConfig != nil {
|
||||
return sharedSecurityConfig, nil
|
||||
}
|
||||
@@ -88,7 +79,7 @@ func loadSecurityConfig() (*SecurityConfig, error) {
|
||||
return sharedSecurityConfig, nil
|
||||
}
|
||||
|
||||
config := &SecurityConfig{}
|
||||
config := &systemconfigs.SecurityConfig{}
|
||||
err = json.Unmarshal(resp.ValueJSON, config)
|
||||
if err != nil {
|
||||
logs.Println("[SECURITY_MANAGER]" + err.Error())
|
||||
@@ -99,8 +90,8 @@ func loadSecurityConfig() (*SecurityConfig, error) {
|
||||
return sharedSecurityConfig, nil
|
||||
}
|
||||
|
||||
func defaultSecurityConfig() *SecurityConfig {
|
||||
return &SecurityConfig{
|
||||
func defaultSecurityConfig() *systemconfigs.SecurityConfig {
|
||||
return &systemconfigs.SecurityConfig{
|
||||
Frame: FrameSameOrigin,
|
||||
AllowLocal: true,
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package securitymanager
|
||||
package configloaders
|
||||
|
||||
import (
|
||||
_ "github.com/iwind/TeaGo/bootstrap"
|
||||
@@ -1,30 +1,21 @@
|
||||
package uimanager
|
||||
package configloaders
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs"
|
||||
"github.com/iwind/TeaGo/logs"
|
||||
"reflect"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var sharedUIConfig *UIConfig = nil
|
||||
var locker sync.Mutex
|
||||
var sharedUIConfig *systemconfigs.UIConfig = nil
|
||||
|
||||
const (
|
||||
UISettingName = "adminUIConfig"
|
||||
)
|
||||
|
||||
type UIConfig struct {
|
||||
ProductName string `json:"productName"` // 产品名
|
||||
AdminSystemName string `json:"adminSystemName"` // 管理员系统名称
|
||||
ShowOpenSourceInfo bool `json:"showOpenSourceInfo"` // 是否显示开源信息
|
||||
ShowVersion bool `json:"showVersion"` // 是否显示版本号
|
||||
Version string `json:"version"` // 显示的版本号
|
||||
}
|
||||
|
||||
func LoadUIConfig() (*UIConfig, error) {
|
||||
func LoadUIConfig() (*systemconfigs.UIConfig, error) {
|
||||
locker.Lock()
|
||||
defer locker.Unlock()
|
||||
|
||||
@@ -33,11 +24,11 @@ func LoadUIConfig() (*UIConfig, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
v := reflect.Indirect(reflect.ValueOf(config)).Interface().(UIConfig)
|
||||
v := reflect.Indirect(reflect.ValueOf(config)).Interface().(systemconfigs.UIConfig)
|
||||
return &v, nil
|
||||
}
|
||||
|
||||
func UpdateUIConfig(uiConfig *UIConfig) error {
|
||||
func UpdateUIConfig(uiConfig *systemconfigs.UIConfig) error {
|
||||
locker.Lock()
|
||||
defer locker.Unlock()
|
||||
|
||||
@@ -61,7 +52,7 @@ func UpdateUIConfig(uiConfig *UIConfig) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func loadUIConfig() (*UIConfig, error) {
|
||||
func loadUIConfig() (*systemconfigs.UIConfig, error) {
|
||||
if sharedUIConfig != nil {
|
||||
return sharedUIConfig, nil
|
||||
}
|
||||
@@ -80,7 +71,7 @@ func loadUIConfig() (*UIConfig, error) {
|
||||
return sharedUIConfig, nil
|
||||
}
|
||||
|
||||
config := &UIConfig{}
|
||||
config := &systemconfigs.UIConfig{}
|
||||
err = json.Unmarshal(resp.ValueJSON, config)
|
||||
if err != nil {
|
||||
logs.Println("[UI_MANAGER]" + err.Error())
|
||||
@@ -91,8 +82,8 @@ func loadUIConfig() (*UIConfig, error) {
|
||||
return sharedUIConfig, nil
|
||||
}
|
||||
|
||||
func defaultUIConfig() *UIConfig {
|
||||
return &UIConfig{
|
||||
func defaultUIConfig() *systemconfigs.UIConfig {
|
||||
return &systemconfigs.UIConfig{
|
||||
ProductName: "GoEdge",
|
||||
AdminSystemName: "GoEdge管理员系统",
|
||||
ShowOpenSourceInfo: true,
|
||||
@@ -1,4 +1,4 @@
|
||||
package uimanager
|
||||
package configloaders
|
||||
|
||||
import (
|
||||
_ "github.com/iwind/TeaGo/bootstrap"
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestLoadSecurityConfig(t *testing.T) {
|
||||
func TestLoadUIConfig(t *testing.T) {
|
||||
for i := 0; i < 10; i++ {
|
||||
before := time.Now()
|
||||
config, err := LoadUIConfig()
|
||||
@@ -2,11 +2,11 @@ package index
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/setup"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/uimanager"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||
@@ -50,7 +50,7 @@ func (this *IndexAction) RunGet(params struct {
|
||||
this.Data["token"] = stringutil.Md5(TokenSalt+timestamp) + timestamp
|
||||
this.Data["from"] = params.From
|
||||
|
||||
config, err := uimanager.LoadUIConfig()
|
||||
config, err := configloaders.LoadUIConfig()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/utils/numberutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
)
|
||||
|
||||
type CleanAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *CleanAction) Init() {
|
||||
this.Nav("", "", "clean")
|
||||
}
|
||||
|
||||
func (this *CleanAction) RunGet(params struct{}) {
|
||||
// 读取配置
|
||||
config, err := configloaders.LoadLogConfig()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
if !config.CanClean {
|
||||
this.WriteString("已设置不能清理")
|
||||
return
|
||||
}
|
||||
this.Data["logConfig"] = config
|
||||
|
||||
sizeResp, err := this.RPC().LogRPC().SumLogsSize(this.AdminContext(), &pb.SumLogsSizeRequest{})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
sizeHuman := ""
|
||||
if sizeResp.SizeBytes < 1024 {
|
||||
sizeHuman = numberutils.FormatInt64(sizeResp.SizeBytes) + "字节"
|
||||
} else if sizeResp.SizeBytes < 1024*1024 {
|
||||
sizeHuman = fmt.Sprintf("%.2fK", float64(sizeResp.SizeBytes)/1024)
|
||||
} else if sizeResp.SizeBytes < 1024*1024*1024 {
|
||||
sizeHuman = fmt.Sprintf("%.2fM", float64(sizeResp.SizeBytes)/1024/1024)
|
||||
} else {
|
||||
sizeHuman = fmt.Sprintf("%.2fG", float64(sizeResp.SizeBytes)/1024/1024/1024)
|
||||
}
|
||||
this.Data["size"] = sizeHuman
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *CleanAction) RunPost(params struct {
|
||||
Type string
|
||||
Days int32
|
||||
|
||||
Must *actions.Must
|
||||
CSRF *actionutils.CSRF
|
||||
}) {
|
||||
// 读取配置
|
||||
config, err := configloaders.LoadLogConfig()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
if !config.CanClean {
|
||||
this.WriteString("已设置不能清理")
|
||||
return
|
||||
}
|
||||
|
||||
switch params.Type {
|
||||
case "all":
|
||||
defer this.CreateLogInfo("清除全部日志")
|
||||
|
||||
_, err := this.RPC().LogRPC().CleanLogsPermanently(this.AdminContext(), &pb.CleanLogsPermanentlyRequest{
|
||||
Days: 0,
|
||||
ClearAll: true,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
case "days":
|
||||
defer this.CreateLogInfo("清除 %d 以前的日志", params.Days)
|
||||
|
||||
_, err := this.RPC().LogRPC().CleanLogsPermanently(this.AdminContext(), &pb.CleanLogsPermanentlyRequest{
|
||||
Days: params.Days,
|
||||
ClearAll: false,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
default:
|
||||
this.Fail("不支持的清理方式 '" + params.Type + "'")
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
)
|
||||
|
||||
type DeleteAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *DeleteAction) RunPost(params struct {
|
||||
LogId int64
|
||||
}) {
|
||||
// 读取配置
|
||||
config, err := configloaders.LoadLogConfig()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
if !config.CanDelete {
|
||||
this.Fail("已设置不能删除")
|
||||
}
|
||||
|
||||
// 记录日志
|
||||
defer this.CreateLogInfo("删除单个操作日志 %d", params.LogId)
|
||||
|
||||
// 执行删除
|
||||
_, err = this.RPC().LogRPC().DeleteLogPermanently(this.AdminContext(), &pb.DeleteLogPermanentlyRequest{LogId: params.LogId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/lists"
|
||||
@@ -14,7 +15,7 @@ type IndexAction struct {
|
||||
}
|
||||
|
||||
func (this *IndexAction) Init() {
|
||||
this.Nav("log", "log", "")
|
||||
this.Nav("log", "log", "list")
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct {
|
||||
@@ -22,6 +23,14 @@ func (this *IndexAction) RunGet(params struct {
|
||||
DayTo string
|
||||
Keyword string
|
||||
}) {
|
||||
// 读取配置
|
||||
config, err := configloaders.LoadLogConfig()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
this.Data["logConfig"] = config
|
||||
|
||||
this.Data["dayFrom"] = params.DayFrom
|
||||
this.Data["dayTo"] = params.DayTo
|
||||
this.Data["keyword"] = params.Keyword
|
||||
@@ -76,6 +85,7 @@ func (this *IndexAction) RunGet(params struct {
|
||||
}
|
||||
|
||||
logMaps = append(logMaps, maps.Map{
|
||||
"id": log.Id,
|
||||
"description": log.Description,
|
||||
"userName": log.UserName,
|
||||
"createdTime": timeutil.FormatTime("Y-m-d H:i:s", log.CreatedAt),
|
||||
|
||||
@@ -13,6 +13,9 @@ func init() {
|
||||
Prefix("/log").
|
||||
Get("", new(IndexAction)).
|
||||
Get("/exportExcel", new(ExportExcelAction)).
|
||||
Post("/delete", new(DeleteAction)).
|
||||
GetPost("/clean", new(CleanAction)).
|
||||
GetPost("/settings", new(SettingsAction)).
|
||||
|
||||
EndAll()
|
||||
})
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
)
|
||||
|
||||
type SettingsAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *SettingsAction) Init() {
|
||||
this.Nav("", "", "setting")
|
||||
}
|
||||
|
||||
func (this *SettingsAction) RunGet(params struct{}) {
|
||||
config, err := configloaders.LoadLogConfig()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Data["logConfig"] = config
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *SettingsAction) RunPost(params struct {
|
||||
CanDelete bool
|
||||
CanClean bool
|
||||
CapacityJSON []byte
|
||||
Days int
|
||||
|
||||
Must *actions.Must
|
||||
CSRF *actionutils.CSRF
|
||||
}) {
|
||||
capacity := &shared.SizeCapacity{}
|
||||
err := json.Unmarshal(params.CapacityJSON, capacity)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
config, err := configloaders.LoadLogConfig()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
config.CanDelete = params.CanDelete
|
||||
config.CanClean = params.CanClean
|
||||
config.Days = params.Days
|
||||
config.Capacity = capacity
|
||||
err = configloaders.UpdateLogConfig(config)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package security
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/securitymanager"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
@@ -18,7 +18,7 @@ func (this *IndexAction) Init() {
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct{}) {
|
||||
config, err := securitymanager.LoadSecurityConfig()
|
||||
config, err := configloaders.LoadSecurityConfig()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
@@ -75,7 +75,7 @@ func (this *IndexAction) RunPost(params struct {
|
||||
}) {
|
||||
defer this.CreateLogInfo("修改管理界面安全设置")
|
||||
|
||||
config, err := securitymanager.LoadSecurityConfig()
|
||||
config, err := configloaders.LoadSecurityConfig()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
@@ -109,7 +109,7 @@ func (this *IndexAction) RunPost(params struct {
|
||||
// 允许本地
|
||||
config.AllowLocal = params.AllowLocal
|
||||
|
||||
err = securitymanager.UpdateSecurityConfig(config)
|
||||
err = configloaders.UpdateSecurityConfig(config)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/uimanager"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
)
|
||||
@@ -15,7 +15,7 @@ func (this *IndexAction) Init() {
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct{}) {
|
||||
config, err := uimanager.LoadUIConfig()
|
||||
config, err := configloaders.LoadUIConfig()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
@@ -41,7 +41,7 @@ func (this *IndexAction) RunPost(params struct {
|
||||
Field("adminSystemName", params.AdminSystemName).
|
||||
Require("请输入管理员系统名称")
|
||||
|
||||
config, err := uimanager.LoadUIConfig()
|
||||
config, err := configloaders.LoadUIConfig()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
@@ -51,7 +51,7 @@ func (this *IndexAction) RunPost(params struct {
|
||||
config.ShowOpenSourceInfo = params.ShowOpenSourceInfo
|
||||
config.ShowVersion = params.ShowVersion
|
||||
config.Version = params.Version
|
||||
err = uimanager.UpdateUIConfig(config)
|
||||
err = configloaders.UpdateUIConfig(config)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package helpers
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
|
||||
nodes "github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/securitymanager"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/setup"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/uimanager"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
@@ -28,7 +27,7 @@ func (this *UserMustAuth) BeforeAction(actionPtr actions.ActionWrapper, paramNam
|
||||
var action = actionPtr.Object()
|
||||
|
||||
// 安全相关
|
||||
securityConfig, _ := securitymanager.LoadSecurityConfig()
|
||||
securityConfig, _ := configloaders.LoadSecurityConfig()
|
||||
if securityConfig == nil {
|
||||
action.AddHeader("X-Frame-Options", "SAMEORIGIN")
|
||||
} else if len(securityConfig.Frame) > 0 {
|
||||
@@ -84,7 +83,7 @@ func (this *UserMustAuth) BeforeAction(actionPtr actions.ActionWrapper, paramNam
|
||||
return true
|
||||
}
|
||||
|
||||
config, err := uimanager.LoadUIConfig()
|
||||
config, err := configloaders.LoadUIConfig()
|
||||
if err != nil {
|
||||
action.WriteString(err.Error())
|
||||
return false
|
||||
@@ -206,16 +205,16 @@ func (this *UserMustAuth) modules() []maps.Map {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"code": "log",
|
||||
"name": "日志审计",
|
||||
"icon": "history",
|
||||
},
|
||||
{
|
||||
"code": "settings",
|
||||
"name": "系统设置",
|
||||
"icon": "setting",
|
||||
},
|
||||
{
|
||||
"code": "log",
|
||||
"name": "操作日志",
|
||||
"icon": "history",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package helpers
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/securitymanager"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/utils/numberutils"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"net/http"
|
||||
@@ -16,7 +16,7 @@ func (this *UserShouldAuth) BeforeAction(actionPtr actions.ActionWrapper, paramN
|
||||
|
||||
// 安全相关
|
||||
action := this.action
|
||||
securityConfig, _ := securitymanager.LoadSecurityConfig()
|
||||
securityConfig, _ := configloaders.LoadSecurityConfig()
|
||||
if securityConfig == nil {
|
||||
action.AddHeader("X-Frame-Options", "SAMEORIGIN")
|
||||
} else if len(securityConfig.Frame) > 0 {
|
||||
|
||||
@@ -3,8 +3,8 @@ package helpers
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/events"
|
||||
nodes "github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/securitymanager"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs"
|
||||
"github.com/iwind/TeaGo/lists"
|
||||
"github.com/iwind/TeaGo/logs"
|
||||
"net"
|
||||
@@ -23,7 +23,7 @@ func init() {
|
||||
}
|
||||
|
||||
// 检查用户IP并支持缓存
|
||||
func checkIP(config *securitymanager.SecurityConfig, ipAddr string) bool {
|
||||
func checkIP(config *systemconfigs.SecurityConfig, ipAddr string) bool {
|
||||
ipCacheLocker.Lock()
|
||||
ipCache, ok := ipCacheMap[ipAddr]
|
||||
if ok && ipCache {
|
||||
@@ -46,7 +46,7 @@ func checkIP(config *securitymanager.SecurityConfig, ipAddr string) bool {
|
||||
}
|
||||
|
||||
// 检查用户IP
|
||||
func checkIPWithoutCache(config *securitymanager.SecurityConfig, ipAddr string) bool {
|
||||
func checkIPWithoutCache(config *systemconfigs.SecurityConfig, ipAddr string) bool {
|
||||
if config == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user