mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-15 00:40:26 +08:00
访问日志支持中文域名搜索
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
|||||||
"github.com/iwind/TeaGo/rands"
|
"github.com/iwind/TeaGo/rands"
|
||||||
"github.com/iwind/TeaGo/types"
|
"github.com/iwind/TeaGo/types"
|
||||||
timeutil "github.com/iwind/TeaGo/utils/time"
|
timeutil "github.com/iwind/TeaGo/utils/time"
|
||||||
|
"golang.org/x/net/idna"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
@@ -509,6 +510,14 @@ func (this *HTTPAccessLogDAO) listAccessLogs(tx *dbs.Tx,
|
|||||||
query.Where("domain LIKE :host2").
|
query.Where("domain LIKE :host2").
|
||||||
Param("host2", domain)
|
Param("host2", domain)
|
||||||
} else {
|
} 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.Attr("domain", domain)
|
||||||
query.UseIndex("domain")
|
query.UseIndex("domain")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user