1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-09-10 14:34:24 +08:00
Files
kubo/netmux/netmux.go
Carlos Cobo 4b06adf7fc gofmt
2014-07-24 14:31:41 +02:00

47 lines
1.0 KiB
Go

package netmux
// The netmux module provides a "network multiplexer".
// The core idea is to have the client be able to connect to
// many different networks (potentially over different transports)
// and multiplex everything over one interface.
type Netmux struct {
// the list of NetMux interfaces
Interfaces []*Interface
// The channels to send/recv from
Incoming <-chan *Packet
Outgoing chan<- *Packet
// internally managed other side of channels
incomingSrc chan<- *Packet
outgoingSrc <-chan *Packet
}
// Warning: will probably change to adopt multiaddr format
type Packet struct {
// the network addresses to send to
// e.g. tcp4://127.0.0.1:12345
NetAddrTo string
// the network addresses to recv from
// e.g. tcp4://127.0.0.1:12345
// may be left blank to select one automatically.
NetAddrFrom string
// the data to send.
Data []byte
}
func NewNetmux() *Netmux {
n := &Netmux{}
// setup channels
och := make(chan *Packet)
ich := make(chan *Packet)
n.Incoming, n.incomingSrc = ich, ich
n.Outgoing, n.outgoingSrc = och, och
return n
}