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 }