Compare commits

..
4 Commits
Author SHA1 Message Date
ddidderr 2bed62e9ec docs: format reference links in plan to satisfy rumdl and prettier
The reference link definitions at the end of PLAN.md included multiline
titles and query strings, which caused Prettier to wrap them across multiple
lines without angle brackets and rumdl (MD034) to flag the indented URLs and
re-add angle brackets. This created an alternating conflict on every `just fmt`
invocation.

Simplify the link reference definitions to single-line URLs without query
strings and titles so both Prettier and rumdl format cleanly and idempotently.

Test Plan:
- `just fmt` -- formatted cleanly with no changes across repeated runs
- `just clippy` -- passed
- `just test` -- all 118 unit tests passed
2026-08-16 18:36:06 +02:00
ddidderr 9175eedce9 [release] softlan-vpn v0.1.0
First release of softlan-vpn, a low-latency virtual Layer 2 gaming VPN and
Ethernet bridge built on QUIC datagrams.

This release introduces the initial workspace architecture, crates, and
operational components:

- lanparty-relay: QUIC-based Layer 2 VPN relay server with room-level isolation,
  learning switch (CAM table), anti-spoofing MAC validation, safety filters
  against rogue DHCP servers and IPv6 Router Advertisements, token-bucket rate
  limiters, and development TLS certificate generation.
- lanparty-gateway: Linux Layer 2 gateway bridge utilizing raw AF_PACKET sockets
  in promiscuous mode to bridge physical LAN segments to remote VPN rooms with
  carrier checking and datagram budget enforcement.
- lanparty-client-win: Windows client CLI and session engine integrating
  TAP-Windows6 adapter I/O, scoped IP route management (relay host route pinning,
  default route suppression, metric configuration), and real-time terminal
  diagnostics.
- lanparty-proto, lanparty-ctrl, lanparty-obs, lanparty-net: Protocol primitives,
  control stream codec, observability reporting, and network resolution helpers.

Initial release is documented in CHANGELOG.md adhering to Keep a Changelog and
Semantic Versioning.

Test Plan:
- `just clippy` -- passed
- `just fmt` -- passed
- `just test` -- passed (118 tests across all crates)
- `git diff --cached --check` -- passed

