Browse Source

migrate to consolidated types. (#45)

pull/1422/head
Raúl Kripalani 6 years ago
committed by GitHub
parent
commit
3255249d4e
  1. 14
      p2p/transport/websocket/websocket.go
  2. 7
      p2p/transport/websocket/websocket_test.go

14
p2p/transport/websocket/websocket.go

@ -8,10 +8,12 @@ import (
"net/http"
"net/url"
ws "github.com/gorilla/websocket"
peer "github.com/libp2p/go-libp2p-peer"
tpt "github.com/libp2p/go-libp2p-transport"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/transport"
tptu "github.com/libp2p/go-libp2p-transport-upgrader"
ws "github.com/gorilla/websocket"
ma "github.com/multiformats/go-multiaddr"
manet "github.com/multiformats/go-multiaddr-net"
mafmt "github.com/whyrusleeping/mafmt"
@ -61,7 +63,7 @@ func New(u *tptu.Upgrader) *WebsocketTransport {
return &WebsocketTransport{u}
}
var _ tpt.Transport = (*WebsocketTransport)(nil)
var _ transport.Transport = (*WebsocketTransport)(nil)
func (t *WebsocketTransport) CanDial(a ma.Multiaddr) bool {
return WsFmt.Matches(a)
@ -94,7 +96,7 @@ func (t *WebsocketTransport) maDial(ctx context.Context, raddr ma.Multiaddr) (ma
return mnc, nil
}
func (t *WebsocketTransport) Dial(ctx context.Context, raddr ma.Multiaddr, p peer.ID) (tpt.Conn, error) {
func (t *WebsocketTransport) Dial(ctx context.Context, raddr ma.Multiaddr, p peer.ID) (transport.CapableConn, error) {
macon, err := t.maDial(ctx, raddr)
if err != nil {
return nil, err
@ -130,7 +132,7 @@ func (t *WebsocketTransport) maListen(a ma.Multiaddr) (manet.Listener, error) {
return malist, nil
}
func (t *WebsocketTransport) Listen(a ma.Multiaddr) (tpt.Listener, error) {
func (t *WebsocketTransport) Listen(a ma.Multiaddr) (transport.Listener, error) {
malist, err := t.maListen(a)
if err != nil {
return nil, err

7
p2p/transport/websocket/websocket_test.go

@ -8,10 +8,11 @@ import (
"testing"
"testing/iotest"
insecure "github.com/libp2p/go-conn-security/insecure"
"github.com/libp2p/go-libp2p-core/sec/insecure"
mplex "github.com/libp2p/go-libp2p-mplex"
ttransport "github.com/libp2p/go-libp2p-testing/suites/transport"
tptu "github.com/libp2p/go-libp2p-transport-upgrader"
utils "github.com/libp2p/go-libp2p-transport/test"
ma "github.com/multiformats/go-multiaddr"
)
@ -50,7 +51,7 @@ func TestWebsocketTransport(t *testing.T) {
})
zero := "/ip4/127.0.0.1/tcp/0/ws"
utils.SubtestTransport(t, ta, tb, zero, "peerA")
ttransport.SubtestTransport(t, ta, tb, zero, "peerA")
}
func TestWebsocketListen(t *testing.T) {

Loading…
Cancel
Save