Skip to content

Commit

Permalink
client: fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
schzhn committed Apr 22, 2024
1 parent 599414b commit fa292ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
8 changes: 6 additions & 2 deletions internal/client/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,10 @@ func (ci *Index) findByIP(ip netip.Addr) (c *Persistent, found bool) {
return ci.uidToClient[uid], true
}

ipWithoutZone := ip.WithZone("")
ci.subnetToUID.Range(func(pref netip.Prefix, id UID) (cont bool) {
// Remove zone before checking because prefixes stip zones.
if pref.Contains(ip.WithZone("")) {
// Remove zone before checking because prefixes strip zones.
if pref.Contains(ipWithoutZone) {
uid, found = id, true

return false
Expand All @@ -218,6 +219,9 @@ func (ci *Index) findByIP(ip netip.Addr) (c *Persistent, found bool) {
// FindByIPWithoutZone finds a persistent client by IP address without zone. It
// strips the IPv6 zone index from the stored IP addresses before comparing,
// because querylog entries don't have it. See TODO on [querylog.logEntry.IP].
//
// Note that multiple clients can have same the IP address with different zones,
// so result of this method is indeterminate.
func (ci *Index) FindByIPWithoutZone(ip netip.Addr) (c *Persistent) {
if (ip == netip.Addr{}) {
return nil
Expand Down
7 changes: 0 additions & 7 deletions internal/client/index_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,6 @@ func TestIndex_FindByIPWithoutZone(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
c := ci.FindByIPWithoutZone(tc.ip.WithZone(""))

if tc.want == nil {
require.Nil(t, c)

return
}

require.Equal(t, tc.want, c)
})
}
Expand Down

0 comments on commit fa292ee

Please sign in to comment.