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/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/)
[![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)
[![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)
[![Build Status](https://travis-ci.org/libp2p/go-ss-multistream.svg?branch=master)](https://travis-ci.org/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-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-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.
2. Secures the stream using the selected transport.
......@@ -21,13 +21,13 @@ Known libp2p security transports include:
## 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
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
......@@ -38,18 +38,18 @@ go get -u github.com/whyrusleeping/gx
go get -u github.com/whyrusleeping/gx-go
cd <your-project-repository>
gx init
gx import github.com/libp2p/go-ss-multistream
gx import github.com/libp2p/go-conn-security-multistream
gx install --global
gx-go --rewrite
```
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
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).
......
package ssms
package csms
import (
"context"
......@@ -6,7 +6,7 @@ import (
"net"
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"
)
......@@ -16,19 +16,19 @@ import (
// after use.
type SSMuxer struct {
mux mss.MultistreamMuxer
tpts map[string]ss.Transport
tpts map[string]connsec.Transport
OrderPreference []string
}
var _ ss.Transport = (*SSMuxer)(nil)
var _ connsec.Transport = (*SSMuxer)(nil)
// AddTransport adds a stream security transport to this multistream muxer.
//
// This method is *not* thread-safe. It should be called only when initializing
// the SSMuxer.
func (sm *SSMuxer) AddTransport(path string, transport ss.Transport) {
func (sm *SSMuxer) AddTransport(path string, transport connsec.Transport) {
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)
......@@ -38,7 +38,7 @@ func (sm *SSMuxer) AddTransport(path string, transport ss.Transport) {
// SecureInbound secures an inbound connection using this multistream
// 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)
if err != nil {
return nil, err
......@@ -48,7 +48,7 @@ func (sm *SSMuxer) SecureInbound(ctx context.Context, insecure net.Conn) (ss.Con
// SecureOutbound secures an outbound connection using this multistream
// 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)
if err != nil {
return nil, err
......@@ -56,7 +56,7 @@ func (sm *SSMuxer) SecureOutbound(ctx context.Context, insecure net.Conn, p peer
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 err error
done := make(chan struct{})
......
package ssms
package csms
import (
"context"
......@@ -6,14 +6,14 @@ import (
"sync"
"testing"
ss "github.com/libp2p/go-stream-security"
sst "github.com/libp2p/go-stream-security/test"
connsec "github.com/libp2p/go-conn-security"
sst "github.com/libp2p/go-conn-security/test"
)
func TestCommonProto(t *testing.T) {
var at, bt SSMuxer
atInsecure := ss.InsecureTransport("peerA")
btInsecure := ss.InsecureTransport("peerB")
atInsecure := connsec.InsecureTransport("peerA")
btInsecure := connsec.InsecureTransport("peerB")
at.AddTransport("/plaintext/1.0.0", &atInsecure)
bt.AddTransport("/plaintext/1.1.0", &btInsecure)
bt.AddTransport("/plaintext/1.0.0", &btInsecure)
......@@ -22,8 +22,8 @@ func TestCommonProto(t *testing.T) {
func TestNoCommonProto(t *testing.T) {
var at, bt SSMuxer
atInsecure := ss.InsecureTransport("peerA")
btInsecure := ss.InsecureTransport("peerB")
atInsecure := connsec.InsecureTransport("peerA")
btInsecure := connsec.InsecureTransport("peerB")
at.AddTransport("/plaintext/1.0.0", &atInsecure)
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