Compare commits
3
Commits
b527019b76
...
v0.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9175eedce9 | ||
|
|
16d0886f36
|
||
|
|
a66ea31ab3
|
@@ -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.
|
||||
@@ -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
@@ -138,9 +138,9 @@ checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.3.0"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c89588d05638b5b4594a3348a2d6c20277e43a7f5c5202b05cc56888475a47b8"
|
||||
checksum = "509591b7bcd67f4ef775afad7662703b4935daaa6ec0e5605cfb1090b32a2b6d"
|
||||
dependencies = [
|
||||
"find-msvc-tools",
|
||||
"shlex",
|
||||
@@ -171,9 +171,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.6.4"
|
||||
version = "4.6.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d91e0c145792ef73a6ad36d27c75ac09f1832222a3c209689d90f534685ee5b7"
|
||||
checksum = "473c7e07f409a8d772161724aa8db6a765a2532a70f9667eeb7b49d3d02fbdca"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
@@ -181,9 +181,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.6.2"
|
||||
version = "4.6.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f09628afdcc538b57f3c6341e9c8e9970f18e4a481690a64974d7023bd33548b"
|
||||
checksum = "7b48fea5a88e9ae728a2dcbedbfc0e730f7d60da42e1cb049a83c9fb8b789889"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
@@ -252,9 +252,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "data-encoding"
|
||||
version = "2.11.0"
|
||||
version = "2.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4ae5f15dda3c708c0ade84bfee31ccab44a3da4f88015ed22f63732abe300c8"
|
||||
checksum = "4583a4551df46e2792f82ceeac45e850d2e2d5debba0b91f102385cda5b11f06"
|
||||
|
||||
[[package]]
|
||||
name = "der-parser"
|
||||
@@ -278,13 +278,13 @@ checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c"
|
||||
|
||||
[[package]]
|
||||
name = "displaydoc"
|
||||
version = "0.2.6"
|
||||
version = "0.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1ac70aa55017e108007fbaf5aa0f54b021c98f92ff8af59d42eda9da96e3dd4f"
|
||||
checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.119",
|
||||
"syn 3.0.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -311,9 +311,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "find-msvc-tools"
|
||||
version = "0.1.9"
|
||||
version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582"
|
||||
checksum = "d45db016d36b838f563236e9193d0ee6ce38f3f68b6c94e914b4929c96bbb890"
|
||||
|
||||
[[package]]
|
||||
name = "foldhash"
|
||||
@@ -323,21 +323,21 @@ checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"
|
||||
|
||||
[[package]]
|
||||
name = "futures-core"
|
||||
version = "0.3.33"
|
||||
version = "0.3.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2cd50c473c80f6d7c3670a752354b8e569b1a7cbfdc0419ec88e5edad85e0dc7"
|
||||
checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e"
|
||||
|
||||
[[package]]
|
||||
name = "futures-task"
|
||||
version = "0.3.33"
|
||||
version = "0.3.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b231ed28831efb4a61a08580c4bc233ec56bc009f4cd8f52da2c3cb97df0c109"
|
||||
checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd"
|
||||
|
||||
[[package]]
|
||||
name = "futures-util"
|
||||
version = "0.3.33"
|
||||
version = "0.3.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a77a90a256fce34da66415271e30f94ee91c57b04b8a2c042d9cf3220179deaa"
|
||||
checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-task",
|
||||
@@ -441,9 +441,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.103"
|
||||
version = "0.3.104"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "53b44bfcdb3f8d5837a46dae1ca9660a837176eee74a28b229bc626816589102"
|
||||
checksum = "0e0c1080212aad755ea003d18543e8768dd432c48819efd73a7bf1e39b7a5a3a"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"futures-util",
|
||||
@@ -655,9 +655,9 @@ checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441"
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
version = "0.1.46"
|
||||
version = "0.1.47"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f"
|
||||
checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
@@ -716,9 +716,9 @@ checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
|
||||
|
||||
[[package]]
|
||||
name = "portable-atomic"
|
||||
version = "1.14.0"
|
||||
version = "1.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d20d5497ef88037a52ff98267d066e7f11fcc5e99bbfbd58a42336193aacec3"
|
||||
checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
|
||||
|
||||
[[package]]
|
||||
name = "powerfmt"
|
||||
@@ -836,9 +836,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rcgen"
|
||||
version = "0.14.8"
|
||||
version = "0.14.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57f6d249aad744e274e682777a50283a225a32705394ee6d5fcc01efa25e4055"
|
||||
checksum = "091e7a8e7d86e6feb87a27ce8e2cba29d49eff9507afeebefab7eeb2ca667fb4"
|
||||
dependencies = [
|
||||
"pem",
|
||||
"ring",
|
||||
@@ -888,9 +888,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustls"
|
||||
version = "0.23.42"
|
||||
version = "0.23.43"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c54fcab019b409d04215d3a17cb438fd7fbf192ee61461f20f4fe18704bc138"
|
||||
checksum = "0283386ce02abc0151e1761d08802dfe86c173b0b494af5cbc086574e453da06"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"ring",
|
||||
@@ -914,9 +914,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustls-pki-types"
|
||||
version = "1.15.0"
|
||||
version = "1.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "764899a24af3980067ee14bc143654f297b22eaebfe3c7b6b211920a5a59b046"
|
||||
checksum = "2f4925028c7eb5d1fcdaf196971378ed9d2c1c4efc7dc5d011256f76c99c0a96"
|
||||
dependencies = [
|
||||
"web-time",
|
||||
"zeroize",
|
||||
@@ -951,9 +951,9 @@ checksum = "f87165f0995f63a9fbeea62b64d10b4d9d8e78ec6d7d51fb2125fda7bb36788f"
|
||||
|
||||
[[package]]
|
||||
name = "rustls-webpki"
|
||||
version = "0.103.13"
|
||||
version = "0.103.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "61c429a8649f110dddef65e2a5ad240f747e85f7758a6bccc7e5777bd33f756e"
|
||||
checksum = "0527518605e68109d875e248ea259b6758801cf165e4b2c2733ae3b51f12535a"
|
||||
dependencies = [
|
||||
"ring",
|
||||
"rustls-pki-types",
|
||||
@@ -1157,18 +1157,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "2.0.19"
|
||||
version = "2.0.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09a43598840e33d5b0331f38c5e30d13bb11c11210a4b58f0d9b18a5a5eefcd9"
|
||||
checksum = "ec86235f5fcc2a73650310756d2ac5b138a5780bbbdfae3eeccec992c435ba4f"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "2.0.19"
|
||||
version = "2.0.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "43cbfe0cf76104d42a574802844187e84a305e531ed54455f11fbde0f10541cd"
|
||||
checksum = "bc04cd3e1236dd4a98afca4569f2deb3f120e5422a4023be2cb683f8486292af"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -1177,9 +1177,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.3.54"
|
||||
version = "0.3.55"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3e1d5e639ff6bab73cb6885cc7e7b1de96c3f32c68ec55f3952614bec1092244"
|
||||
checksum = "cdb87b95ec50ddfa440816d227a17b2ccbdda963a316a727fda0fc4334f7d134"
|
||||
dependencies = [
|
||||
"deranged",
|
||||
"num-conv",
|
||||
@@ -1237,13 +1237,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tokio-macros"
|
||||
version = "2.7.1"
|
||||
version = "2.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6328af13490e73a9b4694030fafd93f8c8c6a9dede33e821c3fc63eddf8042ba"
|
||||
checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.119",
|
||||
"syn 3.0.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1302,9 +1302,9 @@ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.126"
|
||||
version = "0.2.127"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4b067c0c11094aef6b7a801c1e34a26affafdf3d051dba08456b868789aaf9a4"
|
||||
checksum = "1b70935747edd64d89de3efa29d73789b806c15798f8e7dca4d8ac356b50ce70"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
@@ -1315,9 +1315,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.126"
|
||||
version = "0.2.127"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "167ce5e579f6bcf889c4f7175a8a5a585de84e8ff93976ce393efa5f2837aab1"
|
||||
checksum = "77775f8f3f7217702089053b94958f8f54061a3f663417df76e19cbdcca29bc1"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
@@ -1325,9 +1325,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.126"
|
||||
version = "0.2.127"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f3997c7839262f4ef12cf90b818d6340c18e80f263f1a94bf157d0ec4420380e"
|
||||
checksum = "e11d33f857dc2fb11b8bc75aee111aa9cbeb12cd9f25efd3d4c2a3dd4e235284"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"proc-macro2",
|
||||
@@ -1338,9 +1338,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.126"
|
||||
version = "0.2.127"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc1b4cb0cc549fcf58d7dfc081778139b3d283a081644e833e84682ad71cea24"
|
||||
checksum = "7ef64dbcc55df09c7e5a46182d181c2cfa3e925f3da937ea764728b4bbb9dcbf"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
+5
-5
@@ -20,15 +20,15 @@ edition = "2024"
|
||||
[workspace.dependencies]
|
||||
anyhow = "1"
|
||||
bytes = "1"
|
||||
clap = { version = "4.6.1", features = ["derive"] }
|
||||
getrandom = "0.4.2"
|
||||
clap = { version = "4.6.6", features = ["derive"] }
|
||||
getrandom = "0.4.3"
|
||||
libc = "0.2"
|
||||
quinn = "0.11.9"
|
||||
rcgen = "0.14.8"
|
||||
quinn = "0.11.11"
|
||||
rcgen = "0.14.9"
|
||||
rustls = { version = "0.23", default-features = false, features = ["ring", "std"] }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
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"
|
||||
windows-sys = "0.61.2"
|
||||
|
||||
@@ -1,14 +1,23 @@
|
||||
# PLAN
|
||||
|
||||
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**.
|
||||
|
||||
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
|
||||
Windows game
|
||||
@@ -21,13 +30,10 @@ Windows game
|
||||
⇄ physical Ethernet LAN
|
||||
```
|
||||
|
||||
No WireGuard.
|
||||
No Npcap.
|
||||
No Windows bridge.
|
||||
No packet rewriting from the user’s real NIC.
|
||||
No tunnel fragmentation for MVP.
|
||||
No WireGuard. No Npcap. No Windows bridge. No packet rewriting from the user’s
|
||||
real NIC. No tunnel fragmentation for MVP.
|
||||
|
||||
## Goal
|
||||
### Goal
|
||||
|
||||
The remote player should do this:
|
||||
|
||||
@@ -53,11 +59,12 @@ The public server does this:
|
||||
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.
|
||||
|
||||
@@ -75,9 +82,13 @@ Responsibilities:
|
||||
- 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 player’s LAN-party identity.
|
||||
|
||||
@@ -88,7 +99,7 @@ Game sends ARP/broadcast/multicast through TAP
|
||||
Client tunnels the Ethernet frames
|
||||
```
|
||||
|
||||
### 2. Linux gateway: `lanparty-gateway`
|
||||
#### 2. Linux gateway: `lanparty-gateway`
|
||||
|
||||
Runs on the physical LAN party machine.
|
||||
|
||||
@@ -104,15 +115,23 @@ Responsibilities:
|
||||
- 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 host’s 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 host’s 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.
|
||||
|
||||
@@ -139,7 +158,7 @@ gateway → outbound QUIC → relay
|
||||
|
||||
No port forwarding. No NAT traversal pain. Direct P2P can come later.
|
||||
|
||||
## Transport
|
||||
### Transport
|
||||
|
||||
Use QUIC.
|
||||
|
||||
@@ -158,11 +177,16 @@ disconnect reason
|
||||
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.
|
||||
|
||||
@@ -200,9 +224,10 @@ tap_mtu <= quic_max_datagram_size
|
||||
- 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.
|
||||
|
||||
@@ -226,13 +251,16 @@ clear routing header
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
## Switching model
|
||||
### Switching model
|
||||
|
||||
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.
|
||||
|
||||
## MAC identity
|
||||
### MAC identity
|
||||
|
||||
Each Windows client needs a unique locally administered unicast MAC.
|
||||
|
||||
@@ -295,7 +323,8 @@ Example range:
|
||||
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:
|
||||
|
||||
@@ -315,11 +344,13 @@ maybe 2 later for weird cases
|
||||
|
||||
This is your responsibility, not the user’s.
|
||||
|
||||
## 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 client’s source MAC.
|
||||
That happens when the gateway injects frames onto the LAN using the remote
|
||||
client’s source MAC.
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
The exact frame can be decided during implementation, but the goal is simple: keep the LAN switch mapping the remote MAC to the gateway’s 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 gateway’s physical port.
|
||||
|
||||
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.
|
||||
|
||||
## 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:
|
||||
|
||||
@@ -368,7 +401,8 @@ Also drop LAN → remote:
|
||||
|
||||
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:
|
||||
|
||||
@@ -379,11 +413,12 @@ Add rate limits:
|
||||
- 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.
|
||||
|
||||
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:
|
||||
|
||||
@@ -396,7 +431,8 @@ Client startup should:
|
||||
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:
|
||||
|
||||
@@ -409,9 +445,10 @@ bad: 192.168.178.0/24
|
||||
|
||||
Duplicate subnet with a remote user’s 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:
|
||||
|
||||
@@ -421,7 +458,10 @@ client → relay → gateway
|
||||
|
||||
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:
|
||||
|
||||
@@ -431,7 +471,7 @@ mode = direct-p2p
|
||||
mode = direct-failed-relay-fallback
|
||||
```
|
||||
|
||||
## Logging / diagnostics
|
||||
### Logging / diagnostics
|
||||
|
||||
Phase 1 should log heavily.
|
||||
|
||||
@@ -473,9 +513,9 @@ Broadcast traffic flowing
|
||||
Warning: TAP received default route, adjusted metric
|
||||
```
|
||||
|
||||
## Phase plan
|
||||
### Phase plan
|
||||
|
||||
### Phase 1: prove the illusion
|
||||
#### Phase 1: prove the illusion
|
||||
|
||||
Manual, ugly, real.
|
||||
|
||||
@@ -500,7 +540,7 @@ Success criteria:
|
||||
- one real LAN game discovers or joins a LAN server
|
||||
```
|
||||
|
||||
### Phase 2: multi-client
|
||||
#### Phase 2: multi-client
|
||||
|
||||
```text
|
||||
- multiple Windows clients
|
||||
@@ -512,7 +552,7 @@ Success criteria:
|
||||
- reconnect handling
|
||||
```
|
||||
|
||||
### Phase 3: safety and correctness
|
||||
#### Phase 3: safety and correctness
|
||||
|
||||
```text
|
||||
- L2 control-plane filters
|
||||
@@ -524,7 +564,7 @@ Success criteria:
|
||||
- better malformed-frame handling
|
||||
```
|
||||
|
||||
### Phase 4: product UX
|
||||
#### Phase 4: product UX
|
||||
|
||||
```text
|
||||
- Windows installer
|
||||
@@ -536,9 +576,11 @@ Success criteria:
|
||||
- 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
|
||||
- invite tokens / auth
|
||||
@@ -549,7 +591,7 @@ Driver signing and TAP bundling must be validated early. `tap-windows6` is the r
|
||||
- regional relay selection
|
||||
```
|
||||
|
||||
## Explicit non-goals
|
||||
### Explicit non-goals
|
||||
|
||||
For MVP, do not build:
|
||||
|
||||
@@ -565,14 +607,29 @@ For MVP, do not build:
|
||||
- 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)"
|
||||
[2]: https://man7.org/linux/man-pages/man7/packet.7.html?utm_source=chatgpt.com "packet(7) - Linux manual page"
|
||||
[3]: https://man7.org/linux/man-pages/man7/capabilities.7.html?utm_source=chatgpt.com "capabilities(7) - Linux manual page"
|
||||
[4]: https://datatracker.ietf.org/doc/html/rfc9221?utm_source=chatgpt.com "RFC 9221 - An Unreliable Datagram Extension to QUIC"
|
||||
[5]: https://docs.rs/quinn/latest/quinn/struct.Connection.html?utm_source=chatgpt.com "Connection in quinn - Rust"
|
||||
[1]:
|
||||
<https://github.com/OpenVPN/tap-windows6?utm_source=chatgpt.com>
|
||||
"OpenVPN/tap-windows6: Windows TAP driver (NDIS 6)"
|
||||
[2]:
|
||||
<https://man7.org/linux/man-pages/man7/packet.7.html?utm_source=chatgpt.com>
|
||||
"packet(7) - Linux manual page"
|
||||
[3]:
|
||||
<https://man7.org/linux/man-pages/man7/capabilities.7.html?utm_source=chatgpt.com>
|
||||
"capabilities(7) - Linux manual page"
|
||||
[4]:
|
||||
<https://datatracker.ietf.org/doc/html/rfc9221?utm_source=chatgpt.com>
|
||||
"RFC 9221 - An Unreliable Datagram Extension to QUIC"
|
||||
[5]:
|
||||
<https://docs.rs/quinn/latest/quinn/struct.Connection.html?utm_source=chatgpt.com>
|
||||
"Connection in quinn - Rust"
|
||||
|
||||
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.
|
||||
|
||||
@@ -82,7 +82,8 @@ Windows route-table boundary:
|
||||
- unicast IP address snapshots for TAP diagnostics
|
||||
- scoped host-route pinning for the relay IP on the pre-TAP interface
|
||||
- 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
|
||||
|
||||
### `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
|
||||
- reliable `PeerJoined`/`PeerLeft` notifications plus gateway identity in
|
||||
welcome messages
|
||||
- L2 safety filters for invalid-source, jumbo, switch-control, remote VLAN
|
||||
tags, remote IPv6 fragments, IPv4/IPv6 DHCP-server, and IPv6-RA frames,
|
||||
including frames behind ordinary IPv6 extension headers
|
||||
- L2 safety filters for invalid-source, jumbo, switch-control, remote VLAN tags,
|
||||
remote IPv6 fragments, IPv4/IPv6 DHCP-server, and IPv6-RA frames, including
|
||||
frames behind ordinary IPv6 extension headers
|
||||
- client broadcast/multicast, unknown-unicast, and total bandwidth limiting
|
||||
- malformed peer datagram disconnect threshold
|
||||
- peer stats control events retained for relay diagnostics
|
||||
@@ -129,9 +130,9 @@ cargo build --release -p lanparty-relay -p lanparty-gateway
|
||||
git diff --check
|
||||
```
|
||||
|
||||
These checks cover the local Rust code and the real client/relay/gateway
|
||||
session paths that can run without Windows TAP or LAN hardware. For the Windows
|
||||
client build and the manual MVP end-to-end proof, see [TESTING.md](TESTING.md).
|
||||
These checks cover the local Rust code and the real client/relay/gateway session
|
||||
paths that can run without Windows TAP or LAN hardware. For the Windows client
|
||||
build and the manual MVP end-to-end proof, see [TESTING.md](TESTING.md).
|
||||
|
||||
## 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 handling remains future work. Ethernet forwarding decisions are
|
||||
logged with room, peer, MAC, ethertype, action, drop reason, and target count.
|
||||
Safety-policy rejects use the `filtered` action so they are distinguishable
|
||||
from malformed/unknown-destination drops and rate limits.
|
||||
Malformed peer datagrams log their per-peer count before the relay disconnects
|
||||
peers that cross the malformed-datagram threshold.
|
||||
Relay egress skips caused by a target peer's smaller datagram budget are logged
|
||||
with the ingress peer, target peer, encoded length, and target budget.
|
||||
Ingress datagrams larger than the sending peer's negotiated datagram budget are
|
||||
dropped before decode/forwarding and logged with `reason=datagram_budget`.
|
||||
Unknown unicast from a client is forwarded only to the gateway port; unknown
|
||||
unicast from the gateway is dropped instead of flooded to every remote client.
|
||||
When a peer joins or leaves, the relay sends a reliable lifecycle control event
|
||||
to peers that are still present in the room. Newly joined peers also receive
|
||||
`PeerJoined` events for peers that were already present, and catch-up delivery
|
||||
is part of the accepted handshake rather than a best-effort follow-up. When a
|
||||
client joins, the relay notifies existing peers before the client receives its
|
||||
welcome, so gateways can seed client MAC state before that client starts
|
||||
sending frames. When a gateway joins, the relay gives the gateway the current
|
||||
client list before notifying clients that the gateway is available.
|
||||
Safety-policy rejects use the `filtered` action so they are distinguishable from
|
||||
malformed/unknown-destination drops and rate limits. Malformed peer datagrams
|
||||
log their per-peer count before the relay disconnects peers that cross the
|
||||
malformed-datagram threshold. Relay egress skips caused by a target peer's
|
||||
smaller datagram budget are logged with the ingress peer, target peer, encoded
|
||||
length, and target budget. Ingress datagrams larger than the sending peer's
|
||||
negotiated datagram budget are dropped before decode/forwarding and logged with
|
||||
`reason=datagram_budget`. Unknown unicast from a client is forwarded only to the
|
||||
gateway port; unknown unicast from the gateway is dropped instead of flooded to
|
||||
every remote client. When a peer joins or leaves, the relay sends a reliable
|
||||
lifecycle control event to peers that are still present in the room. Newly
|
||||
joined peers also receive `PeerJoined` events for peers that were already
|
||||
present, and catch-up delivery is part of the accepted handshake rather than a
|
||||
best-effort follow-up. When a client joins, the relay notifies existing peers
|
||||
before the client receives its welcome, so gateways can seed client MAC state
|
||||
before that client starts sending frames. When a gateway joins, the relay gives
|
||||
the gateway the current client list before notifying clients that the gateway is
|
||||
available.
|
||||
|
||||
### 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
|
||||
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 up to the
|
||||
overlay payload-length ceiling before deciding whether they fit the tunnel. It
|
||||
never fragments Ethernet frames; LAN frames with invalid source MACs, L2
|
||||
control-plane traffic, jumbo frames, frames above the negotiated TAP MTU, or
|
||||
encoded datagrams exceeding the negotiated QUIC budget are counted, dropped,
|
||||
and logged locally instead of stopping the bridge or consuming relay bandwidth.
|
||||
Remote frames received from
|
||||
the relay are safety-checked again before LAN injection and must use the
|
||||
announced virtual MAC for their source peer, so invalid-source, forged-source,
|
||||
L2 control-plane, remote VLAN, DHCP-server, IPv6 Router Advertisement, IPv6
|
||||
fragment, jumbo, and over-TAP-MTU frames cannot cross the gateway's final
|
||||
physical-LAN boundary even if they reached the gateway over QUIC.
|
||||
`--relay` accepts a DNS name or socket address; bare hosts default to UDP/443.
|
||||
The gateway rejects Linux interfaces that sysfs identifies as Wi-Fi, and rejects
|
||||
wired interfaces whose sysfs carrier state reports no link; managed wireless
|
||||
NICs are not supported for the physical LAN bridge.
|
||||
It tracks remote-client MACs from relay lifecycle events and periodically emits
|
||||
small CAM refresh frames, logged with `reason=periodic`, so the physical
|
||||
switch keeps those MACs associated with the gateway port. A newly observed
|
||||
client also triggers an immediate CAM refresh frame logged with
|
||||
`reason=peer_joined` instead of waiting for the first periodic refresh tick.
|
||||
When control events and frame work are both ready, the bridge handles the
|
||||
lifecycle event first so first packets after a client joins use the freshest
|
||||
remote-MAC state available locally. Gateway
|
||||
frame logs include direction, peer id when present, MACs, ethertype/length,
|
||||
frame length, action, and drop reason. The gateway also tracks frame/datagram
|
||||
counters and periodically sends stats snapshots to the relay. Malformed or runt
|
||||
LAN frames are counted and logged as dropped instead of disappearing before
|
||||
accounting. It drops unrelated LAN unicast locally once the destination is known
|
||||
not to be a connected remote client, so busy LAN traffic is not sent to the
|
||||
public relay just to be discarded there. Relay lifecycle events seed and retire
|
||||
remote-client MACs for CAM refresh and LAN-destination filtering even before
|
||||
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.
|
||||
frames up to the overlay payload-length ceiling before deciding whether they fit
|
||||
the tunnel. It never fragments Ethernet frames; LAN frames with invalid source
|
||||
MACs, L2 control-plane traffic, jumbo frames, frames above the negotiated TAP
|
||||
MTU, or encoded datagrams exceeding the negotiated QUIC budget are counted,
|
||||
dropped, and logged locally instead of stopping the bridge or consuming relay
|
||||
bandwidth. Remote frames received from the relay are safety-checked again before
|
||||
LAN injection and must use the announced virtual MAC for their source peer, so
|
||||
invalid-source, forged-source, L2 control-plane, remote VLAN, DHCP-server, IPv6
|
||||
Router Advertisement, IPv6 fragment, jumbo, and over-TAP-MTU frames cannot cross
|
||||
the gateway's final physical-LAN boundary even if they reached the gateway over
|
||||
QUIC. `--relay` accepts a DNS name or socket address; bare hosts default to
|
||||
UDP/443. The gateway rejects Linux interfaces that sysfs identifies as Wi-Fi,
|
||||
and rejects wired interfaces whose sysfs carrier state reports no link; managed
|
||||
wireless NICs are not supported for the physical LAN bridge. It tracks
|
||||
remote-client MACs from relay lifecycle events and periodically emits small CAM
|
||||
refresh frames, logged with `reason=periodic`, so the physical switch keeps
|
||||
those MACs associated with the gateway port. A newly observed client also
|
||||
triggers an immediate CAM refresh frame logged with `reason=peer_joined` instead
|
||||
of waiting for the first periodic refresh tick. When control events and frame
|
||||
work are both ready, the bridge handles the lifecycle event first so first
|
||||
packets after a client joins use the freshest remote-MAC state available
|
||||
locally. Gateway frame logs include direction, peer id when present, MACs,
|
||||
ethertype/length, frame length, action, and drop reason. The gateway also tracks
|
||||
frame/datagram counters and periodically sends stats snapshots to the relay.
|
||||
Malformed or runt LAN frames are counted and logged as dropped instead of
|
||||
disappearing before accounting. It drops unrelated LAN unicast locally once the
|
||||
destination is known not to be a connected remote client, so busy LAN traffic is
|
||||
not sent to the public relay just to be discarded there. Relay lifecycle events
|
||||
seed and retire remote-client MACs for CAM refresh and LAN-destination filtering
|
||||
even before 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
|
||||
|
||||
@@ -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
|
||||
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
|
||||
persisted in
|
||||
`lanparty-client-identity.json`. Before resolving or connecting to the relay,
|
||||
it writes the generated tunnel MAC to the selected TAP driver's
|
||||
persisted in `lanparty-client-identity.json`. Before resolving or connecting to
|
||||
the relay, it writes the generated tunnel MAC to the selected TAP driver's
|
||||
`NetworkAddress` registry setting and marks TAP media disconnected. That clears
|
||||
stale connected state from a previous crashed run without letting the TAP
|
||||
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
|
||||
pre-TAP interface, verifies that Windows is using that host route, completes
|
||||
the control-stream hello/welcome handshake, verifies the host route again after
|
||||
TAP activation, and bridges Ethernet frames between the relay and the
|
||||
TAP-Windows6 adapter until shutdown. `--relay` accepts a DNS name or socket
|
||||
address; bare hosts default to UDP/443.
|
||||
TAP frames whose source MAC does not match that generated tunnel MAC are
|
||||
dropped locally before they can consume relay bandwidth; the relay still
|
||||
enforces the same source-MAC rule.
|
||||
If the exact relay host route already exists, the client uses it and leaves it
|
||||
alone on exit. The startup status reports whether the relay already has a LAN
|
||||
gateway for the room.
|
||||
pre-TAP interface, verifies that Windows is using that host route, completes the
|
||||
control-stream hello/welcome handshake, verifies the host route again after TAP
|
||||
activation, and bridges Ethernet frames between the relay and the TAP-Windows6
|
||||
adapter until shutdown. `--relay` accepts a DNS name or socket address; bare
|
||||
hosts default to UDP/443. TAP frames whose source MAC does not match that
|
||||
generated tunnel MAC are dropped locally before they can consume relay
|
||||
bandwidth; the relay still enforces the same source-MAC rule. If the exact relay
|
||||
host route already exists, the client uses it and leaves it 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
|
||||
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
|
||||
@@ -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
|
||||
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
|
||||
when TAP default routes were enabled
|
||||
before the scoped protection was applied. Startup still fails before bridging
|
||||
if the driver-reported MAC does not match the tunnel identity, because an
|
||||
already-initialized Windows TAP adapter may need to be disabled/enabled or
|
||||
reinstalled before it reloads the configured `NetworkAddress`.
|
||||
If exactly one TAP-Windows6 adapter is installed, the client opens it
|
||||
automatically. If multiple TAP-Windows6 adapters are installed, startup fails
|
||||
until `--tap-instance-id` selects the intended adapter by NetCfgInstanceId /
|
||||
InterfaceGuid. `--list-tap-adapters` prints the TAP adapter ids and exits
|
||||
without connecting.
|
||||
It prints and reports client diagnostics snapshots with relay reachability,
|
||||
LAN-gateway presence, route-pinning, QUIC datagram budget, relay RTT, TAP
|
||||
status/IP, broadcast frame flow, frame/datagram counters, and drops. The
|
||||
periodic diagnostics refresh the TAP unicast IP so DHCP results that arrive
|
||||
after bridging starts become visible in later status lines, preferring a
|
||||
when TAP default routes were enabled before the scoped protection was applied.
|
||||
Startup still fails before bridging if the driver-reported MAC does not match
|
||||
the tunnel identity, because an already-initialized Windows TAP adapter may need
|
||||
to be disabled/enabled or reinstalled before it reloads the configured
|
||||
`NetworkAddress`. If exactly one TAP-Windows6 adapter is installed, the client
|
||||
opens it automatically. If multiple TAP-Windows6 adapters are installed, startup
|
||||
fails until `--tap-instance-id` selects the intended adapter by NetCfgInstanceId
|
||||
/ InterfaceGuid. `--list-tap-adapters` prints the TAP adapter ids and exits
|
||||
without connecting. It prints and reports client diagnostics snapshots with
|
||||
relay reachability, LAN-gateway presence, route-pinning, QUIC datagram budget,
|
||||
relay RTT, TAP status/IP, broadcast frame flow, frame/datagram counters, and
|
||||
drops. The 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
|
||||
snapshot also emits short user-facing lines such as relay/gateway connection status,
|
||||
relay-route and TAP readiness warnings, DHCP address presence, relay RTT, and
|
||||
broadcast-flow confirmation. One-way broadcast diagnostics distinguish frames
|
||||
sent toward the LAN from broadcast frames received back from the LAN. Malformed frames
|
||||
read from TAP, invalid or unauthorized source-MAC frames, L2 control-plane
|
||||
traffic, remote VLAN tags, DHCP server replies, IPv6 Router Advertisements, IPv6
|
||||
fragments, jumbo frames, frames above the negotiated TAP MTU, and TAP frames
|
||||
whose encoded datagrams exceed the negotiated QUIC budget are counted and
|
||||
dropped before relay send without stopping the bridge. Relayed LAN frames are
|
||||
also safety-checked before TAP writes, so switch-control traffic,
|
||||
snapshot also emits short user-facing lines such as relay/gateway connection
|
||||
status, relay-route and TAP readiness warnings, DHCP address presence, relay
|
||||
RTT, and broadcast-flow confirmation. One-way broadcast diagnostics distinguish
|
||||
frames sent toward the LAN from broadcast frames received back from the LAN.
|
||||
Malformed frames read from TAP, invalid or unauthorized source-MAC frames, L2
|
||||
control-plane traffic, remote VLAN tags, DHCP server replies, IPv6 Router
|
||||
Advertisements, IPv6 fragments, jumbo frames, frames above the negotiated TAP
|
||||
MTU, and TAP frames whose encoded datagrams exceed the negotiated QUIC budget
|
||||
are counted and dropped before relay send without stopping the bridge. Relayed
|
||||
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
|
||||
Windows adapter even if they reached the client over QUIC.
|
||||
Misdirected unicast frames not addressed to the client's virtual MAC are also
|
||||
counted, skipped, and logged with the drop reason; accepted TAP-to-relay and
|
||||
relay-to-TAP frames are logged with direction, peer id, MACs, ethertype/length,
|
||||
frame length, action, and drop reason. TAP device read/write errors still stop
|
||||
the bridge.
|
||||
Relay lifecycle events are logged as they arrive, including gateway joins and
|
||||
peer leaves. The client remembers peer identities from join and catch-up events
|
||||
and from the initial welcome, so later leave logs can identify a disconnected
|
||||
LAN gateway or client MAC when that peer was known.
|
||||
Windows adapter even if they reached the client over QUIC. Misdirected unicast
|
||||
frames not addressed to the client's virtual MAC are also counted, skipped, and
|
||||
logged with the drop reason; accepted TAP-to-relay and relay-to-TAP frames are
|
||||
logged with direction, peer id, MACs, ethertype/length, frame length, action,
|
||||
and drop reason. TAP device read/write errors still stop the bridge. Relay
|
||||
lifecycle events are logged as they arrive, including gateway joins and peer
|
||||
leaves. The client remembers peer identities from join and catch-up events and
|
||||
from the initial welcome, so later leave logs can identify a disconnected LAN
|
||||
gateway or client MAC when that peer was known.
|
||||
|
||||
+24
-25
@@ -58,8 +58,8 @@ Windows TAP IPv4:
|
||||
- Gateway: Linux machine plugged into the LAN party switch with wired Ethernet.
|
||||
- Client: Windows 11 machine with TAP-Windows6 installed.
|
||||
|
||||
Use the same room code everywhere, for example `ROOM1`.
|
||||
Start order is relay first, gateway second, Windows client last.
|
||||
Use the same room code everywhere, for example `ROOM1`. Start order is relay
|
||||
first, gateway second, Windows client last.
|
||||
|
||||
## Log Capture
|
||||
|
||||
@@ -153,8 +153,8 @@ Linux: ./target/release/lanparty-gateway
|
||||
Windows: .\target\release\lanparty-client-win.exe
|
||||
```
|
||||
|
||||
The Windows client must run elevated because it opens TAP and edits routes.
|
||||
The gateway usually needs root because it opens an AF_PACKET raw socket.
|
||||
The Windows client must run elevated because it opens TAP and edits routes. The
|
||||
gateway usually needs root because it opens an AF_PACKET raw socket.
|
||||
|
||||
## Start The Relay
|
||||
|
||||
@@ -196,8 +196,8 @@ sudo ./target/release/lanparty-gateway \
|
||||
```
|
||||
|
||||
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
|
||||
relay if sysfs reports no Ethernet carrier.
|
||||
as a shorter alias. Do not use Wi-Fi. The gateway fails before joining the relay
|
||||
if sysfs reports no Ethernet carrier.
|
||||
|
||||
Expected gateway output:
|
||||
|
||||
@@ -245,7 +245,8 @@ one explicitly:
|
||||
Expected client output:
|
||||
|
||||
```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 verified before TAP activation ...
|
||||
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.
|
||||
`already existed` usually means a matching relay host route was already present,
|
||||
for example after a previous crashed test run.
|
||||
You may also see TAP IPv4/IPv6 MTU, metric, and default-route protection lines
|
||||
between the connect and TAP-open lines. Those are expected.
|
||||
The lifecycle event may appear after the bridge starts because event logging
|
||||
begins once TAP and route protection are ready.
|
||||
for example after a previous crashed test run. You may also see TAP IPv4/IPv6
|
||||
MTU, metric, and default-route protection lines between the connect and TAP-open
|
||||
lines. Those are expected. The lifecycle event may appear after the bridge
|
||||
starts because event logging begins once TAP and route protection are ready.
|
||||
|
||||
The first diagnostics line may show `IP unknown`. After DHCP succeeds, a later
|
||||
line should show:
|
||||
@@ -274,8 +274,8 @@ line should show:
|
||||
DHCP received: 10.x.x.x
|
||||
```
|
||||
|
||||
If Windows reports both a `169.254.x.x` TAP address and a real LAN IPv4
|
||||
address, the client diagnostics should prefer the real LAN address.
|
||||
If Windows reports both a `169.254.x.x` TAP address and a real LAN IPv4 address,
|
||||
the client diagnostics should prefer the real LAN address.
|
||||
|
||||
## Verify The Tunnel
|
||||
|
||||
@@ -395,10 +395,9 @@ drop_reason=RateLimit
|
||||
|
||||
On gateway `LanToRemote` logs, `UnknownDestination` usually means the gateway
|
||||
captured unrelated LAN unicast and dropped it locally instead of sending it to
|
||||
the relay.
|
||||
`TapMtuExceeded` means a host emitted an Ethernet frame larger than the
|
||||
negotiated tunnel MTU; occasional drops can happen while testing software that
|
||||
does not honor the smaller adapter MTU yet.
|
||||
the relay. `TapMtuExceeded` means a host emitted an Ethernet frame larger than
|
||||
the negotiated tunnel MTU; occasional drops can happen while testing software
|
||||
that does not honor the smaller adapter MTU yet.
|
||||
|
||||
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
|
||||
did not match the client MAC announced by lifecycle events. If it repeats,
|
||||
check relay lifecycle logs and duplicate-MAC rejection first.
|
||||
did not match the client MAC announced by lifecycle events. If it repeats, check
|
||||
relay lifecycle logs and duplicate-MAC rejection first.
|
||||
|
||||
## 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.
|
||||
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
|
||||
port, look for `gateway CAM refresh ... reason=peer_joined` immediately after
|
||||
join and `gateway CAM refresh ... reason=periodic` about once per minute after
|
||||
that. If those lines are present but the switch still does not learn it, check
|
||||
the selected gateway interface and switch port first.
|
||||
If switch MAC learning does not show the Windows client MAC on the gateway port,
|
||||
look for `gateway CAM refresh ... reason=peer_joined` immediately after join and
|
||||
`gateway CAM refresh ... reason=periodic` about once per minute after that. If
|
||||
those lines are present but the switch still does not learn it, check the
|
||||
selected gateway interface and switch port first.
|
||||
|
||||
## Cleanup
|
||||
|
||||
|
||||
@@ -21,15 +21,29 @@ use std::{
|
||||
use anyhow::{Context, Result, bail};
|
||||
use bytes::Bytes;
|
||||
use lanparty_ctrl::{
|
||||
CONTROL_LENGTH_PREFIX_LEN, ControlMessage, DisconnectReason, EndpointHello,
|
||||
MAX_CONTROL_MESSAGE_LEN, RELAY_ALPN, RoomCode, ServerWelcome, decode_control_frame,
|
||||
CONTROL_LENGTH_PREFIX_LEN,
|
||||
ControlMessage,
|
||||
DisconnectReason,
|
||||
EndpointHello,
|
||||
MAX_CONTROL_MESSAGE_LEN,
|
||||
RELAY_ALPN,
|
||||
RoomCode,
|
||||
ServerWelcome,
|
||||
decode_control_frame,
|
||||
encode_control_message,
|
||||
};
|
||||
use lanparty_obs::{DropReason, QuicDiagnostics, TunnelStats};
|
||||
use lanparty_proto::{
|
||||
EthernetFrame, FrameType, 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,
|
||||
EthernetFrame,
|
||||
FrameType,
|
||||
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 rustls::pki_types::CertificateDer;
|
||||
|
||||
@@ -6,10 +6,13 @@ edition.workspace = true
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
windows-sys = { workspace = true, features = [
|
||||
"Win32_Foundation",
|
||||
"Win32_NetworkManagement_IpHelper",
|
||||
"Win32_NetworkManagement_Ndis",
|
||||
"Win32_Networking_WinSock",
|
||||
] }
|
||||
[target."cfg(windows)".dependencies]
|
||||
windows-sys = {
|
||||
workspace = true,
|
||||
features = [
|
||||
"Win32_Foundation",
|
||||
"Win32_NetworkManagement_IpHelper",
|
||||
"Win32_NetworkManagement_Ndis",
|
||||
"Win32_Networking_WinSock",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -286,9 +286,15 @@ mod windows;
|
||||
pub use windows::{PinnedRelayRoute, best_route_to, interface_identity_from_guid, pin_relay_route};
|
||||
#[cfg(windows)]
|
||||
pub use windows::{
|
||||
ScopedDefaultRoutes, ScopedInterfaceMetric, ScopedInterfaceMtu, interface_metric,
|
||||
interface_mtu, interface_unicast_addresses, set_scoped_default_routes_disabled,
|
||||
set_scoped_interface_metric, set_scoped_interface_mtu,
|
||||
ScopedDefaultRoutes,
|
||||
ScopedInterfaceMetric,
|
||||
ScopedInterfaceMtu,
|
||||
interface_metric,
|
||||
interface_mtu,
|
||||
interface_unicast_addresses,
|
||||
set_scoped_default_routes_disabled,
|
||||
set_scoped_interface_metric,
|
||||
set_scoped_interface_mtu,
|
||||
};
|
||||
|
||||
#[cfg(not(windows))]
|
||||
|
||||
@@ -1,34 +1,62 @@
|
||||
use std::{
|
||||
fmt, io,
|
||||
fmt,
|
||||
io,
|
||||
net::{IpAddr, Ipv4Addr, Ipv6Addr},
|
||||
ptr::{null, null_mut},
|
||||
slice,
|
||||
};
|
||||
|
||||
use anyhow::{Context, Result, bail};
|
||||
use windows_sys::Win32::{
|
||||
Foundation::{ERROR_OBJECT_ALREADY_EXISTS, ERROR_SUCCESS},
|
||||
NetworkManagement::{
|
||||
IpHelper::{
|
||||
ConvertInterfaceGuidToLuid, ConvertInterfaceLuidToIndex, CreateIpForwardEntry2,
|
||||
DeleteIpForwardEntry2, FreeMibTable, GetBestRoute2, GetIpInterfaceEntry,
|
||||
GetUnicastIpAddressTable, IP_ADDRESS_PREFIX, InitializeIpForwardEntry,
|
||||
InitializeIpInterfaceEntry, MIB_IPFORWARD_ROW2, MIB_IPINTERFACE_ROW,
|
||||
MIB_UNICASTIPADDRESS_ROW, MIB_UNICASTIPADDRESS_TABLE, SetIpInterfaceEntry,
|
||||
use windows_sys::{
|
||||
Win32::{
|
||||
Foundation::{ERROR_OBJECT_ALREADY_EXISTS, ERROR_SUCCESS},
|
||||
NetworkManagement::{
|
||||
IpHelper::{
|
||||
ConvertInterfaceGuidToLuid,
|
||||
ConvertInterfaceLuidToIndex,
|
||||
CreateIpForwardEntry2,
|
||||
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::{
|
||||
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> {
|
||||
let guid = parse_interface_guid(interface_guid)?;
|
||||
|
||||
@@ -7,11 +7,14 @@ edition.workspace = true
|
||||
anyhow.workspace = true
|
||||
lanparty-proto = { path = "../lanparty-proto" }
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
windows-sys = { workspace = true, features = [
|
||||
"Win32_Foundation",
|
||||
"Win32_Security",
|
||||
"Win32_Storage_FileSystem",
|
||||
"Win32_System_IO",
|
||||
"Win32_System_Registry",
|
||||
] }
|
||||
[target."cfg(windows)".dependencies]
|
||||
windows-sys = {
|
||||
workspace = true,
|
||||
features = [
|
||||
"Win32_Foundation",
|
||||
"Win32_Security",
|
||||
"Win32_Storage_FileSystem",
|
||||
"Win32_System_IO",
|
||||
"Win32_System_Registry",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -8,25 +8,51 @@ use anyhow::{Context, Result, bail};
|
||||
use lanparty_proto::MacAddr;
|
||||
use windows_sys::Win32::{
|
||||
Foundation::{
|
||||
CloseHandle, ERROR_FILE_NOT_FOUND, ERROR_MORE_DATA, ERROR_NO_MORE_ITEMS, ERROR_SUCCESS,
|
||||
GENERIC_READ, GENERIC_WRITE, HANDLE, INVALID_HANDLE_VALUE,
|
||||
CloseHandle,
|
||||
ERROR_FILE_NOT_FOUND,
|
||||
ERROR_MORE_DATA,
|
||||
ERROR_NO_MORE_ITEMS,
|
||||
ERROR_SUCCESS,
|
||||
GENERIC_READ,
|
||||
GENERIC_WRITE,
|
||||
HANDLE,
|
||||
INVALID_HANDLE_VALUE,
|
||||
},
|
||||
Storage::FileSystem::{
|
||||
CreateFileW, FILE_ATTRIBUTE_SYSTEM, FILE_SHARE_READ, FILE_SHARE_WRITE, OPEN_EXISTING,
|
||||
ReadFile, WriteFile,
|
||||
CreateFileW,
|
||||
FILE_ATTRIBUTE_SYSTEM,
|
||||
FILE_SHARE_READ,
|
||||
FILE_SHARE_WRITE,
|
||||
OPEN_EXISTING,
|
||||
ReadFile,
|
||||
WriteFile,
|
||||
},
|
||||
System::{
|
||||
IO::DeviceIoControl,
|
||||
Registry::{
|
||||
HKEY, HKEY_LOCAL_MACHINE, KEY_READ, KEY_SET_VALUE, REG_SZ, RegCloseKey, RegEnumKeyExW,
|
||||
RegOpenKeyExW, RegQueryValueExW, RegSetValueExW,
|
||||
HKEY,
|
||||
HKEY_LOCAL_MACHINE,
|
||||
KEY_READ,
|
||||
KEY_SET_VALUE,
|
||||
REG_SZ,
|
||||
RegCloseKey,
|
||||
RegEnumKeyExW,
|
||||
RegOpenKeyExW,
|
||||
RegQueryValueExW,
|
||||
RegSetValueExW,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
TAP_ADAPTER_KEY, 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,
|
||||
TAP_ADAPTER_KEY,
|
||||
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)]
|
||||
|
||||
@@ -14,5 +14,5 @@ lanparty-obs = { path = "../lanparty-obs" }
|
||||
lanparty-proto = { path = "../lanparty-proto" }
|
||||
tokio.workspace = true
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
[target."cfg(windows)".dependencies]
|
||||
lanparty-client-route = { path = "../lanparty-client-route" }
|
||||
|
||||
@@ -12,14 +12,23 @@ use std::{sync::mpsc, thread, time::Duration};
|
||||
use anyhow::{Context, Result, bail};
|
||||
use clap::Parser;
|
||||
use lanparty_client_core::{
|
||||
ClientIdentity, ClientIdentityStore, ClientSession, ClientSessionConfig, connect_client,
|
||||
ClientIdentity,
|
||||
ClientIdentityStore,
|
||||
ClientSession,
|
||||
ClientSessionConfig,
|
||||
connect_client,
|
||||
};
|
||||
#[cfg(windows)]
|
||||
use lanparty_client_core::{ClientReceiveOutcome, ClientRelayIo};
|
||||
#[cfg(windows)]
|
||||
use lanparty_client_route::{
|
||||
IpInterfaceFamily, NetworkInterfaceIdentity, PinnedRelayRoute, RouteSnapshot,
|
||||
ScopedDefaultRoutes, ScopedInterfaceMetric, ScopedInterfaceMtu,
|
||||
IpInterfaceFamily,
|
||||
NetworkInterfaceIdentity,
|
||||
PinnedRelayRoute,
|
||||
RouteSnapshot,
|
||||
ScopedDefaultRoutes,
|
||||
ScopedInterfaceMetric,
|
||||
ScopedInterfaceMtu,
|
||||
};
|
||||
#[cfg(windows)]
|
||||
use lanparty_client_tap::TapAdapter;
|
||||
@@ -1263,11 +1272,12 @@ mod tests {
|
||||
time::{SystemTime, UNIX_EPOCH},
|
||||
};
|
||||
|
||||
use super::*;
|
||||
use lanparty_ctrl::{DisconnectReason, PeerInfo};
|
||||
use lanparty_net::DEFAULT_RELAY_PORT;
|
||||
use lanparty_obs::{QuicDiagnostics, TunnelStats};
|
||||
|
||||
use super::*;
|
||||
|
||||
#[cfg(not(windows))]
|
||||
#[test]
|
||||
fn rejects_runtime_on_non_windows() {
|
||||
|
||||
@@ -9,8 +9,12 @@ use std::{fmt, str::FromStr};
|
||||
mod codec;
|
||||
|
||||
pub use codec::{
|
||||
CONTROL_LENGTH_PREFIX_LEN, ControlCodecError, MAX_CONTROL_MESSAGE_LEN,
|
||||
complete_control_frame_len, decode_control_frame, encode_control_message,
|
||||
CONTROL_LENGTH_PREFIX_LEN,
|
||||
ControlCodecError,
|
||||
MAX_CONTROL_MESSAGE_LEN,
|
||||
complete_control_frame_len,
|
||||
decode_control_frame,
|
||||
encode_control_message,
|
||||
};
|
||||
pub use lanparty_obs::TunnelStats;
|
||||
use lanparty_proto::{MIN_USEFUL_TAP_MTU, MacAddr, MtuError, recommended_tap_mtu};
|
||||
|
||||
@@ -23,27 +23,42 @@ use anyhow::{Context, Result, bail};
|
||||
use bytes::Bytes;
|
||||
use clap::Parser;
|
||||
use lanparty_ctrl::{
|
||||
CONTROL_LENGTH_PREFIX_LEN, ControlMessage, DisconnectReason, EndpointHello,
|
||||
MAX_CONTROL_MESSAGE_LEN, PeerInfo, RELAY_ALPN, Role, RoomCode, ServerWelcome,
|
||||
decode_control_frame, encode_control_message,
|
||||
CONTROL_LENGTH_PREFIX_LEN,
|
||||
ControlMessage,
|
||||
DisconnectReason,
|
||||
EndpointHello,
|
||||
MAX_CONTROL_MESSAGE_LEN,
|
||||
PeerInfo,
|
||||
RELAY_ALPN,
|
||||
Role,
|
||||
RoomCode,
|
||||
ServerWelcome,
|
||||
decode_control_frame,
|
||||
encode_control_message,
|
||||
};
|
||||
use lanparty_net::RelayEndpoint;
|
||||
use lanparty_obs::{DropReason, TunnelStats};
|
||||
#[cfg(target_os = "linux")]
|
||||
use lanparty_obs::{FrameAction, FrameDirection, FrameLog};
|
||||
use lanparty_proto::{
|
||||
EthernetFrame, FrameType, 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,
|
||||
EthernetFrame,
|
||||
FrameType,
|
||||
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 rustls::pki_types::CertificateDer;
|
||||
#[cfg(target_os = "linux")]
|
||||
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 DISCONNECT_DRAIN_TIMEOUT: Duration = Duration::from_millis(250);
|
||||
#[cfg(target_os = "linux")]
|
||||
@@ -1146,7 +1161,7 @@ mod tests {
|
||||
let help = String::from_utf8(help).unwrap();
|
||||
|
||||
assert!(
|
||||
help.contains("[aliases: --iface]"),
|
||||
help.contains("[alias: --iface]") || help.contains("[aliases: --iface]"),
|
||||
"gateway help should advertise --iface alias:\n{help}"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use std::{
|
||||
ffi::CString,
|
||||
fs, io,
|
||||
fs,
|
||||
io,
|
||||
os::fd::{AsRawFd, FromRawFd, OwnedFd, RawFd},
|
||||
path::Path,
|
||||
};
|
||||
|
||||
@@ -11,22 +11,46 @@ mod overlay;
|
||||
mod safety;
|
||||
|
||||
pub use ethernet::{
|
||||
ETHERNET_HEADER_LEN, EthernetFrame, MAX_STANDARD_ETHERNET_FRAME_LEN,
|
||||
MAX_STANDARD_ETHERNET_PAYLOAD_LEN, MIN_ETHERNET_FRAME_LEN,
|
||||
ETHERNET_HEADER_LEN,
|
||||
EthernetFrame,
|
||||
MAX_STANDARD_ETHERNET_FRAME_LEN,
|
||||
MAX_STANDARD_ETHERNET_PAYLOAD_LEN,
|
||||
MIN_ETHERNET_FRAME_LEN,
|
||||
};
|
||||
pub use mac::{MacAddr, MacParseError};
|
||||
pub use mtu::{
|
||||
DEFAULT_DATAGRAM_SAFETY_MARGIN, 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,
|
||||
DEFAULT_DATAGRAM_SAFETY_MARGIN,
|
||||
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,
|
||||
};
|
||||
pub use overlay::{
|
||||
FrameType, OVERLAY_FLAGS_NONE, OVERLAY_HEADER_LEN, OVERLAY_MAGIC, OVERLAY_VERSION,
|
||||
OverlayHeader, OverlayPacket, ProtoError, decode_datagram, encode_datagram,
|
||||
FrameType,
|
||||
OVERLAY_FLAGS_NONE,
|
||||
OVERLAY_HEADER_LEN,
|
||||
OVERLAY_MAGIC,
|
||||
OVERLAY_VERSION,
|
||||
OverlayHeader,
|
||||
OverlayPacket,
|
||||
ProtoError,
|
||||
decode_datagram,
|
||||
encode_datagram,
|
||||
validate_datagram_budget,
|
||||
};
|
||||
pub use safety::{
|
||||
ETHERTYPE_8021AD, ETHERTYPE_8021Q, ETHERTYPE_EAPOL, ETHERTYPE_IPV4, ETHERTYPE_IPV6,
|
||||
ETHERTYPE_LLDP, ETHERTYPE_QINQ, ETHERTYPE_SLOW_PROTOCOLS, EthernetSafetyDrop,
|
||||
gateway_lan_safety_drop_reason, remote_client_safety_drop_reason,
|
||||
ETHERTYPE_8021AD,
|
||||
ETHERTYPE_8021Q,
|
||||
ETHERTYPE_EAPOL,
|
||||
ETHERTYPE_IPV4,
|
||||
ETHERTYPE_IPV6,
|
||||
ETHERTYPE_LLDP,
|
||||
ETHERTYPE_QINQ,
|
||||
ETHERTYPE_SLOW_PROTOCOLS,
|
||||
EthernetSafetyDrop,
|
||||
gateway_lan_safety_drop_reason,
|
||||
remote_client_safety_drop_reason,
|
||||
};
|
||||
|
||||
@@ -9,18 +9,28 @@ mod server;
|
||||
|
||||
use std::{collections::HashMap, time::Instant};
|
||||
|
||||
pub use config::{ConfigError, DEFAULT_RELAY_PORT, ListenEndpoint, RelayArgs, RelayConfig};
|
||||
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_proto::{
|
||||
EthernetFrame, MacAddr, ethernet_frame_exceeds_tap_mtu, gateway_lan_safety_drop_reason,
|
||||
recommended_tap_mtu, remote_client_safety_drop_reason,
|
||||
EthernetFrame,
|
||||
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;
|
||||
use thiserror::Error;
|
||||
|
||||
pub const DEFAULT_MAX_CLIENTS_PER_ROOM: usize = 16;
|
||||
const MEBIBYTE: u64 = 1024 * 1024;
|
||||
@@ -769,9 +779,10 @@ fn reject_control_error(error: ControlError) -> Reject {
|
||||
mod tests {
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use super::*;
|
||||
use lanparty_proto::MAX_STANDARD_ETHERNET_FRAME_LEN;
|
||||
|
||||
use super::*;
|
||||
|
||||
fn room() -> RoomCode {
|
||||
RoomCode::new("ABCD").unwrap()
|
||||
}
|
||||
|
||||
@@ -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 bytes::Bytes;
|
||||
use lanparty_ctrl::{
|
||||
CONTROL_LENGTH_PREFIX_LEN, ControlCodecError, ControlMessage, DisconnectReason, EndpointHello,
|
||||
MAX_CONTROL_MESSAGE_LEN, PeerInfo, RELAY_ALPN, Reject, RejectReason, Role, RoomCode,
|
||||
ServerWelcome, decode_control_frame, encode_control_message,
|
||||
CONTROL_LENGTH_PREFIX_LEN,
|
||||
ControlCodecError,
|
||||
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_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 std::collections::HashMap;
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
use crate::{ForwardingDecision, RelayConfig, RoomRegistry};
|
||||
@@ -1014,13 +1036,17 @@ mod tests {
|
||||
use lanparty_ctrl::{RoomCode, decode_control_frame, encode_control_message};
|
||||
use lanparty_gateway::{GatewayConfig, connect_gateway};
|
||||
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 crate::{DEFAULT_MAX_CLIENTS_PER_ROOM, ListenEndpoint};
|
||||
|
||||
use super::*;
|
||||
use crate::{DEFAULT_MAX_CLIENTS_PER_ROOM, ListenEndpoint};
|
||||
|
||||
const ETHERTYPE_ARP: u16 = 0x0806;
|
||||
const ARP_REQUEST: u16 = 1;
|
||||
|
||||
@@ -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
|
||||
@@ -0,0 +1,3 @@
|
||||
group_imports = "StdExternalCrate"
|
||||
imports_granularity = "Crate"
|
||||
imports_layout = "HorizontalVertical"
|
||||
Reference in New Issue
Block a user