From 7bffa3759773e8f0e8dc2585d9e7c2f1f79e63c2 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 28 Feb 2020 18:58:05 -0800 Subject: [PATCH] feat: add wss protocol Now that we define all protocols in this package, we might as well add wss. fixes #72 --- multiaddr_test.go | 4 ++++ protocols.go | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/multiaddr_test.go b/multiaddr_test.go index 546e792..5c7e36d 100644 --- a/multiaddr_test.go +++ b/multiaddr_test.go @@ -149,6 +149,10 @@ func TestConstructSucceeds(t *testing.T) { "/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/9090/http/p2p-webrtc-direct", + "/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 9516937..d6df859 100644 --- a/protocols.go +++ b/protocols.go @@ -29,6 +29,7 @@ const ( P_GARLIC32 = 0x01BF P_P2P_WEBRTC_DIRECT = 0x0114 P_WS = 0x01DD + P_WSS = 0x01DE ) var ( @@ -201,6 +202,11 @@ var ( Code: P_WS, VCode: CodeToVarint(P_WS), } + protoWSS = Protocol{ + Name: "wss", + Code: P_WSS, + VCode: CodeToVarint(P_WSS), + } ) func init() { @@ -230,6 +236,7 @@ func init() { protoUNIX, protoP2P_WEBRTC_DIRECT, protoWS, + protoWSS, } { if err := AddProtocol(p); err != nil { panic(err)