Skip to content

Commit 2e11ff0

Browse files
Replace deprecated inet.af/netaddr (#8560)
This removes the deprecated `inet.af/netaddr` that imports `go4.org/unsafe/assume-no-moving-gc` and panic when it's not updated. Fixes #8399 and replaces #8495
1 parent 6d59b41 commit 2e11ff0

File tree

23 files changed

+652
-2536
lines changed

23 files changed

+652
-2536
lines changed

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ require (
108108
gopkg.in/alecthomas/kingpin.v2 v2.2.6
109109
gopkg.in/yaml.v2 v2.4.0
110110
gopkg.in/yaml.v3 v3.0.1
111-
inet.af/netaddr v0.0.0-20211027220019-c74959edd3b6
112111
k8s.io/klog v1.0.0
113112
)
114113

@@ -121,6 +120,7 @@ require (
121120
github.com/prometheus/common/sigv4 v0.1.0
122121
github.com/thanos-io/objstore v0.0.0-20230201072718-11ffbc490204
123122
github.com/willf/bloom v2.0.3+incompatible
123+
go4.org/netipx v0.0.0-20230125063823-8449b0a6169f
124124
golang.org/x/exp v0.0.0-20221212164502-fae10dda9338
125125
golang.org/x/oauth2 v0.4.0
126126
golang.org/x/text v0.6.0
@@ -287,8 +287,6 @@ require (
287287
go.opentelemetry.io/otel/trace v1.11.2 // indirect
288288
go.uber.org/multierr v1.8.0 // indirect
289289
go.uber.org/zap v1.21.0 // indirect
290-
go4.org/intern v0.0.0-20211027215823-ae77deb06f29 // indirect
291-
go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760 // indirect
292290
golang.org/x/mod v0.7.0 // indirect
293291
golang.org/x/term v0.4.0 // indirect
294292
golang.org/x/tools v0.4.0 // indirect

go.sum

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,6 @@ github.com/duosecurity/duo_api_golang v0.0.0-20190308151101-6c680f768e74/go.mod
402402
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
403403
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
404404
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
405-
github.com/dvyukov/go-fuzz v0.0.0-20210103155950-6a8e9d1f2415/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw=
406405
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
407406
github.com/eapache/go-resiliency v1.2.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
408407
github.com/eapache/go-resiliency v1.3.0 h1:RRL0nge+cWGlxXbUzJ7yMcq6w2XBEr19dCN6HECGaT0=
@@ -1509,11 +1508,8 @@ go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
15091508
go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo=
15101509
go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8=
15111510
go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw=
1512-
go4.org/intern v0.0.0-20211027215823-ae77deb06f29 h1:UXLjNohABv4S58tHmeuIZDO6e3mHpW2Dx33gaNt03LE=
1513-
go4.org/intern v0.0.0-20211027215823-ae77deb06f29/go.mod h1:cS2ma+47FKrLPdXFpr7CuxiTW3eyJbWew4qx0qtQWDA=
1514-
go4.org/unsafe/assume-no-moving-gc v0.0.0-20211027215541-db492cf91b37/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E=
1515-
go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760 h1:FyBZqvoA/jbNzuAWLQE2kG820zMAkcilx6BMjGbL/E4=
1516-
go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E=
1511+
go4.org/netipx v0.0.0-20230125063823-8449b0a6169f h1:ketMxHg+vWm3yccyYiq+uK8D3fRmna2Fcj+awpQp84s=
1512+
go4.org/netipx v0.0.0-20230125063823-8449b0a6169f/go.mod h1:tgPU4N2u9RByaTN3NC2p9xOzyFpte4jYwsIIRF7XlSc=
15171513
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
15181514
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
15191515
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
@@ -2223,8 +2219,6 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
22232219
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
22242220
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
22252221
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
2226-
inet.af/netaddr v0.0.0-20211027220019-c74959edd3b6 h1:acCzuUSQ79tGsM/O50VRFySfMm19IoMKL+sZztZkCxw=
2227-
inet.af/netaddr v0.0.0-20211027220019-c74959edd3b6/go.mod h1:y3MGhcFMlh0KZPMuXXow8mpjxxAk3yoDNsp4cQz54i8=
22282222
k8s.io/api v0.0.0-20180806132203-61b11ee65332/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA=
22292223
k8s.io/api v0.0.0-20190325185214-7544f9db76f6/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA=
22302224
k8s.io/api v0.26.0 h1:IpPlZnxBpV1xl7TGk/X6lFtpgjgntCg8PJ+qrPHAC7I=

pkg/logql/log/ip.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import (
66
"unicode"
77

88
"github.com/prometheus/prometheus/model/labels"
9-
"inet.af/netaddr"
9+
"go4.org/netipx"
10+
"net/netip"
1011
)
1112

1213
var (
@@ -21,7 +22,7 @@ const (
2122
IPv6Charset = "0123456789abcdefABCDEF:."
2223
)
2324

24-
// Should be one of the netaddr.IP, netaddr.IPRange, netadd.IPPrefix.
25+
// Should be one of the netip.Addr, netip.Prefix, netipx.IPRange.
2526
type IPMatcher interface{}
2627

2728
type IPLineFilter struct {
@@ -190,7 +191,7 @@ func (f *ipFilter) filter(line []byte) bool {
190191
if iplen < 0 {
191192
return false, 0
192193
}
193-
ip, err := netaddr.ParseIP(string(line[start : start+iplen]))
194+
ip, err := netip.ParseAddr(string(line[start : start+iplen]))
194195
if err == nil {
195196
if containsIP(f.matcher, ip) {
196197
return true, 0
@@ -223,13 +224,13 @@ func (f *ipFilter) filter(line []byte) bool {
223224
return false
224225
}
225226

226-
func containsIP(matcher IPMatcher, ip netaddr.IP) bool {
227+
func containsIP(matcher IPMatcher, ip netip.Addr) bool {
227228
switch m := matcher.(type) {
228-
case netaddr.IP:
229+
case netip.Addr:
229230
return m.Compare(ip) == 0
230-
case netaddr.IPRange:
231+
case netipx.IPRange:
231232
return m.Contains(ip)
232-
case netaddr.IPPrefix:
233+
case netip.Prefix:
233234
return m.Contains(ip)
234235
}
235236
return false
@@ -241,16 +242,16 @@ func getMatcher(pattern string) (IPMatcher, error) {
241242
err error
242243
)
243244

244-
matcher, err = netaddr.ParseIP(pattern) // is it simple single IP?
245+
matcher, err = netip.ParseAddr(pattern) // is it simple single IP?
245246
if err == nil {
246247
return matcher, nil
247248
}
248-
matcher, err = netaddr.ParseIPPrefix(pattern) // is it cidr format? (192.168.0.1/16)
249+
matcher, err = netip.ParsePrefix(pattern) // is it cidr format? (192.168.0.1/16)
249250
if err == nil {
250251
return matcher, nil
251252
}
252253

253-
matcher, err = netaddr.ParseIPRange(pattern) // is it IP range format? (192.168.0.1 - 192.168.4.5
254+
matcher, err = netipx.ParseIPRange(pattern) // is it IP range format? (192.168.0.1 - 192.168.4.5
254255
if err == nil {
255256
return matcher, nil
256257
}

vendor/go4.org/intern/LICENSE

Lines changed: 0 additions & 29 deletions
This file was deleted.

vendor/go4.org/intern/README.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

vendor/go4.org/intern/intern.go

Lines changed: 0 additions & 183 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.

vendor/go4.org/netipx/README.md

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)