From 7f2286947ca5f7ce83c94c52fc4fe8f2a96b0178 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Sun, 8 Oct 2023 17:52:53 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BF=E9=97=AE=E6=97=A5=E5=BF=97=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=90=9C=E7=B4=A2=E5=A2=9E=E5=8A=A0=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E6=9D=A5=E6=BA=90=E6=9F=A5=E8=AF=A2=E8=AF=AD=E6=B3=95=EF=BC=9A?= =?UTF-8?q?referer:example.com?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/db/models/http_access_log_dao.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/db/models/http_access_log_dao.go b/internal/db/models/http_access_log_dao.go index ffb471b6..e8668cb0 100644 --- a/internal/db/models/http_access_log_dao.go +++ b/internal/db/models/http_access_log_dao.go @@ -461,6 +461,7 @@ func (this *HTTPAccessLogDAO) listAccessLogs(tx *dbs.Tx, var protoReg = regexp.MustCompile(`proto:(\S+)`) var schemeReg = regexp.MustCompile(`scheme:(\S+)`) var methodReg = regexp.MustCompile(`(?:method|requestMethod):(\S+)`) + var refererReg = regexp.MustCompile(`referer:(\S+)`) var count = len(tableQueries) var wg = &sync.WaitGroup{} @@ -613,6 +614,11 @@ func (this *HTTPAccessLogDAO) listAccessLogs(tx *dbs.Tx, var matches = methodReg.FindStringSubmatch(keyword) query.Where("JSON_EXTRACT(content, '$.requestMethod')=:keyword"). Param("keyword", strings.ToUpper(matches[1])) + } else if refererReg.MatchString(keyword) { + isSpecialKeyword = true + var matches = refererReg.FindStringSubmatch(keyword) + query.Where("JSON_EXTRACT(content, '$.referer') LIKE :keyword"). + Param("keyword", dbutils.QuoteLike(matches[1])) } if !isSpecialKeyword { if regexp.MustCompile(`^ip:.+`).MatchString(keyword) {