Debian Codegraph @

CHANGELOG.md

raw symbols SCIP
1 # Changes
2
3 ## 2.2.0 - 2026-04-26
4
5 - Improved reflection decoding performance by skipping `Unmarshaler` checks for
6 destination types that cannot implement the interface.
7 - Fixed verifier search-tree size arithmetic to match the reader's safe
8 multiplication order instead of using an overflow-prone equivalent formula.
9 - Fixed unsigned bounds checks in search-tree node reads and traversal so very
10 short malformed buffers return errors instead of underflowing the bounds
11 calculation.
12 - Fixed the reflection decoder so pointer fields are not allocated when
13 decoding fails with a type mismatch.
14 - Fixed `Result.Prefix()` to use the reader's measured IPv4 subtree depth
15 instead of assuming IPv4 records always start at bit 96 in IPv6 databases.
16 - Fixed reflection decoding of negative `int32` values into unsigned Go fields
17 so it now returns a type error instead of wrapping them to large integers.
18 - Fixed lookups that followed malformed search-tree pointers past the data
19 section so they now fail during `Lookup` instead of surfacing a deferred
20 decode error.
21 - An error is returned when a `maxminddb` struct tag is clearly invalid (non
22 UTF-8) instead of silently ignoring validation failures.
23 - Increased internal string cache size to 4096 entries to reduce cache thrashing
24 and improve concurrent performance.
25
26 ## 2.1.1 - 2025-11-26
27
28 - Fixed `runtime.AddCleanup` misuse that prevented the memory-mapped file from
29 being unmapped when the `Reader` was garbage collected.
30
31 ## 2.1.0 - 2025-11-04
32
33 - Updated `Offset` method on `Decoder` to return the resolved data offset
34 when positioned at a pointer. This makes more useful for caching values,
35 which is its stated purpose.
36
37 ## 2.0.0 - 2025-10-18
38
39 - BREAKING CHANGE: Removed deprecated `FromBytes`. Use `OpenBytes` instead.
40 - Fixed verifier metadata error message to require a non-empty map for the
41 database description. GitHub #187.
42 - Introduces the v2 API with `Reader.Lookup(ip).Decode(...)`, `netip.Addr`
43 support, custom decoder interfaces, and richer error reporting.
44 - See MIGRATION.md for guidance on upgrading projects from v1 to v2.
45
46 ## 2.0.0-beta.10 - 2025-08-23
47
48 - Replaced `runtime.SetFinalizer` with `runtime.AddCleanup` for resource
49 cleanup in Go 1.24+. This provides more reliable finalization behavior and
50 better garbage collection performance.
51
52 ## 2.0.0-beta.9 - 2025-08-23
53
54 - **SECURITY**: Fixed integer overflow vulnerability in search tree size
55 calculation that could potentially allow malformed databases to trigger
56 security issues.
57 - **SECURITY**: Enhanced bounds checking in tree traversal functions to return
58 proper errors instead of silent failures when encountering malformed
59 databases.
60 - Added validation for invalid prefixes in `NetworksWithin` to prevent
61 unexpected behavior with malformed input.
62 - Added `SkipEmptyValues()` option for `Networks` and `NetworksWithin` to skip
63 networks whose data is an empty map or empty array. This is useful for
64 databases that store empty maps or arrays for records without meaningful
65 data. GitHub #172.
66 - Optimized custom unmarshaler type assertion to use Go 1.25's
67 `reflect.TypeAssert` when available, reducing allocations in reflection code
68 paths.
69 - Improved memory mapping implementation by using `SyscallConn()` instead of
70 `Fd()` to avoid side effects and prepare for Go 1.25+ Windows I/O
71 enhancements. Pull request by database64128. GitHub #179.
72 - Added `OpenBytes` function for better API discoverability and consistency
73 with `Open()`. `FromBytes` is now deprecated and will be removed in a future
74 version.
75
76 ## 2.0.0-beta.8 - 2025-07-15
77
78 - Fixed "no next offset available" error that occurred when using custom
79 unmarshalers that decode container types (maps, slices) in struct fields.
80 The reflection decoder now correctly calculates field positions when
81 advancing to the next field after custom unmarshaling.
82
83 ## 2.0.0-beta.7 - 2025-07-07
84
85 - Update capitalization of "uint" in `ReadUInt*` to match `KindUint*` as well
86 as the Go standard library.
87
88 ## 2.0.0-beta.6 - 2025-07-07
89
90 - Invalid release with no code changes.
91
92 ## 2.0.0-beta.5 - 2025-07-06
93
94 - Added `Offset()` method to `Decoder` to get the current database offset. This
95 enables custom unmarshalers to implement caching for improved performance when
96 loading databases with duplicate data structures.
97 - Fixed infinite recursion in pointer-to-pointer data structures, which are
98 invalid per the MaxMind DB specification.
99
100 ## 2.0.0-beta.4 - 2025-07-05
101
102 - **BREAKING CHANGE**: Removed experimental `deserializer` interface and
103 supporting code. Applications using this interface should migrate to the
104 `Unmarshaler` interface by implementing `UnmarshalMaxMindDB(d *Decoder) error`
105 instead.
106 - `Open` and `FromBytes` now accept options.
107 - **BREAKING CHANGE**: `IncludeNetworksWithoutData` and `IncludeAliasedNetworks`
108 now return a `NetworksOption` rather than being one themselves. These must now
109 be called as functions: `Networks(IncludeAliasedNetworks())` instead of
110 `Networks(IncludeAliasedNetworks)`. This was done to improve the documentation
111 organization.
112 - Added `Unmarshaler` interface to allow custom decoding implementations for
113 performance-critical applications. Types implementing
114 `UnmarshalMaxMindDB(d *Decoder) error` will automatically use custom decoding
115 logic instead of reflection, following the same pattern as
116 `json.Unmarshaler`.
117 - Added public `Decoder` type and `Kind` constants in `mmdbdata` package for
118 manual decoding. `Decoder` provides methods like `ReadMap()`, `ReadSlice()`,
119 `ReadString()`, `ReadUInt32()`, `PeekKind()`, etc. `Kind` type includes
120 helper methods `String()`, `IsContainer()`, and `IsScalar()` for type
121 introspection. The main `maxminddb` package re-exports these types for
122 backward compatibility. `NewDecoder()` supports an options pattern for
123 future extensibility.
124 - Enhanced `UnmarshalMaxMindDB` to work with nested struct fields, slice
125 elements, and map values. The custom unmarshaler is now called recursively
126 for any type that implements the `Unmarshaler` interface, similar to
127 `encoding/json`.
128 - Improved error messages to include byte offset information and, for the
129 reflection-based API, path information for nested structures using JSON
130 Pointer format. For example, errors may now show "at offset 1234, path
131 /city/names/en" or "at offset 1234, path /list/0/name" instead of just the
132 underlying error message.
133 - **PERFORMANCE**: Added string interning optimization that reduces allocations
134 while maintaining thread safety. Reduces allocation count from 33 to 10 per
135 operation in downstream libraries. Uses a fixed 512-entry cache with per-entry
136 mutexes for bounded memory usage (~8KB) while minimizing lock contention.
137
138 ## 2.0.0-beta.3 - 2025-02-16
139
140 - `Open` will now fall back to loading the database in memory if the
141 file-system does not support `mmap`. Pull request by database64128. GitHub
142 #163.
143 - Made significant improvements to the Windows memory-map handling. GitHub
144 #162.
145 - Fix an integer overflow on large databases when using a 32-bit architecture.
146 See ipinfo/mmdbctl#33.
147
148 ## 2.0.0-beta.2 - 2024-11-14
149
150 - Allow negative indexes for arrays when using `DecodePath`. #152
151 - Add `IncludeNetworksWithoutData` option for `Networks` and `NetworksWithin`.
152 #155 and #156
153
154 ## 2.0.0-beta.1 - 2024-08-18
155
156 This is the first beta of the v2 releases. Go 1.23 is required. I don't expect
157 to do a final release until Go 1.24 is available. See #141 for the v2 roadmap.
158
159 Notable changes:
160
161 - `(*Reader).Lookup` now takes only the IP address and returns a `Result`.
162 `Lookup(ip, &rec)` would now become `Lookup(ip).Decode(&rec)`.
163 - `(*Reader).LookupNetwork` has been removed. To get the network for a result,
164 use `(Result).Prefix()`.
165 - `(*Reader).LookupOffset` now _takes_ an offset and returns a `Result`.
166 `Result` has an `Offset()` method that returns the offset value.
167 `(*Reader).Decode` has been removed.
168 - Use of `net.IP` and `*net.IPNet` have been replaced with `netip.Addr` and
169 `netip.Prefix`.
170 - You may now decode a particular path within a database record using
171 `(Result).DecodePath`. For instance, to decode just the country code in
172 GeoLite2 Country to a string called `code`, you might do something like
173 `Lookup(ip).DecodePath(&code, "country", "iso_code")`. Strings should be used
174 for map keys and ints for array indexes.
175 - `(*Reader).Networks` and `(*Reader).NetworksWithin` now return a Go 1.23
176 iterator of `Result` values. Aliased networks are now skipped by default. If
177 you wish to include them, use the `IncludeAliasedNetworks` option.
178
179 ## 1.13.1 - 2024-06-28
180
181 - Return the `*net.IPNet` in canonical form when using `NetworksWithin` to look
182 up a network more specific than the one in the database. Previously, the `IP`
183 field on the `*net.IPNet` would be set to the IP from the lookup network
184 rather than the first IP of the network.
185 - `NetworksWithin` will now correctly handle an `*net.IPNet` parameter that is
186 not in canonical form. This issue would only occur if the `*net.IPNet` was
187 manually constructed, as `net.ParseCIDR` returns the value in canonical form
188 even if the input string is not.
189
190 ## 1.13.0 - 2024-06-03
191
192 - Go 1.21 or greater is now required.
193 - The error messages when decoding have been improved. #119
194
195 ## 1.12.0 - 2023-08-01
196
197 - The `wasi` target is now built without memory-mapping support. Pull request
198 by Alex Kashintsev. GitHub #114.
199 - When decoding to a map of non-scalar, non-interface types such as a
200 `map[string]map[string]any`, the decoder failed to zero out the value for the
201 map elements, which could result in incorrect decoding. Reported by JT Olio.
202 GitHub #115.
203
204 ## 1.11.0 - 2023-06-18
205
206 - `wasm` and `wasip1` targets are now built without memory-mapping support.
207 Pull request by Randy Reddig. GitHub #110.
208
209 **Full Changelog**:
210 https://github.com/oschwald/maxminddb-golang/compare/v1.10.0...v1.11.0
211
212 ## 1.10.0 - 2022-08-07
213
214 - Set Go version in go.mod file to 1.18.
215
216 ## 1.9.0 - 2022-03-26
217
218 - Set the minimum Go version in the go.mod file to 1.17.
219 - Updated dependencies.
220 - Minor performance improvements to the custom deserializer feature added in
221 1.8.0.
222
223 ## 1.8.0 - 2020-11-23
224
225 - Added `maxminddb.SkipAliasedNetworks` option to `Networks` and
226 `NetworksWithin` methods. When set, this option will cause the iterator to
227 skip networks that are aliases of the IPv4 tree.
228 - Added experimental custom deserializer support. This allows much more control
229 over the deserialization. The API is subject to change and you should use at
230 your own risk.
231
232 ## 1.7.0 - 2020-06-13
233
234 - Add `NetworksWithin` method. This returns an iterator that traverses all
235 networks in the database that are contained in the given network. Pull
236 request by Olaf Alders. GitHub #65.
237
238 ## 1.6.0 - 2019-12-25
239
240 - This module now uses Go modules. Requested by Matthew Rothenberg. GitHub #49.
241 - Plan 9 is now supported. Pull request by Jacob Moody. GitHub #61.
242 - Documentation fixes. Pull request by Olaf Alders. GitHub #62.
243 - Thread-safety is now mentioned in the documentation. Requested by Ken
244 Sedgwick. GitHub #39.
245 - Fix off-by-one error in file offset safety check. Reported by Will Storey.
246 GitHub #63.
247
248 ## 1.5.0 - 2019-09-11
249
250 - Drop support for Go 1.7 and 1.8.
251 - Minor performance improvements.
252
253 ## 1.4.0 - 2019-08-28
254
255 - Add the method `LookupNetwork`. This returns the network that the record
256 belongs to as well as a boolean indicating whether there was a record for the
257 IP address in the database. GitHub #59.
258 - Improve performance.
259
260 ## 1.3.1 - 2019-08-28
261
262 - Fix issue with the finalizer running too early on Go 1.12 when using the
263 Verify method. Reported by Robert-André Mauchin. GitHub #55.
264 - Remove unnecessary call to reflect.ValueOf. PR by SenseyeDeveloper. GitHub
265 #53.
266
267 ## 1.3.0 - 2018-02-25
268
269 - The methods on the `maxminddb.Reader` struct now return an error if called on
270 a closed database reader. Previously, this could cause a segmentation
271 violation when using a memory-mapped file.
272 - The `Close` method on the `maxminddb.Reader` struct now sets the underlying
273 buffer to nil, even when using `FromBytes` or `Open` on Google App Engine.
274 - No longer uses constants from `syscall`
275
276 ## 1.2.1 - 2018-01-03
277
278 - Fix incorrect index being used when decoding into anonymous struct fields. PR
279 #42 by Andy Bursavich.
280
281 ## 1.2.0 - 2017-05-05
282
283 - The database decoder now does bound checking when decoding data from the
284 database. This is to help ensure that the reader does not panic when given a
285 corrupt database to decode. Closes #37.
286 - The reader will now return an error on a data structure with a depth greater
287 than 512. This is done to prevent the possibility of a stack overflow on a
288 cyclic data structure in a corrupt database. This matches the maximum depth
289 allowed by `libmaxminddb`. All MaxMind databases currently have a depth of
290 less than five.
291
292 ## 1.1.0 - 2016-12-31
293
294 - Added appengine build tag for Windows. When enabled, memory-mapping will be
295 disabled in the Windows build as it is for the non-Windows build. Pull
296 request #35 by Ingo Oeser.
297 - SetFinalizer is now used to unmap files if the user fails to close the
298 reader. Using `r.Close()` is still recommended for most use cases.
299 - Previously, an unsafe conversion between `[]byte` and string was used to
300 avoid unnecessary allocations when decoding struct keys. The decoder now
301 relies on a compiler optimization on `string([]byte)` map lookups to achieve
302 this rather than using `unsafe`.
303
304 ## 1.0.0 - 2016-11-09
305
306 New release for those using tagged releases.