Refs: CHANGELOG.md "[0.1.0]", AGENTS.md "Versioning Policy"
2026-08-16 10:39:04 +02:00
ddidderr 16d0886f36 justfile, AGENTS.md 2026-08-16 10:36:27 +02:00
ddidderr a66ea31ab3 cippy issue, fmt, update/upgrade 2026-08-16 10:33:28 +02:00
23 changed files with 659 additions and 346 deletions
+19
View File
@@ -0,0 +1,19 @@
# Agent Instructions
## Commit Policy
Automatically commit changes once a full feature, bugfix, refactor, or other
coherent unit of work is finished. Do not wait for the user to ask for a commit.
## Versioning Policy
Only update the version, when the user explicitly asks for it.
### Guidelines for how to update the version
1. Use `cargo set-version` to bump the version. Decide, based on the actual
changes, based on semver semantics, if major, minor or patch needs to be
bumped.
2. Update the CHANGELOG.md file accordingly.
3. Create a release commit.
4. Tag the release commit in the style of previous versioning tags.
+47
View File
@@ -0,0 +1,47 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
## [0.1.0] - 2026-08-16
### Added
- **QUIC-based Layer 2 VPN Relay (`lanparty-relay`)**:
- Room-isolated virtual Layer 2 Ethernet switching over QUIC datagrams
(`quinn` / `rustls`).
- Learning switch (CAM table) for unicast frame forwarding and
broadcast/multicast flooding.
- L2 safety filters: client source MAC anti-spoofing, rogue DHCPv4/DHCPv6
server reply filtering, IPv6 Router Advertisement suppression (including
behind extension headers), IPv6 fragment filtering, remote VLAN tag
filtering, and malformed frame rejection.
- Token-bucket rate limiting for broadcast, unknown unicast, and total client
bandwidth.
- Development TLS certificate generation helper.
- **Linux Physical Gateway Bridge (`lanparty-gateway`)**:
- Promiscuous `AF_PACKET` raw socket bridge connecting local physical LAN
networks to virtual relay rooms.
- Ingress/egress datagram budget enforcement, carrier validation, and
self-injection filtering.
- **Windows Client (`lanparty-client-win`, `lanparty-client-core`,
`lanparty-client-tap`, `lanparty-client-route`)**:
- TAP-Windows6 adapter management and Ethernet frame I/O.
- Scoped Windows IP route management: relay host route pinning, TAP default
route suppression, and interface metric configuration.
- Virtual MAC persistence and reconnect handling.
- Real-time diagnostic reporting for RTT, LAN DHCP lease state, gateway
presence, and frame flow counters.
- **Shared Infrastructure**:
- Protocol primitives (`lanparty-proto`) for datagram framing, MTU
negotiation, and safety classifications.
- Control plane (`lanparty-ctrl`) for room admission, peer lifecycle events,
and stats snapshots.
- Observability suite (`lanparty-obs`) for structured frame logging and
diagnostic formatting.
- Network address resolution utilities (`lanparty-net`).
Generated
+50 -50
View File
@@ -138,9 +138,9 @@ checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04"
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.3.0" version = "1.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c89588d05638b5b4594a3348a2d6c20277e43a7f5c5202b05cc56888475a47b8" checksum = "509591b7bcd67f4ef775afad7662703b4935daaa6ec0e5605cfb1090b32a2b6d"
dependencies = [ dependencies = [
"find-msvc-tools", "find-msvc-tools",
"shlex", "shlex",
@@ -171,9 +171,9 @@ dependencies = [
[[package]] [[package]]
name = "clap" name = "clap"
version = "4.6.4" version = "4.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d91e0c145792ef73a6ad36d27c75ac09f1832222a3c209689d90f534685ee5b7" checksum = "473c7e07f409a8d772161724aa8db6a765a2532a70f9667eeb7b49d3d02fbdca"
dependencies = [ dependencies = [
"clap_builder", "clap_builder",
"clap_derive", "clap_derive",
@@ -181,9 +181,9 @@ dependencies = [
[[package]] [[package]]
name = "clap_builder" name = "clap_builder"
version = "4.6.2" version = "4.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f09628afdcc538b57f3c6341e9c8e9970f18e4a481690a64974d7023bd33548b" checksum = "7b48fea5a88e9ae728a2dcbedbfc0e730f7d60da42e1cb049a83c9fb8b789889"
dependencies = [ dependencies = [
"anstream", "anstream",
"anstyle", "anstyle",
@@ -252,9 +252,9 @@ dependencies = [
[[package]] [[package]]
name = "data-encoding" name = "data-encoding"
version = "2.11.0" version = "2.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4ae5f15dda3c708c0ade84bfee31ccab44a3da4f88015ed22f63732abe300c8" checksum = "4583a4551df46e2792f82ceeac45e850d2e2d5debba0b91f102385cda5b11f06"
[[package]] [[package]]
name = "der-parser" name = "der-parser"
@@ -278,13 +278,13 @@ checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c"
[[package]] [[package]]
name = "displaydoc" name = "displaydoc"
version = "0.2.6" version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ac70aa55017e108007fbaf5aa0f54b021c98f92ff8af59d42eda9da96e3dd4f" checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.119", "syn 3.0.3",
] ]
[[package]] [[package]]
@@ -311,9 +311,9 @@ dependencies = [
[[package]] [[package]]
name = "find-msvc-tools" name = "find-msvc-tools"
version = "0.1.9" version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" checksum = "d45db016d36b838f563236e9193d0ee6ce38f3f68b6c94e914b4929c96bbb890"
[[package]] [[package]]
name = "foldhash" name = "foldhash"
@@ -323,21 +323,21 @@ checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"
[[package]] [[package]]
name = "futures-core" name = "futures-core"
version = "0.3.33" version = "0.3.34"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2cd50c473c80f6d7c3670a752354b8e569b1a7cbfdc0419ec88e5edad85e0dc7" checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e"
[[package]] [[package]]
name = "futures-task" name = "futures-task"
version = "0.3.33" version = "0.3.34"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b231ed28831efb4a61a08580c4bc233ec56bc009f4cd8f52da2c3cb97df0c109" checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd"
[[package]] [[package]]
name = "futures-util" name = "futures-util"
version = "0.3.33" version = "0.3.34"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a77a90a256fce34da66415271e30f94ee91c57b04b8a2c042d9cf3220179deaa" checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc"
dependencies = [ dependencies = [
"futures-core", "futures-core",
"futures-task", "futures-task",
@@ -441,9 +441,9 @@ dependencies = [
[[package]] [[package]]
name = "js-sys" name = "js-sys"
version = "0.3.103" version = "0.3.104"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53b44bfcdb3f8d5837a46dae1ca9660a837176eee74a28b229bc626816589102" checksum = "0e0c1080212aad755ea003d18543e8768dd432c48819efd73a7bf1e39b7a5a3a"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"futures-util", "futures-util",
@@ -655,9 +655,9 @@ checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441"
[[package]] [[package]]
name = "num-integer" name = "num-integer"
version = "0.1.46" version = "0.1.47"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b"
dependencies = [ dependencies = [
"num-traits", "num-traits",
] ]
@@ -716,9 +716,9 @@ checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
[[package]] [[package]]
name = "portable-atomic" name = "portable-atomic"
version = "1.14.0" version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d20d5497ef88037a52ff98267d066e7f11fcc5e99bbfbd58a42336193aacec3" checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
[[package]] [[package]]
name = "powerfmt" name = "powerfmt"
@@ -836,9 +836,9 @@ dependencies = [
[[package]] [[package]]
name = "rcgen" name = "rcgen"
version = "0.14.8" version = "0.14.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57f6d249aad744e274e682777a50283a225a32705394ee6d5fcc01efa25e4055" checksum = "091e7a8e7d86e6feb87a27ce8e2cba29d49eff9507afeebefab7eeb2ca667fb4"
dependencies = [ dependencies = [
"pem", "pem",
"ring", "ring",
@@ -888,9 +888,9 @@ dependencies = [
[[package]] [[package]]
name = "rustls" name = "rustls"
version = "0.23.42" version = "0.23.43"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c54fcab019b409d04215d3a17cb438fd7fbf192ee61461f20f4fe18704bc138" checksum = "0283386ce02abc0151e1761d08802dfe86c173b0b494af5cbc086574e453da06"
dependencies = [ dependencies = [
"once_cell", "once_cell",
"ring", "ring",
@@ -914,9 +914,9 @@ dependencies = [
[[package]] [[package]]
name = "rustls-pki-types" name = "rustls-pki-types"
version = "1.15.0" version = "1.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "764899a24af3980067ee14bc143654f297b22eaebfe3c7b6b211920a5a59b046" checksum = "2f4925028c7eb5d1fcdaf196971378ed9d2c1c4efc7dc5d011256f76c99c0a96"
dependencies = [ dependencies = [
"web-time", "web-time",
"zeroize", "zeroize",
@@ -951,9 +951,9 @@ checksum = "f87165f0995f63a9fbeea62b64d10b4d9d8e78ec6d7d51fb2125fda7bb36788f"
[[package]] [[package]]
name = "rustls-webpki" name = "rustls-webpki"
version = "0.103.13" version = "0.103.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61c429a8649f110dddef65e2a5ad240f747e85f7758a6bccc7e5777bd33f756e" checksum = "0527518605e68109d875e248ea259b6758801cf165e4b2c2733ae3b51f12535a"
dependencies = [ dependencies = [
"ring", "ring",
"rustls-pki-types", "rustls-pki-types",
@@ -1157,18 +1157,18 @@ dependencies = [
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "2.0.19" version = "2.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09a43598840e33d5b0331f38c5e30d13bb11c11210a4b58f0d9b18a5a5eefcd9" checksum = "ec86235f5fcc2a73650310756d2ac5b138a5780bbbdfae3eeccec992c435ba4f"
dependencies = [ dependencies = [
"thiserror-impl", "thiserror-impl",
] ]
[[package]] [[package]]
name = "thiserror-impl" name = "thiserror-impl"
version = "2.0.19" version = "2.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43cbfe0cf76104d42a574802844187e84a305e531ed54455f11fbde0f10541cd" checksum = "bc04cd3e1236dd4a98afca4569f2deb3f120e5422a4023be2cb683f8486292af"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@@ -1177,9 +1177,9 @@ dependencies = [
[[package]] [[package]]
name = "time" name = "time"
version = "0.3.54" version = "0.3.55"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e1d5e639ff6bab73cb6885cc7e7b1de96c3f32c68ec55f3952614bec1092244" checksum = "cdb87b95ec50ddfa440816d227a17b2ccbdda963a316a727fda0fc4334f7d134"
dependencies = [ dependencies = [
"deranged", "deranged",
"num-conv", "num-conv",
@@ -1237,13 +1237,13 @@ dependencies = [
[[package]] [[package]]
name = "tokio-macros" name = "tokio-macros"
version = "2.7.1" version = "2.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6328af13490e73a9b4694030fafd93f8c8c6a9dede33e821c3fc63eddf8042ba" checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.119", "syn 3.0.3",
] ]
[[package]] [[package]]
@@ -1302,9 +1302,9 @@ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
[[package]] [[package]]
name = "wasm-bindgen" name = "wasm-bindgen"
version = "0.2.126" version = "0.2.127"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b067c0c11094aef6b7a801c1e34a26affafdf3d051dba08456b868789aaf9a4" checksum = "1b70935747edd64d89de3efa29d73789b806c15798f8e7dca4d8ac356b50ce70"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"once_cell", "once_cell",
@@ -1315,9 +1315,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-macro" name = "wasm-bindgen-macro"
version = "0.2.126" version = "0.2.127"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "167ce5e579f6bcf889c4f7175a8a5a585de84e8ff93976ce393efa5f2837aab1" checksum = "77775f8f3f7217702089053b94958f8f54061a3f663417df76e19cbdcca29bc1"
dependencies = [ dependencies = [
"quote", "quote",
"wasm-bindgen-macro-support", "wasm-bindgen-macro-support",
@@ -1325,9 +1325,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-macro-support" name = "wasm-bindgen-macro-support"
version = "0.2.126" version = "0.2.127"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3997c7839262f4ef12cf90b818d6340c18e80f263f1a94bf157d0ec4420380e" checksum = "e11d33f857dc2fb11b8bc75aee111aa9cbeb12cd9f25efd3d4c2a3dd4e235284"
dependencies = [ dependencies = [
"bumpalo", "bumpalo",
"proc-macro2", "proc-macro2",
@@ -1338,9 +1338,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-shared" name = "wasm-bindgen-shared"
version = "0.2.126" version = "0.2.127"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc1b4cb0cc549fcf58d7dfc081778139b3d283a081644e833e84682ad71cea24" checksum = "7ef64dbcc55df09c7e5a46182d181c2cfa3e925f3da937ea764728b4bbb9dcbf"
dependencies = [ dependencies = [
"unicode-ident", "unicode-ident",
] ]
+5 -5
View File
@@ -20,15 +20,15 @@ edition = "2024"
[workspace.dependencies] [workspace.dependencies]
anyhow = "1" anyhow = "1"
bytes = "1" bytes = "1"
clap = { version = "4.6.1", features = ["derive"] } clap = { version = "4.6.6", features = ["derive"] }
getrandom = "0.4.2" getrandom = "0.4.3"
libc = "0.2" libc = "0.2"
quinn = "0.11.9" quinn = "0.11.11"
rcgen = "0.14.8" rcgen = "0.14.9"
rustls = { version = "0.23", default-features = false, features = ["ring", "std"] } rustls = { version = "0.23", default-features = false, features = ["ring", "std"] }
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
serde_json = "1" serde_json = "1"
thiserror = "2" thiserror = "2"
tokio = { version = "1.52.3", features = ["macros", "net", "rt-multi-thread", "signal", "sync", "time"] } tokio = { version = "1.53.1", features = ["macros", "net", "rt-multi-thread", "signal", "sync", "time"] }
tracing = "0.1" tracing = "0.1"
windows-sys = "0.61.2" windows-sys = "0.61.2"
+110 -63
View File
@@ -1,14 +1,23 @@
# PLAN
What I want to do: What I want to do:
A simple one-click Layer 2 tunnel software (Windows 11 client) to bridge people who cannot participate in person at a LAN party to the LAN party. And a simple server endpoint (Linux) software that runs physically at the LAN party and bridges the tunneled traffic and the real LAN network. A simple one-click Layer 2 tunnel software (Windows 11 client) to bridge people
who cannot participate in person at a LAN party to the LAN party. And a simple
server endpoint (Linux) software that runs physically at the LAN party and
bridges the tunneled traffic and the real LAN network.
I already talked a bit with different AIs about how to do this, here's the current plan: I already talked a bit with different AIs about how to do this, here's the
current plan:
# LAN Party Tunnel Plan ## LAN Party Tunnel Plan
Build a **TAP-based L2-over-QUIC tunnel**. Build a **TAP-based L2-over-QUIC tunnel**.
The remote Windows client gets a real virtual Ethernet adapter. Ethernet frames from that adapter are sent over QUIC to a public relay. The relay forwards them to a Linux gateway at the LAN party. The Linux gateway injects those frames onto the physical LAN and captures replies. The remote Windows client gets a real virtual Ethernet adapter. Ethernet frames
from that adapter are sent over QUIC to a public relay. The relay forwards them
to a Linux gateway at the LAN party. The Linux gateway injects those frames onto
the physical LAN and captures replies.
```text ```text
Windows game Windows game
@@ -21,13 +30,10 @@ Windows game
⇄ physical Ethernet LAN ⇄ physical Ethernet LAN
``` ```
No WireGuard. No WireGuard. No Npcap. No Windows bridge. No packet rewriting from the users
No Npcap. real NIC. No tunnel fragmentation for MVP.
No Windows bridge.
No packet rewriting from the users real NIC.
No tunnel fragmentation for MVP.
## Goal ### Goal
The remote player should do this: The remote player should do this:
@@ -53,11 +59,12 @@ The public server does this:
lanparty-relay --listen 443/udp lanparty-relay --listen 443/udp
``` ```
UDP/443 is a good default, but the port must be configurable because some networks block QUIC/UDP. UDP/443 is a good default, but the port must be configurable because some
networks block QUIC/UDP.
## Components ### Components
### 1. Windows client: `lanparty-client.exe` #### 1. Windows client: `lanparty-client.exe`
Written in Rust. Written in Rust.
@@ -75,9 +82,13 @@ Responsibilities:
- keep the relay connection routed through the real internet NIC - keep the relay connection routed through the real internet NIC
``` ```
Use a real TAP/Ethernet adapter. `tap-windows6` is an NDIS TAP-Windows driver used by OpenVPN and other apps, which is the right class of device here because we need Ethernet frames, not just IP packets. ([GitHub][1]) Use a real TAP/Ethernet adapter. `tap-windows6` is an NDIS TAP-Windows driver
used by OpenVPN and other apps, which is the right class of device here because
we need Ethernet frames, not just IP packets. ([GitHub][1])
Do **not** use Wintun for this design. Wintun is L3/TUN-style and does not give you the Ethernet/L2 behavior needed for ARP, DHCP, broadcast discovery, and old LAN games. Do **not** use Wintun for this design. Wintun is L3/TUN-style and does not give
you the Ethernet/L2 behavior needed for ARP, DHCP, broadcast discovery, and old
LAN games.
The TAP adapter is the remote players LAN-party identity. The TAP adapter is the remote players LAN-party identity.
@@ -88,7 +99,7 @@ Game sends ARP/broadcast/multicast through TAP
Client tunnels the Ethernet frames Client tunnels the Ethernet frames
``` ```
### 2. Linux gateway: `lanparty-gateway` #### 2. Linux gateway: `lanparty-gateway`
Runs on the physical LAN party machine. Runs on the physical LAN party machine.
@@ -104,15 +115,23 @@ Responsibilities:
- periodically refresh switch CAM table entries - periodically refresh switch CAM table entries
``` ```
Use Linux `AF_PACKET` / `SOCK_RAW` on the real wired NIC. Packet sockets operate at device-driver / OSI Layer 2 level, and `SOCK_RAW` includes the link-layer header, which is exactly what we need for Ethernet frames. ([man7.org][2]) Use Linux `AF_PACKET` / `SOCK_RAW` on the real wired NIC. Packet sockets operate
at device-driver / OSI Layer 2 level, and `SOCK_RAW` includes the link-layer
header, which is exactly what we need for Ethernet frames. ([man7.org][2])
For MVP, run as root. Later, reduce privileges. Opening raw sockets and changing/promiscuous network behavior needs elevated networking privileges; `CAP_NET_ADMIN` covers things like setting promiscuous mode, and `CAP_NET_RAW` covers raw packet access. ([man7.org][3]) For MVP, run as root. Later, reduce privileges. Opening raw sockets and
changing/promiscuous network behavior needs elevated networking privileges;
`CAP_NET_ADMIN` covers things like setting promiscuous mode, and `CAP_NET_RAW`
covers raw packet access. ([man7.org][3])
No Linux bridge is needed for MVP. No `br0`. No moving the hosts IP from `eth0` to a bridge. The gateway daemon directly captures and injects frames on the physical NIC. No Linux bridge is needed for MVP. No `br0`. No moving the hosts IP from `eth0`
to a bridge. The gateway daemon directly captures and injects frames on the
physical NIC.
Wired Ethernet only. No Wi-Fi gateway mode for MVP. Managed Wi-Fi NICs are not reliable for arbitrary source-MAC injection. Wired Ethernet only. No Wi-Fi gateway mode for MVP. Managed Wi-Fi NICs are not
reliable for arbitrary source-MAC injection.
### 3. Public relay: `lanparty-relay` #### 3. Public relay: `lanparty-relay`
Runs on VPS/public server. Runs on VPS/public server.
@@ -139,7 +158,7 @@ gateway → outbound QUIC → relay
No port forwarding. No NAT traversal pain. Direct P2P can come later. No port forwarding. No NAT traversal pain. Direct P2P can come later.
## Transport ### Transport
Use QUIC. Use QUIC.
@@ -158,11 +177,16 @@ disconnect reason
future auth future auth
``` ```
Use QUIC DATAGRAM for Ethernet frames. QUIC DATAGRAM is specifically the unreliable datagram extension for QUIC, which fits Ethernet/game traffic better than reliable streams because old frames should not block newer frames. ([IETF Datatracker][4]) Use QUIC DATAGRAM for Ethernet frames. QUIC DATAGRAM is specifically the
unreliable datagram extension for QUIC, which fits Ethernet/game traffic better
than reliable streams because old frames should not block newer frames. ([IETF
Datatracker][4])
Rust QUIC implementation: start with `quinn`. It exposes `Connection::max_datagram_size()`, which returns the maximum datagram payload size or `None` if datagrams are unsupported/disabled. ([Docs.rs][5]) Rust QUIC implementation: start with `quinn`. It exposes
`Connection::max_datagram_size()`, which returns the maximum datagram payload
size or `None` if datagrams are unsupported/disabled. ([Docs.rs][5])
## No fragmentation for MVP ### No fragmentation for MVP
Do **not** fragment Ethernet frames inside the overlay. Do **not** fragment Ethernet frames inside the overlay.
@@ -200,9 +224,10 @@ tap_mtu <= quic_max_datagram_size
- safety_margin - safety_margin
``` ```
No fragment table. No reassembly timeout. No “one lost fragment kills the whole Ethernet frame.” Add fragmentation later only if testing proves it is necessary. No fragment table. No reassembly timeout. No “one lost fragment kills the whole
Ethernet frame.” Add fragmentation later only if testing proves it is necessary.
## Overlay frame format ### Overlay frame format
Keep the outer routing header small and stable. Keep the outer routing header small and stable.
@@ -226,13 +251,16 @@ clear routing header
encrypted Ethernet payload encrypted Ethernet payload
``` ```
MVP can skip payload encryption beyond QUIC, but the wire format should not make later E2E encryption painful. MVP can skip payload encryption beyond QUIC, but the wire format should not make
later E2E encryption painful.
## Trust model ### Trust model
MVP relay sees plaintext Ethernet frames. MVP relay sees plaintext Ethernet frames.
QUIC encrypts traffic on the wire, but because the relay terminates QUIC connections, it decrypts frames from clients and re-encrypts them to the gateway. QUIC encrypts traffic on the wire, but because the relay terminates QUIC
connections, it decrypts frames from clients and re-encrypts them to the
gateway.
That is acceptable for a LAN-party MVP, but it should be explicitly documented. That is acceptable for a LAN-party MVP, but it should be explicitly documented.
@@ -246,7 +274,7 @@ relay only sees room id, peer id, size, timing
Do not retrofit this into a bad packet format later. Reserve the shape now. Do not retrofit this into a bad packet format later. Reserve the shape now.
## Switching model ### Switching model
Treat the whole thing as a tiny user-space Ethernet switch. Treat the whole thing as a tiny user-space Ethernet switch.
@@ -285,7 +313,7 @@ LAN frames go to matching remote client or all clients if broadcast/multicast
But MAC learning belongs in the real design. But MAC learning belongs in the real design.
## MAC identity ### MAC identity
Each Windows client needs a unique locally administered unicast MAC. Each Windows client needs a unique locally administered unicast MAC.
@@ -295,7 +323,8 @@ Example range:
02:xx:xx:xx:xx:xx 02:xx:xx:xx:xx:xx
``` ```
Generate once per install or per profile. Store it. Configure TAP with it. Announce it during join. Generate once per install or per profile. Store it. Configure TAP with it.
Announce it during join.
Relay must reject: Relay must reject:
@@ -315,11 +344,13 @@ maybe 2 later for weird cases
This is your responsibility, not the users. This is your responsibility, not the users.
## Linux gateway CAM-table refresh ### Linux gateway CAM-table refresh
The physical LAN switch must learn that remote clients MACs live behind the gateway port. The physical LAN switch must learn that remote clients MACs live behind the
gateway port.
That happens when the gateway injects frames onto the LAN using the remote clients source MAC. That happens when the gateway injects frames onto the LAN using the remote
clients source MAC.
But switch CAM entries age out. So the gateway should periodically refresh them. But switch CAM entries age out. So the gateway should periodically refresh them.
@@ -330,7 +361,8 @@ for each connected remote MAC:
inject a tiny harmless Ethernet frame with that MAC as source inject a tiny harmless Ethernet frame with that MAC as source
``` ```
The exact frame can be decided during implementation, but the goal is simple: keep the LAN switch mapping the remote MAC to the gateways physical port. The exact frame can be decided during implementation, but the goal is simple:
keep the LAN switch mapping the remote MAC to the gateways physical port.
Phase 1 success criterion: Phase 1 success criterion:
@@ -340,9 +372,10 @@ remote client MAC appears in the LAN switch MAC table on the gateway port
If that is false, the L2 illusion is broken. If that is false, the L2 illusion is broken.
## Safety filters ### Safety filters
Remote clients must not be allowed to spray arbitrary L2 control-plane junk onto the real LAN. Remote clients must not be allowed to spray arbitrary L2 control-plane junk onto
the real LAN.
Drop remote → LAN unconditionally: Drop remote → LAN unconditionally:
@@ -368,7 +401,8 @@ Also drop LAN → remote:
No remote Windows client needs to see switch/control-plane traffic. No remote Windows client needs to see switch/control-plane traffic.
EAPOL is especially important: remote clients should never be able to interfere with 802.1X or port authentication behavior on the physical switch. EAPOL is especially important: remote clients should never be able to interfere
with 802.1X or port authentication behavior on the physical switch.
Add rate limits: Add rate limits:
@@ -379,11 +413,12 @@ Add rate limits:
- malformed packet disconnect threshold - malformed packet disconnect threshold
``` ```
## Windows routing / metric handling ### Windows routing / metric handling
The TAP adapter may receive DHCP from the party LAN. That is good. The TAP adapter may receive DHCP from the party LAN. That is good.
But if DHCP gives it a default gateway, Windows might try to route the relay connection through the tunnel itself. That would break the tunnel. But if DHCP gives it a default gateway, Windows might try to route the relay
connection through the tunnel itself. That would break the tunnel.
Client startup should: Client startup should:
@@ -396,7 +431,8 @@ Client startup should:
6. detect and neutralize TAP default-route takeover 6. detect and neutralize TAP default-route takeover
``` ```
The TAP should be preferred for the party LAN subnet, but it must not steal general internet traffic. The TAP should be preferred for the party LAN subnet, but it must not steal
general internet traffic.
Also strongly recommend uncommon LAN party subnets: Also strongly recommend uncommon LAN party subnets:
@@ -409,9 +445,10 @@ bad: 192.168.178.0/24
Duplicate subnet with a remote users home LAN will be painful. Duplicate subnet with a remote users home LAN will be painful.
## Relay placement / latency ### Relay placement / latency
Relay-as-data-path is the right MVP. It makes the product work through NAT immediately. Relay-as-data-path is the right MVP. It makes the product work through NAT
immediately.
But latency becomes: But latency becomes:
@@ -421,7 +458,10 @@ client → relay → gateway
So relay location matters. So relay location matters.
For Europe/Germany-focused usage, put the relay near the expected players and LAN site, e.g. Frankfurt/Nuremberg/Amsterdam depending on hosting. Later, add direct QUIC path attempts with relay fallback, but do not block MVP on NAT traversal. For Europe/Germany-focused usage, put the relay near the expected players and
LAN site, e.g. Frankfurt/Nuremberg/Amsterdam depending on hosting. Later, add
direct QUIC path attempts with relay fallback, but do not block MVP on NAT
traversal.
Design the room protocol so future modes are possible: Design the room protocol so future modes are possible:
@@ -431,7 +471,7 @@ mode = direct-p2p
mode = direct-failed-relay-fallback mode = direct-failed-relay-fallback
``` ```
## Logging / diagnostics ### Logging / diagnostics
Phase 1 should log heavily. Phase 1 should log heavily.
@@ -473,9 +513,9 @@ Broadcast traffic flowing
Warning: TAP received default route, adjusted metric Warning: TAP received default route, adjusted metric
``` ```
## Phase plan ### Phase plan
### Phase 1: prove the illusion #### Phase 1: prove the illusion
Manual, ugly, real. Manual, ugly, real.
@@ -500,7 +540,7 @@ Success criteria:
- one real LAN game discovers or joins a LAN server - one real LAN game discovers or joins a LAN server
``` ```
### Phase 2: multi-client #### Phase 2: multi-client
```text ```text
- multiple Windows clients - multiple Windows clients
@@ -512,7 +552,7 @@ Success criteria:
- reconnect handling - reconnect handling
``` ```
### Phase 3: safety and correctness #### Phase 3: safety and correctness
```text ```text
- L2 control-plane filters - L2 control-plane filters
@@ -524,7 +564,7 @@ Success criteria:
- better malformed-frame handling - better malformed-frame handling
``` ```
### Phase 4: product UX #### Phase 4: product UX
```text ```text
- Windows installer - Windows installer
@@ -536,9 +576,11 @@ Success criteria:
- logs export button - logs export button
``` ```
Driver signing and TAP bundling must be validated early. `tap-windows6` is the right kind of driver, but Windows driver installation/signing is a product risk, not something to handwave. ([GitHub][1]) Driver signing and TAP bundling must be validated early. `tap-windows6` is the
right kind of driver, but Windows driver installation/signing is a product risk,
not something to handwave. ([GitHub][1])
### Phase 5: better security and latency #### Phase 5: better security and latency
```text ```text
- invite tokens / auth - invite tokens / auth
@@ -549,7 +591,7 @@ Driver signing and TAP bundling must be validated early. `tap-windows6` is the r
- regional relay selection - regional relay selection
``` ```
## Explicit non-goals ### Explicit non-goals
For MVP, do not build: For MVP, do not build:
@@ -565,14 +607,19 @@ For MVP, do not build:
- full internet VPN mode - full internet VPN mode
``` ```
## One-sentence version ### One-sentence version
Build a **Rust Windows TAP client + public QUIC relay + Linux AF_PACKET gateway** that carries one small-MTU Ethernet frame per QUIC datagram, gives each remote player a unique virtual MAC on the real LAN, filters dangerous L2 control traffic, and keeps the physical LAN gateway as the only machine touching the real LAN. Build a **Rust Windows TAP client + public QUIC relay + Linux AF_PACKET
gateway** that carries one small-MTU Ethernet frame per QUIC datagram, gives
each remote player a unique virtual MAC on the real LAN, filters dangerous L2
control traffic, and keeps the physical LAN gateway as the only machine touching
the real LAN.
[1]: https://github.com/OpenVPN/tap-windows6?utm_source=chatgpt.com "OpenVPN/tap-windows6: Windows TAP driver (NDIS 6)" [1]: https://github.com/OpenVPN/tap-windows6
[2]: https://man7.org/linux/man-pages/man7/packet.7.html?utm_source=chatgpt.com "packet(7) - Linux manual page" [2]: https://man7.org/linux/man-pages/man7/packet.7.html
[3]: https://man7.org/linux/man-pages/man7/capabilities.7.html?utm_source=chatgpt.com "capabilities(7) - Linux manual page" [3]: https://man7.org/linux/man-pages/man7/capabilities.7.html
[4]: https://datatracker.ietf.org/doc/html/rfc9221?utm_source=chatgpt.com "RFC 9221 - An Unreliable Datagram Extension to QUIC" [4]: https://datatracker.ietf.org/doc/html/rfc9221
[5]: https://docs.rs/quinn/latest/quinn/struct.Connection.html?utm_source=chatgpt.com "Connection in quinn - Rust" [5]: https://docs.rs/quinn/latest/quinn/struct.Connection.html
I want a mono-repo, Rust code, crates into a "crates" folder, one cargo workspace. I want a mono-repo, Rust code, crates into a "crates" folder, one cargo
workspace.
+101 -109
View File
@@ -82,7 +82,8 @@ Windows route-table boundary:
- unicast IP address snapshots for TAP diagnostics - unicast IP address snapshots for TAP diagnostics
- scoped host-route pinning for the relay IP on the pre-TAP interface - scoped host-route pinning for the relay IP on the pre-TAP interface
- host-route pin matching for relay-route verification after TAP activation - host-route pin matching for relay-route verification after TAP activation
- reuse of an already-existing matching relay host route without deleting it on exit - reuse of an already-existing matching relay host route without deleting it on
exit
- non-Windows builds return a clear unsupported-platform error - non-Windows builds return a clear unsupported-platform error
### `lanparty-client-tap` ### `lanparty-client-tap`
@@ -109,9 +110,9 @@ Public relay binary and relay-owned room state:
- per-peer egress budget checks against the negotiated datagram size - per-peer egress budget checks against the negotiated datagram size
- reliable `PeerJoined`/`PeerLeft` notifications plus gateway identity in - reliable `PeerJoined`/`PeerLeft` notifications plus gateway identity in
welcome messages welcome messages
- L2 safety filters for invalid-source, jumbo, switch-control, remote VLAN - L2 safety filters for invalid-source, jumbo, switch-control, remote VLAN tags,
tags, remote IPv6 fragments, IPv4/IPv6 DHCP-server, and IPv6-RA frames, remote IPv6 fragments, IPv4/IPv6 DHCP-server, and IPv6-RA frames, including
including frames behind ordinary IPv6 extension headers frames behind ordinary IPv6 extension headers
- client broadcast/multicast, unknown-unicast, and total bandwidth limiting - client broadcast/multicast, unknown-unicast, and total bandwidth limiting
- malformed peer datagram disconnect threshold - malformed peer datagram disconnect threshold
- peer stats control events retained for relay diagnostics - peer stats control events retained for relay diagnostics
@@ -129,9 +130,9 @@ cargo build --release -p lanparty-relay -p lanparty-gateway
git diff --check git diff --check
``` ```
These checks cover the local Rust code and the real client/relay/gateway These checks cover the local Rust code and the real client/relay/gateway session
session paths that can run without Windows TAP or LAN hardware. For the Windows paths that can run without Windows TAP or LAN hardware. For the Windows client
client build and the manual MVP end-to-end proof, see [TESTING.md](TESTING.md). build and the manual MVP end-to-end proof, see [TESTING.md](TESTING.md).
## Relay ## Relay
@@ -147,24 +148,24 @@ self-signed development certificate; `--dev-cert-der-out` writes that
certificate so the gateway and client can pin it in development. Production certificate so the gateway and client can pin it in development. Production
certificate handling remains future work. Ethernet forwarding decisions are certificate handling remains future work. Ethernet forwarding decisions are
logged with room, peer, MAC, ethertype, action, drop reason, and target count. logged with room, peer, MAC, ethertype, action, drop reason, and target count.
Safety-policy rejects use the `filtered` action so they are distinguishable Safety-policy rejects use the `filtered` action so they are distinguishable from
from malformed/unknown-destination drops and rate limits. malformed/unknown-destination drops and rate limits. Malformed peer datagrams
Malformed peer datagrams log their per-peer count before the relay disconnects log their per-peer count before the relay disconnects peers that cross the
peers that cross the malformed-datagram threshold. malformed-datagram threshold. Relay egress skips caused by a target peer's
Relay egress skips caused by a target peer's smaller datagram budget are logged smaller datagram budget are logged with the ingress peer, target peer, encoded
with the ingress peer, target peer, encoded length, and target budget. length, and target budget. Ingress datagrams larger than the sending peer's
Ingress datagrams larger than the sending peer's negotiated datagram budget are negotiated datagram budget are dropped before decode/forwarding and logged with
dropped before decode/forwarding and logged with `reason=datagram_budget`. `reason=datagram_budget`. Unknown unicast from a client is forwarded only to the
Unknown unicast from a client is forwarded only to the gateway port; unknown gateway port; unknown unicast from the gateway is dropped instead of flooded to
unicast from the gateway is dropped instead of flooded to every remote client. every remote client. When a peer joins or leaves, the relay sends a reliable
When a peer joins or leaves, the relay sends a reliable lifecycle control event lifecycle control event to peers that are still present in the room. Newly
to peers that are still present in the room. Newly joined peers also receive joined peers also receive `PeerJoined` events for peers that were already
`PeerJoined` events for peers that were already present, and catch-up delivery present, and catch-up delivery is part of the accepted handshake rather than a
is part of the accepted handshake rather than a best-effort follow-up. When a best-effort follow-up. When a client joins, the relay notifies existing peers
client joins, the relay notifies existing peers before the client receives its before the client receives its welcome, so gateways can seed client MAC state
welcome, so gateways can seed client MAC state before that client starts before that client starts sending frames. When a gateway joins, the relay gives
sending frames. When a gateway joins, the relay gives the gateway the current the gateway the current client list before notifying clients that the gateway is
client list before notifying clients that the gateway is available. available.
### MVP Trust Model ### MVP Trust Model
@@ -195,41 +196,38 @@ and completes the control-stream hello/welcome handshake. That startup order
keeps an invalid, wireless, or unplugged interface from briefly advertising a keeps an invalid, wireless, or unplugged interface from briefly advertising a
gateway that cannot bridge. Once both sides are ready, it bridges Ethernet gateway that cannot bridge. Once both sides are ready, it bridges Ethernet
frames between the relay and wired LAN until shutdown. It captures whole LAN frames between the relay and wired LAN until shutdown. It captures whole LAN
frames up to the frames up to the overlay payload-length ceiling before deciding whether they fit
overlay payload-length ceiling before deciding whether they fit the tunnel. It the tunnel. It never fragments Ethernet frames; LAN frames with invalid source
never fragments Ethernet frames; LAN frames with invalid source MACs, L2 MACs, L2 control-plane traffic, jumbo frames, frames above the negotiated TAP
control-plane traffic, jumbo frames, frames above the negotiated TAP MTU, or MTU, or encoded datagrams exceeding the negotiated QUIC budget are counted,
encoded datagrams exceeding the negotiated QUIC budget are counted, dropped, dropped, and logged locally instead of stopping the bridge or consuming relay
and logged locally instead of stopping the bridge or consuming relay bandwidth. bandwidth. Remote frames received from the relay are safety-checked again before
Remote frames received from LAN injection and must use the announced virtual MAC for their source peer, so
the relay are safety-checked again before LAN injection and must use the invalid-source, forged-source, L2 control-plane, remote VLAN, DHCP-server, IPv6
announced virtual MAC for their source peer, so invalid-source, forged-source, Router Advertisement, IPv6 fragment, jumbo, and over-TAP-MTU frames cannot cross
L2 control-plane, remote VLAN, DHCP-server, IPv6 Router Advertisement, IPv6 the gateway's final physical-LAN boundary even if they reached the gateway over
fragment, jumbo, and over-TAP-MTU frames cannot cross the gateway's final QUIC. `--relay` accepts a DNS name or socket address; bare hosts default to
physical-LAN boundary even if they reached the gateway over QUIC. UDP/443. The gateway rejects Linux interfaces that sysfs identifies as Wi-Fi,
`--relay` accepts a DNS name or socket address; bare hosts default to UDP/443. and rejects wired interfaces whose sysfs carrier state reports no link; managed
The gateway rejects Linux interfaces that sysfs identifies as Wi-Fi, and rejects wireless NICs are not supported for the physical LAN bridge. It tracks
wired interfaces whose sysfs carrier state reports no link; managed wireless remote-client MACs from relay lifecycle events and periodically emits small CAM
NICs are not supported for the physical LAN bridge. refresh frames, logged with `reason=periodic`, so the physical switch keeps
It tracks remote-client MACs from relay lifecycle events and periodically emits those MACs associated with the gateway port. A newly observed client also
small CAM refresh frames, logged with `reason=periodic`, so the physical triggers an immediate CAM refresh frame logged with `reason=peer_joined` instead
switch keeps those MACs associated with the gateway port. A newly observed of waiting for the first periodic refresh tick. When control events and frame
client also triggers an immediate CAM refresh frame logged with work are both ready, the bridge handles the lifecycle event first so first
`reason=peer_joined` instead of waiting for the first periodic refresh tick. packets after a client joins use the freshest remote-MAC state available
When control events and frame work are both ready, the bridge handles the locally. Gateway frame logs include direction, peer id when present, MACs,
lifecycle event first so first packets after a client joins use the freshest ethertype/length, frame length, action, and drop reason. The gateway also tracks
remote-MAC state available locally. Gateway frame/datagram counters and periodically sends stats snapshots to the relay.
frame logs include direction, peer id when present, MACs, ethertype/length, Malformed or runt LAN frames are counted and logged as dropped instead of
frame length, action, and drop reason. The gateway also tracks frame/datagram disappearing before accounting. It drops unrelated LAN unicast locally once the
counters and periodically sends stats snapshots to the relay. Malformed or runt destination is known not to be a connected remote client, so busy LAN traffic is
LAN frames are counted and logged as dropped instead of disappearing before not sent to the public relay just to be discarded there. Relay lifecycle events
accounting. It drops unrelated LAN unicast locally once the destination is known seed and retire remote-client MACs for CAM refresh and LAN-destination filtering
not to be a connected remote client, so busy LAN traffic is not sent to the even before that client sends traffic. On shutdown, the gateway sends a
public relay just to be discarded there. Relay lifecycle events seed and retire best-effort disconnect control message before closing QUIC so the relay can
remote-client MACs for CAM refresh and LAN-destination filtering even before report the intended reason.
that client sends traffic. On shutdown, the gateway sends a best-effort
disconnect control message before closing QUIC so the relay can report the
intended reason.
## Windows Client ## Windows Client
@@ -246,24 +244,21 @@ path depends on TAP-Windows6 and Windows route protection. Non-Windows builds
are useful for type checking, but they fail before tunnel setup instead of are useful for type checking, but they fail before tunnel setup instead of
joining a room without a TAP adapter. On Windows, the binary connects to the joining a room without a TAP adapter. On Windows, the binary connects to the
relay as `role = client` with a generated locally administered virtual MAC relay as `role = client` with a generated locally administered virtual MAC
persisted in persisted in `lanparty-client-identity.json`. Before resolving or connecting to
`lanparty-client-identity.json`. Before resolving or connecting to the relay, the relay, it writes the generated tunnel MAC to the selected TAP driver's
it writes the generated tunnel MAC to the selected TAP driver's
`NetworkAddress` registry setting and marks TAP media disconnected. That clears `NetworkAddress` registry setting and marks TAP media disconnected. That clears
stale connected state from a previous crashed run without letting the TAP stale connected state from a previous crashed run without letting the TAP
adapter influence relay DNS or route selection. The client then resolves the adapter influence relay DNS or route selection. The client then resolves the
relay endpoint, pins a host route for the resolved relay IP on the current relay endpoint, pins a host route for the resolved relay IP on the current
pre-TAP interface, verifies that Windows is using that host route, completes pre-TAP interface, verifies that Windows is using that host route, completes the
the control-stream hello/welcome handshake, verifies the host route again after control-stream hello/welcome handshake, verifies the host route again after TAP
TAP activation, and bridges Ethernet frames between the relay and the activation, and bridges Ethernet frames between the relay and the TAP-Windows6
TAP-Windows6 adapter until shutdown. `--relay` accepts a DNS name or socket adapter until shutdown. `--relay` accepts a DNS name or socket address; bare
address; bare hosts default to UDP/443. hosts default to UDP/443. TAP frames whose source MAC does not match that
TAP frames whose source MAC does not match that generated tunnel MAC are generated tunnel MAC are dropped locally before they can consume relay
dropped locally before they can consume relay bandwidth; the relay still bandwidth; the relay still enforces the same source-MAC rule. If the exact relay
enforces the same source-MAC rule. host route already exists, the client uses it and leaves it alone on exit. The
If the exact relay host route already exists, the client uses it and leaves it startup status reports whether the relay already has a LAN gateway for the room.
alone on exit. The startup status reports whether the relay already has a LAN
gateway for the room.
`--virtual-mac` can still override the stored identity for manual testing. On `--virtual-mac` can still override the stored identity for manual testing. On
Windows it sets the TAP IP interface MTU to the relay-selected MTU, marks the Windows it sets the TAP IP interface MTU to the relay-selected MTU, marks the
TAP media connected for the scoped client run, and reports the driver MAC/MTU TAP media connected for the scoped client run, and reports the driver MAC/MTU
@@ -271,40 +266,37 @@ before forwarding frames, along with the TAP interface index/LUID. The client
applies a scoped TAP interface metric and disables TAP default routes while it applies a scoped TAP interface metric and disables TAP default routes while it
runs, periodically rechecks that the relay route remains pinned, then restores runs, periodically rechecks that the relay route remains pinned, then restores
the previous route policy and TAP media status on exit. Startup prints a warning the previous route policy and TAP media status on exit. Startup prints a warning
when TAP default routes were enabled when TAP default routes were enabled before the scoped protection was applied.
before the scoped protection was applied. Startup still fails before bridging Startup still fails before bridging if the driver-reported MAC does not match
if the driver-reported MAC does not match the tunnel identity, because an the tunnel identity, because an already-initialized Windows TAP adapter may need
already-initialized Windows TAP adapter may need to be disabled/enabled or to be disabled/enabled or reinstalled before it reloads the configured
reinstalled before it reloads the configured `NetworkAddress`. `NetworkAddress`. If exactly one TAP-Windows6 adapter is installed, the client
If exactly one TAP-Windows6 adapter is installed, the client opens it opens it automatically. If multiple TAP-Windows6 adapters are installed, startup
automatically. If multiple TAP-Windows6 adapters are installed, startup fails fails until `--tap-instance-id` selects the intended adapter by NetCfgInstanceId
until `--tap-instance-id` selects the intended adapter by NetCfgInstanceId / / InterfaceGuid. `--list-tap-adapters` prints the TAP adapter ids and exits
InterfaceGuid. `--list-tap-adapters` prints the TAP adapter ids and exits without connecting. It prints and reports client diagnostics snapshots with
without connecting. relay reachability, LAN-gateway presence, route-pinning, QUIC datagram budget,
It prints and reports client diagnostics snapshots with relay reachability, relay RTT, TAP status/IP, broadcast frame flow, frame/datagram counters, and
LAN-gateway presence, route-pinning, QUIC datagram budget, relay RTT, TAP drops. The periodic diagnostics refresh the TAP unicast IP so DHCP results that
status/IP, broadcast frame flow, frame/datagram counters, and drops. The arrive after bridging starts become visible in later status lines, preferring a
periodic diagnostics refresh the TAP unicast IP so DHCP results that arrive
after bridging starts become visible in later status lines, preferring a
non-link-local IPv4 address when Windows reports several TAP addresses. Each non-link-local IPv4 address when Windows reports several TAP addresses. Each
snapshot also emits short user-facing lines such as relay/gateway connection status, snapshot also emits short user-facing lines such as relay/gateway connection
relay-route and TAP readiness warnings, DHCP address presence, relay RTT, and status, relay-route and TAP readiness warnings, DHCP address presence, relay
broadcast-flow confirmation. One-way broadcast diagnostics distinguish frames RTT, and broadcast-flow confirmation. One-way broadcast diagnostics distinguish
sent toward the LAN from broadcast frames received back from the LAN. Malformed frames frames sent toward the LAN from broadcast frames received back from the LAN.
read from TAP, invalid or unauthorized source-MAC frames, L2 control-plane Malformed frames read from TAP, invalid or unauthorized source-MAC frames, L2
traffic, remote VLAN tags, DHCP server replies, IPv6 Router Advertisements, IPv6 control-plane traffic, remote VLAN tags, DHCP server replies, IPv6 Router
fragments, jumbo frames, frames above the negotiated TAP MTU, and TAP frames Advertisements, IPv6 fragments, jumbo frames, frames above the negotiated TAP
whose encoded datagrams exceed the negotiated QUIC budget are counted and MTU, and TAP frames whose encoded datagrams exceed the negotiated QUIC budget
dropped before relay send without stopping the bridge. Relayed LAN frames are are counted and dropped before relay send without stopping the bridge. Relayed
also safety-checked before TAP writes, so switch-control traffic, LAN frames are also safety-checked before TAP writes, so switch-control traffic,
invalid-source frames, jumbo frames, and over-TAP-MTU frames stay out of the invalid-source frames, jumbo frames, and over-TAP-MTU frames stay out of the
Windows adapter even if they reached the client over QUIC. Windows adapter even if they reached the client over QUIC. Misdirected unicast
Misdirected unicast frames not addressed to the client's virtual MAC are also frames not addressed to the client's virtual MAC are also counted, skipped, and
counted, skipped, and logged with the drop reason; accepted TAP-to-relay and logged with the drop reason; accepted TAP-to-relay and relay-to-TAP frames are
relay-to-TAP frames are logged with direction, peer id, MACs, ethertype/length, logged with direction, peer id, MACs, ethertype/length, frame length, action,
frame length, action, and drop reason. TAP device read/write errors still stop and drop reason. TAP device read/write errors still stop the bridge. Relay
the bridge. lifecycle events are logged as they arrive, including gateway joins and peer
Relay lifecycle events are logged as they arrive, including gateway joins and leaves. The client remembers peer identities from join and catch-up events and
peer leaves. The client remembers peer identities from join and catch-up events from the initial welcome, so later leave logs can identify a disconnected LAN
and from the initial welcome, so later leave logs can identify a disconnected gateway or client MAC when that peer was known.
LAN gateway or client MAC when that peer was known.
+24 -25
View File
@@ -58,8 +58,8 @@ Windows TAP IPv4:
- Gateway: Linux machine plugged into the LAN party switch with wired Ethernet. - Gateway: Linux machine plugged into the LAN party switch with wired Ethernet.
- Client: Windows 11 machine with TAP-Windows6 installed. - Client: Windows 11 machine with TAP-Windows6 installed.
Use the same room code everywhere, for example `ROOM1`. Use the same room code everywhere, for example `ROOM1`. Start order is relay
Start order is relay first, gateway second, Windows client last. first, gateway second, Windows client last.
## Log Capture ## Log Capture
@@ -153,8 +153,8 @@ Linux: ./target/release/lanparty-gateway
Windows: .\target\release\lanparty-client-win.exe Windows: .\target\release\lanparty-client-win.exe
``` ```
The Windows client must run elevated because it opens TAP and edits routes. The Windows client must run elevated because it opens TAP and edits routes. The
The gateway usually needs root because it opens an AF_PACKET raw socket. gateway usually needs root because it opens an AF_PACKET raw socket.
## Start The Relay ## Start The Relay
@@ -196,8 +196,8 @@ sudo ./target/release/lanparty-gateway \
``` ```
Use the real wired LAN interface name for `--interface`. `--iface` is accepted Use the real wired LAN interface name for `--interface`. `--iface` is accepted
as a shorter alias. Do not use Wi-Fi. The gateway fails before joining the as a shorter alias. Do not use Wi-Fi. The gateway fails before joining the relay
relay if sysfs reports no Ethernet carrier. if sysfs reports no Ethernet carrier.
Expected gateway output: Expected gateway output:
@@ -245,7 +245,8 @@ one explicitly:
Expected client output: Expected client output:
```text ```text
prepared TAP adapter ... MAC ... configured and media disconnected before relay connect prepared TAP adapter ... MAC ... configured and media disconnected before relay
connect
relay route pinned before TAP ... relay route pinned before TAP ...
relay route verified before TAP activation ... relay route verified before TAP activation ...
lanparty-client-win connecting virtual MAC ... to relay ... room ROOM1 lanparty-client-win connecting virtual MAC ... to relay ... room ROOM1
@@ -261,11 +262,10 @@ relay event: LAN gateway connected as peer ...
The route pin line ends with `(created)` or `(already existed)`. Either is OK. The route pin line ends with `(created)` or `(already existed)`. Either is OK.
`already existed` usually means a matching relay host route was already present, `already existed` usually means a matching relay host route was already present,
for example after a previous crashed test run. for example after a previous crashed test run. You may also see TAP IPv4/IPv6
You may also see TAP IPv4/IPv6 MTU, metric, and default-route protection lines MTU, metric, and default-route protection lines between the connect and TAP-open
between the connect and TAP-open lines. Those are expected. lines. Those are expected. The lifecycle event may appear after the bridge
The lifecycle event may appear after the bridge starts because event logging starts because event logging begins once TAP and route protection are ready.
begins once TAP and route protection are ready.
The first diagnostics line may show `IP unknown`. After DHCP succeeds, a later The first diagnostics line may show `IP unknown`. After DHCP succeeds, a later
line should show: line should show:
@@ -274,8 +274,8 @@ line should show:
DHCP received: 10.x.x.x DHCP received: 10.x.x.x
``` ```
If Windows reports both a `169.254.x.x` TAP address and a real LAN IPv4 If Windows reports both a `169.254.x.x` TAP address and a real LAN IPv4 address,
address, the client diagnostics should prefer the real LAN address. the client diagnostics should prefer the real LAN address.
## Verify The Tunnel ## Verify The Tunnel
@@ -395,10 +395,9 @@ drop_reason=RateLimit
On gateway `LanToRemote` logs, `UnknownDestination` usually means the gateway On gateway `LanToRemote` logs, `UnknownDestination` usually means the gateway
captured unrelated LAN unicast and dropped it locally instead of sending it to captured unrelated LAN unicast and dropped it locally instead of sending it to
the relay. the relay. `TapMtuExceeded` means a host emitted an Ethernet frame larger than
`TapMtuExceeded` means a host emitted an Ethernet frame larger than the the negotiated tunnel MTU; occasional drops can happen while testing software
negotiated tunnel MTU; occasional drops can happen while testing software that that does not honor the smaller adapter MTU yet.
does not honor the smaller adapter MTU yet.
Drops that should be investigated if they dominate: Drops that should be investigated if they dominate:
@@ -414,8 +413,8 @@ drop_reason=Ipv6Fragment
``` ```
On gateway `RemoteToLan` logs, `UnauthorizedSourceMac` means the relayed peer id On gateway `RemoteToLan` logs, `UnauthorizedSourceMac` means the relayed peer id
did not match the client MAC announced by lifecycle events. If it repeats, did not match the client MAC announced by lifecycle events. If it repeats, check
check relay lifecycle logs and duplicate-MAC rejection first. relay lifecycle logs and duplicate-MAC rejection first.
## Troubleshooting ## Troubleshooting
@@ -454,11 +453,11 @@ If ping fails but DHCP worked, check Windows firewall, the target LAN host
firewall, and whether the LAN subnet conflicts with the client's home LAN. firewall, and whether the LAN subnet conflicts with the client's home LAN.
Uncommon LAN subnets such as `10.73.42.0/24` are safer than `192.168.0.0/24`. Uncommon LAN subnets such as `10.73.42.0/24` are safer than `192.168.0.0/24`.
If switch MAC learning does not show the Windows client MAC on the gateway If switch MAC learning does not show the Windows client MAC on the gateway port,
port, look for `gateway CAM refresh ... reason=peer_joined` immediately after look for `gateway CAM refresh ... reason=peer_joined` immediately after join and
join and `gateway CAM refresh ... reason=periodic` about once per minute after `gateway CAM refresh ... reason=periodic` about once per minute after that. If
that. If those lines are present but the switch still does not learn it, check those lines are present but the switch still does not learn it, check the
the selected gateway interface and switch port first. selected gateway interface and switch port first.
## Cleanup ## Cleanup
+19 -5
View File
@@ -21,15 +21,29 @@ use std::{
use anyhow::{Context, Result, bail}; use anyhow::{Context, Result, bail};
use bytes::Bytes; use bytes::Bytes;
use lanparty_ctrl::{ use lanparty_ctrl::{
CONTROL_LENGTH_PREFIX_LEN, ControlMessage, DisconnectReason, EndpointHello, CONTROL_LENGTH_PREFIX_LEN,
MAX_CONTROL_MESSAGE_LEN, RELAY_ALPN, RoomCode, ServerWelcome, decode_control_frame, ControlMessage,
DisconnectReason,
EndpointHello,
MAX_CONTROL_MESSAGE_LEN,
RELAY_ALPN,
RoomCode,
ServerWelcome,
decode_control_frame,
encode_control_message, encode_control_message,
}; };
use lanparty_obs::{DropReason, QuicDiagnostics, TunnelStats}; use lanparty_obs::{DropReason, QuicDiagnostics, TunnelStats};
use lanparty_proto::{ use lanparty_proto::{
EthernetFrame, FrameType, MacAddr, OVERLAY_FLAGS_NONE, decode_datagram, encode_datagram, EthernetFrame,
ethernet_frame_exceeds_tap_mtu, gateway_lan_safety_drop_reason, FrameType,
remote_client_safety_drop_reason, validate_datagram_budget, MacAddr,
OVERLAY_FLAGS_NONE,
decode_datagram,
encode_datagram,
ethernet_frame_exceeds_tap_mtu,
gateway_lan_safety_drop_reason,
remote_client_safety_drop_reason,
validate_datagram_budget,
}; };
use quinn::{ClientConfig, Endpoint, crypto::rustls::QuicClientConfig}; use quinn::{ClientConfig, Endpoint, crypto::rustls::QuicClientConfig};
use rustls::pki_types::CertificateDer; use rustls::pki_types::CertificateDer;
+10 -7
View File
@@ -6,10 +6,13 @@ edition.workspace = true
[dependencies] [dependencies]
anyhow.workspace = true anyhow.workspace = true
[target.'cfg(windows)'.dependencies] [target."cfg(windows)".dependencies]
windows-sys = { workspace = true, features = [ windows-sys = {
"Win32_Foundation", workspace = true,
"Win32_NetworkManagement_IpHelper", features = [
"Win32_NetworkManagement_Ndis", "Win32_Foundation",
"Win32_Networking_WinSock", "Win32_NetworkManagement_IpHelper",
] } "Win32_NetworkManagement_Ndis",
"Win32_Networking_WinSock",
]
}
+9 -3
View File
@@ -286,9 +286,15 @@ mod windows;
pub use windows::{PinnedRelayRoute, best_route_to, interface_identity_from_guid, pin_relay_route}; pub use windows::{PinnedRelayRoute, best_route_to, interface_identity_from_guid, pin_relay_route};
#[cfg(windows)] #[cfg(windows)]
pub use windows::{ pub use windows::{
ScopedDefaultRoutes, ScopedInterfaceMetric, ScopedInterfaceMtu, interface_metric, ScopedDefaultRoutes,
interface_mtu, interface_unicast_addresses, set_scoped_default_routes_disabled, ScopedInterfaceMetric,
set_scoped_interface_metric, set_scoped_interface_mtu, ScopedInterfaceMtu,
interface_metric,
interface_mtu,
interface_unicast_addresses,
set_scoped_default_routes_disabled,
set_scoped_interface_metric,
set_scoped_interface_mtu,
}; };
#[cfg(not(windows))] #[cfg(not(windows))]
+46 -18
View File
@@ -1,34 +1,62 @@
use std::{ use std::{
fmt, io, fmt,
io,
net::{IpAddr, Ipv4Addr, Ipv6Addr}, net::{IpAddr, Ipv4Addr, Ipv6Addr},
ptr::{null, null_mut}, ptr::{null, null_mut},
slice, slice,
}; };
use anyhow::{Context, Result, bail}; use anyhow::{Context, Result, bail};
use windows_sys::Win32::{ use windows_sys::{
Foundation::{ERROR_OBJECT_ALREADY_EXISTS, ERROR_SUCCESS}, Win32::{
NetworkManagement::{ Foundation::{ERROR_OBJECT_ALREADY_EXISTS, ERROR_SUCCESS},
IpHelper::{ NetworkManagement::{
ConvertInterfaceGuidToLuid, ConvertInterfaceLuidToIndex, CreateIpForwardEntry2, IpHelper::{
DeleteIpForwardEntry2, FreeMibTable, GetBestRoute2, GetIpInterfaceEntry, ConvertInterfaceGuidToLuid,
GetUnicastIpAddressTable, IP_ADDRESS_PREFIX, InitializeIpForwardEntry, ConvertInterfaceLuidToIndex,
InitializeIpInterfaceEntry, MIB_IPFORWARD_ROW2, MIB_IPINTERFACE_ROW, CreateIpForwardEntry2,
MIB_UNICASTIPADDRESS_ROW, MIB_UNICASTIPADDRESS_TABLE, SetIpInterfaceEntry, DeleteIpForwardEntry2,
FreeMibTable,
GetBestRoute2,
GetIpInterfaceEntry,
GetUnicastIpAddressTable,
IP_ADDRESS_PREFIX,
InitializeIpForwardEntry,
InitializeIpInterfaceEntry,
MIB_IPFORWARD_ROW2,
MIB_IPINTERFACE_ROW,
MIB_UNICASTIPADDRESS_ROW,
MIB_UNICASTIPADDRESS_TABLE,
SetIpInterfaceEntry,
},
Ndis::NET_LUID_LH,
},
Networking::WinSock::{
AF_INET,
AF_INET6,
AF_UNSPEC,
IN_ADDR,
IN_ADDR_0,
IN6_ADDR,
IN6_ADDR_0,
RouteProtocolNetMgmt,
SOCKADDR_IN,
SOCKADDR_IN6,
SOCKADDR_IN6_0,
SOCKADDR_INET,
}, },
Ndis::NET_LUID_LH,
},
Networking::WinSock::{
AF_INET, AF_INET6, AF_UNSPEC, IN_ADDR, IN_ADDR_0, IN6_ADDR, IN6_ADDR_0,
RouteProtocolNetMgmt, SOCKADDR_IN, SOCKADDR_IN6, SOCKADDR_IN6_0, SOCKADDR_INET,
}, },
core::GUID,
}; };
use windows_sys::core::GUID;
use crate::{ use crate::{
InterfaceMetricSnapshot, InterfaceMtuSnapshot, InterfaceUnicastAddress, IpInterfaceFamily, InterfaceMetricSnapshot,
InterfaceMtuSnapshot,
InterfaceUnicastAddress,
IpInterfaceFamily,
NetworkInterfaceIdentity,
RouteSnapshot,
}; };
use crate::{NetworkInterfaceIdentity, RouteSnapshot};
pub fn interface_identity_from_guid(interface_guid: &str) -> Result<NetworkInterfaceIdentity> { pub fn interface_identity_from_guid(interface_guid: &str) -> Result<NetworkInterfaceIdentity> {
let guid = parse_interface_guid(interface_guid)?; let guid = parse_interface_guid(interface_guid)?;
+11 -8
View File
@@ -7,11 +7,14 @@ edition.workspace = true
anyhow.workspace = true anyhow.workspace = true
lanparty-proto = { path = "../lanparty-proto" } lanparty-proto = { path = "../lanparty-proto" }
[target.'cfg(windows)'.dependencies] [target."cfg(windows)".dependencies]
windows-sys = { workspace = true, features = [ windows-sys = {
"Win32_Foundation", workspace = true,
"Win32_Security", features = [
"Win32_Storage_FileSystem", "Win32_Foundation",
"Win32_System_IO", "Win32_Security",
"Win32_System_Registry", "Win32_Storage_FileSystem",
] } "Win32_System_IO",
"Win32_System_Registry",
]
}
+34 -8
View File
@@ -8,25 +8,51 @@ use anyhow::{Context, Result, bail};
use lanparty_proto::MacAddr; use lanparty_proto::MacAddr;
use windows_sys::Win32::{ use windows_sys::Win32::{
Foundation::{ Foundation::{
CloseHandle, ERROR_FILE_NOT_FOUND, ERROR_MORE_DATA, ERROR_NO_MORE_ITEMS, ERROR_SUCCESS, CloseHandle,
GENERIC_READ, GENERIC_WRITE, HANDLE, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND,
ERROR_MORE_DATA,
ERROR_NO_MORE_ITEMS,
ERROR_SUCCESS,
GENERIC_READ,
GENERIC_WRITE,
HANDLE,
INVALID_HANDLE_VALUE,
}, },
Storage::FileSystem::{ Storage::FileSystem::{
CreateFileW, FILE_ATTRIBUTE_SYSTEM, FILE_SHARE_READ, FILE_SHARE_WRITE, OPEN_EXISTING, CreateFileW,
ReadFile, WriteFile, FILE_ATTRIBUTE_SYSTEM,
FILE_SHARE_READ,
FILE_SHARE_WRITE,
OPEN_EXISTING,
ReadFile,
WriteFile,
}, },
System::{ System::{
IO::DeviceIoControl, IO::DeviceIoControl,
Registry::{ Registry::{
HKEY, HKEY_LOCAL_MACHINE, KEY_READ, KEY_SET_VALUE, REG_SZ, RegCloseKey, RegEnumKeyExW, HKEY,
RegOpenKeyExW, RegQueryValueExW, RegSetValueExW, HKEY_LOCAL_MACHINE,
KEY_READ,
KEY_SET_VALUE,
REG_SZ,
RegCloseKey,
RegEnumKeyExW,
RegOpenKeyExW,
RegQueryValueExW,
RegSetValueExW,
}, },
}, },
}; };
use crate::{ use crate::{
TAP_ADAPTER_KEY, TapAdapterInfo, is_tap_component_id, tap_ioctl_get_mac, tap_ioctl_get_mtu, TAP_ADAPTER_KEY,
tap_ioctl_set_media_status, tap_network_address_value, validate_tap_ethernet_frame, TapAdapterInfo,
is_tap_component_id,
tap_ioctl_get_mac,
tap_ioctl_get_mtu,
tap_ioctl_set_media_status,
tap_network_address_value,
validate_tap_ethernet_frame,
}; };
#[derive(Debug)] #[derive(Debug)]
+1 -1
View File
@@ -14,5 +14,5 @@ lanparty-obs = { path = "../lanparty-obs" }
lanparty-proto = { path = "../lanparty-proto" } lanparty-proto = { path = "../lanparty-proto" }
tokio.workspace = true tokio.workspace = true
[target.'cfg(windows)'.dependencies] [target."cfg(windows)".dependencies]
lanparty-client-route = { path = "../lanparty-client-route" } lanparty-client-route = { path = "../lanparty-client-route" }
+14 -4
View File
@@ -12,14 +12,23 @@ use std::{sync::mpsc, thread, time::Duration};
use anyhow::{Context, Result, bail}; use anyhow::{Context, Result, bail};
use clap::Parser; use clap::Parser;
use lanparty_client_core::{ use lanparty_client_core::{
ClientIdentity, ClientIdentityStore, ClientSession, ClientSessionConfig, connect_client, ClientIdentity,
ClientIdentityStore,
ClientSession,
ClientSessionConfig,
connect_client,
}; };
#[cfg(windows)] #[cfg(windows)]
use lanparty_client_core::{ClientReceiveOutcome, ClientRelayIo}; use lanparty_client_core::{ClientReceiveOutcome, ClientRelayIo};
#[cfg(windows)] #[cfg(windows)]
use lanparty_client_route::{ use lanparty_client_route::{
IpInterfaceFamily, NetworkInterfaceIdentity, PinnedRelayRoute, RouteSnapshot, IpInterfaceFamily,
ScopedDefaultRoutes, ScopedInterfaceMetric, ScopedInterfaceMtu, NetworkInterfaceIdentity,
PinnedRelayRoute,
RouteSnapshot,
ScopedDefaultRoutes,
ScopedInterfaceMetric,
ScopedInterfaceMtu,
}; };
#[cfg(windows)] #[cfg(windows)]
use lanparty_client_tap::TapAdapter; use lanparty_client_tap::TapAdapter;
@@ -1263,11 +1272,12 @@ mod tests {
time::{SystemTime, UNIX_EPOCH}, time::{SystemTime, UNIX_EPOCH},
}; };
use super::*;
use lanparty_ctrl::{DisconnectReason, PeerInfo}; use lanparty_ctrl::{DisconnectReason, PeerInfo};
use lanparty_net::DEFAULT_RELAY_PORT; use lanparty_net::DEFAULT_RELAY_PORT;
use lanparty_obs::{QuicDiagnostics, TunnelStats}; use lanparty_obs::{QuicDiagnostics, TunnelStats};
use super::*;
#[cfg(not(windows))] #[cfg(not(windows))]
#[test] #[test]
fn rejects_runtime_on_non_windows() { fn rejects_runtime_on_non_windows() {
+6 -2
View File
@@ -9,8 +9,12 @@ use std::{fmt, str::FromStr};
mod codec; mod codec;
pub use codec::{ pub use codec::{
CONTROL_LENGTH_PREFIX_LEN, ControlCodecError, MAX_CONTROL_MESSAGE_LEN, CONTROL_LENGTH_PREFIX_LEN,
complete_control_frame_len, decode_control_frame, encode_control_message, ControlCodecError,
MAX_CONTROL_MESSAGE_LEN,
complete_control_frame_len,
decode_control_frame,
encode_control_message,
}; };
pub use lanparty_obs::TunnelStats; pub use lanparty_obs::TunnelStats;
use lanparty_proto::{MIN_USEFUL_TAP_MTU, MacAddr, MtuError, recommended_tap_mtu}; use lanparty_proto::{MIN_USEFUL_TAP_MTU, MacAddr, MtuError, recommended_tap_mtu};
+25 -10
View File
@@ -23,27 +23,42 @@ use anyhow::{Context, Result, bail};
use bytes::Bytes; use bytes::Bytes;
use clap::Parser; use clap::Parser;
use lanparty_ctrl::{ use lanparty_ctrl::{
CONTROL_LENGTH_PREFIX_LEN, ControlMessage, DisconnectReason, EndpointHello, CONTROL_LENGTH_PREFIX_LEN,
MAX_CONTROL_MESSAGE_LEN, PeerInfo, RELAY_ALPN, Role, RoomCode, ServerWelcome, ControlMessage,
decode_control_frame, encode_control_message, DisconnectReason,
EndpointHello,
MAX_CONTROL_MESSAGE_LEN,
PeerInfo,
RELAY_ALPN,
Role,
RoomCode,
ServerWelcome,
decode_control_frame,
encode_control_message,
}; };
use lanparty_net::RelayEndpoint; use lanparty_net::RelayEndpoint;
use lanparty_obs::{DropReason, TunnelStats}; use lanparty_obs::{DropReason, TunnelStats};
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
use lanparty_obs::{FrameAction, FrameDirection, FrameLog}; use lanparty_obs::{FrameAction, FrameDirection, FrameLog};
use lanparty_proto::{ use lanparty_proto::{
EthernetFrame, FrameType, MacAddr, OVERLAY_FLAGS_NONE, decode_datagram, encode_datagram, EthernetFrame,
ethernet_frame_exceeds_tap_mtu, gateway_lan_safety_drop_reason, FrameType,
remote_client_safety_drop_reason, validate_datagram_budget, MacAddr,
OVERLAY_FLAGS_NONE,
decode_datagram,
encode_datagram,
ethernet_frame_exceeds_tap_mtu,
gateway_lan_safety_drop_reason,
remote_client_safety_drop_reason,
validate_datagram_budget,
}; };
#[cfg(target_os = "linux")]
pub use packet::PacketSocket;
use quinn::{ClientConfig, Endpoint, crypto::rustls::QuicClientConfig}; use quinn::{ClientConfig, Endpoint, crypto::rustls::QuicClientConfig};
use rustls::pki_types::CertificateDer; use rustls::pki_types::CertificateDer;
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
use tokio::io::unix::AsyncFd; use tokio::io::unix::AsyncFd;
#[cfg(target_os = "linux")]
pub use packet::PacketSocket;
const MAX_CONTROL_FRAME_LEN: usize = CONTROL_LENGTH_PREFIX_LEN + MAX_CONTROL_MESSAGE_LEN; const MAX_CONTROL_FRAME_LEN: usize = CONTROL_LENGTH_PREFIX_LEN + MAX_CONTROL_MESSAGE_LEN;
const DISCONNECT_DRAIN_TIMEOUT: Duration = Duration::from_millis(250); const DISCONNECT_DRAIN_TIMEOUT: Duration = Duration::from_millis(250);
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
@@ -1146,7 +1161,7 @@ mod tests {
let help = String::from_utf8(help).unwrap(); let help = String::from_utf8(help).unwrap();
assert!( assert!(
help.contains("[aliases: --iface]"), help.contains("[alias: --iface]") || help.contains("[aliases: --iface]"),
"gateway help should advertise --iface alias:\n{help}" "gateway help should advertise --iface alias:\n{help}"
); );
} }
+2 -1
View File
@@ -1,6 +1,7 @@
use std::{ use std::{
ffi::CString, ffi::CString,
fs, io, fs,
io,
os::fd::{AsRawFd, FromRawFd, OwnedFd, RawFd}, os::fd::{AsRawFd, FromRawFd, OwnedFd, RawFd},
path::Path, path::Path,
}; };
+33 -9
View File
@@ -11,22 +11,46 @@ mod overlay;
mod safety; mod safety;
pub use ethernet::{ pub use ethernet::{
ETHERNET_HEADER_LEN, EthernetFrame, MAX_STANDARD_ETHERNET_FRAME_LEN, ETHERNET_HEADER_LEN,
MAX_STANDARD_ETHERNET_PAYLOAD_LEN, MIN_ETHERNET_FRAME_LEN, EthernetFrame,
MAX_STANDARD_ETHERNET_FRAME_LEN,
MAX_STANDARD_ETHERNET_PAYLOAD_LEN,
MIN_ETHERNET_FRAME_LEN,
}; };
pub use mac::{MacAddr, MacParseError}; pub use mac::{MacAddr, MacParseError};
pub use mtu::{ pub use mtu::{
DEFAULT_DATAGRAM_SAFETY_MARGIN, DEFAULT_TAP_MTU, MIN_USEFUL_TAP_MTU, MtuError, DEFAULT_DATAGRAM_SAFETY_MARGIN,
ethernet_frame_exceeds_tap_mtu, max_ethernet_frame_len_for_tap_mtu, max_tap_mtu_for_datagram, DEFAULT_TAP_MTU,
MIN_USEFUL_TAP_MTU,
MtuError,
ethernet_frame_exceeds_tap_mtu,
max_ethernet_frame_len_for_tap_mtu,
max_tap_mtu_for_datagram,
recommended_tap_mtu, recommended_tap_mtu,
}; };
pub use overlay::{ pub use overlay::{
FrameType, OVERLAY_FLAGS_NONE, OVERLAY_HEADER_LEN, OVERLAY_MAGIC, OVERLAY_VERSION, FrameType,
OverlayHeader, OverlayPacket, ProtoError, decode_datagram, encode_datagram, OVERLAY_FLAGS_NONE,
OVERLAY_HEADER_LEN,
OVERLAY_MAGIC,
OVERLAY_VERSION,
OverlayHeader,
OverlayPacket,
ProtoError,
decode_datagram,
encode_datagram,
validate_datagram_budget, validate_datagram_budget,
}; };
pub use safety::{ pub use safety::{
ETHERTYPE_8021AD, ETHERTYPE_8021Q, ETHERTYPE_EAPOL, ETHERTYPE_IPV4, ETHERTYPE_IPV6, ETHERTYPE_8021AD,
ETHERTYPE_LLDP, ETHERTYPE_QINQ, ETHERTYPE_SLOW_PROTOCOLS, EthernetSafetyDrop, ETHERTYPE_8021Q,
gateway_lan_safety_drop_reason, remote_client_safety_drop_reason, ETHERTYPE_EAPOL,
ETHERTYPE_IPV4,
ETHERTYPE_IPV6,
ETHERTYPE_LLDP,
ETHERTYPE_QINQ,
ETHERTYPE_SLOW_PROTOCOLS,
EthernetSafetyDrop,
gateway_lan_safety_drop_reason,
remote_client_safety_drop_reason,
}; };
+18 -7
View File
@@ -9,18 +9,28 @@ mod server;
use std::{collections::HashMap, time::Instant}; use std::{collections::HashMap, time::Instant};
pub use config::{ConfigError, DEFAULT_RELAY_PORT, ListenEndpoint, RelayArgs, RelayConfig};
use lanparty_ctrl::{ use lanparty_ctrl::{
ControlError, EndpointHello, PeerInfo, Reject, RejectReason, Role, RoomCode, ServerWelcome, ControlError,
EndpointHello,
PeerInfo,
Reject,
RejectReason,
Role,
RoomCode,
ServerWelcome,
}; };
use lanparty_obs::{DropReason, FrameAction}; use lanparty_obs::{DropReason, FrameAction};
use lanparty_proto::{ use lanparty_proto::{
EthernetFrame, MacAddr, ethernet_frame_exceeds_tap_mtu, gateway_lan_safety_drop_reason, EthernetFrame,
recommended_tap_mtu, remote_client_safety_drop_reason, MacAddr,
ethernet_frame_exceeds_tap_mtu,
gateway_lan_safety_drop_reason,
recommended_tap_mtu,
remote_client_safety_drop_reason,
}; };
use thiserror::Error;
pub use config::{ConfigError, DEFAULT_RELAY_PORT, ListenEndpoint, RelayArgs, RelayConfig};
pub use server::RelayServer; pub use server::RelayServer;
use thiserror::Error;
pub const DEFAULT_MAX_CLIENTS_PER_ROOM: usize = 16; pub const DEFAULT_MAX_CLIENTS_PER_ROOM: usize = 16;
const MEBIBYTE: u64 = 1024 * 1024; const MEBIBYTE: u64 = 1024 * 1024;
@@ -769,9 +779,10 @@ fn reject_control_error(error: ControlError) -> Reject {
mod tests { mod tests {
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
use super::*;
use lanparty_proto::MAX_STANDARD_ETHERNET_FRAME_LEN; use lanparty_proto::MAX_STANDARD_ETHERNET_FRAME_LEN;
use super::*;
fn room() -> RoomCode { fn room() -> RoomCode {
RoomCode::new("ABCD").unwrap() RoomCode::new("ABCD").unwrap()
} }
+37 -11
View File
@@ -1,20 +1,42 @@
use std::{fs, net::SocketAddr, path::Path, sync::Arc}; use std::{collections::HashMap, fs, net::SocketAddr, path::Path, sync::Arc};
use anyhow::{Context, Result, anyhow, bail}; use anyhow::{Context, Result, anyhow, bail};
use bytes::Bytes; use bytes::Bytes;
use lanparty_ctrl::{ use lanparty_ctrl::{
CONTROL_LENGTH_PREFIX_LEN, ControlCodecError, ControlMessage, DisconnectReason, EndpointHello, CONTROL_LENGTH_PREFIX_LEN,
MAX_CONTROL_MESSAGE_LEN, PeerInfo, RELAY_ALPN, Reject, RejectReason, Role, RoomCode, ControlCodecError,
ServerWelcome, decode_control_frame, encode_control_message, ControlMessage,
DisconnectReason,
EndpointHello,
MAX_CONTROL_MESSAGE_LEN,
PeerInfo,
RELAY_ALPN,
Reject,
RejectReason,
Role,
RoomCode,
ServerWelcome,
decode_control_frame,
encode_control_message,
}; };
use lanparty_obs::{DropReason, FrameDirection, FrameLog, TunnelStats}; use lanparty_obs::{DropReason, FrameDirection, FrameLog, TunnelStats};
use lanparty_proto::{ use lanparty_proto::{
EthernetFrame, FrameType, OVERLAY_FLAGS_NONE, decode_datagram, encode_datagram, EthernetFrame,
FrameType,
OVERLAY_FLAGS_NONE,
decode_datagram,
encode_datagram,
};
use quinn::{
Endpoint,
Incoming,
RecvStream,
SendStream,
ServerConfig,
TransportConfig,
crypto::rustls::QuicServerConfig,
}; };
use quinn::crypto::rustls::QuicServerConfig;
use quinn::{Endpoint, Incoming, RecvStream, SendStream, ServerConfig, TransportConfig};
use rustls::pki_types::{CertificateDer, PrivateKeyDer, PrivatePkcs8KeyDer}; use rustls::pki_types::{CertificateDer, PrivateKeyDer, PrivatePkcs8KeyDer};
use std::collections::HashMap;
use tokio::sync::Mutex; use tokio::sync::Mutex;
use crate::{ForwardingDecision, RelayConfig, RoomRegistry}; use crate::{ForwardingDecision, RelayConfig, RoomRegistry};
@@ -1014,13 +1036,17 @@ mod tests {
use lanparty_ctrl::{RoomCode, decode_control_frame, encode_control_message}; use lanparty_ctrl::{RoomCode, decode_control_frame, encode_control_message};
use lanparty_gateway::{GatewayConfig, connect_gateway}; use lanparty_gateway::{GatewayConfig, connect_gateway};
use lanparty_proto::{ use lanparty_proto::{
ETHERNET_HEADER_LEN, ETHERTYPE_IPV4, FrameType, MacAddr, decode_datagram, encode_datagram, ETHERNET_HEADER_LEN,
ETHERTYPE_IPV4,
FrameType,
MacAddr,
decode_datagram,
encode_datagram,
}; };
use quinn::{ClientConfig, crypto::rustls::QuicClientConfig}; use quinn::{ClientConfig, crypto::rustls::QuicClientConfig};
use crate::{DEFAULT_MAX_CLIENTS_PER_ROOM, ListenEndpoint};
use super::*; use super::*;
use crate::{DEFAULT_MAX_CLIENTS_PER_ROOM, ListenEndpoint};
const ETHERTYPE_ARP: u16 = 0x0806; const ETHERTYPE_ARP: u16 = 0x0806;
const ARP_REQUEST: u16 = 1; const ARP_REQUEST: u16 = 1;
+35
View File
@@ -0,0 +1,35 @@
set positional-arguments
run *args:
cargo run -- "$@"
build:
cargo build
build-release:
cargo build --release
build-production:
cargo build --profile production
fmt:
cargo +nightly fmt
tombi format
fd -tf -e md -x prettier --write --prose-wrap always --print-width 80
rumdl check --flavor commonmark --fix
just --fmt
_fix:
cargo fix --workspace --all-targets --all-features
cargo clippy --fix --workspace --all-targets --all-features
fix: _fix fmt
clippy:
cargo clippy --workspace --all-targets --all-features -- -D warnings
test:
cargo test --workspace --all-targets --all-features
clean:
cargo clean
+3
View File
@@ -0,0 +1,3 @@
group_imports = "StdExternalCrate"
imports_granularity = "Crate"
imports_layout = "HorizontalVertical"