ADD and DEL operations now supported

This commit is contained in:
yo
2022-11-13 13:41:14 +01:00
parent aff1c5af75
commit 2cbac9a0c3
2 changed files with 126 additions and 10 deletions

View File

@ -43,10 +43,14 @@ const (
UnbindRE = `(UNBIND)?`
// group[40]
ConnClosedRE = `(closed)?(?: \(connection lost\))?`
// group[41]
AddDnRE = `(?:ADD dn="(.*)")?`
// group[42]
DelDnRE = `(?:DEL dn="(.*)")?`
LogLineRE = SyslogPri + TimeRE + ` ` + HostRE + ` ` + ProcessRE + ` ` + ConnIdRE + ` ` + ConnFdRE + OperationIdRE + ` ` +
AcceptRE + STARTTLSRE + BindMethodRE + BindMechRE + ResultRE + SearchBaseRE + SearchAttrRE + SearchResultRE + ModDnRE + ModAttrRE +
PassModRE + UnbindRE + ConnClosedRE
PassModRE + UnbindRE + ConnClosedRE + AddDnRE + DelDnRE
)
type (
@ -74,6 +78,8 @@ type (
SSF string `json:"ssf"`
ModDN string `json:"mod_dn"`
ModAttr string `json:"mod_attr"`
AddDN string `json:"add_dn"`
DelDN string `json:"del_dn"`
PassModDN string `json:"passmod_dn"`
Result bool
ResTag string `json:"result_tag"`
@ -184,6 +190,8 @@ func (o *OpenldapLog) Parse(text []byte) (LogFormat, error) {
ModDN: string(group[36]),
ModAttr: string(group[37]),
PassModDN: string(group[38]),
AddDN: string(group[41]),
DelDN: string(group[42]),
}
// Now handle Operation Type
@ -203,6 +211,10 @@ func (o *OpenldapLog) Parse(text []byte) (LogFormat, error) {
logFormat.OpType = "unbind"
} else if len(group[40]) > 0 {
logFormat.OpType = "close"
} else if len(group[41]) > 0 {
logFormat.OpType = "add"
} else if len(group[42]) > 0 {
logFormat.OpType = "del"
}
return logFormat, nil