Commit 5bbe0661 authored by Steven Allen's avatar Steven Allen

complete rename

parent b40b2555
# go-ss-multistream # go-conn-security-multistream
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) [![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io)
[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) [![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/) [![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/)
[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme) [![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
[![GoDoc](https://godoc.org/github.com/libp2p/go-ss-multistream?status.svg)](https://godoc.org/github.com/libp2p/go-ss-multistream) [![GoDoc](https://godoc.org/github.com/libp2p/go-conn-security-multistream?status.svg)](https://godoc.org/github.com/libp2p/go-conn-security-multistream)
[![Coverage Status](https://coveralls.io/repos/github/libp2p/go-ss-multistream/badge.svg?branch=master)](https://coveralls.io/github/libp2p/go-ss-multistream?branch=master) [![Coverage Status](https://coveralls.io/repos/github/libp2p/go-conn-security-multistream/badge.svg?branch=master)](https://coveralls.io/github/libp2p/go-conn-security-multistream?branch=master)
[![Build Status](https://travis-ci.org/libp2p/go-ss-multistream.svg?branch=master)](https://travis-ci.org/libp2p/go-ss-multistream) [![Build Status](https://travis-ci.org/libp2p/go-conn-security-multistream.svg?branch=master)](https://travis-ci.org/libp2p/go-conn-security-multistream)
> Stream security transport multistream multiplexer > Connection security multistream multiplexer
This package provides a multistream multiplexed stream security transport. It: This package provides a multistream multiplexed [security transport](https://github.com/libp2p/go-conn-security). It:
1. Selects a security security transport using multistream-select. 1. Selects a security security transport using multistream-select.
2. Secures the stream using the selected transport. 2. Secures the stream using the selected transport.
...@@ -21,13 +21,13 @@ Known libp2p security transports include: ...@@ -21,13 +21,13 @@ Known libp2p security transports include:
## Install ## Install
`go-ss-multistream` is a standard Go module which can be installed with: `go-conn-security-multistream` is a standard Go module which can be installed with:
```sh ```sh
go get github.com/libp2p/go-ss-multistream go get github.com/libp2p/go-conn-security-multistream
``` ```
Note that `go-ss-multistream` is packaged with Gx, so it is recommended to use Gx to install and use it (see the Usage section). Note that `go-conn-security-multistream` is packaged with Gx, so it is recommended to use Gx to install and use it (see the Usage section).
## Usage ## Usage
...@@ -38,18 +38,18 @@ go get -u github.com/whyrusleeping/gx ...@@ -38,18 +38,18 @@ go get -u github.com/whyrusleeping/gx
go get -u github.com/whyrusleeping/gx-go go get -u github.com/whyrusleeping/gx-go
cd <your-project-repository> cd <your-project-repository>
gx init gx init
gx import github.com/libp2p/go-ss-multistream gx import github.com/libp2p/go-conn-security-multistream
gx install --global gx install --global
gx-go --rewrite gx-go --rewrite
``` ```
Please check [Gx](https://github.com/whyrusleeping/gx) and [Gx-go](https://github.com/whyrusleeping/gx-go) documentation for more information. Please check [Gx](https://github.com/whyrusleeping/gx) and [Gx-go](https://github.com/whyrusleeping/gx-go) documentation for more information.
For more information about how `go-ss-multistream` is used in the libp2p context, you can see the [go-libp2p-conn](https://github.com/libp2p/go-libp2p-conn) module. For more information about how `go-conn-security-multistream` is used in the libp2p context, you can see the [go-libp2p-conn](https://github.com/libp2p/go-libp2p-conn) module.
## Contribute ## Contribute
Feel free to join in. All welcome. Open an [issue](https://github.com/libp2p/go-ss-multistream/issues)! Feel free to join in. All welcome. Open an [issue](https://github.com/libp2p/go-conn-security-multistream/issues)!
This repository falls under the IPFS [Code of Conduct](https://github.com/libp2p/community/blob/master/code-of-conduct.md). This repository falls under the IPFS [Code of Conduct](https://github.com/libp2p/community/blob/master/code-of-conduct.md).
......
package ssms package csms
import ( import (
"context" "context"
...@@ -6,7 +6,7 @@ import ( ...@@ -6,7 +6,7 @@ import (
"net" "net"
peer "github.com/libp2p/go-libp2p-peer" peer "github.com/libp2p/go-libp2p-peer"
ss "github.com/libp2p/go-stream-security" connsec "github.com/libp2p/go-conn-security"
mss "github.com/multiformats/go-multistream" mss "github.com/multiformats/go-multistream"
) )
...@@ -16,19 +16,19 @@ import ( ...@@ -16,19 +16,19 @@ import (
// after use. // after use.
type SSMuxer struct { type SSMuxer struct {
mux mss.MultistreamMuxer mux mss.MultistreamMuxer
tpts map[string]ss.Transport tpts map[string]connsec.Transport
OrderPreference []string OrderPreference []string
} }
var _ ss.Transport = (*SSMuxer)(nil) var _ connsec.Transport = (*SSMuxer)(nil)
// AddTransport adds a stream security transport to this multistream muxer. // AddTransport adds a stream security transport to this multistream muxer.
// //
// This method is *not* thread-safe. It should be called only when initializing // This method is *not* thread-safe. It should be called only when initializing
// the SSMuxer. // the SSMuxer.
func (sm *SSMuxer) AddTransport(path string, transport ss.Transport) { func (sm *SSMuxer) AddTransport(path string, transport connsec.Transport) {
if sm.tpts == nil { if sm.tpts == nil {
sm.tpts = make(map[string]ss.Transport, 1) sm.tpts = make(map[string]connsec.Transport, 1)
} }
sm.mux.AddHandler(path, nil) sm.mux.AddHandler(path, nil)
...@@ -38,7 +38,7 @@ func (sm *SSMuxer) AddTransport(path string, transport ss.Transport) { ...@@ -38,7 +38,7 @@ func (sm *SSMuxer) AddTransport(path string, transport ss.Transport) {
// SecureInbound secures an inbound connection using this multistream // SecureInbound secures an inbound connection using this multistream
// multiplexed stream security transport. // multiplexed stream security transport.
func (sm *SSMuxer) SecureInbound(ctx context.Context, insecure net.Conn) (ss.Conn, error) { func (sm *SSMuxer) SecureInbound(ctx context.Context, insecure net.Conn) (connsec.Conn, error) {
tpt, err := sm.selectProto(ctx, insecure, true) tpt, err := sm.selectProto(ctx, insecure, true)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -48,7 +48,7 @@ func (sm *SSMuxer) SecureInbound(ctx context.Context, insecure net.Conn) (ss.Con ...@@ -48,7 +48,7 @@ func (sm *SSMuxer) SecureInbound(ctx context.Context, insecure net.Conn) (ss.Con
// SecureOutbound secures an outbound connection using this multistream // SecureOutbound secures an outbound connection using this multistream
// multiplexed stream security transport. // multiplexed stream security transport.
func (sm *SSMuxer) SecureOutbound(ctx context.Context, insecure net.Conn, p peer.ID) (ss.Conn, error) { func (sm *SSMuxer) SecureOutbound(ctx context.Context, insecure net.Conn, p peer.ID) (connsec.Conn, error) {
tpt, err := sm.selectProto(ctx, insecure, false) tpt, err := sm.selectProto(ctx, insecure, false)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -56,7 +56,7 @@ func (sm *SSMuxer) SecureOutbound(ctx context.Context, insecure net.Conn, p peer ...@@ -56,7 +56,7 @@ func (sm *SSMuxer) SecureOutbound(ctx context.Context, insecure net.Conn, p peer
return tpt.SecureOutbound(ctx, insecure, p) return tpt.SecureOutbound(ctx, insecure, p)
} }
func (sm *SSMuxer) selectProto(ctx context.Context, insecure net.Conn, server bool) (ss.Transport, error) { func (sm *SSMuxer) selectProto(ctx context.Context, insecure net.Conn, server bool) (connsec.Transport, error) {
var proto string var proto string
var err error var err error
done := make(chan struct{}) done := make(chan struct{})
......
package ssms package csms
import ( import (
"context" "context"
...@@ -6,14 +6,14 @@ import ( ...@@ -6,14 +6,14 @@ import (
"sync" "sync"
"testing" "testing"
ss "github.com/libp2p/go-stream-security" connsec "github.com/libp2p/go-conn-security"
sst "github.com/libp2p/go-stream-security/test" sst "github.com/libp2p/go-conn-security/test"
) )
func TestCommonProto(t *testing.T) { func TestCommonProto(t *testing.T) {
var at, bt SSMuxer var at, bt SSMuxer
atInsecure := ss.InsecureTransport("peerA") atInsecure := connsec.InsecureTransport("peerA")
btInsecure := ss.InsecureTransport("peerB") btInsecure := connsec.InsecureTransport("peerB")
at.AddTransport("/plaintext/1.0.0", &atInsecure) at.AddTransport("/plaintext/1.0.0", &atInsecure)
bt.AddTransport("/plaintext/1.1.0", &btInsecure) bt.AddTransport("/plaintext/1.1.0", &btInsecure)
bt.AddTransport("/plaintext/1.0.0", &btInsecure) bt.AddTransport("/plaintext/1.0.0", &btInsecure)
...@@ -22,8 +22,8 @@ func TestCommonProto(t *testing.T) { ...@@ -22,8 +22,8 @@ func TestCommonProto(t *testing.T) {
func TestNoCommonProto(t *testing.T) { func TestNoCommonProto(t *testing.T) {
var at, bt SSMuxer var at, bt SSMuxer
atInsecure := ss.InsecureTransport("peerA") atInsecure := connsec.InsecureTransport("peerA")
btInsecure := ss.InsecureTransport("peerB") btInsecure := connsec.InsecureTransport("peerB")
at.AddTransport("/plaintext/1.0.0", &atInsecure) at.AddTransport("/plaintext/1.0.0", &atInsecure)
bt.AddTransport("/plaintext/1.1.0", &btInsecure) bt.AddTransport("/plaintext/1.1.0", &btInsecure)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment