mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-01 19:24:14 +08:00
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.
This commit is contained in:
@ -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 {
|
|||||||
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,
|
|||||||
// 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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user