mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-12-14 14:50:24 +08:00
IP名单新增IPv6和所有IP两种类型
This commit is contained in:
@@ -3,8 +3,9 @@ package iplibrary
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/errors"
|
||||
"github.com/iwind/TeaGo/logs"
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/remotelogs"
|
||||
"github.com/lionsoul2014/ip2region/binding/golang/ip2region"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type IP2RegionLibrary struct {
|
||||
@@ -26,11 +27,16 @@ func (this *IP2RegionLibrary) Lookup(ip string) (*Result, error) {
|
||||
return nil, errors.New("library has not been loaded")
|
||||
}
|
||||
|
||||
// 暂不支持IPv6
|
||||
if strings.Contains(ip, ":") {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
defer func() {
|
||||
// 防止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