From d9b49b55fab5c7d4b60da2b5445840a9ba9ca134 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Wed, 7 Sep 2022 17:07:46 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BF=E9=97=AE=E6=97=A5=E5=BF=97=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E4=B8=AD=E6=96=87=E5=9F=9F=E5=90=8D=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/db/models/http_access_log_dao.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/db/models/http_access_log_dao.go b/internal/db/models/http_access_log_dao.go index 29d00801..9f5ce54b 100644 --- a/internal/db/models/http_access_log_dao.go +++ b/internal/db/models/http_access_log_dao.go @@ -21,6 +21,7 @@ import ( "github.com/iwind/TeaGo/rands" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" + "golang.org/x/net/idna" "net" "net/http" "net/url" @@ -144,7 +145,7 @@ func (this *HTTPAccessLogDAO) DumpAccessLogsFromQueue(size int) (hasMore bool, e if size <= 0 { size = 100 } - + var dao = randomHTTPAccessLogDAO() if dao == nil { dao = &HTTPAccessLogDAOWrapper{ @@ -509,6 +510,14 @@ func (this *HTTPAccessLogDAO) listAccessLogs(tx *dbs.Tx, query.Where("domain LIKE :host2"). Param("host2", domain) } else { + // δΈ­ζ–‡εŸŸε + if !regexp.MustCompile(`^[a-zA-Z0-9-.]+$`).MatchString(domain) { + unicodeDomain, err := idna.ToASCII(domain) + if err == nil && len(unicodeDomain) > 0 { + domain = unicodeDomain + } + } + query.Attr("domain", domain) query.UseIndex("domain") }