Commit 231b8f2b authored by Lars Gierth's avatar Lars Gierth
Browse files

WIP

parent aa7aa16b
......@@ -5,51 +5,27 @@ I'm using it to test out interfaces and conventions, and also to produce working
For now it's going to be the simplest possible echo server/client.
## Additions
## New packages
package p2phost
type MsgHandler func(peer.ID, protocol.ID, []byte)
type Host interface {
MsgMux() *msmux.MultigramMuxer
SetMsgHandler(protocol.ID, inet.MsgHandler)
SetMsgHandlerMatch(protocol.ID, func(string) bool, MsgHandler)
RemoveMsgHandler(protocol.ID)
WriteMsg(context.Context, peer.ID, ...protocol.ID, []byte)
}
package p2pswarm
type MsgHandler func(peer.ID, []byte)
func (s *Swarm) AddPacketTransport(p2ptransport.PacketTransport) {}
func (s *Swarm) SetMsgHandler(MsgHandler) {}
func (s *Swarm) MsgHandler() MsgHandler {}
package p2piconn
type PacketConn interface {}
package p2pnet
package p2pstream
func NoOpMsgHandler(msg []byte, peeridOrConn) {}
package p2ptransport
package udptransport
- [ ] go-multigram
- [ ] go-multigram-select
- [ ] go-libp2p-wireguard
- [ ] go-udp-transport
package manet
## TODO
## Affected packages
- [ ] go-multiaddr-net datagram support
- [ ] go-libp2p-transport datagram support
- [ ] go-udp-transport
- [ ] go-peerstream datagram support
- [ ] go-libp2p-swarm datagram support
- [ ] go-multigram
- [ ] go-shs vs. go-dtls vs. go-cryptoauth
- [ ] label-based switch
- [ ] overlay routing interfaces
- [x] go-multiaddr-net (manet.PacketConn)
- [ ] go-libp2p-transport (tptiface.PacketTransport/Dialer/Conn)
- [ ] go-libp2p-swarm (sw.AddPacketTransport(), sw.SetPacketHandler(), sw.WritePacket())
- [ ] go-libp2p-host (hostiface.SetPacketHandler(), hostiface.WritePacket())
- [ ] go-libp2p-net (netiface.PacketHandler)
## PR
## About wireguard-go
This PR adds APIs for message-based communication
- Looks good, but way too tightly coupled
- main.go, device.go
- send.go, receive.go
- device routines/queues and peer routines/queues
- split up: packetconn, cli+uapi+tun+routing
......@@ -16,7 +16,6 @@ func fatal(i interface{}) {
os.Exit(1)
}
// XXX unrewritten broken because jbenet/go-stream-muxer is out of date
// TODO move to libp2p org: go-stream-muxer go-smux-multistream go-smux-spdystream go-smux-yamux
// TODO multigram will live in BasicHost, for now it's only swarm
......@@ -44,18 +43,17 @@ func main() {
fatal(err)
}
// Conn as argument, for WriteMsg()?
s.SetMsgHandler(func(msg []byte, p peer.ID) {
fmt.Printf("got message from %s: %s\n", p, string(msg))
s.SetPacketHandler(func(pkt *[]byte, p peer.ID) {
fmt.Printf("got message from %s: %s\n", p, pkt)
_, err = s.WriteMsg(msg, p)
_, err = s.WritePacket(pkt, p)
if err != nil {
fmt.Println(err)
return
}
})
s.WriteMsg("hey bob", QmBob)
// s.WritePacket("hey bob", QmBob)
// Wait forever
<-make(chan bool)
......
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