-
Notifications
You must be signed in to change notification settings - Fork 30
Add SNI, NOISE, CERTHASH, WEBRTC, WEBRTC-DIRECT in py-multiaddr #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
@acul71: Can you please take a look why these checks are failing with my changes, I am not understanding. |
- Added the protocol utils in certhash.py - Added the internal logic test suite in test_protocols.py - Added the certhash multiaddr test cases in test_multiaddr.py
Added the certhash protcol, along with the test-suite |
- Added the protocols in the registry in protcols.py - Added the maddr test cases in test_multiaddr.py
Added webrtc and webrtc-direct in 4507543, along with maddr test cases in test_multiaddr.py |
- Fix multihash.encode() to multihash.digest().encode() in tests - Rename newsfragment from 97.feature.rst to 181.feature.rst to match issue #181 - All tests now pass with correct multihash API usage
- Use multihash.encode() instead of multihash.digest().encode() - This matches the py-multihash library API used in CI - All tests now pass with correct multihash library version
PR #97 Review: Add SNI, NOISE, CERTHASH, WEBRTC, WEBRTC-DIRECT in py-multiaddrSummaryThis PR adds support for 5 new multiaddr protocols to py-multiaddr:
The implementation follows the go-multiaddr reference implementation and includes comprehensive test coverage. Detailed Review✅ Protocol Codes VerificationAll protocol codes match the go-multiaddr reference implementation:
✅ Protocol ConfigurationsProtocol configurations correctly match the go-multiaddr implementation:
✅ CERTHASH ImplementationThe CERTHASH codec implementation correctly matches the go-multiaddr transcoder: Go Implementation: func certHashStB(s string) ([]byte, error) {
_, data, err := multibase.Decode(s)
if err != nil {
return nil, err
}
if _, err := mh.Decode(data); err != nil {
return nil, err
}
return data, nil
}
func certHashBtS(b []byte) (string, error) {
return multibase.Encode(multibase.Base64url, b)
}
func validateCertHash(b []byte) error {
_, err := mh.Decode(b)
return err
} Python Implementation: def to_bytes(self, proto: Any, string: str) -> bytes:
decoded_bytes = multibase.decode(string)
self.validate(decoded_bytes)
return decoded_bytes
def to_string(self, proto: Any, buf: bytes) -> str:
self.validate(buf)
encoded_string = multibase.encode("base64url", buf)
return encoded_string.decode("utf-8")
def validate(self, b: bytes) -> None:
multihash.decode(b) Analysis:
✅ Test CoverageComprehensive test coverage has been added: Multiaddr String Tests# SNI test case
"/ip4/127.0.0.1/tcp/443/tls/sni/example.com/http/http-path/foo"
# NOISE test case
"/ip4/127.0.0.1/tcp/127/noise"
# CERTHASH test cases
"/ip4/127.0.0.1/udp/1234/quic-v1/webtransport/certhash/b2uaraocy6yrdblb4sfptaddgimjmmpy"
"/ip4/127.0.0.1/udp/1234/quic-v1/webtransport/certhash/b2uaraocy6yrdblb4sfptaddgimjmmpy/certhash/zQmbWTwYGcmdyK9CYfNBcfs9nhZs17a6FQ4Y8oea278xx41"
# WEBRTC test cases
"/ip4/127.0.0.1/tcp/127/webrtc-direct"
"/ip4/127.0.0.1/tcp/127/webrtc" CERTHASH Codec Tests
✅ Code Quality
✅ DependenciesThe implementation correctly uses existing dependencies:
Issues Found✅ Fixed Issues
|
Tracks: multiformats/multiaddr#181
Added
SNI, NOISE, CERTHASH, WEBRTC, WEBRTC-DIRECT
protocol in py-multiaddr in reference with go-multiaddrSNI
had the same codec configs as DNS in go-multiaddrSo just added this line in the protocol registry
Did the same thing with
NOISE
Added the
CERTHASH
protocol as per go implementation