Skip to content

fix(filters): a whole address is that address; CIDR and patterns too - #99

Merged
Wasabules merged 1 commit into
mainfrom
fix-source-address-match
Oct 27, 2026
Merged

Wasabules merged 1 commit into
mainfrom
fix-source-address-match

Conversation

@Wasabules

Copy link
Copy Markdown
Owner

Fixes #98.

The bug

The Source IP box kept every address that contains the typed text. Typing 10.10.1.1 also showed 10.10.1.10 to .19 and 10.10.1.100 to .199. The same happens in the online demo with 10.10.0.2, which also shows 10.10.0.23.

What the box takes now

Typed Keeps
10.10.1.1 that address only. An IPv6 address matches however it is written: fe80:0::1 is fe80::1.
10.10.1.0/24 the CIDR range
10.10.1.*, 10.10.1.? a pattern, matched against the whole address
10.10.1. (not a whole address) addresses containing the text, as before, so the box still narrows while you type

One definition, everywhere

search.Address defines what an address matches. It is used by:

  • the Source IP filter, in the live view, the history and exports;
  • the Addresses of source rules;
  • the sources of routing rules.

The history answers each kind in SQL:

  • An exact address or a pattern uses the column's own comparison for rows in plain ASCII, and ss_fold for the others, as the text boxes already do.
  • A CIDR uses a new ss_addr SQL function. Before calling it, the index narrows the rows to those starting with the network's whole octets, so 10.10.1.0/24 reads LIKE '10.10.1.%' first.

The window repeats all of this in lib/search.ts:

  • parseIP and ipString follow Go's netip parser and net.IP.String step by step.
  • testdata/addresses.json holds them to Go: 52 address texts (leading zeros, ::, embedded IPv4, zones) and 42 match cases.
  • testdata/filters.json gains the address cases, which the history (SQL), Go and npm test all check.
  • The old spec case expected 10.0.0.1 to find 10.0.0.10. That was the bug, and the case is gone.

Source rules

  • Saving: an address entry that is not a whole address, a CIDR or a pattern is refused, because it could match nothing a message arrives from. Examples: 10.0.0 (half an address), gateway (a name).
  • Preview: it follows the addresses as they are typed, CIDR ranges and patterns included. It used to keep the messages it was opened with.
  • Right-click: "Read this device's messages differently…" opens the rule that reads the device by a range as well. Before, it opened a new rule, and that rule, added after the range rule, would never have been reached.
  • Help text: the Source IP box (tooltip) and the rule's Addresses field say what they take, in the 8 languages.

Routing

Route sources go through the same matcher. A CIDR, an exact address and * / ? behave as before. […] character classes from path.Match are no longer special. A /0 still takes both families.

Checked

  • go vet (Windows, Linux), staticcheck, go test -race ./...
  • svelte-check --fail-on-warnings, npm test (5 suites, the new address one included), npm run build

The Source IP box kept every address containing what was typed, so
10.10.1.1 also showed 10.10.1.10-19 and 10.10.1.100-199 (#98). It now
reads what is typed as an address:

- a whole address is that address, an IPv6 one however written;
- a CIDR (10.10.1.0/24) is its range;
- "*" and "?" make a pattern (10.10.1.*), matched whole;
- anything else is still text the address contains, while it is typed.

One definition, search.Address, for the filter in the live view, the
history and exports, and for the addresses of source rules and routes.
The history answers a CIDR through an ss_addr SQL function, after the
index has narrowed the rows to its whole octets. The window repeats it
in lib/search.ts: parseIP and ipString follow Go's netip step by step,
held to it by testdata/addresses.json (52 texts, 42 cases), and the
filters spec gains the address cases. The case that said 10.0.0.1
finds 10.0.0.10 was the bug, and is gone.

Source rules: an address entry that is none of the above (half an
address, a name) is refused when saved, since it could match nothing.
The editor's preview follows the addresses as they are typed, CIDR and
patterns included, and right-clicking a message opens the rule that
reads its device by a range too: a new rule added after it would never
be reached. The Source IP box and the rule's addresses say what they
take, in the 8 languages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] IP address search returns results for other IPs with the same prefix

1 participant