Spark Program | FiberVPN: Pay-Per-Hour WireGuard Tunnels over Fiber

Project: FiberVPN
Applicant: Akan Theodore (kd-designs on GitHub: GitHub - kd-designs/fibervpn: Pay-per-hour and pay-per-MB WireGuard VPN exit gateway powered by Nervos Fiber Network · GitHub )
Funding requested: $750 USD equivalent in CKB (payout address shared on approval)
Timeline: 5 weeks
Contact: Nervos Talk DM


What FiberVPN Is

FiberVPN is a self-hosted WireGuard exit gateway and browser checkout that sells encrypted VPN tunnels by the hour or by the megabyte over Nervos Fiber Network.

You open the web page, pick a tier (1 hour / 500 MB or 24 hours / 5 GB), pay a Fiber invoice and get a WireGuard QR code and .conf file immediately. You scan it into the official WireGuard app on your phone or laptop, route traffic through the exit node and get disconnected cleanly as soon as the paid time or byte quota hits zero

Why Build This

Most commercial VPNs force users into $10+/month subscriptions, email signups or credit card billing just to get encrypted internet on airport, hotel or cafe Wi-Fi for an afternoon. On Bitcoin Lightning, LNVPN showed that pay-as-you-go WireGuard tunnels are one of the few micropayment apps people actually return to use.

FiberVPN brings that same pattern to Fiber without accounts or custodial logins:

  • The browser generates the WireGuard keypair locally and persists it in localStorage so refreshing the tab while waiting for payment never orphans a paid tunnel.
  • The backend validates the Curve25519 public key, creates a Fiber invoice via fnn (new_invoice) and allocates a tunnel IP only after get_invoice reports Paid.
  • Every 10 seconds, the quota daemon checks wg show wg0 transfer and tears down any peer whose paid duration or byte limit is reached, recycling its IP back into the /24 pool.

How it sits next to other Fiber projects: MeterNet meters local router Wi-Fi per megabyte via openNDS captive-portal rules, while Fiber Paid HTTP gates single HTTP requests behind payment headers. Neither gives a remote user an OS-level encrypted WireGuard tunnel they can turn on from anywhere using the standard WireGuard app.

How It Works

Browser generates WireGuard keypair locally (saved in localStorage)
  -> sends publicKey + tier to FiberVPN gateway
  -> gateway validates Curve25519 key, calls fnn new_invoice and returns invoice

User pays invoice (~1s via Fiber wallet or @nervosnetwork/fiber-js WASM)
  -> gateway sees Paid via get_invoice
  -> allocates IP from /24 pool -> runs `wg set wg0 peer <pubkey> allowed-ips <ip>/32`
  -> browser injects local PrivateKey and renders WireGuard QR / .conf

Quota daemon (every 10s, backed by SQLite)
  -> reads `wg show wg0 transfer`
  -> on expiry or rx+tx >= maxBytes, runs `wg set wg0 peer <pubkey> remove` and recycles IP

The HTTP server runs unprivileged (not as root), scoped via CAP_NET_ADMIN / sudoers strictly to wg set wg0 and wg show wg0 transfer with execFile and zero shell interpolation. During the public testnet trial, nftables forwarding on wg0 blocks outbound SMTP (25, 465, 587) and BitTorrent while leaving standard web, SSH and DNS ports (80, 443, 53) open so testers cannot get the VPS flagged for spam.

For reviewers who do not run a local fnn node, Week 2 puts a public testnet web MVP online with a built-in @nervosnetwork/fiber-js browser WASM flow alongside the raw invoice QR. You fund from the testnet faucet, pay a 15 min / 50 MB test tier right in your browser, scan the WireGuard QR on your phone or laptop and confirm your public IP switches to the exit node and cuts off at expiry.

Applicant Background

I’m Akan Theodore (kd-designs), an independent full-stack developer working mostly with TypeScript, Node.js services and Linux networking. I haven’t run a public fnn node before, so Week 1 tackles live Pudge testnet channel opening and wg set peer provisioning on a Linux VPS up front before building the browser UI on top of it.

