Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 41 minutes and 4 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds IPv6 support across UI and tooling: new disable‑IPv6 preference and UI row, peer model and adapter show/copy IPv6, TUN/VPN tooling accepts and persists IPv6 address, NetworkChangeNotifier gains an IPv6 setter, and the netbird submodule pointer is bumped. Changes
Sequence Diagram(s)sequenceDiagram
participant User as "User (UI)"
participant Advanced as "AdvancedFragment"
participant Prefs as "goPreferences"
participant VM as "PeersFragmentViewModel"
participant Adapter as "PeersAdapter"
participant Clipboard as "Clipboard"
participant VPN as "VPNService"
participant IFace as "IFace / TUN builder"
User->>Advanced: Toggle Disable IPv6
Advanced->>Prefs: setDisableIPv6(isChecked) + commit
Prefs-->>Advanced: ack
VM->>Adapter: bind Peer(status, ip, ipv6, fqdn)
Adapter->>User: display IPv4\nIPv6 (if present)
User->>Adapter: long-press -> copy IPv6
Adapter->>Clipboard: copy "IPv6 Address"
VPN->>IFace: configureInterface(address, addressV6, mtu, dns, routes)
IFace->>IFace: parse addrV6, add IPv6 addr to builder or append ::/0 route
IFace-->>VPN: tunFd / success
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
fa435ce to
3f573e8
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@app/src/main/java/io/netbird/client/ui/home/Resource.java`:
- Around line 38-40: The isExitNode method in class Resource can NPE and misses
IPv6 when multiple addresses are present; update Resource.isExitNode to be
null-safe and use the same containment logic for both IPv4 and IPv6 (e.g., check
address != null and then address.contains("0.0.0.0/0") ||
address.contains("::/0")) so both "0.0.0.0/0,::/0" and "::/0,10.0.0.0/8" are
detected consistently.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 07976be7-06ad-4c85-aeb7-69281ce165ee
📒 Files selected for processing (13)
app/src/main/java/io/netbird/client/ui/advanced/AdvancedFragment.javaapp/src/main/java/io/netbird/client/ui/home/Peer.javaapp/src/main/java/io/netbird/client/ui/home/PeersAdapter.javaapp/src/main/java/io/netbird/client/ui/home/PeersFragmentViewModel.javaapp/src/main/java/io/netbird/client/ui/home/Resource.javaapp/src/main/res/layout/fragment_advanced.xmlapp/src/main/res/menu/peer_clipboard_menu.xmlapp/src/main/res/values/strings.xmlnetbirdtool/src/main/java/io/netbird/client/tool/IFace.javatool/src/main/java/io/netbird/client/tool/NetworkChangeNotifier.javatool/src/main/java/io/netbird/client/tool/TUNParameters.javatool/src/main/java/io/netbird/client/tool/VPNService.java
Use contains() for IPv6 check to match IPv4 logic, so multi-address strings like "0.0.0.0/0,::/0" are handled correctly. Add null guard for address field.
# Conflicts: # app/src/main/java/io/netbird/client/ui/home/PeersFragmentViewModel.java # netbird
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tool/src/main/java/io/netbird/client/tool/IFace.java`:
- Around line 80-82: The current logic only adds a blackhole ::/0 when addrV6 ==
null and hasIPv4DefaultRoute(routes) is true, but the presence of an IPv6
address is not the right signal — we must add the ::/0 blackhole whenever there
is an IPv4 default route and there is no IPv6 default route. Change the
condition in IFace where routes are built: replace the addrV6 == null check with
a check for absence of an IPv6 default route (e.g., !hasIPv6DefaultRoute(routes)
or !routes.stream().anyMatch(r -> r.prefix.equals("::/0"))), so that if
hasIPv4DefaultRoute(routes) && no IPv6 /0 route then routes.add(new
Route("::/0")). Use or add a helper like hasIPv6DefaultRoute(routes) to mirror
hasIPv4DefaultRoute for clarity; keep Route and routes usage unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 08479a13-3a8b-4b3b-b88c-f6846203f348
📒 Files selected for processing (2)
netbirdtool/src/main/java/io/netbird/client/tool/IFace.java
🚧 Files skipped from review as they are similar to previous changes (1)
- netbird
| if (addrV6 == null && hasIPv4DefaultRoute(routes)) { | ||
| routes.add(new Route("::/0")); | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
cat -n tool/src/main/java/io/netbird/client/tool/IFace.java | head -90Repository: netbirdio/android-client
Length of output: 4092
🏁 Script executed:
cat -n tool/src/main/java/io/netbird/client/tool/IFace.java | sed -n '60,180p'Repository: netbirdio/android-client
Length of output: 5157
🏁 Script executed:
fd -t f "Route\.java" --exec cat {} \;Repository: netbirdio/android-client
Length of output: 396
Blackhole IPv6 based on missing ::/0 route, not missing IPv6 address.
The presence of an IPv6 interface address does not guarantee a ::/0 default route exists. With allowFamily(AF_INET6) enabled and an IPv4 default route (0.0.0.0/0), non-matching IPv6 traffic can fall through to the underlying network if no ::/0 route is present. Add the blackhole whenever 0.0.0.0/0 exists and no IPv6 /0 route exists, regardless of whether an IPv6 address is configured on the interface.
Proposed fix
- if (addrV6 == null && hasIPv4DefaultRoute(routes)) {
+ if (hasIPv4DefaultRoute(routes) && !hasIPv6DefaultRoute(routes)) {
routes.add(new Route("::/0"));
}- // Blackhole IPv6 when the tunnel has an IPv4 default route but no IPv6
- // address on the interface, to prevent IPv6 leaks around the tunnel.
+ // Blackhole IPv6 when the tunnel has an IPv4 default route but no IPv6
+ // default route, to prevent IPv6 leaks around the tunnel.
private boolean hasIPv4DefaultRoute(LinkedList<Route> routes) {
for (Route r : routes) {
if ("0.0.0.0".equals(r.addr) && r.prefixLength == 0) {
return true;
}
}
return false;
}
+
+ private boolean hasIPv6DefaultRoute(LinkedList<Route> routes) {
+ for (Route r : routes) {
+ if (r.addr != null && r.addr.contains(":") && r.prefixLength == 0) {
+ return true;
+ }
+ }
+ return false;
+ }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@tool/src/main/java/io/netbird/client/tool/IFace.java` around lines 80 - 82,
The current logic only adds a blackhole ::/0 when addrV6 == null and
hasIPv4DefaultRoute(routes) is true, but the presence of an IPv6 address is not
the right signal — we must add the ::/0 blackhole whenever there is an IPv4
default route and there is no IPv6 default route. Change the condition in IFace
where routes are built: replace the addrV6 == null check with a check for
absence of an IPv6 default route (e.g., !hasIPv6DefaultRoute(routes) or
!routes.stream().anyMatch(r -> r.prefix.equals("::/0"))), so that if
hasIPv4DefaultRoute(routes) && no IPv6 /0 route then routes.add(new
Route("::/0")). Use or add a helper like hasIPv6DefaultRoute(routes) to mirror
hasIPv4DefaultRoute for clarity; keep Route and routes usage unchanged.
There was a problem hiding this comment.
In the hasIpv6 case mgmt will send a proper non black hole route as well
There was a problem hiding this comment.
@lixmal, thanks for the clarification! That makes sense — since the management server will always supply a proper IPv6 route when an IPv6 address is assigned to the interface, the addrV6 == null guard is the correct signal for when the blackhole is needed. The existing logic is intentional and correct. My apologies for the noise.
✏️ Learnings added
Learnt from: lixmal
Repo: netbirdio/android-client PR: 148
File: tool/src/main/java/io/netbird/client/tool/IFace.java:80-82
Timestamp: 2026-04-21T11:08:22.712Z
Learning: In `tool/src/main/java/io/netbird/client/tool/IFace.java` (netbirdio/android-client), the blackhole `::/0` route is intentionally added only when `addrV6 == null && hasIPv4DefaultRoute(routes)`. When an IPv6 address IS configured (`addrV6 != null`), the NetBird management server always sends a proper (non-blackhole) IPv6 route, so no blackhole is needed in that case. The `addrV6 == null` check is the correct condition to detect when mgmt won't send an IPv6 route.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
New PlatformFiles.CacheDir() method in the netbird submodule. Pass context.getCacheDir() through from EngineRunner.
Add IPv6 dual-stack support to the Android client.
Summary by CodeRabbit
New Features
Bug Fixes / Enhancements