Add thin waist address (127.0.0.1, 192.168.1.44, etc) validation to examples #807
Replies: 3 comments 1 reply
-
Currently, exploring the codebase and setting it up. |
Beta Was this translation helpful? Give feedback.
-
Issue here #804 |
Beta Was this translation helpful? Give feedback.
-
Developer Docs: Thin Waist Address Validation Utilities & Echo Example Integration (PR #811)PR: #811 1. Problem StatementBefore this PR, examples (notably echo) relied on hardcoded wildcard addresses (e.g. /ip4/0.0.0.0/tcp/{port}). This limited:
Goal: Introduce reusable, future‑extensible Thin Waist address/interface discovery & validation utilities and migrate an example to demonstrate best practice—without breaking existing user code. 2. Release Plan & Phase StatusRelease Plan Current PR (#811) Coverage:
3. High-Level ArchitectureA new utility module centralizes:
This isolates complexity from examples, encouraging uniform adoption. 4. Key Modules & FunctionsNEW: libp2p/utils/address_validation.py
MODIFIED: libp2p/utils/init.py
UPDATED EXAMPLE: examples/echo/echo.py
ADDED ADVANCED DEMO: examples/advanced/network_discovery.py
TESTS:
5. Data & Control Flow (Echo Path)
6. Selection Heuristics (Current vs Future)Current (Simplified):
Future Enhancements:
7. Error Handling & RobustnessImplemented:
8. Logging & ObservabilityCurrent: Echo logs chosen address & enumeration summary.
9. Collaboration & Review NotesReviewer Highlights:
Acknowledgements retained for traceability & attribution. 10. Pre-Merge ChecklistUtilities / Code: Testing: Docs & Release: Quality: 11. SummaryPR #811 establishes Phase 1 (core utilities, non-breaking), seeds Phase 2 (example migration), and begins Phase 3 (advanced demonstration) of the defined release plan. It provides a scalable foundation to modernize address handling while preserving backward compatibility. The next engineering focus: broaden adoption (Phase 2), enrich advanced demonstrations (Phase 3), and only then progress to deprecation (Phase 4). 12. Contributors
My experience:- At first when I joined, it was tough to understand things, and after getting to work and hang of the stuff I made my way through from assistance (or help) from the maintainers and mentors, I developed a approah and presented and the feedback I got and the way the contributors and maitainers helped was really good and awesome, was like actual people who wants to teach and work with us, not demand or tell us to do stuff. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Looking at the issue, it seems that the currently all our examples bind to /ip4/0.0.0.0/tcp/{port}, which hides what network interfaces are actually available, doesn’t support IPv6, and doesn’t teach proper multiaddr usage.
What we could is add a small helper module that:
Finds all available interface addresses for a given port (IPv4 and optionally IPv6)
Expands wildcard addresses like 0.0.0.0 into real ones
Picks a good default address, like the first non-loopback interface, but still falls back to 0.0.0.0 if needed
Adding test cases scenarios
We’ll replace the hardcoded address in examples with this helper, log the chosen address and all found interfaces, and add an advanced example for IPv6 and port overrides.
We’ll keep the old behavior if discovery fails, so nothing breaks. This will make examples more transparent, future-proof for IPv6, and more instructive.
Already, shared approach with @seetadev
Beta Was this translation helpful? Give feedback.
All reactions