[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/v1.2.0 #765

Merged
merged 33 commits into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
636704f
Merge pull request #728 from bfenetworks/master
iyangsj Apr 8, 2021
40598ae
Update VERSION
iyangsj Apr 9, 2021
39388f0
Update docs/DOWNLOAD.md
iyangsj Apr 9, 2021
2b7d383
Support log to single file and stdout (#724)
wangrzneu Apr 12, 2021
3b92e98
http/cookie: fix cookie Expires minimum year to 1601 instead of Epoch…
YuqiXiao Apr 12, 2021
9dc6cdc
Support URI hash strategy (#734)
yangshuothtf Apr 13, 2021
cdcb451
mod_block: support global request rules and ALLOW action (#735)
yangshuothtf Apr 13, 2021
e965eb7
Update doc for mod_block (#736)
yangshuothtf Apr 13, 2021
3cf932a
Remove useless reqToCheck from mod_block (#737)
yangshuothtf Apr 13, 2021
cdc38cc
Update CONTRIBUTORS.md
iyangsj Apr 13, 2021
ac05077
mod_header: support variables about client certificate (#738)
dblate Apr 14, 2021
24f1cb7
Update doc about mod_header.md (#741)
zhangxiaogang01 Apr 15, 2021
a4b467f
Update Dockerfile and fix build of docker image (#743)
liuximu Apr 15, 2021
ff181ec
Set GOMAXPROCS according to real CPU quota if running on container (#…
wangrzneu Apr 15, 2021
818b3a6
Support condition primitive periodic_time_range (#746)
yangshuothtf Apr 16, 2021
54ee6b6
Support condition primitive bfe_time_range (#747)
yangshuothtf Apr 16, 2021
bca29de
Update Dockerfile
iyangsj Apr 16, 2021
216e8c1
Update build ldflags
iyangsj Apr 21, 2021
00d26b9
Update docs/DOWNLOAD.md
iyangsj Apr 21, 2021
0bd8c1d
mod_header: validate header rule with empty actions (#750)
zhugelianglongming Apr 28, 2021
9eb1eb0
Add GOCLEAN (#752)
qloog May 12, 2021
6f032d5
Add doc for periodic_time_range (#751)
yangshuothtf May 12, 2021
d15e70b
Add case_sensitive param for req_context_value_in (#754)
yangshuothtf May 13, 2021
ba96085
Simplify declaration of command-line flags (#753)
qloog May 13, 2021
a126a1c
Optimize tls default config (#755)
xiaofei0800 May 24, 2021
8a52eff
Tweak bfe_basic.Session (#756)
xiaofei0800 Jun 12, 2021
e11a6b9
Fix a typo in mod_http_code doc (#758)
mingjliu9 Jun 16, 2021
8e8cc3d
Fix Typos in doc (#760)
mingjliu9 Jun 16, 2021
a6703c3
Tweak bfe_route/trie/ and keep consistent code style under the same p…
lancoLiu Jun 17, 2021
580ac1e
Tweak bfe_tls/common.go and add byte alignment optimization (#762)
lancoLiu Jun 17, 2021
cc8ccf6
Update CHANGELOG.md
iyangsj Jun 17, 2021
70f3200
Update comments and byte alignment (#764)
lancoLiu Jun 21, 2021
9c7b97b
Update CHANGELOG and VERSION
iyangsj Jun 21, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Support log to single file and stdout (#724)
  • Loading branch information
wangrzneu authored Apr 12, 2021
commit 2b7d38317dfe042432243ef4584079c61ec6036a
29 changes: 5 additions & 24 deletions bfe_modules/mod_access/conf_mod_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,16 @@ import (
)

import (
"github.com/baidu/go-lib/log/log4go"
gcfg "gopkg.in/gcfg.v1"
)

import (
"github.com/bfenetworks/bfe/bfe_util"
"github.com/bfenetworks/bfe/bfe_util/access_log"
)

// ConfModAccess holds the config of access module.
type ConfModAccess struct {
Log struct {
LogPrefix string // log file prefix
LogDir string // log file dir
RotateWhen string // rotate time
BackupCount int // log file backup number
}
Log access_log.LogConfig

Template struct {
RequestTemplate string // access log formate string
Expand Down Expand Up @@ -63,21 +57,9 @@ func ConfLoad(filePath string, confRoot string) (*ConfModAccess, error) {
}

func (cfg *ConfModAccess) Check(confRoot string) error {
if cfg.Log.LogPrefix == "" {
return fmt.Errorf("ModAccess.LogPrefix is empty")
}

if cfg.Log.LogDir == "" {
return fmt.Errorf("ModAccess.LogDir is empty")
}
cfg.Log.LogDir = bfe_util.ConfPathProc(cfg.Log.LogDir, confRoot)

if !log4go.WhenIsValid(cfg.Log.RotateWhen) {
return fmt.Errorf("ModAccess.RotateWhen invalid: %s", cfg.Log.RotateWhen)
}

if cfg.Log.BackupCount <= 0 {
return fmt.Errorf("ModAccess.BackupCount should > 0: %d", cfg.Log.BackupCount)
err := cfg.Log.Check(confRoot)
if err != nil {
return err
}

if cfg.Template.RequestTemplate == "" {
Expand All @@ -87,7 +69,6 @@ func (cfg *ConfModAccess) Check(confRoot string) error {
if cfg.Template.SessionTemplate == "" {
return fmt.Errorf("ModAccess.SessionTemplate not set")
}

return nil
}

Expand Down
9 changes: 3 additions & 6 deletions bfe_modules/mod_access/mod_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ func (m *ModuleAccess) init(conf *ConfModAccess, cbs *bfe_module.BfeCallbacks, w
return fmt.Errorf("%s.Init(): CheckLogFormat %s", m.name, err.Error())
}

m.logger, err = access_log.LoggerInit(conf.Log.LogPrefix, conf.Log.LogDir,
conf.Log.RotateWhen, conf.Log.BackupCount)
m.logger, err = access_log.LoggerInit(conf.Log)
if err != nil {
return fmt.Errorf("%s.Init(): create logger", m.name)
}
Expand Down Expand Up @@ -148,8 +147,7 @@ func (m *ModuleAccess) requestLogHandler(req *bfe_basic.Request, res *bfe_http.R
}
}

byteStr.WriteString("\n")
m.logger.Info(byteStr.Bytes())
m.logger.Info(byteStr.String())

return bfe_module.BfeHandlerGoOn
}
Expand All @@ -173,8 +171,7 @@ func (m *ModuleAccess) sessionLogHandler(session *bfe_basic.Session) int {
}
}

byteStr.WriteString("\n")
m.logger.Info(byteStr.Bytes())
m.logger.Info(byteStr.String())

return bfe_module.BfeHandlerGoOn
}
33 changes: 3 additions & 30 deletions bfe_modules/mod_key_log/conf_mod_key_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,51 +15,24 @@
package mod_key_log

import (
"fmt"
)

import (
"github.com/baidu/go-lib/log/log4go"
gcfg "gopkg.in/gcfg.v1"
)

import (
"github.com/bfenetworks/bfe/bfe_util"
"github.com/bfenetworks/bfe/bfe_util/access_log"
)

// ConfModKeyLog represents the basic config for mod_key_log.
type ConfModKeyLog struct {
Basic struct {
DataPath string // path of config data (key_log)
}
Log struct {
LogPrefix string // log file prefix
LogDir string // log file dir
RotateWhen string // rotate time
BackupCount int // log file backup number
}
Log access_log.LogConfig
}

// Check validates module config
func (cfg *ConfModKeyLog) Check(confRoot string) error {
if cfg.Log.LogPrefix == "" {
return fmt.Errorf("LogPrefix is empty")
}

if cfg.Log.LogDir == "" {
return fmt.Errorf("LogDir is empty")
}
cfg.Log.LogDir = bfe_util.ConfPathProc(cfg.Log.LogDir, confRoot)

if !log4go.WhenIsValid(cfg.Log.RotateWhen) {
return fmt.Errorf("RotateWhen invalid: %s", cfg.Log.RotateWhen)
}

if cfg.Log.BackupCount <= 0 {
return fmt.Errorf("BackupCount should > 0: %d", cfg.Log.BackupCount)
}

return nil
return cfg.Log.Check(confRoot)
}

// ConfLoad loads config from file
Expand Down
3 changes: 1 addition & 2 deletions bfe_modules/mod_key_log/mod_key_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ func (m *ModuleKeyLog) Init(cbs *bfe_module.BfeCallbacks, whs *web_monitor.WebHa
}

// init logger
m.logger, err = access_log.LoggerInit(m.conf.Log.LogPrefix, m.conf.Log.LogDir,
m.conf.Log.RotateWhen, m.conf.Log.BackupCount)
m.logger, err = access_log.LoggerInit(m.conf.Log)
if err != nil {
return fmt.Errorf("%s.Init():create logger:%s", m.name, err.Error())
}
Expand Down
32 changes: 3 additions & 29 deletions bfe_modules/mod_waf/conf_mod_waf.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,14 @@
// limitations under the License.
package mod_waf

import (
"fmt"
)

import (
"github.com/baidu/go-lib/log"
"github.com/baidu/go-lib/log/log4go"
"gopkg.in/gcfg.v1"
)

import (
"github.com/bfenetworks/bfe/bfe_util"
"github.com/bfenetworks/bfe/bfe_util/access_log"
)

const (
Expand All @@ -35,12 +31,7 @@ type ConfModWaf struct {
Basic struct {
ProductRulePath string // path of waf rule data
}
Log struct {
LogPrefix string // log file prefix
LogDir string // log file dir
RotateWhen string // rotate time
BackupCount int // log file backup number
}
Log access_log.LogConfig
}

func (cfg *ConfModWaf) Check(confRoot string) error {
Expand All @@ -51,24 +42,7 @@ func (cfg *ConfModWaf) Check(confRoot string) error {

cfg.Basic.ProductRulePath = bfe_util.ConfPathProc(cfg.Basic.ProductRulePath, confRoot)

if cfg.Log.LogPrefix == "" {
return fmt.Errorf("ConfModWaf.LogPrefix is empty")
}

if cfg.Log.LogDir == "" {
return fmt.Errorf("ConfModWaf.LogDir is empty")
}
cfg.Log.LogDir = bfe_util.ConfPathProc(cfg.Log.LogDir, confRoot)

if !log4go.WhenIsValid(cfg.Log.RotateWhen) {
return fmt.Errorf("ConfModWaf.RotateWhen invalid: %s", cfg.Log.RotateWhen)
}

if cfg.Log.BackupCount <= 0 {
return fmt.Errorf("ConfModWaf.BackupCount should > 0: %d", cfg.Log.BackupCount)
}

return nil
return cfg.Log.Check(confRoot)
}

func ConfLoad(filePath string, confRoot string) (*ConfModWaf, error) {
Expand Down
64 changes: 10 additions & 54 deletions bfe_modules/mod_waf/conf_mod_waf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package mod_waf

import (
"github.com/bfenetworks/bfe/bfe_util/access_log"
"reflect"
"testing"
)
Expand All @@ -23,12 +24,7 @@ func TestConfModWafCheck(t *testing.T) {
Basic struct {
ProductRulePath string
}
Log struct {
LogPrefix string
LogDir string
RotateWhen string
BackupCount int
}
Log access_log.LogConfig
}
type args struct {
confRoot string
Expand All @@ -47,12 +43,7 @@ func TestConfModWafCheck(t *testing.T) {
}{
ProductRulePath: "mod_waf/waf_rule.data",
},
Log: struct {
LogPrefix string
LogDir string
RotateWhen string
BackupCount int
}{
Log: access_log.LogConfig{
LogPrefix: "waf",
LogDir: "../log",
RotateWhen: "NEXTHOUR",
Expand All @@ -72,12 +63,7 @@ func TestConfModWafCheck(t *testing.T) {
}{
ProductRulePath: "",
},
Log: struct {
LogPrefix string
LogDir string
RotateWhen string
BackupCount int
}{
Log: access_log.LogConfig {
LogPrefix: "waf",
LogDir: "../log",
RotateWhen: "NEXTHOUR",
Expand All @@ -97,12 +83,7 @@ func TestConfModWafCheck(t *testing.T) {
}{
ProductRulePath: "mod_waf/waf_rule.data",
},
Log: struct {
LogPrefix string
LogDir string
RotateWhen string
BackupCount int
}{
Log: access_log.LogConfig {
LogPrefix: "waf",
LogDir: "../log",
RotateWhen: "NEXTHOUR",
Expand All @@ -122,12 +103,7 @@ func TestConfModWafCheck(t *testing.T) {
}{
ProductRulePath: "mod_waf/waf_rule.data",
},
Log: struct {
LogPrefix string
LogDir string
RotateWhen string
BackupCount int
}{
Log: access_log.LogConfig {
LogPrefix: "",
LogDir: "../log",
RotateWhen: "NEXTHOUR",
Expand All @@ -147,12 +123,7 @@ func TestConfModWafCheck(t *testing.T) {
}{
ProductRulePath: "mod_waf/waf_rule.data",
},
Log: struct {
LogPrefix string
LogDir string
RotateWhen string
BackupCount int
}{
Log: access_log.LogConfig {
LogPrefix: "waf",
LogDir: "",
RotateWhen: "NEXTHOUR",
Expand All @@ -172,12 +143,7 @@ func TestConfModWafCheck(t *testing.T) {
}{
ProductRulePath: "mod_waf/waf_rule.data",
},
Log: struct {
LogPrefix string
LogDir string
RotateWhen string
BackupCount int
}{
Log: access_log.LogConfig {
LogPrefix: "waf",
LogDir: "",
RotateWhen: "NEXTHOUR",
Expand All @@ -197,12 +163,7 @@ func TestConfModWafCheck(t *testing.T) {
}{
ProductRulePath: "mod_waf/waf_rule.data",
},
Log: struct {
LogPrefix string
LogDir string
RotateWhen string
BackupCount int
}{
Log: access_log.LogConfig {
LogPrefix: "waf",
LogDir: "../log",
RotateWhen: "HHHH",
Expand Down Expand Up @@ -251,12 +212,7 @@ func TestConfLoad(t *testing.T) {
}{
ProductRulePath: "testdata/mod_waf/waf_rule.data",
},
Log: struct {
LogPrefix string
LogDir string
RotateWhen string
BackupCount int
}{
Log: access_log.LogConfig {
LogPrefix: "waf",
LogDir: "log",
RotateWhen: "NEXTHOUR",
Expand Down
3 changes: 1 addition & 2 deletions bfe_modules/mod_waf/waf_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ func (wf *wafLogger) Init(conf *ConfModWaf) error {
var err error
// WAF LOG Demo:[2020/08/25 13:40:58 CST] [INFO] [69613] {"Rule":"RuleBashCmd","Type":"Block","Hit":true ...
logFormatter := "[%D %T] [%L] [%P] %M"
wf.log, err = access_log.LoggerInitWithFormat(conf.Log.LogPrefix, conf.Log.LogDir,
conf.Log.RotateWhen, conf.Log.BackupCount, logFormatter)
wf.log, err = access_log.LoggerInitWithFormat(conf.Log, logFormatter)
if err != nil {
return fmt.Errorf("WafLogger.Init(): create logger error:%v", err)
}
Expand Down
Loading