添加审计日志界面

This commit is contained in:
bjdgyc
2021-08-17 13:14:13 +08:00
parent 6dcdc9766a
commit d9a3b0152b
7 changed files with 187 additions and 1 deletions

View File

@@ -0,0 +1,33 @@
package admin
import (
"net/http"
"strconv"
"github.com/bjdgyc/anylink/dbdata"
)
func SetAuditList(w http.ResponseWriter, r *http.Request) {
_ = r.ParseForm()
pageS := r.FormValue("page")
page, _ := strconv.Atoi(pageS)
if page < 1 {
page = 1
}
var datas []dbdata.AccessAudit
count := dbdata.CountAll(&dbdata.AccessAudit{})
err := dbdata.Find(&datas, dbdata.PageSize, page)
if err != nil && !dbdata.CheckErrNotFound(err) {
RespError(w, RespInternalErr, err)
return
}
data := map[string]interface{}{
"count": count,
"page_size": dbdata.PageSize,
"datas": datas,
}
RespSucess(w, data)
}

View File

@@ -32,6 +32,7 @@ func StartAdmin() {
r.HandleFunc("/set/other/edit", SetOtherEdit)
r.HandleFunc("/set/other/smtp", SetOtherSmtp)
r.HandleFunc("/set/other/smtp/edit", SetOtherSmtpEdit)
r.HandleFunc("/set/audit/list", SetAuditList)
r.HandleFunc("/user/list", UserList)
r.HandleFunc("/user/detail", UserDetail)

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: "审计去重间隔(秒)", ValInt: 1800},
{Typ: cfgInt, Name: "audit_interval", Usage: "审计去重间隔(秒),0关闭", ValInt: 0},
}
var envs = map[string]string{}

View File

@@ -100,6 +100,10 @@ func checkLinkAcl(group *dbdata.Group, pl *sessdata.Payload) bool {
// 访问日志审计
func logAudit(cSess *sessdata.ConnSession, pl *sessdata.Payload) {
if base.Cfg.AuditInterval <= 0 {
return
}
ipSrc := waterutil.IPv4Source(pl.Data)
ipDst := waterutil.IPv4Destination(pl.Data)
ipPort := waterutil.IPv4DestinationPort(pl.Data)