Skip to content

Commit

Permalink
migrate to consolidated types (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
raulk authored May 25, 2019
1 parent 1de116d commit c86093d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions p2p/net/conn-security-multistream/ssms.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"
"net"

connsec "github.com/libp2p/go-conn-security"
peer "github.com/libp2p/go-libp2p-peer"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/sec"
mss "github.com/multiformats/go-multistream"
)

Expand All @@ -16,19 +16,19 @@ import (
// after use.
type SSMuxer struct {
mux mss.MultistreamMuxer
tpts map[string]connsec.Transport
tpts map[string]sec.SecureTransport
OrderPreference []string
}

var _ connsec.Transport = (*SSMuxer)(nil)
var _ sec.SecureTransport = (*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 connsec.Transport) {
func (sm *SSMuxer) AddTransport(path string, transport sec.SecureTransport) {
if sm.tpts == nil {
sm.tpts = make(map[string]connsec.Transport, 1)
sm.tpts = make(map[string]sec.SecureTransport, 1)
}

sm.mux.AddHandler(path, nil)
Expand All @@ -38,7 +38,7 @@ func (sm *SSMuxer) AddTransport(path string, transport connsec.Transport) {

// SecureInbound secures an inbound connection using this multistream
// multiplexed stream security transport.
func (sm *SSMuxer) SecureInbound(ctx context.Context, insecure net.Conn) (connsec.Conn, error) {
func (sm *SSMuxer) SecureInbound(ctx context.Context, insecure net.Conn) (sec.SecureConn, error) {
tpt, err := sm.selectProto(ctx, insecure, true)
if err != nil {
return nil, err
Expand All @@ -48,15 +48,15 @@ func (sm *SSMuxer) SecureInbound(ctx context.Context, insecure net.Conn) (connse

// 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) (connsec.Conn, error) {
func (sm *SSMuxer) SecureOutbound(ctx context.Context, insecure net.Conn, p peer.ID) (sec.SecureConn, error) {
tpt, err := sm.selectProto(ctx, insecure, false)
if err != nil {
return nil, err
}
return tpt.SecureOutbound(ctx, insecure, p)
}

func (sm *SSMuxer) selectProto(ctx context.Context, insecure net.Conn, server bool) (connsec.Transport, error) {
func (sm *SSMuxer) selectProto(ctx context.Context, insecure net.Conn, server bool) (sec.SecureTransport, error) {
var proto string
var err error
done := make(chan struct{})
Expand Down
4 changes: 2 additions & 2 deletions p2p/net/conn-security-multistream/ssms_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"sync"
"testing"

insecure "github.com/libp2p/go-conn-security/insecure"
sst "github.com/libp2p/go-conn-security/test"
"github.com/libp2p/go-libp2p-core/sec/insecure"
sst "github.com/libp2p/go-libp2p-testing/suites/sec"
)

func TestCommonProto(t *testing.T) {
Expand Down

0 comments on commit c86093d

Please sign in to comment.