Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@thomaseizinger
Copy link
Member

Currently, the order in which connlib matches against the patterns of DNS resources is not specified. We simply iterate over all patterns and take the first one that matches. Due to the iteration order of HashMaps, this also isn't deterministic.

With this patch, we introduce a defined order in which we attempt to match a particular domain against the defined DNS resources:

  • Resources without wildcards are always prioritised over wildcard domains
  • Single-char wildcards (?) take priority over label wildcards (*)
  • Label wildcards (*) take priority over catch-all wildcards (**)

By matching against the DNS resources in a defined order, we ensure that DNS resources that overlap always resolve to the most specific resource.

@vercel
Copy link

vercel bot commented Sep 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
firezone ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 25, 2024 11:58pm

Copy link
Contributor

@ReactorScram ReactorScram left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM just suggested a brief explanation of the reverse iteration trick

Copy link
Contributor

@conectado conectado left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +508 to +510
(Some(self_char), Some(other_char)) => {
break self_char.cmp(&other_char).reverse(); // Reverse because we compare from right to left.
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean this will return the ordering of the first non-wildcard character where they differ?

I guess we're fine with that because that means they're non overlapping

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean this will return the ordering of the first non-wildcard character where they differ?

Yes.

Copy link
Member

@jamilbk jamilbk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add this to docs

@AndrewDryga
Copy link
Contributor

@thomaseizinger lets merge this? Want to ship it to the client that hit this issue.

Copy link
Member

@jamilbk jamilbk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the Changelog conflicts, but LGTM.

@thomaseizinger
Copy link
Member Author

thomaseizinger commented Sep 25, 2024

@thomaseizinger lets merge this? Want to ship it to the client that hit this issue.

@AndrewDryga I'll be at my desk for standup, if you want it earlier, feel free to jump and merge it :)

@thomaseizinger thomaseizinger force-pushed the fix/prioritise-non-wildcard-dns-matching branch from c7c0a7e to 22fec29 Compare September 25, 2024 23:51
Co-authored-by: Reactor Scram <[email protected]>
Signed-off-by: Thomas Eizinger <[email protected]>
@thomaseizinger thomaseizinger force-pushed the fix/prioritise-non-wildcard-dns-matching branch from 8371363 to fa3a4ad Compare September 25, 2024 23:57
@thomaseizinger thomaseizinger added this pull request to the merge queue Sep 26, 2024
Merged via the queue into main with commit 42a1378 Sep 26, 2024
136 checks passed
@thomaseizinger thomaseizinger deleted the fix/prioritise-non-wildcard-dns-matching branch September 26, 2024 00:23
github-merge-queue bot pushed a commit that referenced this pull request Sep 26, 2024
jamilbk added a commit that referenced this pull request Sep 26, 2024
jamilbk added a commit that referenced this pull request Sep 26, 2024
github-merge-queue bot pushed a commit that referenced this pull request Sep 28, 2024
Documents how overlapping addresses are matched.

Draft until #6809 is merged and published.

---------

Signed-off-by: Jamil <[email protected]>
Co-authored-by: Thomas Eizinger <[email protected]>
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.

6 participants