From f52ea4fa4fbfe7a6d975883869c67dd5d25bd866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Sun, 18 Jul 2021 17:09:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=80=9A=E8=BF=87IP=E6=9F=A5?= =?UTF-8?q?=E6=89=BE=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/db/models/http_access_log_dao.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/db/models/http_access_log_dao.go b/internal/db/models/http_access_log_dao.go index b2ad6374..cb3322be 100644 --- a/internal/db/models/http_access_log_dao.go +++ b/internal/db/models/http_access_log_dao.go @@ -227,8 +227,15 @@ func (this *HTTPAccessLogDAO) listAccessLogs(tx *dbs.Tx, lastRequestId string, s // remoteAddr if hasRemoteAddr && net.ParseIP(keyword) != nil { query.Attr("remoteAddr", keyword) + } else if hasRemoteAddr && regexp.MustCompile(`^ip:.+`).MatchString(keyword) { + keyword = keyword[3:] + pieces := strings.SplitN(keyword, ",", 2) + if len(pieces) == 1 || len(pieces[1]) == 0 { + query.Attr("remoteAddr", pieces[0]) + } else { + query.Between("remoteAddr", pieces[0], pieces[1]) + } } else { - useOriginKeyword := false where := "JSON_EXTRACT(content, '$.remoteAddr') LIKE :keyword OR JSON_EXTRACT(content, '$.requestURI') LIKE :keyword OR JSON_EXTRACT(content, '$.host') LIKE :keyword"