Replies: 1 comment
-
WebSocket Multiaddr ExamplesSource: libp2p specifications Transport Addresses (No Peer ID)Insecure WebSocket
Secure WebSocket (WSS)
WSS with SNI (Server Name Indication)
WSS with HTTP Path
Peer Addresses (With Peer ID)WS + Peer ID
WSS + Peer ID
Real-World Examples from libp2p Bootstrap Nodes
Port 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-libp2p
is PARTIALLY COMPLIANT with the official libp2p WebSocket specification. We have implemented a robust foundation with/ws
protocol 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
WebsocketTransport
classws
protocol/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/ws
ssl
module 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)/ws
only, 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/tls
package for WSS (standard TLS)https
module for WSS (standard TLS)ssl
module +trio-websocket
SSL 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
,/dns6
Connection 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
/wss
NotImplementedError
/tls/ws
)/tls/ws
/tls/sni/domain/ws
/dns/domain/ws
/dns/domain/wss
/ip6/addr/ws
Multiaddr Format Differences Explained
1.
/wss
vs/tls/ws
/wss
is a shorthand for/tls/ws
2.
/tls/sni/domain/ws
vs/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/ws
3. 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:
ssl
module (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
ssl
module + trio-websocket's SSL support is all that's needed for WebSocket Secure transport layer security.Evidence from other implementations:
crypto/tls
package for WSShttps
module 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
/ws
protocol, DNS addressing, IPv6, and proper libp2p integration. The implementation is production-ready for non-TLS scenarios and demonstrates solid engineering practices.Key Strengths:
/ws
protocol 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