diff --git a/p2p/protocol/internal/circuitv1-deprecated/conn.go b/p2p/protocol/internal/circuitv1-deprecated/conn.go index 35043e5e39..b0afbd063f 100644 --- a/p2p/protocol/internal/circuitv1-deprecated/conn.go +++ b/p2p/protocol/internal/circuitv1-deprecated/conn.go @@ -4,24 +4,17 @@ import ( "fmt" "net" - ic "github.com/libp2p/go-libp2p-crypto" - iconn "github.com/libp2p/go-libp2p-interface-conn" inet "github.com/libp2p/go-libp2p-net" - peer "github.com/libp2p/go-libp2p-peer" pstore "github.com/libp2p/go-libp2p-peerstore" - tpt "github.com/libp2p/go-libp2p-transport" ma "github.com/multiformats/go-multiaddr" manet "github.com/multiformats/go-multiaddr-net" ) type Conn struct { inet.Stream - remote pstore.PeerInfo - transport tpt.Transport + remote pstore.PeerInfo } -var _ iconn.Conn = (*Conn)(nil) - type NetAddr struct { Relay string Remote string @@ -62,27 +55,3 @@ func (c *Conn) LocalAddr() net.Addr { } return na } - -func (c *Conn) Transport() tpt.Transport { - return c.transport -} - -func (c *Conn) LocalPeer() peer.ID { - return c.Conn().LocalPeer() -} - -func (c *Conn) RemotePeer() peer.ID { - return c.remote.ID -} - -func (c *Conn) LocalPrivateKey() ic.PrivKey { - return nil -} - -func (c *Conn) RemotePublicKey() ic.PubKey { - return nil -} - -func (c *Conn) ID() string { - return iconn.ID(c) -} diff --git a/p2p/protocol/internal/circuitv1-deprecated/dial.go b/p2p/protocol/internal/circuitv1-deprecated/dial.go index 1f01be6aa6..3f021fa434 100644 --- a/p2p/protocol/internal/circuitv1-deprecated/dial.go +++ b/p2p/protocol/internal/circuitv1-deprecated/dial.go @@ -11,24 +11,16 @@ import ( ma "github.com/multiformats/go-multiaddr" ) -var _ tpt.Dialer = (*RelayDialer)(nil) - -type RelayDialer Relay - -func (d *RelayDialer) Relay() *Relay { - return (*Relay)(d) -} - -func (r *Relay) Dialer() *RelayDialer { - return (*RelayDialer)(r) -} - -func (d *RelayDialer) Dial(a ma.Multiaddr) (tpt.Conn, error) { - return d.DialContext(d.ctx, a) +func (d *RelayTransport) Dial(ctx context.Context, a ma.Multiaddr, p peer.ID) (tpt.Conn, error) { + c, err := d.Relay().Dial(ctx, a) + if err != nil { + return nil, err + } + return d.upgrader.UpgradeOutbound(ctx, d, c, p) } -func (d *RelayDialer) DialContext(ctx context.Context, a ma.Multiaddr) (tpt.Conn, error) { - if !d.Matches(a) { +func (r *Relay) Dial(ctx context.Context, a ma.Multiaddr) (*Conn, error) { + if !r.Matches(a) { return nil, fmt.Errorf("%s is not a relay address", a) } parts := ma.Split(a) @@ -51,24 +43,25 @@ func (d *RelayDialer) DialContext(ctx context.Context, a ma.Multiaddr) (tpt.Conn if len(relayaddr.Bytes()) == 0 { // unspecific relay address, try dialing using known hop relays - return d.tryDialRelays(ctx, *dinfo) + return r.tryDialRelays(ctx, *dinfo) } - rinfo, err := pstore.InfoFromP2pAddr(relayaddr) + var rinfo *pstore.PeerInfo + rinfo, err = pstore.InfoFromP2pAddr(relayaddr) if err != nil { return nil, err } - return d.Relay().DialPeer(ctx, *rinfo, *dinfo) + return r.DialPeer(ctx, *rinfo, *dinfo) } -func (d *RelayDialer) tryDialRelays(ctx context.Context, dinfo pstore.PeerInfo) (tpt.Conn, error) { +func (r *Relay) tryDialRelays(ctx context.Context, dinfo pstore.PeerInfo) (*Conn, error) { var relays []peer.ID - d.mx.Lock() - for p := range d.relays { + r.mx.Lock() + for p := range r.relays { relays = append(relays, p) } - d.mx.Unlock() + r.mx.Unlock() // shuffle list of relays, avoid overloading a specific relay for i := range relays { @@ -77,12 +70,12 @@ func (d *RelayDialer) tryDialRelays(ctx context.Context, dinfo pstore.PeerInfo) } for _, relay := range relays { - if len(d.host.Network().ConnsToPeer(relay)) == 0 { + if len(r.host.Network().ConnsToPeer(relay)) == 0 { continue } rctx, cancel := context.WithTimeout(ctx, HopConnectTimeout) - c, err := d.Relay().DialPeer(rctx, pstore.PeerInfo{ID: relay}, dinfo) + c, err := r.DialPeer(rctx, pstore.PeerInfo{ID: relay}, dinfo) cancel() if err == nil { @@ -94,8 +87,3 @@ func (d *RelayDialer) tryDialRelays(ctx context.Context, dinfo pstore.PeerInfo) return nil, fmt.Errorf("Failed to dial through %d known relay hosts", len(relays)) } - -func (d *RelayDialer) Matches(a ma.Multiaddr) bool { - _, err := a.ValueForProtocol(P_CIRCUIT) - return err == nil -} diff --git a/p2p/protocol/internal/circuitv1-deprecated/listen.go b/p2p/protocol/internal/circuitv1-deprecated/listen.go index 9eac888913..ee1f92e15d 100644 --- a/p2p/protocol/internal/circuitv1-deprecated/listen.go +++ b/p2p/protocol/internal/circuitv1-deprecated/listen.go @@ -6,13 +6,11 @@ import ( pb "github.com/libp2p/go-libp2p-circuit/pb" - peer "github.com/libp2p/go-libp2p-peer" - tpt "github.com/libp2p/go-libp2p-transport" - filter "github.com/libp2p/go-maddr-filter" ma "github.com/multiformats/go-multiaddr" + manet "github.com/multiformats/go-multiaddr-net" ) -var _ tpt.Listener = (*RelayListener)(nil) +var _ manet.Listener = (*RelayListener)(nil) type RelayListener Relay @@ -21,10 +19,11 @@ func (l *RelayListener) Relay() *Relay { } func (r *Relay) Listener() *RelayListener { + // TODO: Only allow one! return (*RelayListener)(r) } -func (l *RelayListener) Accept() (tpt.Conn, error) { +func (l *RelayListener) Accept() (manet.Conn, error) { select { case c := <-l.incoming: err := l.Relay().writeResponse(c.Stream, pb.CircuitRelay_SUCCESS) @@ -34,7 +33,8 @@ func (l *RelayListener) Accept() (tpt.Conn, error) { return nil, err } - log.Infof("accepted relay connection: %s", c.ID()) + // TODO: Pretty print. + log.Infof("accepted relay connection: %s", c) return c, nil case <-l.ctx.Done(): @@ -57,14 +57,6 @@ func (l *RelayListener) Multiaddr() ma.Multiaddr { return a } -func (l *RelayListener) LocalPeer() peer.ID { - return l.self -} - -func (l *RelayListener) SetAddrFilters(f *filter.Filters) { - // noop ? -} - func (l *RelayListener) Close() error { // TODO: noop? return nil diff --git a/p2p/protocol/internal/circuitv1-deprecated/notify.go b/p2p/protocol/internal/circuitv1-deprecated/notify.go index dec311671a..7ded2b623b 100644 --- a/p2p/protocol/internal/circuitv1-deprecated/notify.go +++ b/p2p/protocol/internal/circuitv1-deprecated/notify.go @@ -27,7 +27,7 @@ func (n *RelayNotifiee) OpenedStream(net inet.Network, s inet.Stream) {} func (n *RelayNotifiee) ClosedStream(net inet.Network, s inet.Stream) {} func (n *RelayNotifiee) Connected(s inet.Network, c inet.Conn) { - if n.Relay().Transport().Matches(c.RemoteMultiaddr()) { + if n.Relay().Matches(c.RemoteMultiaddr()) { return } diff --git a/p2p/protocol/internal/circuitv1-deprecated/relay.go b/p2p/protocol/internal/circuitv1-deprecated/relay.go index 91ba7f23c6..99e89d45ff 100644 --- a/p2p/protocol/internal/circuitv1-deprecated/relay.go +++ b/p2p/protocol/internal/circuitv1-deprecated/relay.go @@ -14,6 +14,8 @@ import ( inet "github.com/libp2p/go-libp2p-net" peer "github.com/libp2p/go-libp2p-peer" pstore "github.com/libp2p/go-libp2p-peerstore" + tptu "github.com/libp2p/go-libp2p-transport-upgrader" + ma "github.com/multiformats/go-multiaddr" ) var log = logging.Logger("relay") @@ -26,9 +28,10 @@ var RelayAcceptTimeout = time.Minute var HopConnectTimeout = 10 * time.Second type Relay struct { - host host.Host - ctx context.Context - self peer.ID + host host.Host + upgrader *tptu.Upgrader + ctx context.Context + self peer.ID active bool hop bool @@ -54,8 +57,9 @@ func (e RelayError) Error() string { return fmt.Sprintf("error opening relay circuit: %s (%d)", pb.CircuitRelay_Status_name[int32(e.Code)], e.Code) } -func NewRelay(ctx context.Context, h host.Host, opts ...RelayOpt) (*Relay, error) { +func NewRelay(ctx context.Context, h host.Host, upgrader *tptu.Upgrader, opts ...RelayOpt) (*Relay, error) { r := &Relay{ + upgrader: upgrader, host: h, ctx: ctx, self: h.ID(), @@ -126,7 +130,13 @@ func (r *Relay) DialPeer(ctx context.Context, relay pstore.PeerInfo, dest pstore return nil, RelayError{msg.GetCode()} } - return &Conn{Stream: s, remote: dest, transport: r.Transport()}, nil + return &Conn{Stream: s, remote: dest}, nil +} + +func (r *Relay) Matches(addr ma.Multiaddr) bool { + // TODO: Look at the prefix transport as well. + _, err := addr.ValueForProtocol(P_CIRCUIT) + return err == nil } func (r *Relay) CanHop(ctx context.Context, id peer.ID) (bool, error) { @@ -142,18 +152,18 @@ func (r *Relay) CanHop(ctx context.Context, id peer.ID) (bool, error) { msg.Type = pb.CircuitRelay_CAN_HOP.Enum() - err = wr.WriteMsg(&msg) - if err != nil { + if err := wr.WriteMsg(&msg); err != nil { s.Reset() return false, err } msg.Reset() - err = rd.ReadMsg(&msg) - s.Close() - - if err != nil { + if err := rd.ReadMsg(&msg); err != nil { + s.Reset() + return false, err + } + if err := inet.FullClose(s); err != nil { return false, err } @@ -340,7 +350,7 @@ func (r *Relay) handleStopStream(s inet.Stream, msg *pb.CircuitRelay) { } select { - case r.incoming <- &Conn{Stream: s, remote: src, transport: r.Transport()}: + case r.incoming <- &Conn{Stream: s, remote: src}: case <-time.After(RelayAcceptTimeout): r.handleError(s, pb.CircuitRelay_STOP_RELAY_REFUSED) } @@ -359,7 +369,7 @@ func (r *Relay) handleCanHop(s inet.Stream, msg *pb.CircuitRelay) { s.Reset() log.Debugf("error writing relay response: %s", err.Error()) } else { - s.Close() + inet.FullClose(s) } } @@ -370,7 +380,7 @@ func (r *Relay) handleError(s inet.Stream, code pb.CircuitRelay_Status) { s.Reset() log.Debugf("error writing relay response: %s", err.Error()) } else { - s.Close() + inet.FullClose(s) } } diff --git a/p2p/protocol/internal/circuitv1-deprecated/relay_test.go b/p2p/protocol/internal/circuitv1-deprecated/relay_test.go index 5213e122bd..04feb6ca80 100644 --- a/p2p/protocol/internal/circuitv1-deprecated/relay_test.go +++ b/p2p/protocol/internal/circuitv1-deprecated/relay_test.go @@ -13,7 +13,8 @@ import ( bhost "github.com/libp2p/go-libp2p-blankhost" host "github.com/libp2p/go-libp2p-host" - netutil "github.com/libp2p/go-libp2p-netutil" + swarm "github.com/libp2p/go-libp2p-swarm" + swarmt "github.com/libp2p/go-libp2p-swarm/testing" ma "github.com/multiformats/go-multiaddr" ) @@ -30,7 +31,7 @@ func getNetHosts(t *testing.T, ctx context.Context, n int) []host.Host { var out []host.Host for i := 0; i < n; i++ { - netw := netutil.GenSwarmNetwork(t, ctx) + netw := swarmt.GenSwarm(t, ctx) h := bhost.NewBlankHost(netw) out = append(out, h) } @@ -38,6 +39,14 @@ func getNetHosts(t *testing.T, ctx context.Context, n int) []host.Host { return out } +func newTestRelay(t *testing.T, ctx context.Context, host host.Host, opts ...RelayOpt) *Relay { + r, err := NewRelay(ctx, host, swarmt.GenUpgrader(host.Network().(*swarm.Swarm)), opts...) + if err != nil { + t.Fatal(err) + } + return r +} + func connect(t *testing.T, a, b host.Host) { pinfo := a.Peerstore().PeerInfo(a.ID()) err := b.Connect(context.Background(), pinfo) @@ -57,20 +66,11 @@ func TestBasicRelay(t *testing.T) { time.Sleep(10 * time.Millisecond) - r1, err := NewRelay(ctx, hosts[0]) - if err != nil { - t.Fatal(err) - } + r1 := newTestRelay(t, ctx, hosts[0]) - _, err = NewRelay(ctx, hosts[1], OptHop) - if err != nil { - t.Fatal(err) - } + newTestRelay(t, ctx, hosts[1], OptHop) - r3, err := NewRelay(ctx, hosts[2]) - if err != nil { - t.Fatal(err) - } + r3 := newTestRelay(t, ctx, hosts[2]) msg := []byte("relay works!") go func() { @@ -122,20 +122,11 @@ func TestRelayReset(t *testing.T) { time.Sleep(10 * time.Millisecond) - r1, err := NewRelay(ctx, hosts[0]) - if err != nil { - t.Fatal(err) - } + r1 := newTestRelay(t, ctx, hosts[0]) - _, err = NewRelay(ctx, hosts[1], OptHop) - if err != nil { - t.Fatal(err) - } + newTestRelay(t, ctx, hosts[1], OptHop) - r3, err := NewRelay(ctx, hosts[2]) - if err != nil { - t.Fatal(err) - } + r3 := newTestRelay(t, ctx, hosts[2]) ready := make(chan struct{}) @@ -190,20 +181,10 @@ func TestBasicRelayDial(t *testing.T) { time.Sleep(10 * time.Millisecond) - r1, err := NewRelay(ctx, hosts[0]) - if err != nil { - t.Fatal(err) - } - - _, err = NewRelay(ctx, hosts[1], OptHop) - if err != nil { - t.Fatal(err) - } + r1 := newTestRelay(t, ctx, hosts[0]) - r3, err := NewRelay(ctx, hosts[2]) - if err != nil { - t.Fatal(err) - } + _ = newTestRelay(t, ctx, hosts[1], OptHop) + r3 := newTestRelay(t, ctx, hosts[2]) msg := []byte("relay works!") go func() { @@ -231,8 +212,7 @@ func TestBasicRelayDial(t *testing.T) { rctx, rcancel := context.WithTimeout(ctx, time.Second) defer rcancel() - d := r1.Dialer() - con, err := d.DialContext(rctx, addr) + con, err := r1.Dial(rctx, addr) if err != nil { t.Fatal(err) } @@ -253,20 +233,11 @@ func TestUnspecificRelayDial(t *testing.T) { hosts := getNetHosts(t, ctx, 3) - r1, err := NewRelay(ctx, hosts[0]) - if err != nil { - t.Fatal(err) - } + r1 := newTestRelay(t, ctx, hosts[0]) - _, err = NewRelay(ctx, hosts[1], OptHop) - if err != nil { - t.Fatal(err) - } + newTestRelay(t, ctx, hosts[1], OptHop) - r3, err := NewRelay(ctx, hosts[2]) - if err != nil { - t.Fatal(err) - } + r3 := newTestRelay(t, ctx, hosts[2]) connect(t, hosts[0], hosts[1]) connect(t, hosts[1], hosts[2]) @@ -299,8 +270,7 @@ func TestUnspecificRelayDial(t *testing.T) { rctx, rcancel := context.WithTimeout(ctx, time.Second) defer rcancel() - d := r1.Dialer() - con, err := d.DialContext(rctx, addr) + con, err := r1.Dial(rctx, addr) if err != nil { t.Fatal(err) } @@ -326,20 +296,11 @@ func TestRelayThroughNonHop(t *testing.T) { time.Sleep(10 * time.Millisecond) - r1, err := NewRelay(ctx, hosts[0]) - if err != nil { - t.Fatal(err) - } + r1 := newTestRelay(t, ctx, hosts[0]) - _, err = NewRelay(ctx, hosts[1]) - if err != nil { - t.Fatal(err) - } + newTestRelay(t, ctx, hosts[1]) - _, err = NewRelay(ctx, hosts[2]) - if err != nil { - t.Fatal(err) - } + newTestRelay(t, ctx, hosts[2]) rinfo := hosts[1].Peerstore().PeerInfo(hosts[1].ID()) dinfo := hosts[2].Peerstore().PeerInfo(hosts[2].ID()) @@ -347,7 +308,7 @@ func TestRelayThroughNonHop(t *testing.T) { rctx, rcancel := context.WithTimeout(ctx, time.Second) defer rcancel() - _, err = r1.DialPeer(rctx, rinfo, dinfo) + _, err := r1.DialPeer(rctx, rinfo, dinfo) if err == nil { t.Fatal("expected error") } @@ -372,15 +333,9 @@ func TestRelayNoDestConnection(t *testing.T) { time.Sleep(10 * time.Millisecond) - r1, err := NewRelay(ctx, hosts[0]) - if err != nil { - t.Fatal(err) - } + r1 := newTestRelay(t, ctx, hosts[0]) - _, err = NewRelay(ctx, hosts[1], OptHop) - if err != nil { - t.Fatal(err) - } + newTestRelay(t, ctx, hosts[1], OptHop) rinfo := hosts[1].Peerstore().PeerInfo(hosts[1].ID()) dinfo := hosts[2].Peerstore().PeerInfo(hosts[2].ID()) @@ -388,7 +343,7 @@ func TestRelayNoDestConnection(t *testing.T) { rctx, rcancel := context.WithTimeout(ctx, time.Second) defer rcancel() - _, err = r1.DialPeer(rctx, rinfo, dinfo) + _, err := r1.DialPeer(rctx, rinfo, dinfo) if err == nil { t.Fatal("expected error") } @@ -413,20 +368,11 @@ func TestActiveRelay(t *testing.T) { time.Sleep(10 * time.Millisecond) - r1, err := NewRelay(ctx, hosts[0]) - if err != nil { - t.Fatal(err) - } + r1 := newTestRelay(t, ctx, hosts[0]) - _, err = NewRelay(ctx, hosts[1], OptHop, OptActive) - if err != nil { - t.Fatal(err) - } + newTestRelay(t, ctx, hosts[1], OptHop, OptActive) - r3, err := NewRelay(ctx, hosts[2]) - if err != nil { - t.Fatal(err) - } + r3 := newTestRelay(t, ctx, hosts[2]) msg := []byte("relay works!") go func() { @@ -477,15 +423,9 @@ func TestRelayCanHop(t *testing.T) { time.Sleep(10 * time.Millisecond) - r1, err := NewRelay(ctx, hosts[0]) - if err != nil { - t.Fatal(err) - } + r1 := newTestRelay(t, ctx, hosts[0]) - _, err = NewRelay(ctx, hosts[1], OptHop) - if err != nil { - t.Fatal(err) - } + newTestRelay(t, ctx, hosts[1], OptHop) canhop, err := r1.CanHop(ctx, hosts[1].ID()) if err != nil { diff --git a/p2p/protocol/internal/circuitv1-deprecated/transport.go b/p2p/protocol/internal/circuitv1-deprecated/transport.go index 1396828747..86821d327c 100644 --- a/p2p/protocol/internal/circuitv1-deprecated/transport.go +++ b/p2p/protocol/internal/circuitv1-deprecated/transport.go @@ -4,10 +4,9 @@ import ( "context" "fmt" - addrutil "github.com/libp2p/go-addr-util" host "github.com/libp2p/go-libp2p-host" - swarm "github.com/libp2p/go-libp2p-swarm" tpt "github.com/libp2p/go-libp2p-transport" + tptu "github.com/libp2p/go-libp2p-transport-upgrader" ma "github.com/multiformats/go-multiaddr" ) @@ -22,29 +21,6 @@ var Protocol = ma.Protocol{ func init() { ma.AddProtocol(Protocol) - - // Add dialer transport - const unspecific = "/p2p-circuit/ipfs" - const proto = "/ipfs/p2p-circuit/ipfs" - - tps := addrutil.SupportedTransportStrings - - err := addrutil.AddTransport(unspecific) - if err != nil { - panic(err) - } - - err = addrutil.AddTransport(proto) - if err != nil { - panic(err) - } - - for _, tp := range tps { - err = addrutil.AddTransport(tp + proto) - if err != nil { - panic(err) - } - } } var _ tpt.Transport = (*RelayTransport)(nil) @@ -59,40 +35,46 @@ func (r *Relay) Transport() *RelayTransport { return (*RelayTransport)(r) } -func (t *RelayTransport) Dialer(laddr ma.Multiaddr, opts ...tpt.DialOpt) (tpt.Dialer, error) { - if !t.Matches(laddr) { +func (t *RelayTransport) Listen(laddr ma.Multiaddr) (tpt.Listener, error) { + // TODO: Ensure we have a connection to the relay, if specified. Also, + // make sure the multiaddr makes sense. + if !t.Relay().Matches(laddr) { return nil, fmt.Errorf("%s is not a relay address", laddr) } - return t.Relay().Dialer(), nil + return t.upgrader.UpgradeListener(t, t.Relay().Listener()), nil } -func (t *RelayTransport) Listen(laddr ma.Multiaddr) (tpt.Listener, error) { - if !t.Matches(laddr) { - return nil, fmt.Errorf("%s is not a relay address", laddr) - } - return t.Relay().Listener(), nil +func (t *RelayTransport) CanDial(raddr ma.Multiaddr) bool { + return t.Relay().Matches(raddr) } -func (t *RelayTransport) Matches(a ma.Multiaddr) bool { - return t.Relay().Dialer().Matches(a) +func (t *RelayTransport) Proxy() bool { + return true +} + +func (t *RelayTransport) Protocols() []int { + return []int{P_CIRCUIT} } // AddRelayTransport constructs a relay and adds it as a transport to the host network. -func AddRelayTransport(ctx context.Context, h host.Host, opts ...RelayOpt) error { - // the necessary methods are not part of the Network interface, only exported by Swarm - // TODO: generalize the network interface for adding tranports - n, ok := h.Network().(*swarm.Network) +func AddRelayTransport(ctx context.Context, h host.Host, upgrader *tptu.Upgrader, opts ...RelayOpt) error { + n, ok := h.Network().(tpt.Network) if !ok { - return fmt.Errorf("%v is not a swarm network", h.Network()) + return fmt.Errorf("%v is not a transport network", h.Network()) } - s := n.Swarm() - - r, err := NewRelay(ctx, h, opts...) + r, err := NewRelay(ctx, h, upgrader, opts...) if err != nil { return err } - s.AddTransport(r.Transport()) - return s.AddListenAddr(r.Listener().Multiaddr()) + // There's no nice way to handle these errors as we have no way to tear + // down the relay. + // TODO + if err := n.AddTransport(r.Transport()); err != nil { + log.Error("failed to add relay transport:", err) + } else if err := n.Listen(r.Listener().Multiaddr()); err != nil { + log.Error("failed to listen on relay transport:", err) + } + return nil } diff --git a/p2p/protocol/internal/circuitv1-deprecated/transport_test.go b/p2p/protocol/internal/circuitv1-deprecated/transport_test.go index 512ba8644b..b718a90fe7 100644 --- a/p2p/protocol/internal/circuitv1-deprecated/transport_test.go +++ b/p2p/protocol/internal/circuitv1-deprecated/transport_test.go @@ -13,6 +13,8 @@ import ( host "github.com/libp2p/go-libp2p-host" inet "github.com/libp2p/go-libp2p-net" pstore "github.com/libp2p/go-libp2p-peerstore" + swarm "github.com/libp2p/go-libp2p-swarm" + swarmt "github.com/libp2p/go-libp2p-swarm/testing" ma "github.com/multiformats/go-multiaddr" ) @@ -23,17 +25,17 @@ var msg = []byte("relay works!") func testSetupRelay(t *testing.T, ctx context.Context) []host.Host { hosts := getNetHosts(t, ctx, 3) - err := AddRelayTransport(ctx, hosts[0]) + err := AddRelayTransport(ctx, hosts[0], swarmt.GenUpgrader(hosts[0].Network().(*swarm.Swarm))) if err != nil { t.Fatal(err) } - err = AddRelayTransport(ctx, hosts[1], OptHop) + err = AddRelayTransport(ctx, hosts[1], swarmt.GenUpgrader(hosts[1].Network().(*swarm.Swarm)), OptHop) if err != nil { t.Fatal(err) } - err = AddRelayTransport(ctx, hosts[2]) + err = AddRelayTransport(ctx, hosts[2], swarmt.GenUpgrader(hosts[2].Network().(*swarm.Swarm))) if err != nil { t.Fatal(err) }