diff --git a/p2p/net/swarm/addr/addr.go b/p2p/net/swarm/addr/addr.go index 7759625f11..08ca90ac46 100644 --- a/p2p/net/swarm/addr/addr.go +++ b/p2p/net/swarm/addr/addr.go @@ -7,6 +7,8 @@ import ( ma "github.com/jbenet/go-multiaddr" manet "github.com/jbenet/go-multiaddr-net" context "golang.org/x/net/context" + + _ "github.com/whyrusleeping/ws-transport" ) var log = logging.Logger("github.com/libp2p/go-libp2p/p2p/net/swarm/addr") @@ -19,6 +21,8 @@ var SupportedTransportStrings = []string{ "/ip6/tcp", "/ip4/udp/utp", "/ip6/udp/utp", + "/ip4/tcp/ws", + "/ip6/tcp/ws", // "/ip4/udp/udt", disabled because the lib doesnt work on arm // "/ip6/udp/udt", disabled because the lib doesnt work on arm } diff --git a/p2p/net/swarm/addr/addr_test.go b/p2p/net/swarm/addr/addr_test.go index 17039967e3..213b7b9f1a 100644 --- a/p2p/net/swarm/addr/addr_test.go +++ b/p2p/net/swarm/addr/addr_test.go @@ -29,6 +29,7 @@ func TestFilterAddrs(t *testing.T) { newMultiaddr(t, "/ip4/127.0.0.1/tcp/1234"), newMultiaddr(t, "/ip6/::1/tcp/1234"), newMultiaddr(t, "/ip4/1.2.3.4/udp/1234/utp"), + newMultiaddr(t, "/ip4/1.2.3.4/tcp/1234/ws"), } goodAndBad := append(good, bad...) diff --git a/p2p/net/swarm/swarm.go b/p2p/net/swarm/swarm.go index 704beb761e..c342f411c4 100644 --- a/p2p/net/swarm/swarm.go +++ b/p2p/net/swarm/swarm.go @@ -29,6 +29,7 @@ import ( spdy "github.com/whyrusleeping/go-smux-spdystream" yamux "github.com/whyrusleeping/go-smux-yamux" mafilter "github.com/whyrusleeping/multiaddr-filter" + ws "github.com/whyrusleeping/ws-transport" context "golang.org/x/net/context" ) @@ -120,6 +121,7 @@ func NewSwarm(ctx context.Context, listenAddrs []ma.Multiaddr, transports: []transport.Transport{ transport.NewTCPTransport(), transport.NewUtpTransport(), + new(ws.WebsocketTransport), }, bwc: bwc, fdRateLimit: make(chan struct{}, concurrentFdDials), diff --git a/package.json b/package.json index 792962c66b..0428bc12bf 100644 --- a/package.json +++ b/package.json @@ -186,6 +186,12 @@ "hash": "QmSZi9ygLohBUGyHMqE5N6eToPwqcg7bZQTULeVLFu7Q6d", "name": "go-libp2p-peerstore", "version": "1.2.2" + }, + { + "author": "whyrusleeping", + "hash": "QmU6T64asAHorS9vUT2LQtCt6mxNpynxL3LXWBtc3tqiB4", + "name": "ws-transport", + "version": "1.0.5" } ], "gxVersion": "0.4.0",