From 9fd0beed7c6c42b59e10626f7935c415dec297da Mon Sep 17 00:00:00 2001 From: gpestana Date: Fri, 13 Jul 2018 18:16:49 +0300 Subject: [PATCH] feat: Adds ws and wss multiaddr --- multiaddr_test.go | 4 ++++ protocols.go | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/multiaddr_test.go b/multiaddr_test.go index 59e50c4..4699fe7 100644 --- a/multiaddr_test.go +++ b/multiaddr_test.go @@ -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 { diff --git a/protocols.go b/protocols.go index 175c5fe..b5c6602 100644 --- a/protocols.go +++ b/protocols.go @@ -38,6 +38,8 @@ const ( P_HTTP = 0x01E0 P_HTTPS = 0x01BB P_ONION = 0x01BC + P_WS = 0x01DD + P_WSS = 0x01DE ) // These are special sizes @@ -61,6 +63,8 @@ var Protocols = []Protocol{ protoHTTPS, protoP2P, protoUNIX, + protoWS, + protoWSS, } var ( @@ -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{}