From 678e7f2c2a0c6ad97f6df11608ccc6cd11fe2fe0 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Sun, 1 Aug 2021 09:20:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DIPv6=E8=AE=BF=E9=97=AE?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E5=AF=BC=E8=87=B4=E8=BF=9B=E7=A8=8B=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E9=80=80=E5=87=BA=E7=9A=84Bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/iplibrary/library_interface.go | 7 ++++--- internal/stats/http_request_stat_manager.go | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/iplibrary/library_interface.go b/internal/iplibrary/library_interface.go index df0ef7c..5616397 100644 --- a/internal/iplibrary/library_interface.go +++ b/internal/iplibrary/library_interface.go @@ -1,12 +1,13 @@ package iplibrary type LibraryInterface interface { - // 加载数据库文件 + // Load 加载数据库文件 Load(dbPath string) error - // 查询IP + // Lookup 查询IP + // 返回结果有可能为空 Lookup(ip string) (*Result, error) - // 关闭数据库文件 + // Close 关闭数据库文件 Close() } diff --git a/internal/stats/http_request_stat_manager.go b/internal/stats/http_request_stat_manager.go index c30b61e..2e808f3 100644 --- a/internal/stats/http_request_stat_manager.go +++ b/internal/stats/http_request_stat_manager.go @@ -165,7 +165,7 @@ Loop: ip := ipString[atIndex+1:] if iplibrary.SharedLibrary != nil { result, err := iplibrary.SharedLibrary.Lookup(ip) - if err == nil { + if err == nil && result != nil { this.cityMap[serverId+"@"+result.Country+"@"+result.Province+"@"+result.City] ++ if len(result.ISP) > 0 {