What Already Exists vs. What the Grant Funds

An initial v0.1.0 core is already written in TypeScript ( GitHub - kd-designs/fibervpn: Pay-per-hour and pay-per-MB WireGuard VPN exit gateway powered by Nervos Fiber Network · GitHub ) and runs locally today:

  • Curve25519 base64 key validation rejecting malformed or shell-injected keys (src/wireguard.ts)
  • /24 IP pool allocator (IpPoolAllocator), .conf builder and WgCliAdapter using execFile('wg', ...)
  • FnnRpcClient wired to FNN’s new_invoice and get_invoice JSON-RPC schema plus an in-memory mock (src/fiber-rpc.ts)
  • VpnManager with post-payment IP allocation, concurrent activation locking, duplicate-active-key protection and automatic time/byte quota cutoffs (src/manager.ts)
  • 8 passing unit tests (npm test) and a local simulation (npm run demo)

What this grant funds (5 weeks):

  • Live Linux + WireGuard + fnn gateway: Provisioning wg0 NAT/forwarding, nftables port filtering and a funded Pudge testnet fnn node on a public Linux VPS.
  • Public browser MVP (Week 2): Hosted testnet page with client-side Curve25519 keygen (localStorage-backed), @nervosnetwork/fiber-js WASM checkout alongside raw invoice QRs and WireGuard QR rendering.
  • SQLite persistence & restart reconciliation (Week 3): Persisting sessions and byte checkpoints in SQLite so daemon restarts clean up peers that expired offline and never reset wg byte counters.
  • 14-day public testnet trial & verifier (Weeks 4-5): Opening the testnet exit node to Nervos Talk testers for two weeks, publishing a standalone status/verification CLI (npx fibervpn status <payment_hash>), recording an unedited mobile WireGuard demo video and posting the closing report with testnet payment hashes and honest latency/failure notes.

Deliverables & Timeline

  • Week 1: Live wg0 + fnn testnet node: Linux VPS running WireGuard wg0, nftables rules and a funded Pudge testnet fnn node; first real invoice-to-peer-add test passed
  • Week 2: Public testnet web MVP: Hosted demo URL posted on this thread with browser @nervosnetwork/fiber-js + QR checkout, WireGuard QR generation and live peer status board.
  • Week 3: Persistence & quota cutoff suite: SQLite session recovery across restarts and live cutoff tests for both time expiry and byte-cap exhaustion.
  • Weeks 4-5: 14-day community trial, CLI & wrap-up: Two weeks of public testnet usage, verification CLI published, unedited mobile WireGuard cutoff video recorded and closing report posted.

Budget: $750 USD in CKB

Priced by milestone (no VPS hardware or hosting fees billed separately):

  • Week 1 ($150): Linux VPS wg0 setup, nftables rules and testnet fnn channel liquidity
  • Week 2 ($200): Public testnet web MVP, client-side keygen, WASM checkout and WireGuard QR UI
  • Week 3 ($200): SQLite persistence, restart reconciliation and automated quota cutoff tests
  • Weeks 4-5 ($200): 14-day public trial, verification CLI, walkthrough video and closing report

How Anyone Can Verify

  1. Right now (local repo): Clone GitHub - kd-designs/fibervpn: Pay-per-hour and pay-per-MB WireGuard VPN exit gateway powered by Nervos Fiber Network · GitHub , run npm install && npm test && npm run demo to verify the 8 tests, key validation, concurrency guard and quota cutoff simulation.
  2. From Week 2: Open the live testnet URL, pay a testnet Fiber invoice via the browser WASM flow (or your own Fiber node), scan the WireGuard QR in the official WireGuard app, check ifconfig.me before and after connecting and watch traffic stop at expiry.
  3. At completion: Run npx fibervpn status <payment_hash> against our public logs and watch the unedited phone-to-WireGuard walkthrough video.

Maintenance

For 6 months after completion, I will keep fibervpn updated against fnn JSON-RPC changes and answer setup issues on GitHub within 48 hours.

2 Likes