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 ...@@ -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. For now it's going to be the simplest possible echo server/client.
## Additions ## New packages
package p2phost - [ ] go-multigram
type MsgHandler func(peer.ID, protocol.ID, []byte) - [ ] go-multigram-select
type Host interface { - [ ] go-libp2p-wireguard
MsgMux() *msmux.MultigramMuxer - [ ] go-udp-transport
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
package manet
## TODO ## Affected packages
- [ ] go-multiaddr-net datagram support - [x] go-multiaddr-net (manet.PacketConn)
- [ ] go-libp2p-transport datagram support - [ ] go-libp2p-transport (tptiface.PacketTransport/Dialer/Conn)
- [ ] go-udp-transport - [ ] go-libp2p-swarm (sw.AddPacketTransport(), sw.SetPacketHandler(), sw.WritePacket())
- [ ] go-peerstream datagram support - [ ] go-libp2p-host (hostiface.SetPacketHandler(), hostiface.WritePacket())
- [ ] go-libp2p-swarm datagram support - [ ] go-libp2p-net (netiface.PacketHandler)
- [ ] go-multigram
- [ ] go-shs vs. go-dtls vs. go-cryptoauth
- [ ] label-based switch
- [ ] overlay routing interfaces
## 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{}) { ...@@ -16,7 +16,6 @@ func fatal(i interface{}) {
os.Exit(1) 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 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 // TODO multigram will live in BasicHost, for now it's only swarm
...@@ -44,18 +43,17 @@ func main() { ...@@ -44,18 +43,17 @@ func main() {
fatal(err) fatal(err)
} }
// Conn as argument, for WriteMsg()? s.SetPacketHandler(func(pkt *[]byte, p peer.ID) {
s.SetMsgHandler(func(msg []byte, p peer.ID) { fmt.Printf("got message from %s: %s\n", p, pkt)
fmt.Printf("got message from %s: %s\n", p, string(msg))
_, err = s.WriteMsg(msg, p) _, err = s.WritePacket(pkt, p)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
}) })
s.WriteMsg("hey bob", QmBob) // s.WritePacket("hey bob", QmBob)
// Wait forever // Wait forever
<-make(chan bool) <-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