From 999c0dd5941576e7b9dff030e73102d6590c3cca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E5=90=B9=E6=88=91=E5=B7=B2=E6=95=A3?= Date: Thu, 11 Jul 2024 15:56:51 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E6=9B=BF=E6=8D=A2ipv6?= =?UTF-8?q?=E5=88=86=E5=89=B2=E7=AC=A6=E4=B8=BA=E7=A9=BA=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/ip2region/ip2region.go | 10 +++++----- pkg/zxipv6wry/zxipv6wry.go | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/ip2region/ip2region.go b/pkg/ip2region/ip2region.go index a8f2c387..b9e91cab 100644 --- a/pkg/ip2region/ip2region.go +++ b/pkg/ip2region/ip2region.go @@ -3,7 +3,7 @@ package ip2region import ( "errors" "fmt" - "io/ioutil" + "io" "log" "os" "strings" @@ -39,7 +39,7 @@ func NewIp2Region(filePath string) (*Ip2Region, error) { } defer f.Close() - data, err := ioutil.ReadAll(f) + data, err := io.ReadAll(f) if err != nil { return nil, err } @@ -56,9 +56,9 @@ func NewIp2Region(filePath string) (*Ip2Region, error) { func (db Ip2Region) Find(query string, params ...string) (result fmt.Stringer, err error) { if db.seacher != nil { res, err := db.seacher.SearchByStr(query) - res = strings.ReplaceAll(res, "|", " ") //替换分割符为空格 - res = strings.ReplaceAll(res, "\t", " ") //替换制表符为空格 - res = strings.ReplaceAll(res, "–", " ") //替换纯真分隔符为空格 + res = strings.ReplaceAll(res, "|", " ") //替换分割符为空格 + res = strings.ReplaceAll(res, "\t", " ") //替换制表符为空格 + res = strings.ReplaceAll(res, "–", " ") //替换纯真分隔符为空格 if err != nil { return nil, err } else { diff --git a/pkg/zxipv6wry/zxipv6wry.go b/pkg/zxipv6wry/zxipv6wry.go index f1ec1c3e..69605808 100644 --- a/pkg/zxipv6wry/zxipv6wry.go +++ b/pkg/zxipv6wry/zxipv6wry.go @@ -8,6 +8,7 @@ import ( "log" "net" "os" + "strings" "github.com/zu1k/nali/pkg/wry" ) @@ -79,6 +80,7 @@ func (db *ZXwry) Find(query string, _ ...string) (result fmt.Stringer, err error offset := db.SearchIndexV6(ipu64) reader := wry.NewReader(db.Data) reader.Parse(offset) + reader.Result.Country = strings.ReplaceAll(reader.Result.Country, "\t", " ") return reader.Result, nil }