修改审计参数

This commit is contained in:
bjdgyc 2021-08-26 15:33:56 +08:00
parent a47cdc9a00
commit a0065ade42
4 changed files with 12 additions and 8 deletions

View File

@ -55,7 +55,7 @@ var configs = []config{
{Typ: cfgInt, Name: "mobile_dpd", Usage: "移动端死链接检测时间(秒)", ValInt: 60},
{Typ: cfgInt, Name: "session_timeout", Usage: "session过期时间(秒)", ValInt: 3600},
// {Typ: cfgInt, Name: "auth_timeout", Usage: "auth_timeout", ValInt: 0},
{Typ: cfgInt, Name: "audit_interval", Usage: "审计去重间隔(秒),0关闭", ValInt: 0},
{Typ: cfgInt, Name: "audit_interval", Usage: "审计去重间隔(秒),-1关闭", ValInt: -1},
}
var envs = map[string]string{}

View File

@ -62,7 +62,7 @@ mobile_dpd = 50
#session过期时间用于断线重连0永不过期
session_timeout = 3600
auth_timeout = 0
audit_interval = -1

View File

@ -100,15 +100,11 @@ func checkLinkAcl(group *dbdata.Group, pl *sessdata.Payload) bool {
// 访问日志审计
func logAudit(cSess *sessdata.ConnSession, pl *sessdata.Payload) {
if base.Cfg.AuditInterval <= 0 {
if base.Cfg.AuditInterval < 0 {
return
}
ipSrc := waterutil.IPv4Source(pl.Data)
ipDst := waterutil.IPv4Destination(pl.Data)
ipPort := waterutil.IPv4DestinationPort(pl.Data)
ipProto := waterutil.IPv4Protocol(pl.Data)
// 只统计 tcp和udp 的访问
switch ipProto {
case waterutil.TCP:
@ -117,6 +113,10 @@ func logAudit(cSess *sessdata.ConnSession, pl *sessdata.Payload) {
return
}
ipSrc := waterutil.IPv4Source(pl.Data)
ipDst := waterutil.IPv4Destination(pl.Data)
ipPort := waterutil.IPv4DestinationPort(pl.Data)
b := getByte34()
key := *b
copy(key[:16], ipSrc)

View File

@ -186,10 +186,14 @@ func (s *Session) NewConn() *ConnSession {
PayloadIn: make(chan *Payload, 64),
PayloadOutCstp: make(chan *Payload, 64),
PayloadOutDtls: make(chan *Payload, 64),
IpAuditMap: make(map[string]int64, 512),
dSess: &atomic.Value{},
}
// ip 审计
if base.Cfg.AuditInterval >= 0 {
cSess.IpAuditMap = make(map[string]int64, 512)
}
dSess := &DtlsSession{
isActive: -1,
}