diff --git a/deprecated.go b/deprecated.go new file mode 100644 index 0000000..7ba99e0 --- /dev/null +++ b/deprecated.go @@ -0,0 +1,10 @@ +// Deprecated: use github.com/libp2p/go-libp2p-core/sec instead. +package connsec + +import core "github.com/libp2p/go-libp2p-core/sec" + +// Deprecated: use github.com/libp2p/go-libp2p-core/sec.SecureTransport instead. +type Transport = core.SecureTransport + +// Deprecated: use github.com/libp2p/go-libp2p-core/sec.SecureConn instead. +type Conn = core.SecureConn diff --git a/go.mod b/go.mod index e5831d3..24fde90 100644 --- a/go.mod +++ b/go.mod @@ -1,7 +1,8 @@ module github.com/libp2p/go-conn-security require ( - github.com/libp2p/go-libp2p-crypto v0.0.1 - github.com/libp2p/go-libp2p-net v0.0.1 - github.com/libp2p/go-libp2p-peer v0.0.1 + github.com/libp2p/go-libp2p-core v0.0.1 + github.com/libp2p/go-libp2p-testing v0.0.2 + golang.org/x/crypto v0.0.0-20190228161510-8dd112bcdc25 // indirect + golang.org/x/sys v0.0.0-20190228124157-a34e9553db1e // indirect ) diff --git a/go.sum b/go.sum index 90920ec..729a051 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,3 @@ -github.com/AndreasBriese/bbloom v0.0.0-20180913140656-343706a395b7/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= -github.com/Kubuxu/go-os-helper v0.0.1/go.mod h1:N8B+I7vPCT80IcP58r50u4+gEEcsZETFUpAzWW2ep1Y= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/btcsuite/btcd v0.0.0-20190213025234-306aecffea32 h1:qkOC5Gd33k54tobS36cXdAzJbeHaduLtnLQQwNoIi78= github.com/btcsuite/btcd v0.0.0-20190213025234-306aecffea32/go.mod h1:DrZx5ec/dmnfpw9KyYoQyYo7d0KEvTkk/5M/vbZjAr8= @@ -10,31 +8,19 @@ github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVa github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= +github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495 h1:6IyqGr3fnd0tM3YxipK27TUskaOVUjU2nG45yzwcQKY= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgraph-io/badger v1.5.5-0.20190226225317-8115aed38f8f/go.mod h1:VZxzAIRPHRVNRKRo6AXrX9BJegn6il06VMTZVJYCIjQ= -github.com/dgryski/go-farm v0.0.0-20190104051053-3adb47b1fb0f/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= -github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= -github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gxed/hashland/keccakpg v0.0.1 h1:wrk3uMNaMxbXiHibbPO4S0ymqJMm41WiudyFSs7UnsU= github.com/gxed/hashland/keccakpg v0.0.1/go.mod h1:kRzw3HkwxFU1mpmPP8v1WyQzwdGfmKFJ6tItnhQ67kU= github.com/gxed/hashland/murmur3 v0.0.1 h1:SheiaIt0sda5K+8FLz952/1iWS9zrnKsEJaOJu4ZbSc= github.com/gxed/hashland/murmur3 v0.0.1/go.mod h1:KjXop02n4/ckmZSnY2+HKcLud/tcmvhST0bie/0lS48= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/ipfs/go-datastore v0.0.1/go.mod h1:d4KVXhMt913cLBEI/PXAy6ko+W7e9AhyAKBGh803qeE= -github.com/ipfs/go-ds-badger v0.0.2/go.mod h1:Y3QpeSFWQf6MopLTiZD+VT6IC1yZqaGmjvRcKeSGij8= -github.com/ipfs/go-ds-leveldb v0.0.1/go.mod h1:feO8V3kubwsEF22n0YRQCffeb79OOYIykR4L04tMOYc= -github.com/ipfs/go-ipfs-delay v0.0.0-20181109222059-70721b86a9a8/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw= -github.com/ipfs/go-log v0.0.1/go.mod h1:kL1d2/hzSpI0thNYjiKfjanbVNU+IIGA/WnNESY9leM= +github.com/ipfs/go-cid v0.0.1/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM= github.com/jbenet/goprocess v0.0.0-20160826012719-b497e2f366b8 h1:bspPhN+oKYFk5fcGNuQzp6IGzYQSenLEgH3s6jkXrWw= github.com/jbenet/goprocess v0.0.0-20160826012719-b497e2f366b8/go.mod h1:Ly/wlsjFq/qrU3Rar62tu1gASgGw6chQbSh/XgIIXCY= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= @@ -42,65 +28,46 @@ github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlT github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/libp2p/go-buffer-pool v0.0.1/go.mod h1:xtyIz9PMobb13WaxR6Zo1Pd1zXJKYg0a8KiIvDp3TzQ= -github.com/libp2p/go-libp2p-crypto v0.0.1 h1:JNQd8CmoGTohO/akqrH16ewsqZpci2CbgYH/LmYl8gw= -github.com/libp2p/go-libp2p-crypto v0.0.1/go.mod h1:yJkNyDmO341d5wwXxDUGO0LykUVT72ImHNUqh5D/dBE= -github.com/libp2p/go-libp2p-net v0.0.1 h1:xJ4Vh4yKF/XKb8fd1Ev0ebAGzVjMxXzrxG2kjtU+F5Q= -github.com/libp2p/go-libp2p-net v0.0.1/go.mod h1:Yt3zgmlsHOgUWSXmt5V/Jpz9upuJBE8EgNU9DrCcR8c= -github.com/libp2p/go-libp2p-peer v0.0.1 h1:0qwAOljzYewINrU+Kndoc+1jAL7vzY/oY2Go4DCGfyY= -github.com/libp2p/go-libp2p-peer v0.0.1/go.mod h1:nXQvOBbwVqoP+T5Y5nCjeH4sP9IX/J0AMzcDUVruVoo= -github.com/libp2p/go-libp2p-peerstore v0.0.1 h1:twKovq8YK5trLrd3nB7PD2Zu9JcyAIdm7Bz9yBWjhq8= -github.com/libp2p/go-libp2p-peerstore v0.0.1/go.mod h1:RabLyPVJLuNQ+GFyoEkfi8H4Ti6k/HtZJ7YKgtSq+20= -github.com/libp2p/go-libp2p-protocol v0.0.1 h1:+zkEmZ2yFDi5adpVE3t9dqh/N9TbpFWywowzeEzBbLM= -github.com/libp2p/go-libp2p-protocol v0.0.1/go.mod h1:Af9n4PiruirSDjHycM1QuiMi/1VZNHYcK8cLgFJLZ4s= -github.com/libp2p/go-stream-muxer v0.0.1 h1:Ce6e2Pyu+b5MC1k3eeFtAax0pW4gc6MosYSLV05UeLw= -github.com/libp2p/go-stream-muxer v0.0.1/go.mod h1:bAo8x7YkSpadMTbtTaxGVHWUQsR/l5MEaHbKaliuT14= -github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= -github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/libp2p/go-flow-metrics v0.0.1/go.mod h1:Iv1GH0sG8DtYN3SVJ2eG221wMiNpZxBdp967ls1g+k8= +github.com/libp2p/go-libp2p-core v0.0.1 h1:HSTZtFIq/W5Ue43Zw+uWZyy2Vl5WtF0zDjKN8/DT/1I= +github.com/libp2p/go-libp2p-core v0.0.1/go.mod h1:g/VxnTZ/1ygHxH3dKok7Vno1VfpvGcGip57wjTU4fco= +github.com/libp2p/go-libp2p-testing v0.0.2 h1:p9ySW7MFvGGs83hAAe0MPGnjy/tPjl5KyxpMkojdZ+g= +github.com/libp2p/go-libp2p-testing v0.0.2/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MBLK8jM3V4Zghvmi+E= 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.0.0-20190131020904-2d45a736cd16 h1:5W7KhL8HVF3XCFOweFD3BNESdnO8ewyYTFT2R+/b8FQ= github.com/minio/sha256-simd v0.0.0-20190131020904-2d45a736cd16/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U= -github.com/mr-tron/base58 v1.1.0 h1:Y51FGVJ91WBqCEabAi5OPUz38eAx8DakuAm5svLcsfQ= github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8= +github.com/mr-tron/base58 v1.1.1 h1:OJIdWOWYe2l5PQNgimGtuwHY8nDskvJ5vvs//YnzRLs= +github.com/mr-tron/base58 v1.1.1/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8= github.com/multiformats/go-base32 v0.0.3/go.mod h1:pLiuGC8y0QR3Ue4Zug5UzK9LjgbkL8NSQj0zQ5Nz/AA= -github.com/multiformats/go-multiaddr v0.0.1 h1:/QUV3VBMDI6pi6xfiw7lr6xhDWWvQKn9udPn68kLSdY= -github.com/multiformats/go-multiaddr v0.0.1/go.mod h1:xKVEak1K9cS1VdmPZW3LSIb6lgmoS58qz/pzqmAxV44= -github.com/multiformats/go-multiaddr-dns v0.0.1/go.mod h1:9kWcqw/Pj6FwxAwW38n/9403szc57zJPs45fmnznu3Q= -github.com/multiformats/go-multiaddr-net v0.0.1/go.mod h1:nw6HSxNmCIQH27XPGBuX+d1tnvM7ihcFwHMSstNAVUU= +github.com/multiformats/go-multiaddr v0.0.2 h1:RBysRCv5rv3FWlhKWKoXv8tnsCUpEpIZpCmqAGZos2s= +github.com/multiformats/go-multiaddr v0.0.2/go.mod h1:xKVEak1K9cS1VdmPZW3LSIb6lgmoS58qz/pzqmAxV44= +github.com/multiformats/go-multibase v0.0.1/go.mod h1:bja2MqRZ3ggyXtZSEDKpl0uO/gviWFaSteVbWT51qgs= github.com/multiformats/go-multihash v0.0.1 h1:HHwN1K12I+XllBCrqKnhX949Orn4oawPkegHMu2vDqQ= github.com/multiformats/go-multihash v0.0.1/go.mod h1:w/5tugSrLEbWqlcgJabL3oHFKTwfvkofsjW2Qa1ct4U= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ= -github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1/go.mod h1:8UvriyWtv5Q5EOgjHaSseUEdkQfvwFv1I/In/O2M9gc= -github.com/whyrusleeping/go-logging v0.0.0-20170515211332-0457bb6b88fc/go.mod h1:bopw91TMyo8J3tvftk8xmU2kPmlrt4nScJQZU2hE5EM= -github.com/whyrusleeping/mafmt v1.2.8/go.mod h1:faQJFPbLSxzD9xpA02ttW/tS9vZykNvXwGvqIpk20FA= +github.com/spacemonkeygo/openssl v0.0.0-20181017203307-c2dcc5cca94a h1:/eS3yfGjQKG+9kayBkj0ip1BGhq6zJ3eaVksphxAaek= +github.com/spacemonkeygo/openssl v0.0.0-20181017203307-c2dcc5cca94a/go.mod h1:7AyxJNCJ7SBZ1MfVQCWD6Uqo2oubI2Eq2y2eqf+A5r0= +github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 h1:RC6RW7j+1+HkWaX/Yh71Ee5ZHaHYt7ZP4sQgUrm6cDU= +github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572/go.mod h1:w0SWMsp6j9O/dk4/ZpIhL+3CkG8ofA2vuv7k+ltqUMc= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190225124518-7f87c0fbb88b h1:+/WWzjwW6gidDJnMKWLKLX1gxn7irUTF1fLpQovfQ5M= golang.org/x/crypto v0.0.0-20190225124518-7f87c0fbb88b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190228161510-8dd112bcdc25 h1:jsG6UpNLt9iAsb0S2AGW28DveNzzgmbXR+ENoPjUeIU= +golang.org/x/crypto v0.0.0-20190228161510-8dd112bcdc25/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190227160552-c95aed5357e7/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190219092855-153ac476189d/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190228124157-a34e9553db1e h1:ZytStCyV048ZqDsWHiYDdoI2Vd4msMcrDECFxS+tL9c= +golang.org/x/sys v0.0.0-20190228124157-a34e9553db1e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/insecure/deprecated.go b/insecure/deprecated.go new file mode 100644 index 0000000..844fc8e --- /dev/null +++ b/insecure/deprecated.go @@ -0,0 +1,21 @@ +// Deprecated: use github.com/libp2p/go-libp2p-core/sec/insecure instead. +package insecure + +import ( + "github.com/libp2p/go-libp2p-core/peer" + core "github.com/libp2p/go-libp2p-core/sec/insecure" +) + +// Deprecated: use github.com/libp2p/go-libp2p-core/sec/insecure.ID instead. +const ID = core.ID + +// Deprecated: use github.com/libp2p/go-libp2p-core/sec/insecure.Transport instead. +type Transport = core.Transport + +// Deprecated: use github.com/libp2p/go-libp2p-core/sec/insecure.New instead. +func New(id peer.ID) *core.Transport { + return core.New(id) +} + +// Deprecated: use github.com/libp2p/go-libp2p-core/sec/insecure.Conn instead. +type Conn = core.Conn diff --git a/insecure/insecure.go b/insecure/insecure.go deleted file mode 100644 index 4c2cf6b..0000000 --- a/insecure/insecure.go +++ /dev/null @@ -1,86 +0,0 @@ -package insecure - -import ( - "context" - "net" - - security "github.com/libp2p/go-conn-security" - - ci "github.com/libp2p/go-libp2p-crypto" - peer "github.com/libp2p/go-libp2p-peer" -) - -// ID is the multistream-select protocol ID that should be used when identifying -// this security transport. -const ID = "/plaintext/1.0.0" - -// Transport is a no-op stream security transport. It provides no -// security and simply wraps connections in blank -type Transport struct { - id peer.ID -} - -// New constructs a new insecure transport. -func New(id peer.ID) *Transport { - return &Transport{ - id: id, - } -} - -// LocalPeer returns the transports local peer ID. -func (t *Transport) LocalPeer() peer.ID { - return t.id -} - -// LocalPrivateKey returns nil. This transport is not secure. -func (t *Transport) LocalPrivateKey() ci.PrivKey { - return nil -} - -// SecureInbound *pretends to secure* an outbound connection to the given peer. -func (t *Transport) SecureInbound(ctx context.Context, insecure net.Conn) (security.Conn, error) { - return &Conn{ - Conn: insecure, - local: t.id, - }, nil -} - -// SecureOutbound *pretends to secure* an outbound connection to the given peer. -func (t *Transport) SecureOutbound(ctx context.Context, insecure net.Conn, p peer.ID) (security.Conn, error) { - return &Conn{ - Conn: insecure, - local: t.id, - remote: p, - }, nil -} - -// Conn is the connection type returned by the insecure transport. -type Conn struct { - net.Conn - local peer.ID - remote peer.ID -} - -// LocalPeer returns the local peer ID. -func (ic *Conn) LocalPeer() peer.ID { - return ic.local -} - -// RemotePeer returns the remote peer ID if we initiated the dial. Otherwise, it -// returns "" (because this connection isn't actually secure). -func (ic *Conn) RemotePeer() peer.ID { - return ic.remote -} - -// RemotePublicKey returns nil. This connection is not secure -func (ic *Conn) RemotePublicKey() ci.PubKey { - return nil -} - -// LocalPrivateKey returns nil. This connection is not secure. -func (ic *Conn) LocalPrivateKey() ci.PrivKey { - return nil -} - -var _ security.Transport = (*Transport)(nil) -var _ security.Conn = (*Conn)(nil) diff --git a/interface.go b/interface.go deleted file mode 100644 index 844c139..0000000 --- a/interface.go +++ /dev/null @@ -1,25 +0,0 @@ -package connsec - -import ( - "context" - "net" - - inet "github.com/libp2p/go-libp2p-net" - peer "github.com/libp2p/go-libp2p-peer" -) - -// A Transport turns inbound and outbound unauthenticated, -// plain-text connections into authenticated, encrypted connections. -type Transport interface { - // SecureInbound secures an inbound connection. - SecureInbound(ctx context.Context, insecure net.Conn) (Conn, error) - - // SecureOutbound secures an outbound connection. - SecureOutbound(ctx context.Context, insecure net.Conn, p peer.ID) (Conn, error) -} - -// Conn is an authenticated, encrypted connection. -type Conn interface { - net.Conn - inet.ConnSecurity -} diff --git a/test/deprecated.go b/test/deprecated.go new file mode 100644 index 0000000..f0fb6ec --- /dev/null +++ b/test/deprecated.go @@ -0,0 +1,59 @@ +// Deprecated: use github.com/libp2p/go-libp2p-testing/suites/sec instead. +package ss_test + +import ( + "testing" + + "github.com/libp2p/go-libp2p-core/peer" + "github.com/libp2p/go-libp2p-core/sec" + + tsec "github.com/libp2p/go-libp2p-testing/suites/sec" +) + +// Deprecated: use github.com/libp2p/go-libp2p-testing/suites/sec.Subtests instead. +var Subtests = tsec.Subtests + +// Deprecated: use github.com/libp2p/go-libp2p-testing/suites/sec.TestMessage instead. +// Warning: it's impossible to alias a var in go. Writes to this var would have no longer +// have any effect, so it has been commented out to induce breakage for added safety. +// var TestMessage = tsec.TestMessage + +// Deprecated: use github.com/libp2p/go-libp2p-testing/suites/sec.TestStreamLen instead. +// Warning: it's impossible to alias a var in go. Writes to this var would have no longer +// have any effect, so it has been commented out to induce breakage for added safety. +// var TestStreamLen = tsec.TestStreamLen + +// Deprecated: use github.com/libp2p/go-libp2p-testing/suites/sec.TestSeed instead. +// Warning: it's impossible to alias a var in go. Writes to this var would have no longer +// have any effect, so it has been commented out to induce breakage for added safety. +// var TestSeed = tsec.TestSeed + +// Deprecated: use github.com/libp2p/go-libp2p-testing/suites/sec.SubtestAll instead. +func SubtestAll(t *testing.T, at, bt sec.SecureTransport, ap, bp peer.ID) { + tsec.SubtestAll(t, at, bt, ap, bp) +} + +// Deprecated: use github.com/libp2p/go-libp2p-testing/suites/sec.SubtestKeys instead. +func SubtestKeys(t *testing.T, at, bt sec.SecureTransport, ap, bp peer.ID) { + tsec.SubtestKeys(t, at, bt, ap, bp) +} + +// Deprecated: use github.com/libp2p/go-libp2p-testing/suites/sec.SubtestWrongPeer instead. +func SubtestWrongPeer(t *testing.T, at, bt sec.SecureTransport, ap, bp peer.ID) { + tsec.SubtestWrongPeer(t, at, bt, ap, bp) +} + +// Deprecated: use github.com/libp2p/go-libp2p-testing/suites/sec.SubtestCancelHandshakeOutbound instead. +func SubtestCancelHandshakeOutbound(t *testing.T, at, bt sec.SecureTransport, ap, bp peer.ID) { + tsec.SubtestCancelHandshakeOutbound(t, at, bt, ap, bp) +} + +// Deprecated: use github.com/libp2p/go-libp2p-testing/suites/sec.SubtestCancelHandshakeInbound instead. +func SubtestCancelHandshakeInbound(t *testing.T, at, bt sec.SecureTransport, ap, bp peer.ID) { + tsec.SubtestCancelHandshakeInbound(t, at, bt, ap, bp) +} + +// Deprecated: use github.com/libp2p/go-libp2p-testing/suites/sec.SubtestStream instead. +func SubtestStream(t *testing.T, at, bt sec.SecureTransport, ap, bp peer.ID) { + tsec.SubtestStream(t, at, bt, ap, bp) +} diff --git a/test/ttest.go b/test/ttest.go deleted file mode 100644 index 8ad9af3..0000000 --- a/test/ttest.go +++ /dev/null @@ -1,373 +0,0 @@ -package ss_test - -import ( - "bytes" - "context" - "io" - "net" - "sync" - "testing" - "time" - - "math/rand" - - connsec "github.com/libp2p/go-conn-security" - peer "github.com/libp2p/go-libp2p-peer" -) - -var Subtests = map[string]func(t *testing.T, at, bt connsec.Transport, ap, bp peer.ID){ - "RW": SubtestRW, - "Keys": SubtestKeys, - "WrongPeer": SubtestWrongPeer, - "Stream": SubtestStream, - "CancelHandshakeInbound": SubtestCancelHandshakeInbound, - "CancelHandshakeOutbound": SubtestCancelHandshakeOutbound, -} - -var TestMessage = []byte("hello world!") -var TestStreamLen int64 = 1024 * 1024 -var TestSeed int64 = 1812 - -func SubtestAll(t *testing.T, at, bt connsec.Transport, ap, bp peer.ID) { - for n, f := range Subtests { - t.Run(n, func(t *testing.T) { - f(t, at, bt, ap, bp) - f(t, bt, at, bp, ap) - }) - } -} - -func randStream() io.Reader { - return &io.LimitedReader{ - R: rand.New(rand.NewSource(TestSeed)), - N: TestStreamLen, - } -} - -func testWriteSustain(t *testing.T, c connsec.Conn) { - source := randStream() - n := int64(0) - for { - coppied, err := io.CopyN(c, source, int64(rand.Intn(8000))) - n += coppied - - switch err { - case io.EOF: - if n != TestStreamLen { - t.Fatal("incorrect random stream length") - } - return - case nil: - default: - t.Fatal(err) - } - } -} - -func testReadSustain(t *testing.T, c connsec.Conn) { - expected := randStream() - total := 0 - ebuf := make([]byte, 1024) - abuf := make([]byte, 1024) - for { - n, err := c.Read(abuf) - if err != nil { - t.Fatal(err) - } - total += n - _, err = io.ReadFull(expected, ebuf[:n]) - if err != nil { - t.Fatal(err) - } - if !bytes.Equal(abuf[:n], ebuf[:n]) { - t.Fatal("bytes not equal") - } - if total == int(TestStreamLen) { - return - } - } -} -func testWrite(t *testing.T, c connsec.Conn) { - n, err := c.Write(TestMessage) - if err != nil { - t.Fatal(err) - } - if n != len(TestMessage) { - t.Errorf("wrote %d bytes, expected to write %d bytes", n, len(TestMessage)) - } -} - -func testRead(t *testing.T, c connsec.Conn) { - buf := make([]byte, 100) - n, err := c.Read(buf) - if err != nil { - t.Fatal(err) - } - if n != len(TestMessage) { - t.Errorf("wrote %d bytes, expected to write %d bytes", n, len(TestMessage)) - } - if !bytes.Equal(buf[:n], TestMessage) { - t.Errorf("received bad test message: %s", string(buf[:n])) - } -} - -func testWriteFail(t *testing.T, c connsec.Conn) { - n, err := c.Write(TestMessage) - if n != 0 || err == nil { - t.Error("shouldn't have been able to write to a closed conn") - } -} - -func testReadFail(t *testing.T, c connsec.Conn) { - buf := make([]byte, len(TestMessage)) - n, err := c.Read(buf) - if n != 0 || err == nil { - t.Error("shouldn't have been able to write to a closed conn") - } -} - -func testEOF(t *testing.T, c connsec.Conn) { - buf := make([]byte, 100) - n, err := c.Read(buf) - if n != 0 { - t.Errorf("didn't expect to read any bytes, read: %d", n) - } - if err != io.EOF { - t.Errorf("expected read to fail with EOF, got: %s", err) - } -} - -func SubtestRW(t *testing.T, at, bt connsec.Transport, ap, bp peer.ID) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - a, b := net.Pipe() - - var wg sync.WaitGroup - wg.Add(2) - go func() { - defer wg.Done() - c, err := at.SecureInbound(ctx, a) - if err != nil { - a.Close() - t.Fatal(err) - } - - if c.LocalPeer() != ap { - t.Errorf("expected local peer %s, got %s", ap, c.LocalPeer()) - } - testWrite(t, c) - testRead(t, c) - c.Close() - testWriteFail(t, c) - testReadFail(t, c) - }() - - go func() { - defer wg.Done() - c, err := bt.SecureOutbound(ctx, b, ap) - if err != nil { - b.Close() - t.Fatal(err) - } - - if c.RemotePeer() != ap { - t.Errorf("expected remote peer %s, got %s", ap, c.RemotePeer()) - } - if c.LocalPeer() != bp { - t.Errorf("expected local peer %s, got %s", bp, c.LocalPeer()) - } - testRead(t, c) - testWrite(t, c) - testEOF(t, c) - testWriteFail(t, c) - c.Close() - }() - wg.Wait() -} - -func SubtestKeys(t *testing.T, at, bt connsec.Transport, ap, bp peer.ID) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - a, b := net.Pipe() - - var wg sync.WaitGroup - wg.Add(2) - go func() { - defer wg.Done() - c, err := at.SecureInbound(ctx, a) - if err != nil { - a.Close() - t.Fatal(err) - } - defer c.Close() - - if c.RemotePeer() != bp { - t.Errorf("expected remote peer %s, got remote peer %s", bp, c.RemotePeer()) - } - if c.LocalPeer() != ap { - t.Errorf("expected local peer %s, got local peer %s", ap, c.LocalPeer()) - } - if !c.LocalPeer().MatchesPrivateKey(c.LocalPrivateKey()) { - t.Error("local private key mismatch") - } - if !c.RemotePeer().MatchesPublicKey(c.RemotePublicKey()) { - t.Error("local private key mismatch") - } - }() - - go func() { - defer wg.Done() - c, err := bt.SecureOutbound(ctx, b, ap) - if err != nil { - b.Close() - t.Fatal(err) - } - defer c.Close() - - if c.RemotePeer() != ap { - t.Errorf("expected remote peer %s, got remote peer %s", ap, c.RemotePeer()) - } - if c.LocalPeer() != bp { - t.Errorf("expected local peer %s, got local peer %s", bp, c.LocalPeer()) - } - if !c.LocalPeer().MatchesPrivateKey(c.LocalPrivateKey()) { - t.Error("local private key mismatch") - } - if !c.RemotePeer().MatchesPublicKey(c.RemotePublicKey()) { - t.Error("local private key mismatch") - } - c.Close() - }() - wg.Wait() -} - -func SubtestWrongPeer(t *testing.T, at, bt connsec.Transport, ap, bp peer.ID) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - a, b := net.Pipe() - - var wg sync.WaitGroup - wg.Add(2) - go func() { - defer wg.Done() - defer a.Close() - _, err := at.SecureInbound(ctx, a) - if err == nil { - t.Fatal("conection should have failed") - } - }() - - go func() { - defer wg.Done() - defer b.Close() - _, err := bt.SecureOutbound(ctx, b, bp) - if err == nil { - t.Fatal("connection should have failed") - } - }() - wg.Wait() -} - -func SubtestCancelHandshakeOutbound(t *testing.T, at, bt connsec.Transport, ap, bp peer.ID) { - ctx, cancel := context.WithCancel(context.Background()) - a, b := net.Pipe() - defer a.Close() - defer b.Close() - - var wg sync.WaitGroup - wg.Add(1) - go func() { - defer wg.Done() - _, err := at.SecureOutbound(ctx, a, ap) - if err == nil { - t.Fatal("connection should have failed") - } - }() - time.Sleep(time.Millisecond) - cancel() - wg.Add(1) - go func() { - defer wg.Done() - _, err := bt.SecureInbound(ctx, b) - if err == nil { - t.Fatal("connection should have failed") - } - }() - - wg.Wait() - -} - -func SubtestCancelHandshakeInbound(t *testing.T, at, bt connsec.Transport, ap, bp peer.ID) { - ctx, cancel := context.WithCancel(context.Background()) - a, b := net.Pipe() - defer a.Close() - defer b.Close() - - var wg sync.WaitGroup - wg.Add(1) - go func() { - defer wg.Done() - _, err := at.SecureInbound(ctx, a) - if err == nil { - t.Fatal("connection should have failed") - } - }() - time.Sleep(time.Millisecond) - cancel() - wg.Add(1) - go func() { - defer wg.Done() - _, err := bt.SecureOutbound(ctx, b, bp) - if err == nil { - t.Fatal("connection should have failed") - } - }() - - wg.Wait() - -} - -func SubtestStream(t *testing.T, at, bt connsec.Transport, ap, bp peer.ID) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - a, b := net.Pipe() - - defer a.Close() - defer b.Close() - - var wg sync.WaitGroup - wg.Add(2) - go func() { - defer wg.Done() - - c, err := at.SecureInbound(ctx, a) - if err != nil { - t.Fatal(err) - } - - var swg sync.WaitGroup - swg.Add(2) - go func() { - defer swg.Done() - testWriteSustain(t, c) - }() - go func() { - defer swg.Done() - testReadSustain(t, c) - }() - swg.Wait() - c.Close() - }() - - go func() { - defer wg.Done() - c, err := bt.SecureOutbound(ctx, b, ap) - if err != nil { - t.Fatal(err) - } - io.Copy(c, c) - c.Close() - }() - wg.Wait() -}