Replies: 1 comment
-
WebSocket Multiaddr ExamplesSource: libp2p specifications Transport Addresses (No Peer ID)Insecure WebSocketSecure WebSocket (WSS)WSS with SNI (Server Name Indication)WSS with HTTP PathPeer Addresses (With Peer ID)WS + Peer IDWSS + Peer IDReal-World Examples from libp2p Bootstrap NodesPort Defaulting Behavior
Notes
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
WebSocket Protocol Implementation Compliance Analysis
Date: August 2025
Project: py-libp2p WebSocket Transport Implementation
Specification Reference: libp2p WebSocket Spec
Executive Summary
Our current WebSocket implementation in
py-libp2pis PARTIALLY COMPLIANT with the official libp2p WebSocket specification. We have implemented a robust foundation with/wsprotocol support, DNS addressing, IPv6 support, and proper libp2p integration. However, we are missing critical security features (/wss,/tls/ws,/tls/sni/domain/ws) and port defaulting behavior required for full specification compliance.Compliance Level: 🟡 PARTIALLY COMPLIANT
Current Implementation Status
✅ What We Have Implemented
WebsocketTransportclasswsprotocol/ip4/addr/tcp/port/ws,/ip6/addr/tcp/port/ws, and DNS formats/dns/domain/tcp/port/ws,/dns4/domain/tcp/port/ws,/dns6/domain/tcp/port/wssslmodule and trio-websocket SSL support available❌ What We Are Missing (Critical Gaps)
/wss,/tls/ws, or/tls/sni/domain/ws(explicitly throwsNotImplementedError)/ws, 443 for secure variants)/wsonly, missing secure variantsTLS vs WSS: Critical Distinction
Two Different Security Mechanisms
Based on our research of Go and JavaScript implementations, there are two distinct security layers in libp2p:
1. Transport Layer Security (WSS) - Standard TLS
Evidence from implementations:
crypto/tlspackage for WSS (standard TLS)httpsmodule for WSS (standard TLS)sslmodule +trio-websocketSSL support2. Application Layer Security (libp2p TLS) - Custom Protocol
/tls/1.0.0)Key Differences:
OSI Layer Architecture in libp2p
Based on the libp2p specifications, here's the complete OSI layer mapping:
libp2p Protocol Stack by OSI Layer
/ping/1.0.0,/identify/1.0.0,/kad/1.0.0,/pubsub/1.0.0/tls/1.0.0,/noise/1.0.0,/secio/1.0.0/yamux/1.0.0,/mplex/1.0.0/tcp,/ws,/wss,/quic,/webrtc/ip4,/ip6,/dns,/dns4,/dns6Connection Upgrade Process
Transport Registry Role
The transport registry operates at Layer 4 and handles:
/ws,/wss,/tcp,/quic)It does NOT handle:
Multiaddr Format Analysis
Supported vs Required Formats
/ws/wssNotImplementedError/tls/ws)/tls/ws/tls/sni/domain/ws/dns/domain/ws/dns/domain/wss/ip6/addr/wsMultiaddr Format Differences Explained
1.
/wssvs/tls/ws/wssis a shorthand for/tls/ws2.
/tls/sni/domain/wsvs/dns/domain/ws/tls/sni/domain/ws: Uses resolved IP address with explicit SNI/ip4/resolved_ip/tcp/port/tls/sni/domain.com/ws/dns/domain/ws: Uses DNS name with implicit SNI/dns/domain.com/tcp/port/ws3. Port Defaulting Behavior
/ip4/addr/ws/ip4/192.0.2.0/ws→ port 80/ip4/addr/wss/ip4/192.0.2.0/wss→ port 443/ip4/addr/tls/ws/ip4/192.0.2.0/tls/ws→ port 443/dns/domain/ws/dns/example.com/ws→ port 80/dns/domain/wss/dns/example.com/wss→ port 443Technical Implementation Analysis
Current Infrastructure Readiness
✅ Available Components:
sslmodule (comprehensive TLS support)trio-websocket>=0.11.0(already supports SSL/TLS)✅ trio-websocket SSL Support:
Required Changes for Full Compliance
Phase 1: Multiaddr Format Support (Critical)
Phase 2: Port Defaulting
Phase 3: TLS Infrastructure
Implementation Recommendations
1. Use Standard TLS Infrastructure for WSS
Standard TLS packages are sufficient for WSS - Python's
sslmodule + trio-websocket's SSL support is all that's needed for WebSocket Secure transport layer security.Evidence from other implementations:
crypto/tlspackage for WSShttpsmodule for WSS2. Clarify Security Layer Distinction
Two different security mechanisms:
Transport Layer Security (WSS): Uses standard TLS/HTTPS
Application Layer Security (libp2p TLS): Custom protocol (
/tls/1.0.0) for connection encryption3. Extend Current WebSocket Transport
4. Update Transport Registry
Conclusion
Our current WebSocket implementation provides a robust foundation with comprehensive support for
/wsprotocol, DNS addressing, IPv6, and proper libp2p integration. The implementation is production-ready for non-TLS scenarios and demonstrates solid engineering practices.Key Strengths:
/wsprotocol implementationPrimary Gaps:
/wss,/tls/ws,/tls/sni/domain/ws) - This is the main missing pieceImplementation Path:
The path to full compliance is straightforward since all required infrastructure is already available. The main work involves:
Standard TLS packages are sufficient for WSS - the existing Python SSL infrastructure is all that's needed for WebSocket Secure transport layer security. The custom libp2p TLS protocol (
/tls/1.0.0) is used for additional application-layer security after the WebSocket connection is established.Beta Was this translation helpful? Give feedback.
All reactions