From 6a69377568c6677a198bb9847e7a3ec7349cd554 Mon Sep 17 00:00:00 2001 From: lanrenwo Date: Fri, 15 Jul 2022 11:27:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E5=AE=A1=E8=AE=A1=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E7=9A=84=E9=A1=B5=E9=9D=A2=E5=A2=9E=E5=8A=A0=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E5=92=8C=E8=AE=BF=E9=97=AE=E5=8D=8F=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/handler/payload.go | 10 ++++---- server/handler/pool.go | 16 ++++++------- web/src/pages/set/Audit.vue | 46 +++++++++++++++++++++++++++---------- 3 files changed, 48 insertions(+), 24 deletions(-) diff --git a/server/handler/payload.go b/server/handler/payload.go index ab2b387..df403d7 100644 --- a/server/handler/payload.go +++ b/server/handler/payload.go @@ -1,7 +1,9 @@ package handler import ( + "crypto/md5" "encoding/binary" + "encoding/hex" "github.com/bjdgyc/anylink/base" "github.com/bjdgyc/anylink/dbdata" @@ -127,7 +129,7 @@ func logAudit(cSess *sessdata.ConnSession, pl *sessdata.Payload) { ipDst := waterutil.IPv4Destination(pl.Data) ipPort := waterutil.IPv4DestinationPort(pl.Data) - b := getByte290() + b := getByte51() key := *b copy(key[:16], ipSrc) copy(key[16:32], ipDst) @@ -139,9 +141,9 @@ func logAudit(cSess *sessdata.ConnSession, pl *sessdata.Payload) { } key[34] = byte(accessProto) if info != "" { - copy(key[35:35+len(info)], info) + md5Sum := md5.Sum([]byte(info)) + copy(key[35:51], hex.EncodeToString(md5Sum[:])) } - s := utils.BytesToString(key) nu := utils.NowSec().Unix() @@ -149,7 +151,7 @@ func logAudit(cSess *sessdata.ConnSession, pl *sessdata.Payload) { v, ok := cSess.IpAuditMap[s] if ok && nu-v < int64(base.Cfg.AuditInterval) { // 回收byte对象 - putByte290(b) + putByte51(b) return } diff --git a/server/handler/pool.go b/server/handler/pool.go index c56b305..bf9b1c7 100644 --- a/server/handler/pool.go +++ b/server/handler/pool.go @@ -92,20 +92,20 @@ type BufferPool struct { sync.Pool } -// 长度 290 对象 -var byte290Pool = sync.Pool{ +// 长度 51 小对象 +var byte51Pool = sync.Pool{ New: func() interface{} { - b := make([]byte, 290) + b := make([]byte, 51) return &b }, } -func getByte290() *[]byte { - b := byte290Pool.Get().(*[]byte) +func getByte51() *[]byte { + b := byte51Pool.Get().(*[]byte) return b } -func putByte290(b *[]byte) { - *b = (*b)[:290] - byte290Pool.Put(b) +func putByte51(b *[]byte) { + *b = (*b)[:51] + byte51Pool.Put(b) } diff --git a/web/src/pages/set/Audit.vue b/web/src/pages/set/Audit.vue index 6c4e436..fe7d0e0 100644 --- a/web/src/pages/set/Audit.vue +++ b/web/src/pages/set/Audit.vue @@ -16,39 +16,50 @@ - - - - + label="用户名" + width="120"> + label="源IP地址" + width="140"> + label="目的IP地址" + width="140"> + label="目的端口" + width="85"> + + + + + + + width="100">