Skip to content

feat: Adds ws and wss multiaddr #72

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions multiaddr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ func TestConstructSucceeds(t *testing.T) {
"/ip4/1.2.3.4/tcp/80/unix/a/b/c/d/e/f",
"/ip4/127.0.0.1/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC/tcp/1234/unix/stdio",
"/ip4/127.0.0.1/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC/tcp/1234/unix/stdio",
"/ip4/127.0.0.1/tcp/127/ws",
"/ip4/127.0.0.1/tcp/127/ws/",
"/ip4/127.0.0.1/tcp/127/wss",
"/ip4/127.0.0.1/tcp/127/wss/",
}

for _, a := range cases {
Expand Down
6 changes: 6 additions & 0 deletions protocols.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ const (
P_HTTP = 0x01E0
P_HTTPS = 0x01BB
P_ONION = 0x01BC
P_WS = 0x01DD
P_WSS = 0x01DE
)

// These are special sizes
Expand All @@ -61,6 +63,8 @@ var Protocols = []Protocol{
protoHTTPS,
protoP2P,
protoUNIX,
protoWS,
protoWSS,
}

var (
Expand All @@ -79,6 +83,8 @@ var (
protoHTTPS = Protocol{P_HTTPS, 0, "https", CodeToVarint(P_HTTPS), false, nil}
protoP2P = Protocol{P_P2P, LengthPrefixedVarSize, "ipfs", CodeToVarint(P_P2P), false, TranscoderP2P}
protoUNIX = Protocol{P_UNIX, LengthPrefixedVarSize, "unix", CodeToVarint(P_UNIX), true, TranscoderUnix}
protoWS = Protocol{P_WS, 0, "ws", CodeToVarint(P_WS), false, nil}
protoWSS = Protocol{P_WSS, 0, "wss", CodeToVarint(P_WSS), false, nil}
)

var ProtocolsByName = map[string]Protocol{}
Expand Down