meshconn/peer.go
func (p *Peer) WriteTo(b []byte, dst net.Addr) (n int, err error) {
	c := make(chan struct{})
	p.actions <- func() {
		defer close(c)
		if p.gossip == nil {
			err = ErrGossipNotRegistered
			return
		}
		meshAddr, ok := dst.(MeshAddr)
		if !ok {
			err = ErrNotMeshAddr
			return
		}
		pkt := pkt{SrcName: p.name, SrcUID: p.uid, Buf: b}
		if meshAddr.PeerName == p.name {
			p.recv <- pkt
			return
		}
		// TODO(pb): detect and support broadcast
		buf := pkt.encode()
		n = len(buf)
		err = p.gossip.GossipUnicast(meshAddr.PeerName, buf)
	}
	<-c
	return n, err
}
func (p *Peer) WriteTo(b []byte, dst net.Addr) (n int, err error) {
	c := make(chan struct{})
	p.actions <- func() {
		defer close(c)
		if p.gossip == nil {
			err = ErrGossipNotRegistered
			return
		}
		meshAddr, ok := dst.(MeshAddr)
		if !ok {
			err = ErrNotMeshAddr
			return
		}
		pkt := pkt{SrcName: p.name, SrcUID: p.uid, Buf: b}
		if meshAddr.PeerName == p.name {
			p.recv <- pkt
			return
		}
		// TODO(pb): detect and support broadcast
		buf := pkt.encode()
		n = len(buf)
		err = p.gossip.GossipUnicast(meshAddr.PeerName, buf)
	}
	<-c
	return n, err
}
// WriteTo implements net.PacketConn.