mirror of
https://github.com/bjdgyc/anylink.git
synced 2025-08-07 21:28:50 +08:00
添加审计日志界面
This commit is contained in:
33
server/admin/api_set_audit.go
Normal file
33
server/admin/api_set_audit.go
Normal 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)
|
||||
}
|
@@ -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)
|
||||
|
@@ -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{}
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user