Add three-tier discovery system with UDP broadcast and manual peer entry fallbacks#37
Merged
infinityabundance merged 6 commits intomainfrom Feb 13, 2026
Merged
Conversation
Co-authored-by: infinityabundance <255699974+infinityabundance@users.noreply.github.com>
Co-authored-by: infinityabundance <255699974+infinityabundance@users.noreply.github.com>
Co-authored-by: infinityabundance <255699974+infinityabundance@users.noreply.github.com>
Co-authored-by: infinityabundance <255699974+infinityabundance@users.noreply.github.com>
Co-authored-by: infinityabundance <255699974+infinityabundance@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add UDP broadcast fallback and manual peer entry for discovery
Add three-tier discovery system with UDP broadcast and manual peer entry fallbacks
Feb 13, 2026
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Peer discovery fails completely when Avahi is unavailable (daemon down, not installed, or isolated networks). Implements three-tier discovery with automatic fallback: mDNS/Avahi → UDP broadcast → manual entry.
Details
What changed?
Tier 2: UDP Broadcast Discovery (
src/discovery_broadcast.c, 238 lines)getifaddrs()Tier 3: Manual Peer Entry (
src/discovery_manual.c, 215 lines)--peer-add IP:PORT,--peer-code CODE,--peer-listFallback Logic (
src/discovery.c)Header Changes (
include/rootstream.h)peer_history_entry_tstructure (hostname, address, port, code)rootstream_ctx_taspeer_history_entries[32]Security
strcpy()withstrncpy()in address parsingRationale
Testing
Describe how you tested this change:
make HEADLESS=1)--peer-add,--peer-list)Notes
Original prompt
PHASE 5: Discovery Resilience & Peer Finding
Current State
src/discovery.c- mDNS/Avahi discovery (fully implemented)src/network.c- Core networking with peer managementProblem
Currently in discovery:
On systems with:
Peer discovery becomes impossible.
Solution: Three-Tier Discovery with Manual Fallback
Tier 1: mDNS/Avahi (Primary)
src/discovery.c(already exists)Tier 2: UDP Broadcast Discovery (New)
src/discovery_broadcast.c(NEW)Tier 3: Manual Peer Entry (New)
src/discovery_manual.c(NEW)Implementation
File 1:
src/discovery_broadcast.c- UDP Broadcast Discovery