mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2026-01-02 12:06:35 +08:00
IP名单新增IPv6和所有IP两种类型
This commit is contained in:
@@ -3,8 +3,9 @@ package iplibrary
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/TeaOSLab/EdgeNode/internal/errors"
|
||||
"github.com/iwind/TeaGo/logs"
|
||||
"github.com/TeaOSLab/EdgeNode/internal/remotelogs"
|
||||
"github.com/lionsoul2014/ip2region/binding/golang/ip2region"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type IP2RegionLibrary struct {
|
||||
@@ -22,6 +23,11 @@ func (this *IP2RegionLibrary) Load(dbPath string) error {
|
||||
}
|
||||
|
||||
func (this *IP2RegionLibrary) Lookup(ip string) (*Result, error) {
|
||||
// 暂不支持IPv6
|
||||
if strings.Contains(ip, ":") {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
if this.db == nil {
|
||||
return nil, errors.New("library has not been loaded")
|
||||
}
|
||||
@@ -30,7 +36,7 @@ func (this *IP2RegionLibrary) Lookup(ip string) (*Result, error) {
|
||||
// 防止panic发生
|
||||
err := recover()
|
||||
if err != nil {
|
||||
logs.Println("[IP2RegionLibrary]panic: " + fmt.Sprintf("%#v", err))
|
||||
remotelogs.Error("IP2RegionLibrary", "panic: "+fmt.Sprintf("%#v", err))
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user