Skip to content

Feat/wireguard example + UDP listener#101

Merged
singchia merged 17 commits into
mainfrom
feat/wireguard
Apr 24, 2026
Merged

Feat/wireguard example + UDP listener#101
singchia merged 17 commits into
mainfrom
feat/wireguard

Conversation

@singchia

Copy link
Copy Markdown
Owner

Summary

Adds a new examples/wireguard/ example that tunnels WireGuard UDP
traffic between two peers through a frontier instance, plus the
supporting UDP-listener work in pkg/utils/listen.go (via
pion/transport/v2) on which the frontier-UDP path rests.

What's Changed

New example: examples/wireguard/

  • internal/frame/: 2-byte length-prefix codec, unit-tested under -race
  • edge/: wg-edge daemon — listens UDP locally for a WireGuard peer,
    opens one long-lived geminio stream to the router, shuttles datagrams
    as length-prefixed frames, with reopen loop + exponential backoff
    reset after a healthy session
  • router/: wg-router service — accepts streams, pairs by first-frame
    pair-id, bridges matched pairs verbatim; cleans up pending streams on
    shutdown
  • cmd/udpping/: minimal UDP send/echo helper for demo without real WG
  • scripts/demo.sh: one-command local demo. On macOS runs the
    udpping send/echo pair; on Linux (root + ip/wg) creates two
    temporary netns, brings up real wg0 peers on 10.44.0.0/24, and
    verifies end-to-end with ping
  • README.md: quickstart, flag tables, real-WG walkthrough, and a
    status table that honestly marks the UDP frontier transport as
    experimental (see below)
  • Makefile follows the conventions in examples/{rtmp,iclm,chatroom}

Frontier UDP listener (base commit)

  • Adds UDP support to pkg/utils/listen.go via pion/transport/v2/udp
  • Adds etc/frontier_udp.yaml and a smoke test

Note: the UDP listener path accepts connections but the geminio
handshake over it currently times out end-to-end. The example's default
--frontier-network is therefore tcp and the example flag-tables mark
udp as experimental. The listener work is kept so the fix (likely at
the pion ↔ geminio boundary) can land incrementally without reverting
the scaffolding. Tracked as a separate framework issue.

Dependency bumps

  • github.com/singchia/geminiov1.3.0-rc.2
  • transitive: singchia/go-timer v2.2.2, and go.mod/go.sum for pion

Design docs

  • docs/superpowers/specs/2026-04-21-wireguard-example-design.md
  • docs/superpowers/plans/2026-04-23-wireguard-example.md

Test plan

  • go build ./... clean
  • go test ./examples/wireguard/internal/frame/... -race pass
  • go vet ./examples/wireguard/... clean
  • macOS demo.sh end-to-end: bidirectional UDP echo through frontier+router+two edges+two udpping processes
  • Linux netns demo.sh path verified (requires root on a Linux host)
  • iperf3 -c ... over real wg0 through the tunnel measured at ~70 Mbps on test VPS

singchia and others added 17 commits April 24, 2026 22:00
Capture the agreed design for examples/wireguard/: two symmetric
wg-edge processes plus a wg-router service, single long-lived
geminio stream with 2B length-prefix framing, UDP frontier
transport, pair-id-based matching. Guides the upcoming
implementation.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Breaks the spec into 8 tasks: scaffold + Makefile, frame package (TDD),
wg-edge binary, wg-router binary, udpping helper, demo script, README,
and a manual smoke-test gate. Each task is bite-sized with full code
and exact commands.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Pulls in the latest geminio SDK plus transitive upgrades (x/crypto,
x/net, x/sys, x/text, x/tools). Go toolchain directive tracks Go 1.24.13.
Existing frontier and example code compile and tests pass unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Track whether OpenStream actually succeeded. When it did, reset the
backoff to 1s before the next reconnect so a brief outage after a long
healthy session does not inherit a 30s wait from earlier open failures.

Addresses code-review feedback on commit 115cb85.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…arify pairing

- Add closeAll(): drain waiting map, stop timers, close streams on
  shutdown per spec §8.
- Rewrite matchOrPark's doc comment: the previous "reject third stream"
  wording misdescribed the code, which actually does arrival-order
  pairing. Arrival-order is intentional — reject semantics would break
  reconnect recovery (edge reconnects would be rejected instead of
  re-pairing after a transient fault).

Addresses code-review feedback on commit bddc91a.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… UDP gap

End-to-end verified working over TCP (frontier + wg-router + two wg-edges
+ two udpping processes): bidirectional UDP echo through the tunnel with
stream pairing visible in router logs.

The pion-wrapped UDP listener path in pkg/utils/listen.go accepts the
connection but geminio's handshake times out; the branch's listener test
only exercised Accept, not a full geminio session. Tracked as a
frontier-framework issue, out of scope for this example.

- wg-edge / wg-router default --frontier-network now tcp
- demo.sh uses etc/frontier.yaml (TCP config) and plumbs FRONTIER_NET env
  var so UDP can be re-enabled once the framework fix lands
- README grew a Status table, one-command demo recipe, and flag-table
  entries marking udp as experimental

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
demo.sh now branches on the host OS:
- macOS: original udpping send/echo demo (unchanged).
- Linux (root, with ip + wg + ping): create two temporary network
  namespaces, wire veth pairs to the host, run a wg-edge per namespace,
  configure a real wg0 peer with generated keypairs on 10.44.0.0/24,
  and verify end-to-end connectivity with ping before exiting.
  Self-cleans namespaces on exit.

Adds --hold (keep running after verification) and --detach (run in
background, redirect logs to a console.log file) flags. Environment
overrides FRONTIER_BIN / FRONTIER_CFG / FRONTIER_NET / FRONTIER_*_ADDR
so the script composes cleanly with non-default setups.

README updated: Status table marks Linux netns verification as
automated; one-command demo section documents the per-OS behavior and
new flags.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Transitive: go-timer v2.2.1 → v2.2.2.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Apr 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
frontier Ready Ready Preview, Comment Apr 24, 2026 5:14pm

@singchia singchia merged commit c57c979 into main Apr 24, 2026
3 checks passed
@singchia singchia mentioned this pull request Apr 24, 2026
2 tasks
@singchia singchia deleted the feat/wireguard branch April 25, 2026 06:08
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