fix(net): use subnet-directed broadcast for LAN discovery (#86)#1
fix(net): use subnet-directed broadcast for LAN discovery (#86)#1Omar-Bsoul wants to merge 1 commit into
Conversation
LAN game discovery sent its announce/request packets to the global 255.255.255.255 broadcast, which routers and virtual NICs (Docker/VPN) frequently drop or route onto the wrong interface, so two machines on the same LAN never see each other. Capture each interface's netmask in IPEnumeration (host byte order) and derive the per-interface subnet-directed broadcast (ip | ~netmask). LANAPI::SetLocalIP now selects the broadcast target from the interface backing the local IP, preferring a real private-LAN NIC over virtual adapters, and falls back to INADDR_BROADCAST when no netmask is known so behavior never regresses. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🔬 Adversarial review — passed (0 confirmed defects)This branch was put through a multi-agent adversarial review before being marked ready:
Result for this PR: no confirmed defects. The only finding raised in the whole review set was on PR #1 ( 🤖 Review performed by Claude Code (multi-agent workflow). |
|
hey there, thanks for working on that. it's hard to me due I have no engought hardware to test all combination needed. I'm currently working on CRC mismatches fbraz3#176 Also found something interesting on I'm also testing disabling all RETAIL_COMPATIBLE flags because mac/linux will never be compatible with retail. |
Summary
Fixes fbraz3#86 — LAN lobby discovery fails between machines because announcements broadcast to the global
255.255.255.255, which routers/OSes often drop or route onto the wrong (Docker/VPN/virtual) NIC. Switches discovery to a per-interface subnet-directed broadcast and prefers the real private-LAN NIC.Changes
IPEnumeration: readsifa_netmaskin thegetifaddrs()loop and stores netmask + derived directed broadcast (ip | ~netmask, host byte order) onEnumeratedIP. Defaults toINADDR_BROADCASTwhen unknown (e.g. Win32 path) so nothing regresses.LANAPI::SetLocalIP: setsm_broadcastAddrfrom the interface backing the selected local IP (exact match preferred; first real private-LAN interface as fallback), falling back toINADDR_BROADCASTonly when no subnet is known. AddsisPrivateLanIP()(10/8, 172.16/12, 192.168/16).Validation
🤖 AI-assisted (drafted with Claude, human-reviewed). Staged in this fork.