diff --git a/addrs.go b/addrs.go index e789399da3f26eb5a518a2d68bbaf4991e17f302..68cd8b00388fb06b91d01b716dd34cd5e28b1be5 100644 --- a/addrs.go +++ b/addrs.go @@ -5,8 +5,8 @@ import ( "net" "net/url" - ma "github.com/multiformats/go-multiaddr" - manet "github.com/multiformats/go-multiaddr/net" + ma "gitlab.dms3.io/mf/go-multiaddr" + manet "gitlab.dms3.io/mf/go-multiaddr/net" ) // Addr is an implementation of net.Addr for WebSocket. diff --git a/addrs_test.go b/addrs_test.go index d9627600889bd22b68567d5c298b3a7df2e87ab4..6519c18bc76dc7263f374841b8e2c05e302ba7a4 100644 --- a/addrs_test.go +++ b/addrs_test.go @@ -4,7 +4,7 @@ import ( "net/url" "testing" - ma "github.com/multiformats/go-multiaddr" + ma "gitlab.dms3.io/mf/go-multiaddr" ) func TestMultiaddrParsing(t *testing.T) { diff --git a/browser_integration_browser_test.go b/browser_integration_browser_test.go index 39bafc2f89f3c404a900f1f96fd800e5a345132d..c0202a4de797e92067935c0cf9b3717b83ce7d0a 100644 --- a/browser_integration_browser_test.go +++ b/browser_integration_browser_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - ma "github.com/multiformats/go-multiaddr" + ma "gitlab.dms3.io/mf/go-multiaddr" "gitlab.dms3.io/p2p/go-p2p-core/sec/insecure" mplex "gitlab.dms3.io/p2p/go-p2p-mplex" tptu "gitlab.dms3.io/p2p/go-p2p-transport-upgrader" diff --git a/browser_integration_native_test.go b/browser_integration_native_test.go index 67ddc34053834afa0020cd2e376f124bb079c6a8..e79a383cc0b6038fec528459eba85d547a3f0477 100644 --- a/browser_integration_native_test.go +++ b/browser_integration_native_test.go @@ -11,8 +11,7 @@ import ( "strings" "testing" - ma "github.com/multiformats/go-multiaddr" - "gitlab.dms3.io/p2p/go-p2p-core/sec/insecure" + ma "gitlab.dms3.io/mf/go-multiaddr" mplex "gitlab.dms3.io/p2p/go-p2p-mplex" tptu "gitlab.dms3.io/p2p/go-p2p-transport-upgrader" ) @@ -53,7 +52,7 @@ func TestInBrowser(t *testing.T) { close(serverDoneSignal) }() tpt := New(&tptu.Upgrader{ - Secure: insecure.New("serverPeer"), + Secure: makeInsecureTransport("serverPeer"), Muxer: new(mplex.Transport), }) addr, err := ma.NewMultiaddr("/ip4/127.0.0.1/tcp/5555/ws") diff --git a/go.mod b/go.mod index 863395db7954d35107be6115e405db73f30602a6..a56e4c4c61908f3f5ff6e27038b862ba56764268 100644 --- a/go.mod +++ b/go.mod @@ -2,12 +2,13 @@ module gitlab.dms3.io/p2p/go-ws-transport require ( github.com/gorilla/websocket v1.4.2 - github.com/multiformats/go-multiaddr v0.3.1 - github.com/multiformats/go-multiaddr-fmt v0.1.0 - gitlab.dms3.io/p2p/go-p2p-core v0.0.1 - gitlab.dms3.io/p2p/go-p2p-mplex v0.0.1 - gitlab.dms3.io/p2p/go-p2p-testing v0.0.1 - gitlab.dms3.io/p2p/go-p2p-transport-upgrader v0.0.1 + gitlab.dms3.io/mf/go-multiaddr v0.0.2 + gitlab.dms3.io/mf/go-multiaddr-fmt v0.0.1 + gitlab.dms3.io/p2p/go-conn-security-multistream v0.0.2 + gitlab.dms3.io/p2p/go-p2p-core v0.0.2 + gitlab.dms3.io/p2p/go-p2p-mplex v0.0.2 + gitlab.dms3.io/p2p/go-p2p-testing v0.0.2 + gitlab.dms3.io/p2p/go-p2p-transport-upgrader v0.0.2 ) go 1.15 diff --git a/go.sum b/go.sum index 87d40047af6fbfdf1bcf45caa6b8d2de467f6b35..0fb16b1a28087a6b9c53c5c51a479833d9f62a45 100644 --- a/go.sum +++ b/go.sum @@ -47,8 +47,6 @@ github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0U github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/ipfs/go-cid v0.0.7 h1:ysQJVJA3fNDF1qigJbsSQOdjhVLsOEoPdh0+R97k3jY= -github.com/ipfs/go-cid v0.0.7/go.mod h1:6Ux9z5e+HpkQdckYoX1PG/6xqKspzlEIR5SDmgqgC/I= github.com/jbenet/go-cienv v0.1.0/go.mod h1:TqNnHUmJgXau0nCzC7kXWeotg3J9W34CUv5Djy1+FlA= github.com/jbenet/go-temp-err-catcher v0.1.0 h1:zpb3ZH6wIE8Shj2sKS+khgRvf7T7RABoLk/+KKHggpk= github.com/jbenet/go-temp-err-catcher v0.1.0/go.mod h1:0kJRvmDZXNMIiJirNPEYfhpPwbGVtZVWC34vc5WLsDk= @@ -64,8 +62,6 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/libp2p/go-maddr-filter v0.1.0 h1:4ACqZKw8AqiuJfwFGq1CYDFugfXTOos+qQ3DETkhtCE= -github.com/libp2p/go-maddr-filter v0.1.0/go.mod h1:VzZhTXkMucEGGEOSKddrwGiOv0tUhgnKqNEmIAz/bPU= github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 h1:lYpkrQH5ajf0OXOcUbGjvZxxijuBwbbmlSxLiuofa+g= github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8RvIylQ358TN4wwqatJ8rNavkEINozVn9DtGI3dfQ= github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771 h1:MHkK1uRtFbVqvAgvWxafZe54+5uBxLluGylDiKgdhwo= @@ -73,8 +69,6 @@ github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771/go.mod h1:B5e1 github.com/minio/sha256-simd v0.1.1 h1:5QHSlgo3nt5yKOJrC7W8w7X+NFl8cMPZm96iu8kKUJU= github.com/minio/sha256-simd v0.1.1/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM= github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8= -github.com/mr-tron/base58 v1.1.2 h1:ZEw4I2EgPKDJ2iEw0cNmLB3ROrEmkOtXIkaG7wZg+78= -github.com/mr-tron/base58 v1.1.2/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/mr-tron/base58 v1.1.3 h1:v+sk57XuaCKGXpWtVBX8YJzO7hMGx4Aajh4TQbdEFdc= github.com/mr-tron/base58 v1.1.3/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= @@ -83,24 +77,12 @@ github.com/multiformats/go-base32 v0.0.3 h1:tw5+NhuwaOjJCC5Pp82QuXbrmLzWg7uxlMFp github.com/multiformats/go-base32 v0.0.3/go.mod h1:pLiuGC8y0QR3Ue4Zug5UzK9LjgbkL8NSQj0zQ5Nz/AA= github.com/multiformats/go-base36 v0.1.0 h1:JR6TyF7JjGd3m6FbLU2cOxhC0Li8z8dLNGQ89tUg4F4= github.com/multiformats/go-base36 v0.1.0/go.mod h1:kFGE83c6s80PklsHO9sRn2NCoffoRdUUOENyW/Vv6sM= -github.com/multiformats/go-multiaddr v0.1.1 h1:rVAztJYMhCQ7vEFr8FvxW3mS+HF2eY/oPbOMeS0ZDnE= -github.com/multiformats/go-multiaddr v0.1.1/go.mod h1:aMKBKNEYmzmDmxfX88/vz+J5IU55txyt0p4aiWVohjo= -github.com/multiformats/go-multiaddr v0.2.2/go.mod h1:NtfXiOtHvghW9KojvtySjH5y0u0xW5UouOmQQrn6a3Y= -github.com/multiformats/go-multiaddr v0.3.0/go.mod h1:dF9kph9wfJ+3VLAaeBqo9Of8x4fJxp6ggJGteB8HQTI= -github.com/multiformats/go-multiaddr v0.3.1 h1:1bxa+W7j9wZKTZREySx1vPMs2TqrYWjVZ7zE6/XLG1I= -github.com/multiformats/go-multiaddr v0.3.1/go.mod h1:uPbspcUPd5AfaP6ql3ujFY+QWzmBD8uLLL4bXW0XfGc= -github.com/multiformats/go-multiaddr-fmt v0.1.0 h1:WLEFClPycPkp4fnIzoFoV9FVd49/eQsuaL3/CWe167E= -github.com/multiformats/go-multiaddr-fmt v0.1.0/go.mod h1:hGtDIW4PU4BqJ50gW2quDuPVjyWNZxToGUh/HwTZYJo= -github.com/multiformats/go-multiaddr-net v0.2.0 h1:MSXRGN0mFymt6B1yo/6BPnIRpLPEnKgQNvVfCX5VDJk= -github.com/multiformats/go-multiaddr-net v0.2.0/go.mod h1:gGdH3UXny6U3cKKYCvpXI5rnK7YaOIEOPVDI9tsJbEA= github.com/multiformats/go-multibase v0.0.3 h1:l/B6bJDQjvQ5G52jw4QGSYeOTZoAwIO77RblWplfIqk= github.com/multiformats/go-multibase v0.0.3/go.mod h1:5+1R4eQrT3PkYZ24C3W2Ue2tPwIdYQD509ZjSb5y9Oc= -github.com/multiformats/go-multihash v0.0.8 h1:wrYcW5yxSi3dU07n5jnuS5PrNwyHy0zRHGVoUugWvXg= -github.com/multiformats/go-multihash v0.0.8/go.mod h1:YSLudS+Pi8NHE7o6tb3D8vrpKa63epEDmG8nTduyAew= -github.com/multiformats/go-multihash v0.0.13 h1:06x+mk/zj1FoMsgNejLpy6QTvJqlSt/BhLEy87zidlc= -github.com/multiformats/go-multihash v0.0.13/go.mod h1:VdAWLKTwram9oKAatUcLxBNUjdtcVwxObEQBtRfuyjc= github.com/multiformats/go-multihash v0.0.14 h1:QoBceQYQQtNUuf6s7wHxnE2c8bhbMqhfGzNI032se/I= github.com/multiformats/go-multihash v0.0.14/go.mod h1:VdAWLKTwram9oKAatUcLxBNUjdtcVwxObEQBtRfuyjc= +github.com/multiformats/go-multistream v0.2.1 h1:R5exp4cKvGlePuxg/bn4cnV53K4DxCe+uldxs7QzfrE= +github.com/multiformats/go-multistream v0.2.1/go.mod h1:5GZPQZbkWOLOn3J2y4Y99vVW7vOfsAflxARk3x14o6k= github.com/multiformats/go-varint v0.0.5 h1:XVZwSo04Cs3j/jS0uAEPpT3JY6DzMcVLLoWOSnCxOjg= github.com/multiformats/go-varint v0.0.5/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= github.com/multiformats/go-varint v0.0.6 h1:gk85QWKxh3TazbLxED/NlDVv8+q+ReFJk7Y2W/KhfNY= @@ -123,29 +105,35 @@ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0 github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -gitlab.dms3.io/dms3/public/go-cid v0.0.1 h1:qs4dtkDigcLGY/58dIZaFjKLt+orrTcmTBvtqaM3570= -gitlab.dms3.io/dms3/public/go-cid v0.0.1/go.mod h1:GQw3gc4CSrFY+aX6M+OBQDlg0p5/eQJoRrayaZzkAOQ= -gitlab.dms3.io/dms3/public/go-log v0.0.1 h1:jqz2g8pVdPW+Sy8CCo4rYfGEjktGhCBfgIb3oeY6yx8= -gitlab.dms3.io/dms3/public/go-log v0.0.1/go.mod h1:OsyF7lVYe47r03v1ZCbrmz0byeGUWB0Y219jN1DJx3s= +gitlab.dms3.io/dms3/go-cid v0.0.3 h1:5qZ1sl1Bi26naLz7Vsc8fjWcJKX8bR6njt3WPCteXac= +gitlab.dms3.io/dms3/go-cid v0.0.3/go.mod h1:qT/Q1NZD31UnWQ+rwsQgzGrrsQhpq7dYSlXf7ulDgtk= +gitlab.dms3.io/dms3/go-log v0.0.2 h1:vuNG5qmx6P9iK+A1+k4AmC6Q+ORm2ekWaQVbMmeL2wc= +gitlab.dms3.io/dms3/go-log v0.0.2/go.mod h1:iLuW2zqJJaP1WdbME4P6AS9AIMovwGDAn3zV/riR5iE= +gitlab.dms3.io/mf/go-multiaddr v0.0.2 h1:MZSIKYi5qBk5iurELtESiTsczdXauQhaqKOnk9vMJfI= +gitlab.dms3.io/mf/go-multiaddr v0.0.2/go.mod h1:BMNP0l/IA8/dbE6vNBf/ben61YNaPU0kn6wXgqZs9vU= +gitlab.dms3.io/mf/go-multiaddr-fmt v0.0.1 h1:rgX0NJwnjLUXA426H8la0BLxQLhCRcyzaZu5GX4Wsbc= +gitlab.dms3.io/mf/go-multiaddr-fmt v0.0.1/go.mod h1:IJHPnGlg0LS5nSWJW0tFX2VMDh9jjhetou42HElWdP4= gitlab.dms3.io/p2p/go-buffer-pool v0.0.1 h1:2IUBfHOWOarILKvoF1NHnfSUD5MMI/g6f64ZTUwacoA= gitlab.dms3.io/p2p/go-buffer-pool v0.0.1/go.mod h1:M+a5uWIUEkiKihMm5+IL0+pqzG6G7mcD6nNWosKUKO0= -gitlab.dms3.io/p2p/go-flow-metrics v0.0.1/go.mod h1:0QFTYtRYP6Y1xfK0xycr40drfoM+0WVCoOXPyI0eFN0= -gitlab.dms3.io/p2p/go-mplex v0.0.1 h1:U6s3YoddoXmiZF5TEQRRVUd0cwefZPCtUDkhtIzlLmY= -gitlab.dms3.io/p2p/go-mplex v0.0.1/go.mod h1:1wv8JOAbNlhSTCOWLTrWqdZBagdh7REbYiwZQ0am+30= +gitlab.dms3.io/p2p/go-conn-security-multistream v0.0.2 h1:sYH5gW8N/Xyni1lA5h5tVqnJLOmevDy5csinG4tpcMQ= +gitlab.dms3.io/p2p/go-conn-security-multistream v0.0.2/go.mod h1:xZy3z0EGD3IPU1SjzKA4XJZzNPG5/gL73JK3b7WuQuQ= +gitlab.dms3.io/p2p/go-flow-metrics v0.0.2/go.mod h1:0QFTYtRYP6Y1xfK0xycr40drfoM+0WVCoOXPyI0eFN0= +gitlab.dms3.io/p2p/go-mplex v0.0.2 h1:H6IJCR9SIjM5W5uXe2HYAectN1HTJu/+eWkj0SkbZRY= +gitlab.dms3.io/p2p/go-mplex v0.0.2/go.mod h1:xybsl2Yr4EXk0OKjB8xt7Fn6GhHQfUYe63tbTmxKvNM= gitlab.dms3.io/p2p/go-msgio v0.0.1 h1:Yh+40UhoamgwL8J3PD8wezS1ottJGHHwVdp/d1vIWZA= gitlab.dms3.io/p2p/go-msgio v0.0.1/go.mod h1:H6AqMy1HOxZb+yEXj2d3o4wgWb+lJx9aYI+nWka46T0= gitlab.dms3.io/p2p/go-openssl v0.0.1 h1:BC9zzxiRliZmWNpxQQX37DDkmKpR2rXNUkwxRT0f6NI= gitlab.dms3.io/p2p/go-openssl v0.0.1/go.mod h1:aQ3IGGzTd5vw48HiiXv6z6sFKiB52w2jZdg2TFNjylA= -gitlab.dms3.io/p2p/go-p2p-core v0.0.1 h1:ENn1teKT3rq5v5BN0y4hRWP3rjKEZbOCiwUI1t8CiGI= -gitlab.dms3.io/p2p/go-p2p-core v0.0.1/go.mod h1:xm5X+ChR6cZDKYaIDSmuCs6Uvd1GtbDy47xXjCljBAk= -gitlab.dms3.io/p2p/go-p2p-mplex v0.0.1 h1:umePc6wXeP7T9Y0EKOdaiuliVawVDM8euNNL5g8Fwg0= -gitlab.dms3.io/p2p/go-p2p-mplex v0.0.1/go.mod h1:iW5naFZ8U9XjwcX8gzkQzUiTCH7l1fgXpQlPHAypnP0= -gitlab.dms3.io/p2p/go-p2p-pnet v0.0.1 h1:IpKT0i694bzYGbml81t0uOa8ihrtsR8z3dR9BN5T1LU= -gitlab.dms3.io/p2p/go-p2p-pnet v0.0.1/go.mod h1:+7VrE3IPZMnD9nJeUtQUjbTOVIyy5wJ36CnTHk2dTJQ= -gitlab.dms3.io/p2p/go-p2p-testing v0.0.1 h1:ygs+JIxfnLLtdtzTv7JQr7SiAgv+Lk6qpBHcNL37YWc= -gitlab.dms3.io/p2p/go-p2p-testing v0.0.1/go.mod h1:Wy5MSYvMlDtf8GZ9rOdZm0Sxv57XCh1XqNI5z9E6JrU= -gitlab.dms3.io/p2p/go-p2p-transport-upgrader v0.0.1 h1:ZNSWc5UH+aKduy3/Gzhx6Q+XxGFv/nODCstDV0FFz+w= -gitlab.dms3.io/p2p/go-p2p-transport-upgrader v0.0.1/go.mod h1:yJ7+av8YB960D2ay6V/Sr1p1MwjkA8Nk/uvBrq8nqaw= +gitlab.dms3.io/p2p/go-p2p-core v0.0.2 h1:mMe0MmJaiG4zzDSc2u6BwXeZ4o5P5EuRM4maXL0AP5Q= +gitlab.dms3.io/p2p/go-p2p-core v0.0.2/go.mod h1:V4Oqm6ZHKOwCcf0tkBJBomlztwnytpABtOsQIeD676E= +gitlab.dms3.io/p2p/go-p2p-mplex v0.0.2 h1:bgDSuMuzesrMqLfromBUlSxX8W4Kmnw62Y0ceRFzpSQ= +gitlab.dms3.io/p2p/go-p2p-mplex v0.0.2/go.mod h1:bohexmBfoDjkqd2zx5s+uYsb066m3gPcppRGq4c8SIw= +gitlab.dms3.io/p2p/go-p2p-pnet v0.0.2 h1:8DK7on8L18v+zkxhP9cuO+99Xz07s3quY7s1Ni/OtJk= +gitlab.dms3.io/p2p/go-p2p-pnet v0.0.2/go.mod h1:VRKLLhFhnX6+1CZVNJBGm05mcnm5VJSHgn9ISmG6pME= +gitlab.dms3.io/p2p/go-p2p-testing v0.0.2 h1:mAAzsnTbNDDXToKxAWs1dSJTFcG8jO4vwmgg/JRYdCE= +gitlab.dms3.io/p2p/go-p2p-testing v0.0.2/go.mod h1:2PatJW3XwpOT2bxlR3Q9IqBuwZaMN483guaseyQkdZk= +gitlab.dms3.io/p2p/go-p2p-transport-upgrader v0.0.2 h1:YgWZHt4fkBdAVdH6oU86jM6hgxsbeZYX/hm7xjPMOlA= +gitlab.dms3.io/p2p/go-p2p-transport-upgrader v0.0.2/go.mod h1:+iia44MgzuwSZCssqZ2CvVW8l/nVRYDNUVMB66TPz8Q= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= diff --git a/listener.go b/listener.go index 1af9ed428bbc9f559e6bca4ea6db1e615a35e2bb..274112dfce9acc32c6fc159c7aaa54bd24138839 100644 --- a/listener.go +++ b/listener.go @@ -7,8 +7,8 @@ import ( "net" "net/http" - ma "github.com/multiformats/go-multiaddr" - manet "github.com/multiformats/go-multiaddr/net" + ma "gitlab.dms3.io/mf/go-multiaddr" + manet "gitlab.dms3.io/mf/go-multiaddr/net" ) type listener struct { diff --git a/tools/go.mod b/tools/go.mod index d34d7385b2a85fbc589c365732e7575253e52b3c..d12ba0c5de04306fb3b64de463dc32c23f2b7cc2 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -1,5 +1,5 @@ -module github.com/libp2p/go-ws-transport/tools +module gitlab.dms3.io/p2p/go-ws-transport/tools -go 1.13 +go 1.15 require github.com/agnivade/wasmbrowsertest v0.3.1 diff --git a/websocket.go b/websocket.go index fccaa342a04e74441c6c683f4c03e30ebda21a14..e2134f1695c4bbdabcd62e87fac9bc993d567c05 100644 --- a/websocket.go +++ b/websocket.go @@ -1,44 +1,32 @@ -// Package websocket implements a websocket based transport for go-libp2p. +// Package websocket implements a websocket based transport for go-p2p. package websocket import ( "context" - ma "github.com/multiformats/go-multiaddr" - mafmt "github.com/multiformats/go-multiaddr-fmt" - manet "github.com/multiformats/go-multiaddr/net" + ma "gitlab.dms3.io/mf/go-multiaddr" + mafmt "gitlab.dms3.io/mf/go-multiaddr-fmt" + manet "gitlab.dms3.io/mf/go-multiaddr/net" "gitlab.dms3.io/p2p/go-p2p-core/peer" "gitlab.dms3.io/p2p/go-p2p-core/transport" tptu "gitlab.dms3.io/p2p/go-p2p-transport-upgrader" ) -// WsProtocol is the multiaddr protocol definition for this transport. -// -// Deprecated: use `ma.ProtocolWithCode(ma.P_WS) -var WsProtocol = ma.ProtocolWithCode(ma.P_WS) - // WsFmt is multiaddr formatter for WsProtocol var WsFmt = mafmt.And(mafmt.TCP, mafmt.Base(ma.P_WS)) -// WsCodec is the multiaddr-net codec definition for the websocket transport -var WsCodec = &manet.NetCodec{ - NetAddrNetworks: []string{"websocket"}, - ProtocolName: "ws", - ConvertMultiaddr: ConvertWebsocketMultiaddrToNetAddr, - ParseNetAddr: ParseWebsocketNetAddr, -} - // This is _not_ WsFmt because we want the transport to stick to dialing fully // resolved addresses. -var dialMatcher = mafmt.And(mafmt.IP, mafmt.Base(ma.P_TCP), mafmt.Base(ma.P_WS)) +var dialMatcher = mafmt.And(mafmt.IP, mafmt.Base(ma.P_TCP), mafmt.Base(ma.P_WS)) // WsCodec is the multiaddr-net codec definition for the websocket transport func init() { - manet.RegisterNetCodec(WsCodec) + manet.RegisterFromNetAddr(ParseWebsocketNetAddr, "websocket") + manet.RegisterToNetAddr(ConvertWebsocketMultiaddrToNetAddr, "ws") } var _ transport.Transport = (*WebsocketTransport)(nil) -// WebsocketTransport is the actual go-libp2p transport +// WebsocketTransport is the actual go-p2p transport type WebsocketTransport struct { Upgrader *tptu.Upgrader } @@ -52,7 +40,7 @@ func (t *WebsocketTransport) CanDial(a ma.Multiaddr) bool { } func (t *WebsocketTransport) Protocols() []int { - return []int{WsProtocol.Code} + return []int{ma.ProtocolWithCode(ma.P_WS).Code} } func (t *WebsocketTransport) Proxy() bool { diff --git a/websocket_browser.go b/websocket_browser.go index df370607a83c2c580ea7a6fe311f8fe60329f870..735ce4cebefe04dbe6908ac9a2c66fc4b1dfba96 100644 --- a/websocket_browser.go +++ b/websocket_browser.go @@ -7,8 +7,8 @@ import ( "errors" "syscall/js" - ma "github.com/multiformats/go-multiaddr" - manet "github.com/multiformats/go-multiaddr/net" + ma "gitlab.dms3.io/mf/go-multiaddr" + manet "gitlab.dms3.io/mf/go-multiaddr/net" "gitlab.dms3.io/p2p/go-p2p-core/transport" ) diff --git a/websocket_native.go b/websocket_native.go index e5b87c063e71f42c8c9e81272508803b79ec7bf6..2ec8a90f61b90001ae7f336607d1bbd2f05369bb 100644 --- a/websocket_native.go +++ b/websocket_native.go @@ -9,8 +9,8 @@ import ( "net/url" ws "github.com/gorilla/websocket" - ma "github.com/multiformats/go-multiaddr" - manet "github.com/multiformats/go-multiaddr/net" + ma "gitlab.dms3.io/mf/go-multiaddr" + manet "gitlab.dms3.io/mf/go-multiaddr/net" "gitlab.dms3.io/p2p/go-p2p-core/transport" ) diff --git a/websocket_test.go b/websocket_test.go index 35c8f367474597077f1d3a125ba3c9411de0c4c3..d21f18ccb07e648932d5743b772b29d0ac962e31 100644 --- a/websocket_test.go +++ b/websocket_test.go @@ -10,7 +10,10 @@ import ( "testing" "testing/iotest" - ma "github.com/multiformats/go-multiaddr" + ma "gitlab.dms3.io/mf/go-multiaddr" + csms "gitlab.dms3.io/p2p/go-conn-security-multistream" + "gitlab.dms3.io/p2p/go-p2p-core/peer" + sec "gitlab.dms3.io/p2p/go-p2p-core/sec" "gitlab.dms3.io/p2p/go-p2p-core/sec/insecure" mplex "gitlab.dms3.io/p2p/go-p2p-mplex" ttransport "gitlab.dms3.io/p2p/go-p2p-testing/suites/transport" @@ -42,13 +45,13 @@ func TestCanDial(t *testing.T) { } func TestWebsocketTransport(t *testing.T) { - t.Skip("This test is failing, see https://github.com/libp2p/go-ws-transport/issues/99") + t.Skip("This test is failing, see https://gitlab.dms3.io/p2p/go-ws-transport/issues/99") ta := New(&tptu.Upgrader{ - Secure: insecure.New("peerA"), + Secure: makeInsecureTransport("peerA"), Muxer: new(mplex.Transport), }) tb := New(&tptu.Upgrader{ - Secure: insecure.New("peerB"), + Secure: makeInsecureTransport("peerB"), Muxer: new(mplex.Transport), }) @@ -196,3 +199,9 @@ func TestWriteZero(t *testing.T) { t.Errorf("expected EOF, got err: %s", err) } } + +func makeInsecureTransport(a peer.ID) sec.SecureMuxer { + secMuxer := new(csms.SSMuxer) + secMuxer.AddTransport(insecure.ID, insecure.New(a)) + return secMuxer +}