Commit 2984fb72 authored by Juan Batiz-Benet's avatar Juan Batiz-Benet

add relaying to mocknet

These services should all be added separately, in a function
that is Network impl independent. The interfaces need to be
massaged a bit (split inet.Network in two), so will do when
needed. For now this is fine.
parent 49cb135c
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
inet "github.com/jbenet/go-ipfs/net" inet "github.com/jbenet/go-ipfs/net"
ids "github.com/jbenet/go-ipfs/net/services/identify" ids "github.com/jbenet/go-ipfs/net/services/identify"
mux "github.com/jbenet/go-ipfs/net/services/mux" mux "github.com/jbenet/go-ipfs/net/services/mux"
relay "github.com/jbenet/go-ipfs/net/services/relay"
peer "github.com/jbenet/go-ipfs/peer" peer "github.com/jbenet/go-ipfs/peer"
context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context" context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
...@@ -30,8 +31,9 @@ type peernet struct { ...@@ -30,8 +31,9 @@ type peernet struct {
connsByLink map[*link]map[*conn]struct{} connsByLink map[*link]map[*conn]struct{}
// needed to implement inet.Network // needed to implement inet.Network
mux mux.Mux mux mux.Mux
ids *ids.IDService ids *ids.IDService
relay *relay.RelayService
cg ctxgroup.ContextGroup cg ctxgroup.ContextGroup
sync.RWMutex sync.RWMutex
...@@ -69,6 +71,9 @@ func newPeernet(ctx context.Context, m *mocknet, k ic.PrivKey, ...@@ -69,6 +71,9 @@ func newPeernet(ctx context.Context, m *mocknet, k ic.PrivKey,
// this is ProtocolIdentify. // this is ProtocolIdentify.
n.ids = ids.NewIDService(n) n.ids = ids.NewIDService(n)
// setup ProtocolRelay to allow traffic relaying.
// Feed things we get for ourselves into the muxer.
n.relay = relay.NewRelayService(n.cg.Context(), n, n.mux.HandleSync)
return n, nil return n, nil
} }
......
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