Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(libs/utils): Use valid ip4 address #2394

Merged
merged 4 commits into from
Jun 27, 2023

Conversation

renaynay
Copy link
Member

@renaynay renaynay commented Jun 23, 2023

Fixes an issue where localhost was not accepted as a valid --gateway.addr. Uses net.ResolveIPAddr instead.

Found by @tuxcanfly

@renaynay renaynay added the kind:fix Attached to bug-fixing PRs label Jun 23, 2023
@renaynay renaynay self-assigned this Jun 23, 2023
@Wondertan
Copy link
Member

We have tests for the func and should cover this case

@codecov-commenter
Copy link

Codecov Report

Merging #2394 (fda991e) into main (f32c903) will decrease coverage by 0.22%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #2394      +/-   ##
==========================================
- Coverage   50.74%   50.52%   -0.22%     
==========================================
  Files         157      157              
  Lines        9925     9925              
==========================================
- Hits         5036     5015      -21     
- Misses       4445     4464      +19     
- Partials      444      446       +2     
Impacted Files Coverage Δ
libs/utils/address.go 53.84% <100.00%> (ø)

... and 3 files with indirect coverage changes

@walldiss
Copy link
Member

Why do you think the address is invalid?

@renaynay
Copy link
Member Author

@walldiss first addr returned for localhost is ipv6 shorthand loopback addr and it's not compatible with validation

@walldiss
Copy link
Member

To filter out ipv6 you can use

net.ResolveIPAddr("ip4",addr)

Wondertan
Wondertan previously approved these changes Jun 27, 2023
@renaynay renaynay requested a review from Wondertan June 27, 2023 09:57
@renaynay renaynay changed the title fix(libs/utils): Use valid address from LookupHost addr slice fix(libs/utils): Use valid ip4 address Jun 27, 2023
libs/utils/address.go Outdated Show resolved Hide resolved
@renaynay renaynay requested a review from walldiss June 27, 2023 12:12
@Wondertan Wondertan added this pull request to the merge queue Jun 27, 2023
Merged via the queue into celestiaorg:main with commit 637072e Jun 27, 2023
11 of 14 checks passed
@Wondertan Wondertan deleted the allow-localhost-addrparse branch June 27, 2023 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:fix Attached to bug-fixing PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants