mirror of
https://gitee.com/samwaf/SamWaf.git
synced 2026-09-24 22:39:38 +08:00
Vendored
+3
@@ -1,6 +1,7 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"SamWaf/common/zlog"
|
||||
"errors"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -107,6 +108,7 @@ func (wafCache *WafCache) GetLastTime(key string) (time.Time, error) {
|
||||
if time.Since(item.createTime) <= item.ttl {
|
||||
return item.lastTime, nil
|
||||
}
|
||||
zlog.Debug("GetLastTime CLEAR CACHE EXPIRE :" + key)
|
||||
delete(wafCache.cache, key)
|
||||
return time.Time{}, errors.New("数据已过期")
|
||||
}
|
||||
@@ -114,6 +116,7 @@ func (wafCache *WafCache) ClearExpirationCache() {
|
||||
now := time.Now()
|
||||
for key, item := range wafCache.cache {
|
||||
if now.Sub(item.createTime) > item.ttl {
|
||||
zlog.Debug("ClearExpirationCache CLEAR CACHE EXPIRE :" + key)
|
||||
delete(wafCache.cache, key)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,9 @@ func setConfigIntValue(name string, value int64, change int) {
|
||||
case "record_all_src_byte_info":
|
||||
global.GCONFIG_RECORD_ALL_SRC_BYTE_INFO = value
|
||||
break
|
||||
case "token_expire_time":
|
||||
global.GCONFIG_RECORD_TOKEN_EXPIRE_MINTUTES = value
|
||||
break
|
||||
default:
|
||||
zlog.Warn("Unknown config item:", name)
|
||||
}
|
||||
@@ -162,5 +165,6 @@ func TaskLoadSetting(initLoad bool) {
|
||||
updateConfigIntItem(initLoad, "network", "keepalive_time_out", global.GCONFIG_RECORD_KEEPALIVE_TIME_OUT, "保持活动超时(默认30s)", "int", "")
|
||||
|
||||
updateConfigIntItem(initLoad, "system", "record_all_src_byte_info", global.GCONFIG_RECORD_ALL_SRC_BYTE_INFO, "启动记录原始请求BODY报文(1启动 0关闭)", "int", "")
|
||||
updateConfigIntItem(initLoad, "system", "token_expire_time", global.GCONFIG_RECORD_TOKEN_EXPIRE_MINTUTES, "管理平台令牌有效期,单位分钟(默认5分钟)", "int", "")
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user