diff --git a/go.mod b/go.mod index 798833d985dc7..8dbe233c49e8b 100644 --- a/go.mod +++ b/go.mod @@ -79,7 +79,7 @@ require ( github.com/opentracing-contrib/go-grpc v0.1.2 // indirect github.com/opentracing-contrib/go-stdlib v1.1.0 // indirect github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b - github.com/oschwald/geoip2-golang/v2 v2.0.0 + github.com/oschwald/geoip2-golang/v2 v2.0.1 // github.com/pierrec/lz4 v2.0.5+incompatible github.com/pierrec/lz4/v4 v4.1.22 github.com/pkg/errors v0.9.1 @@ -262,7 +262,7 @@ require ( github.com/open-telemetry/opentelemetry-collector-contrib/internal/exp/metrics v0.136.0 // indirect github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.136.0 // indirect github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor v0.136.0 // indirect - github.com/oschwald/maxminddb-golang/v2 v2.0.0 // indirect + github.com/oschwald/maxminddb-golang/v2 v2.1.1 // indirect github.com/philhofer/fwd v1.2.0 // indirect github.com/pires/go-proxyproto v0.7.0 // indirect github.com/pkg/xattr v0.4.12 // indirect diff --git a/go.sum b/go.sum index 6f929b7310ebe..df65522ffbe06 100644 --- a/go.sum +++ b/go.sum @@ -961,10 +961,10 @@ github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b/go.mo github.com/oracle/oci-go-sdk/v65 v65.41.1 h1:+lbosOyNiib3TGJDvLq1HwEAuFqkOjPJDIkyxM15WdQ= github.com/oracle/oci-go-sdk/v65 v65.41.1/go.mod h1:MXMLMzHnnd9wlpgadPkdlkZ9YrwQmCOmbX5kjVEJodw= github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0= -github.com/oschwald/geoip2-golang/v2 v2.0.0 h1:1GZ7MsQsbIKeOXMDV2MqBVfV8NuCIqWatomkS67LwQo= -github.com/oschwald/geoip2-golang/v2 v2.0.0/go.mod h1:MR3+NmQTkjxyJ/u6iZJSfpfy5al/QqsaJL1Gg6uI7sU= -github.com/oschwald/maxminddb-golang/v2 v2.0.0 h1:Gyljxck1kHbBxDgLM++NfDWBqvu1pWWfT8XbosSo0bo= -github.com/oschwald/maxminddb-golang/v2 v2.0.0/go.mod h1:gG4V88LsawPEqtbL1Veh1WRh+nVSYwXzJ1P5Fcn77g0= +github.com/oschwald/geoip2-golang/v2 v2.0.1 h1:YcYoG/L+gmSfk7AlToTmoL0JvblNyhGC8NyVhwDzzi8= +github.com/oschwald/geoip2-golang/v2 v2.0.1/go.mod h1:qdVmcPgrTJ4q2eP9tHq/yldMTdp2VMr33uVdFbHBiBc= +github.com/oschwald/maxminddb-golang/v2 v2.1.1 h1:lA8FH0oOrM4u7mLvowq8IT6a3Q/qEnqRzLQn9eH5ojc= +github.com/oschwald/maxminddb-golang/v2 v2.1.1/go.mod h1:PLdx6PR+siSIoXqqy7C7r3SB3KZnhxWr1Dp6g0Hacl8= github.com/ovh/go-ovh v1.9.0 h1:6K8VoL3BYjVV3In9tPJUdT7qMx9h0GExN9EXx1r2kKE= github.com/ovh/go-ovh v1.9.0/go.mod h1:cTVDnl94z4tl8pP1uZ/8jlVxntjSIf09bNcQ5TJSC7c= github.com/parquet-go/parquet-go v0.25.1 h1:l7jJwNM0xrk0cnIIptWMtnSnuxRkwq53S+Po3KG8Xgo= diff --git a/vendor/github.com/oschwald/geoip2-golang/v2/.gitignore b/vendor/github.com/oschwald/geoip2-golang/v2/.gitignore index dca06949cad17..9c518294f6ea0 100644 --- a/vendor/github.com/oschwald/geoip2-golang/v2/.gitignore +++ b/vendor/github.com/oschwald/geoip2-golang/v2/.gitignore @@ -1,3 +1,8 @@ .vscode *.out *.test +*.mmdb +*.prof +*.pprof +*.svg +*.tar.gz diff --git a/vendor/github.com/oschwald/geoip2-golang/v2/.precious.toml b/vendor/github.com/oschwald/geoip2-golang/v2/.precious.toml new file mode 100644 index 0000000000000..1cc359dbf41d1 --- /dev/null +++ b/vendor/github.com/oschwald/geoip2-golang/v2/.precious.toml @@ -0,0 +1,44 @@ +exclude = [ + "test-data/**/*", + "vendor/**/*", + "GeoLite2-ASN.mmdb", + "GeoLite2-City.mmdb", + "*.prof", + "*.pprof", + "*.out", + "*.svg", + "*.tar.gz", + "*.test", +] + +[commands.golangci-lint-fmt] +type = "both" +include = "**/*.go" +invoke = "once" +path-args = "none" +cmd = ["golangci-lint", "fmt"] +lint-flags = "--diff" +ok-exit-codes = [0] +lint-failure-exit-codes = [1] + +[commands.golangci-lint] +type = "both" +include = "**/*.go" +invoke = "once" +path-args = "none" +cmd = ["golangci-lint", "run"] +tidy-flags = "--fix" +ok-exit-codes = [0] +lint-failure-exit-codes = [1] + +[commands.prettier] +type = "both" +include = ["**/*.md", "**/*.yml", "**/*.yaml"] +invoke = "once" +path-args = "file" +cmd = ["prettier"] +lint-flags = "--check" +tidy-flags = "--write" +ok-exit-codes = [0] +lint-failure-exit-codes = [1] +expect-stderr = true diff --git a/vendor/github.com/oschwald/geoip2-golang/v2/CHANGELOG.md b/vendor/github.com/oschwald/geoip2-golang/v2/CHANGELOG.md index eeb5ded69d375..d38b4de5adf30 100644 --- a/vendor/github.com/oschwald/geoip2-golang/v2/CHANGELOG.md +++ b/vendor/github.com/oschwald/geoip2-golang/v2/CHANGELOG.md @@ -1,4 +1,12 @@ -# 2.0.0 - 2025-10-19 +# Changes + +## 2.0.1 - 2025-11-26 + +- Upgraded `github.com/oschwald/geoip2-golang/v2` to 2.1.1, which fixes an + issue that prevented a unclosed memory-mapped file from being unmapped + when the reader was garbage collected. + +## 2.0.0 - 2025-10-19 - **BREAKING CHANGE**: Lookup methods now require `netip.Addr`, return typed `Names`, and provide `HasData()` helpers while always populating @@ -14,20 +22,20 @@ - **BREAKING CHANGE**: Removed deprecated `FromBytes` method. Use `OpenBytes` instead. -# 2.0.0-beta.4 - 2025-08-23 +## 2.0.0-beta.4 - 2025-08-23 - Updated maxminddb dependency to v2.0.0-beta.9. - Added `OpenBytes` method to match the API changes in maxminddb v2.0.0-beta.9. - Deprecated `FromBytes` method. Use `OpenBytes` instead. `FromBytes` will be removed in a future version. -# 2.0.0-beta.3 - 2025-07-07 +## 2.0.0-beta.3 - 2025-07-07 -- Add support for `GeoIP-City-Redacted-US` and `GeoIP-Enterprise-Redacted-US`. +- Added support for `GeoIP-City-Redacted-US` and `GeoIP-Enterprise-Redacted-US`. Requested by Tom Anderson. GitHub #134. - Upgrade `github.com/oschwald/maxminddb-golang/v2` to `v2.0.0-beta.7`. -# 2.0.0-beta.2 - 2025-06-28 +## 2.0.0-beta.2 - 2025-06-28 - **BREAKING CHANGE**: Replaced `IsZero()` methods with `HasData()` methods on all result structs (including Names). The new methods provide clearer @@ -50,7 +58,7 @@ incorrectly treated as "no data". Added `Location.HasCoordinates()` method for safe coordinate access. Reported by Nick Bruun. GitHub #5. -# 2.0.0-beta.1 - 2025-06-22 +## 2.0.0-beta.1 - 2025-06-22 - **BREAKING CHANGE**: Updated to use `maxminddb-golang/v2` which provides significant performance improvements and a more modern API. @@ -93,7 +101,7 @@ - Updated linting rules to support both v1 and v2 import paths during the transition period. -## Migration Guide +### Migration Guide To migrate from v1 to v2: @@ -171,7 +179,7 @@ To migrate from v1 to v2: } ``` -# 1.11.0 - 2024-06-03 +## 1.11.0 - 2024-06-03 - Go 1.21 or greater is now required. - The new `is_anycast` output is now supported on the GeoIP2 Country, City, and @@ -180,31 +188,31 @@ To migrate from v1 to v2: Note: 1.10.0 was accidentally skipped. -# 1.9.0 - 2023-06-18 +## 1.9.0 - 2023-06-18 - Rearrange fields in structs to reduce memory usage. Although this does reduce readability, these structs are often created at very rates, making the trade-off worth it. -# 1.8.0 - 2022-08-07 +## 1.8.0 - 2022-08-07 - Set Go version to 1.18 in go.mod. -# 1.7.0 - 2022-03-26 +## 1.7.0 - 2022-03-26 - Set the minimum Go version in the go.mod file to 1.17. - Updated dependencies. -# 1.6.1 - 2022-01-28 +## 1.6.1 - 2022-01-28 - This is a re-release with the changes that were supposed to be in 1.6.0. -# 1.6.0 - 2022-01-28 +## 1.6.0 - 2022-01-28 - Add support for new `mobile_country_code` and `mobile_network_code` outputs on GeoIP2 ISP and GeoIP2 Enterprise. -# 1.5.0 - 2021-02-20 +## 1.5.0 - 2021-02-20 - Add `StaticIPScore` field to Enterprise. Pull request by Pierre Bonzel. GitHub [#54](https://github.com/oschwald/geoip2-golang/issues/54). @@ -213,7 +221,7 @@ Note: 1.10.0 was accidentally skipped. - Support DBIP-ASN-Lite database. Requested by Muhammad Hussein Fattahizadeh. GitHub [#69](https://github.com/oschwald/geoip2-golang/issues/69). -# 1.4.0 - 2019-12-25 +## 1.4.0 - 2019-12-25 - This module now uses Go modules. Requested by Axel Etcheverry. GitHub [#52](https://github.com/oschwald/geoip2-golang/issues/52). @@ -225,15 +233,15 @@ Note: 1.10.0 was accidentally skipped. before using it. GitHub [#51](https://github.com/oschwald/geoip2-golang/issues/51). -# 1.3.0 - 2019-08-28 +## 1.3.0 - 2019-08-28 - Added support for the GeoIP2 Enterprise database. -# 1.2.1 - 2018-02-25 +## 1.2.1 - 2018-02-25 - HTTPS is now used for the test data submodule rather than the Git protocol -# 1.2.0 - 2018-02-19 +## 1.2.0 - 2018-02-19 - The country structs for `geoip2.City` and `geoip2.Country` now have an `IsInEuropeanUnion` boolean field. This is true when the associated country @@ -242,13 +250,13 @@ Note: 1.10.0 was accidentally skipped. - Switch from Go Check to Testify. Closes [#27](https://github.com/oschwald/geoip2-golang/issues/27) -# 1.1.0 - 2017-04-23 +## 1.1.0 - 2017-04-23 - Add support for the GeoLite2 ASN database. - Add support for the GeoIP2 City by Continent databases. GitHub [#26](https://github.com/oschwald/geoip2-golang/issues/26). -# 1.0.0 - 2016-11-09 +## 1.0.0 - 2016-11-09 New release for those using tagged releases. Closes [#21](https://github.com/oschwald/geoip2-golang/issues/21). diff --git a/vendor/github.com/oschwald/geoip2-golang/v2/README.md b/vendor/github.com/oschwald/geoip2-golang/v2/README.md index ae2dadff40c6c..9c04fea150b91 100644 --- a/vendor/github.com/oschwald/geoip2-golang/v2/README.md +++ b/vendor/github.com/oschwald/geoip2-golang/v2/README.md @@ -7,7 +7,7 @@ This library reads MaxMind [GeoIP2](https://www.maxmind.com/en/geolocation_landing) databases. This library is built using -[the Go maxminddb reader](https://github.com/oschwald/maxminddb-golang/v2). All +[the Go maxminddb reader](https://github.com/oschwald/maxminddb-golang). All data for the database record is decoded using this library. Version 2.0 provides significant performance improvements with 56% fewer allocations and 34% less memory usage compared to v1. Version 2.0 also adds `Network` and diff --git a/vendor/github.com/oschwald/maxminddb-golang/v2/CHANGELOG.md b/vendor/github.com/oschwald/maxminddb-golang/v2/CHANGELOG.md index 7d37e3a948d74..bbbefac5de734 100644 --- a/vendor/github.com/oschwald/maxminddb-golang/v2/CHANGELOG.md +++ b/vendor/github.com/oschwald/maxminddb-golang/v2/CHANGELOG.md @@ -1,5 +1,16 @@ # Changes +## 2.1.1 - 2025-11-26 + +- Fixed `runtime.AddCleanup` misuse that prevented the memory-mapped file from + being unmapped when the `Reader` was garbage collected. + +## 2.1.0 - 2025-11-04 + +- Updated `Offset` method on `Decoder` to return the resolved data offset + when positioned at a pointer. This makes more useful for caching values, + which is its stated purpose. + ## 2.0.0 - 2025-10-18 - BREAKING CHANGE: Removed deprecated `FromBytes`. Use `OpenBytes` instead. diff --git a/vendor/github.com/oschwald/maxminddb-golang/v2/internal/decoder/decoder.go b/vendor/github.com/oschwald/maxminddb-golang/v2/internal/decoder/decoder.go index 264619a9da9f6..73b6d04b80e9a 100644 --- a/vendor/github.com/oschwald/maxminddb-golang/v2/internal/decoder/decoder.go +++ b/vendor/github.com/oschwald/maxminddb-golang/v2/internal/decoder/decoder.go @@ -352,9 +352,36 @@ func (d *Decoder) PeekKind() (Kind, error) { } // Offset returns the current offset position in the database. -// This can be used by custom unmarshalers for caching purposes. +// If the current position points to a pointer, this method resolves the +// pointer chain and returns the offset of the actual data. This ensures +// that multiple pointers to the same data return the same offset, which +// is important for caching purposes. func (d *Decoder) Offset() uint { - return d.offset + // Follow pointer chain to get resolved data location + dataOffset := d.offset + for { + kindNum, size, ctrlEndOffset, err := d.d.decodeCtrlData(dataOffset) + if err != nil { + // Return original offset to avoid breaking the public API. + // Offset() returns uint (not (uint, error)), so we can't propagate errors. + // In practice, errors here are rare and the original offset is still valid. + return d.offset + } + if kindNum != KindPointer { + // dataOffset is now pointing at the actual data (not a pointer) + // Return this offset, which is where the data's control bytes start + break + } + // Follow the pointer to get the target offset + dataOffset, _, err = d.d.decodePointer(size, ctrlEndOffset) + if err != nil { + // Return original offset to avoid breaking the public API. + // The caller will encounter the same error when they try to read. + return d.offset + } + // dataOffset is now the pointer target; loop to check if it's also a pointer + } + return dataOffset } func (d *Decoder) reset(offset uint) { diff --git a/vendor/github.com/oschwald/maxminddb-golang/v2/internal/decoder/reflection.go b/vendor/github.com/oschwald/maxminddb-golang/v2/internal/decoder/reflection.go index d22c86c9bceeb..2f85c9bf73da9 100644 --- a/vendor/github.com/oschwald/maxminddb-golang/v2/internal/decoder/reflection.go +++ b/vendor/github.com/oschwald/maxminddb-golang/v2/internal/decoder/reflection.go @@ -402,7 +402,7 @@ func (d *ReflectionDecoder) unmarshalBool( return newOffset, mmdberrors.NewUnmarshalTypeError(value, result.Type()) } -var sliceType = reflect.TypeOf([]byte{}) +var sliceType = reflect.TypeFor[[]byte]() func (d *ReflectionDecoder) unmarshalBytes( size, offset uint, @@ -700,7 +700,7 @@ func (d *ReflectionDecoder) unmarshalUint( return newOffset, mmdberrors.NewUnmarshalTypeError(value, result.Type()) } -var bigIntType = reflect.TypeOf(big.Int{}) +var bigIntType = reflect.TypeFor[big.Int]() func (d *ReflectionDecoder) unmarshalUint128( size, offset uint, result addressableValue, diff --git a/vendor/github.com/oschwald/maxminddb-golang/v2/internal/mmdberrors/context.go b/vendor/github.com/oschwald/maxminddb-golang/v2/internal/mmdberrors/context.go index d24e1d5342d19..ef2168f8a92fe 100644 --- a/vendor/github.com/oschwald/maxminddb-golang/v2/internal/mmdberrors/context.go +++ b/vendor/github.com/oschwald/maxminddb-golang/v2/internal/mmdberrors/context.go @@ -127,8 +127,8 @@ func (p *PathBuilder) ParseAndExtend(path string) { path = path[1:] } - segments := strings.Split(path, "/") - for _, segment := range segments { + segments := strings.SplitSeq(path, "/") + for segment := range segments { if segment != "" { p.segments = append(p.segments, segment) } diff --git a/vendor/github.com/oschwald/maxminddb-golang/v2/mmap_windows.go b/vendor/github.com/oschwald/maxminddb-golang/v2/mmap_windows.go index 8fc4500ba59ea..19773f69f68ef 100644 --- a/vendor/github.com/oschwald/maxminddb-golang/v2/mmap_windows.go +++ b/vendor/github.com/oschwald/maxminddb-golang/v2/mmap_windows.go @@ -1,5 +1,4 @@ //go:build windows && !appengine -// +build windows,!appengine package maxminddb diff --git a/vendor/github.com/oschwald/maxminddb-golang/v2/reader.go b/vendor/github.com/oschwald/maxminddb-golang/v2/reader.go index 66cd67f90c877..69c564e39c660 100644 --- a/vendor/github.com/oschwald/maxminddb-golang/v2/reader.go +++ b/vendor/github.com/oschwald/maxminddb-golang/v2/reader.go @@ -135,13 +135,13 @@ type mmapCleanup struct { // All of the methods on Reader are thread-safe. The struct may be safely // shared across goroutines. type Reader struct { - buffer []byte + hasMappedFile *atomic.Bool decoder decoder.ReflectionDecoder + buffer []byte Metadata Metadata ipv4Start uint ipv4StartBitDepth int nodeOffsetMult uint - hasMappedFile atomic.Bool } // Metadata holds the metadata decoded from the MaxMind DB file. @@ -262,7 +262,7 @@ func Open(file string, options ...ReaderOption) (*Reader, error) { reader.hasMappedFile.Store(true) cleanup := &mmapCleanup{ data: data, - hasMapped: &reader.hasMappedFile, + hasMapped: reader.hasMappedFile, } runtime.AddCleanup(reader, func(mc *mmapCleanup) { if mc.hasMapped.CompareAndSwap(true, false) { @@ -356,6 +356,7 @@ func OpenBytes(buffer []byte, options ...ReaderOption) (*Reader, error) { Metadata: metadata, ipv4Start: 0, nodeOffsetMult: metadata.RecordSize / 4, + hasMappedFile: &atomic.Bool{}, } err = reader.setIPv4Start() diff --git a/vendor/modules.txt b/vendor/modules.txt index 685e4c92a7f55..f81841630aad0 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1623,10 +1623,10 @@ github.com/opentracing-contrib/go-stdlib/nethttp github.com/opentracing/opentracing-go github.com/opentracing/opentracing-go/ext github.com/opentracing/opentracing-go/log -# github.com/oschwald/geoip2-golang/v2 v2.0.0 +# github.com/oschwald/geoip2-golang/v2 v2.0.1 ## explicit; go 1.24.0 github.com/oschwald/geoip2-golang/v2 -# github.com/oschwald/maxminddb-golang/v2 v2.0.0 +# github.com/oschwald/maxminddb-golang/v2 v2.1.1 ## explicit; go 1.24.0 github.com/oschwald/maxminddb-golang/v2 github.com/oschwald/maxminddb-golang/v2/internal/decoder