Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

host lookup simplifications and refactorings #2

Merged
merged 7 commits into from
Nov 14, 2022
Merged

Conversation

flokli
Copy link
Collaborator

@flokli flokli commented Nov 11, 2022

Commits from @andir from #1 (comment).

We don't have to use a lambda to return a value from a
sub-expression. Rust takes the last value in a scope as return value
even if it isn't a function.
The function belongs to the data format and not to the actual
processing logic. This isn't a clean cut just yet all over the
codebase but moving this very fragile piece into its own function will
enable us to test it in isolation.
This makes the result filtering similar and thus should be less confusing.
This is as efficient as doing the manual pre-allocation as the
`to_vec` method will use the length of the slice for the initial size
allocation of the vector.
Previously this would produce a malformed packet as far as glibc is
concerned.

If there are no addresses the "found" field should not be one and the
other lookup fields can also be left blank.
This moves the "well-known" wire format structs to constants that can
be reused without having to duplicate their definition all the time.
@flokli flokli merged commit 47e580f into host-lookups Nov 14, 2022
@flokli flokli deleted the andir-fixes branch November 14, 2022 09:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants