Skip to content

Conversation

lla-dane
Copy link
Contributor

@lla-dane lla-dane commented Oct 7, 2025

Tracks: multiformats/multiaddr#181

Added SNI, NOISE, CERTHASH, WEBRTC, WEBRTC-DIRECT protocol in py-multiaddr in reference with go-multiaddr

SNI had the same codec configs as DNS in go-multiaddr

protoSNI = Protocol{
	Name:       "sni",
	Size:       LengthPrefixedVarSize,
	Code:       P_SNI,
	VCode:      CodeToVarint(P_SNI),
	Transcoder: TranscoderDns,
}

So just added this line in the protocol registry

Protocol(P_SNI, "sni", "domain"),

Did the same thing with NOISE

Added the CERTHASH protocol as per go implementation

var TranscoderCertHash = NewTranscoderFromFunctions(certHashStB, certHashBtS, validateCertHash)

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
}

"/ip4/127.0.0.1/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC/tcp/1234/unix/stdio",
"/dns/example.com",
"/dns4/موقع.وزارة-الاتصالات.مصر",
"/ip4/127.0.0.1/tcp/443/tls/sni/example.com/http/http-path/foo",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also added a test case for sni multiaddr as given in go-multiaddr tests

@lla-dane
Copy link
Contributor Author

lla-dane commented Oct 7, 2025

@acul71: Can you please take a look why these checks are failing with my changes, I am not understanding.

@lla-dane lla-dane changed the title Add sni protocol in py-multiaddr Add SNI and NOISE protocol in py-multiaddr Oct 7, 2025
- 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
@lla-dane
Copy link
Contributor Author

Added the certhash protcol, along with the test-suite

@lla-dane lla-dane changed the title Add SNI and NOISE protocol in py-multiaddr Add SNI, NOISE and CERTHASH protocol in py-multiaddr Oct 10, 2025
- Added the protocols in the registry in protcols.py
- Added the maddr test cases in test_multiaddr.py
@lla-dane lla-dane changed the title Add SNI, NOISE and CERTHASH protocol in py-multiaddr Add SNI, NOISE, CERTHASH, WEBRTC, WEBRTC-DIRECT in py-multiaddr Oct 11, 2025
@lla-dane
Copy link
Contributor Author

lla-dane commented Oct 11, 2025

Added webrtc and webrtc-direct in 4507543, along with maddr test cases in test_multiaddr.py

@lla-dane
Copy link
Contributor Author

@seetadev @acul71: Did some tweaks in aa2202d to resolve the CI checks, please take a look and see if anything else remains, other than make docs content addition in this PR.

Will add the doc content for all protocols in a separate PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant