Skip to content

fix: filter IPv4 link-local addresses from network interfaces#226

Merged
pi0 merged 1 commit into
unjs:mainfrom
tkrajcar:fix/filter-ipv4-link-local
Apr 30, 2026
Merged

fix: filter IPv4 link-local addresses from network interfaces#226
pi0 merged 1 commit into
unjs:mainfrom
tkrajcar:fix/filter-ipv4-link-local

Conversation

@tkrajcar

@tkrajcar tkrajcar commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

resolves #225 - filter 169.254.x.x (IPv4 link-local) addresses in getNetworkInterfaces(), mirroring the existing fe80:: filter for IPv6 link-local addresses

Summary by CodeRabbit

Bug Fixes

  • Refined network interface detection to exclude link-local IPv4 addresses, improving the accuracy of interface identification.

`getNetworkInterfaces` already filters IPv6 link-local addresses
(`fe80::`) but not their IPv4 equivalent (`169.254.x.x`). On machines
with a link-local interface (common on macOS), this causes the dev
server QR code and Network URL to show the unreachable 169.254 address
instead of the actual LAN address (e.g. 192.168.x.x).
@coderabbitai

coderabbitai Bot commented Apr 10, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b606c301-1790-49bd-a557-7582e717082a

📥 Commits

Reviewing files that changed from the base of the PR and between 60ba9f2 and 702d5c7.

📒 Files selected for processing (1)
  • src/_utils.ts

📝 Walkthrough

Walkthrough

The getNetworkInterfaces() function now filters out link-local IPv4 addresses (169.254.x.x) when building the set of candidate network addresses. This prevents unreachable link-local addresses from being selected as the primary network URL or QR code target.

Changes

Cohort / File(s) Summary
Link-local IPv4 Filtering
src/_utils.ts
Added exclusion filter for IPv4 addresses starting with 169.254. in getNetworkInterfaces(), mirroring existing IPv6 link-local (fe80::) and internal interface exclusions.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 A link-local hop that led astray,
Now filtered far, out of the way!
No more 169 in the QR's sight,
Just LAN addresses, crisp and right! 🎯✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: filtering IPv4 link-local addresses from network interfaces, which directly addresses the core issue.
Linked Issues check ✅ Passed The pull request directly implements the required fix: filtering IPv4 link-local addresses (169.254.0.0/16) from getNetworkInterfaces(), resolving issue #225.
Out of Scope Changes check ✅ Passed The change is narrowly scoped to adding one filter condition to getNetworkInterfaces(); no unrelated modifications are present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pi0 pi0 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thnx!

@pi0 pi0 merged commit 49ef95e into unjs:main Apr 30, 2026
3 checks passed
@codecov

codecov Bot commented Apr 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 48.38%. Comparing base (d115045) to head (702d5c7).
⚠️ Report is 54 commits behind head on main.

Files with missing lines Patch % Lines
src/_utils.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #226      +/-   ##
==========================================
- Coverage   49.42%   48.38%   -1.04%     
==========================================
  Files          17        9       -8     
  Lines        1819      558    -1261     
  Branches      147      193      +46     
==========================================
- Hits          899      270     -629     
+ Misses        915      233     -682     
- Partials        5       55      +50     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

QR code / Network URL shows unreachable 169.254.x.x link-local address

2 participants