Skip to content

Z13: Runtime handles RENDEZVOUS/PUSH_DIRECT_PATHS - #3

Merged
JKamsker merged 1 commit into
masterfrom
z13-runtime-direct-paths
Feb 26, 2026
Merged

JKamsker merged 1 commit into
masterfrom
z13-runtime-direct-paths

Conversation

@JKamsker

@JKamsker JKamsker commented Feb 26, 2026 •

Copy link
Copy Markdown
Owner

Implements handling of root RENDEZVOUS + peer PUSH_DIRECT_PATHS in ZeroTierDataplaneRuntime and sends UDP hole punches. Adds unit tests and marks the final MVP checklist item complete.

Summary by CodeRabbit

  • New Features

    • Added support for UDP direct path establishment between peers with rendezvous and hole punch signaling capabilities.
  • Tests

    • Added comprehensive integration tests verifying direct path discovery and hole punch message handling.

@coderabbitai

coderabbitai Bot commented Feb 26, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4608072 and a460dc0.

📒 Files selected for processing (5)
  • ZTSharp.Tests/ZeroTierDataplaneRuntimeDirectPathTests.cs
  • ZTSharp/ZeroTier/Internal/ZeroTierDataplanePeerPacketHandler.cs
  • ZTSharp/ZeroTier/Internal/ZeroTierDataplaneRuntime.cs
  • ZTSharp/ZeroTier/Internal/ZeroTierDataplaneRxLoops.cs
  • docs/Tasks/zerotier-real-stack-mvp.md

📝 Walkthrough

Walkthrough

This PR implements UDP hole punch functionality for ZeroTier direct path establishment. It adds control message handlers (Rendezvous, PushDirectPaths) to the dataplane runtime, introduces per-peer endpoint management infrastructure, and includes integration tests verifying hole punch packet exchanges.

Changes

Cohort / File(s) Summary
Test Suite
ZTSharp.Tests/ZeroTierDataplaneRuntimeDirectPathTests.cs
New integration test class with two async tests: one for handling Rendezvous messages and another for PushDirectPaths, both verifying hole punch payload reception within 2 seconds. Includes internal helpers to build test payloads and configure runtime/transport/identity setup.
Runtime Control Handlers
ZTSharp/ZeroTier/Internal/ZeroTierDataplaneRuntime.cs
Introduces per-peer direct endpoint cache (ConcurrentDictionary), wires control handlers (HandleRootControlPacketAsync, HandlePeerControlPacketAsync) to packet processors, and adds GetOrCreateDirectEndpointManager helper. Routes Rendezvous and PushDirectPaths messages to respective endpoint managers.
Peer Packet Handler
ZTSharp/ZeroTier/Internal/ZeroTierDataplanePeerPacketHandler.cs
Adds optional async control handler field and constructor parameter. Introduces handling case for PushDirectPaths verb that delegates to the control handler when provided, enabling peer-initiated direct path updates.
RX Loop Handler
ZTSharp/ZeroTier/Internal/ZeroTierDataplaneRxLoops.cs
Adds optional root-control handler hook with constructor parameter. Converts root payload handling from ReadOnlySpan to ReadOnlyMemory, and invokes handler on dispatch failures to process Rendezvous and other root-directed control messages.
Documentation
docs/Tasks/zerotier-real-stack-mvp.md
Marks Milestone Z13 (Rendezvous and PushDirectPaths handling) as completed.

Sequence Diagram(s)

sequenceDiagram
    participant Root as ZeroTier Root
    participant RxLoop as ZeroTierDataplaneRxLoops
    participant Runtime as ZeroTierDataplaneRuntime
    participant Manager as DirectEndpointManager

    Root->>RxLoop: Rendezvous packet
    RxLoop->>RxLoop: TryDispatchResponse fails
    RxLoop->>Runtime: HandleRootControlPacketAsync(Rendezvous, ...)
    Runtime->>Runtime: GetOrCreateDirectEndpointManager(peerId)
    Runtime->>Manager: HandleRendezvousFromRoot(...)
    Manager->>Manager: Parse rendezvous endpoint
    Manager->>Root: Send hole punch packet
Loading
sequenceDiagram
    participant Peer as Remote Peer
    participant Handler as ZeroTierDataplanePeerPacketHandler
    participant Runtime as ZeroTierDataplaneRuntime
    participant Manager as DirectEndpointManager

    Peer->>Handler: PushDirectPaths packet
    Handler->>Handler: Dispatch to control handler
    Handler->>Runtime: HandlePeerControlPacketAsync(peerId, PushDirectPaths, ...)
    Runtime->>Runtime: GetOrCreateDirectEndpointManager(peerId)
    Runtime->>Manager: HandleDirectPathsFromPeer(...)
    Manager->>Manager: Update direct endpoints
    Manager->>Peer: Send hole punch packet
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Bouncing through the network hops,
Direct paths spring where firewall stops,
Rendezvous whispers, punch cards fly,
Peers find peers beneath the sky! 🌐✨

🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 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 identifies the main change: implementing handling of RENDEZVOUS and PUSH_DIRECT_PATHS messages in the ZeroTier dataplane runtime, matching the PR's primary objective.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch z13-runtime-direct-paths

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.

@JKamsker
JKamsker merged commit b6df7fa into master Feb 26, 2026
6 checks passed
@JKamsker
JKamsker deleted the z13-runtime-direct-paths branch February 26, 2026 04:59
@coderabbitai coderabbitai Bot mentioned this pull request Feb 27, 2026
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.

1 participant