From 7cd3a9f901f5e581247e708b39b80535122ba7ed Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Fri, 31 Mar 2023 12:40:13 +0800 Subject: [PATCH] =?UTF-8?q?IP=E5=BA=93=E5=A2=9E=E5=8A=A0=E9=87=8A=E6=94=BE?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/iplibrary/default_ip_library.go | 6 ++++++ pkg/iplibrary/reader.go | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/pkg/iplibrary/default_ip_library.go b/pkg/iplibrary/default_ip_library.go index 8052abd..11741cc 100644 --- a/pkg/iplibrary/default_ip_library.go +++ b/pkg/iplibrary/default_ip_library.go @@ -115,3 +115,9 @@ func (this *IPLibrary) LookupIP(ip string) *QueryResult { } return this.Lookup(net.ParseIP(ip)) } + +func (this *IPLibrary) Destroy() { + if this.reader != nil { + this.reader.Destroy() + } +} diff --git a/pkg/iplibrary/reader.go b/pkg/iplibrary/reader.go index 0b0dab7..49cb4b1 100644 --- a/pkg/iplibrary/reader.go +++ b/pkg/iplibrary/reader.go @@ -170,6 +170,13 @@ func (this *Reader) IPv6Items() []*ipv6Item { return this.ipV6Items } +func (this *Reader) Destroy() { + this.meta = nil + this.regionMap = nil + this.ipV4Items = nil + this.ipV6Items = nil +} + // 分析数据 func (this *Reader) parse(data []byte) (left []byte, err error) { if len(data) == 0 {