mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 11:15:07 +03:00 
			
		
		
		
	update for wire format changes
This commit is contained in:
		
						commit
						34939d4b18
					
				
					 7 changed files with 283 additions and 283 deletions
				
			
		| 
						 | 
				
			
			@ -583,9 +583,9 @@ func (a *admin) getResponse_dot() []byte {
 | 
			
		|||
			infos[info.key] = info
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	addInfo(dht, "fillcolor=\"#ffffff\" style=filled fontname=\"sans serif\"", "Known in DHT") // white
 | 
			
		||||
	addInfo(sessions, "fillcolor=\"#acf3fd\" style=filled fontname=\"sans serif\"", "Open session") // blue
 | 
			
		||||
	addInfo(peers, "fillcolor=\"#ffffb5\" style=filled fontname=\"sans serif\"", "Connected peer") // yellow
 | 
			
		||||
	addInfo(dht, "fillcolor=\"#ffffff\" style=filled fontname=\"sans serif\"", "Known in DHT")                               // white
 | 
			
		||||
	addInfo(sessions, "fillcolor=\"#acf3fd\" style=filled fontname=\"sans serif\"", "Open session")                          // blue
 | 
			
		||||
	addInfo(peers, "fillcolor=\"#ffffb5\" style=filled fontname=\"sans serif\"", "Connected peer")                           // yellow
 | 
			
		||||
	addInfo(append([]admin_nodeInfo(nil), *self), "fillcolor=\"#a5ff8a\" style=filled fontname=\"sans serif\"", "This node") // green
 | 
			
		||||
	// Get coords as a slice of strings, FIXME? this looks very fragile
 | 
			
		||||
	coordSlice := func(coords string) []string {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -51,16 +51,16 @@ type bucket struct {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
type dhtReq struct {
 | 
			
		||||
	key    boxPubKey // Key of whoever asked
 | 
			
		||||
	coords []byte    // Coords of whoever asked
 | 
			
		||||
	dest   NodeID    // NodeID they're asking about
 | 
			
		||||
	Key    boxPubKey // Key of whoever asked
 | 
			
		||||
	Coords []byte    // Coords of whoever asked
 | 
			
		||||
	Dest   NodeID    // NodeID they're asking about
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type dhtRes struct {
 | 
			
		||||
	key    boxPubKey // key to respond to
 | 
			
		||||
	coords []byte    // coords to respond to
 | 
			
		||||
	dest   NodeID
 | 
			
		||||
	infos  []*dhtInfo // response
 | 
			
		||||
	Key    boxPubKey // key to respond to
 | 
			
		||||
	Coords []byte    // coords to respond to
 | 
			
		||||
	Dest   NodeID
 | 
			
		||||
	Infos  []*dhtInfo // response
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type dht_rumor struct {
 | 
			
		||||
| 
						 | 
				
			
			@ -90,16 +90,16 @@ func (t *dht) handleReq(req *dhtReq) {
 | 
			
		|||
	loc := t.core.switchTable.getLocator()
 | 
			
		||||
	coords := loc.getCoords()
 | 
			
		||||
	res := dhtRes{
 | 
			
		||||
		key:    t.core.boxPub,
 | 
			
		||||
		coords: coords,
 | 
			
		||||
		dest:   req.dest,
 | 
			
		||||
		infos:  t.lookup(&req.dest, false),
 | 
			
		||||
		Key:    t.core.boxPub,
 | 
			
		||||
		Coords: coords,
 | 
			
		||||
		Dest:   req.Dest,
 | 
			
		||||
		Infos:  t.lookup(&req.Dest, false),
 | 
			
		||||
	}
 | 
			
		||||
	t.sendRes(&res, req)
 | 
			
		||||
	// Also (possibly) add them to our DHT
 | 
			
		||||
	info := dhtInfo{
 | 
			
		||||
		key:    req.key,
 | 
			
		||||
		coords: req.coords,
 | 
			
		||||
		key:    req.Key,
 | 
			
		||||
		coords: req.Coords,
 | 
			
		||||
	}
 | 
			
		||||
	t.insertIfNew(&info, false) // This seems DoSable (we just trust their coords...)
 | 
			
		||||
	//if req.dest != t.nodeID { t.ping(&info, info.getNodeID()) } // Or spam...
 | 
			
		||||
| 
						 | 
				
			
			@ -107,17 +107,17 @@ func (t *dht) handleReq(req *dhtReq) {
 | 
			
		|||
 | 
			
		||||
func (t *dht) handleRes(res *dhtRes) {
 | 
			
		||||
	t.core.searches.handleDHTRes(res)
 | 
			
		||||
	reqs, isIn := t.reqs[res.key]
 | 
			
		||||
	reqs, isIn := t.reqs[res.Key]
 | 
			
		||||
	if !isIn {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	_, isIn = reqs[res.dest]
 | 
			
		||||
	_, isIn = reqs[res.Dest]
 | 
			
		||||
	if !isIn {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	rinfo := dhtInfo{
 | 
			
		||||
		key:    res.key,
 | 
			
		||||
		coords: res.coords,
 | 
			
		||||
		key:    res.Key,
 | 
			
		||||
		coords: res.Coords,
 | 
			
		||||
		send:   time.Now(), // Technically wrong but should be OK...
 | 
			
		||||
		recv:   time.Now(),
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -139,15 +139,15 @@ func (t *dht) handleRes(res *dhtRes) {
 | 
			
		|||
	}
 | 
			
		||||
	// Insert into table
 | 
			
		||||
	t.insert(&rinfo, false)
 | 
			
		||||
	if res.dest == *rinfo.getNodeID() {
 | 
			
		||||
	if res.Dest == *rinfo.getNodeID() {
 | 
			
		||||
		return
 | 
			
		||||
	} // No infinite recursions
 | 
			
		||||
	if len(res.infos) > dht_lookup_size {
 | 
			
		||||
	if len(res.Infos) > dht_lookup_size {
 | 
			
		||||
		// Ignore any "extra" lookup results
 | 
			
		||||
		res.infos = res.infos[:dht_lookup_size]
 | 
			
		||||
		res.Infos = res.Infos[:dht_lookup_size]
 | 
			
		||||
	}
 | 
			
		||||
	for _, info := range res.infos {
 | 
			
		||||
		if dht_firstCloserThanThird(info.getNodeID(), &res.dest, rinfo.getNodeID()) {
 | 
			
		||||
	for _, info := range res.Infos {
 | 
			
		||||
		if dht_firstCloserThanThird(info.getNodeID(), &res.Dest, rinfo.getNodeID()) {
 | 
			
		||||
			t.addToMill(info, info.getNodeID())
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -319,12 +319,12 @@ func (t *dht) sendReq(req *dhtReq, dest *dhtInfo) {
 | 
			
		|||
	shared := t.core.sessions.getSharedKey(&t.core.boxPriv, &dest.key)
 | 
			
		||||
	payload, nonce := boxSeal(shared, bs, nil)
 | 
			
		||||
	p := wire_protoTrafficPacket{
 | 
			
		||||
		ttl:     ^uint64(0),
 | 
			
		||||
		coords:  dest.coords,
 | 
			
		||||
		toKey:   dest.key,
 | 
			
		||||
		fromKey: t.core.boxPub,
 | 
			
		||||
		nonce:   *nonce,
 | 
			
		||||
		payload: payload,
 | 
			
		||||
		TTL:     ^uint64(0),
 | 
			
		||||
		Coords:  dest.coords,
 | 
			
		||||
		ToKey:   dest.key,
 | 
			
		||||
		FromKey: t.core.boxPub,
 | 
			
		||||
		Nonce:   *nonce,
 | 
			
		||||
		Payload: payload,
 | 
			
		||||
	}
 | 
			
		||||
	packet := p.encode()
 | 
			
		||||
	t.core.router.out(packet)
 | 
			
		||||
| 
						 | 
				
			
			@ -336,21 +336,21 @@ func (t *dht) sendReq(req *dhtReq, dest *dhtInfo) {
 | 
			
		|||
			panic("This should never happen")
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	reqsToDest[req.dest] = time.Now()
 | 
			
		||||
	reqsToDest[req.Dest] = time.Now()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (t *dht) sendRes(res *dhtRes, req *dhtReq) {
 | 
			
		||||
	// Send a reply for a dhtReq
 | 
			
		||||
	bs := res.encode()
 | 
			
		||||
	shared := t.core.sessions.getSharedKey(&t.core.boxPriv, &req.key)
 | 
			
		||||
	shared := t.core.sessions.getSharedKey(&t.core.boxPriv, &req.Key)
 | 
			
		||||
	payload, nonce := boxSeal(shared, bs, nil)
 | 
			
		||||
	p := wire_protoTrafficPacket{
 | 
			
		||||
		ttl:     ^uint64(0),
 | 
			
		||||
		coords:  req.coords,
 | 
			
		||||
		toKey:   req.key,
 | 
			
		||||
		fromKey: t.core.boxPub,
 | 
			
		||||
		nonce:   *nonce,
 | 
			
		||||
		payload: payload,
 | 
			
		||||
		TTL:     ^uint64(0),
 | 
			
		||||
		Coords:  req.Coords,
 | 
			
		||||
		ToKey:   req.Key,
 | 
			
		||||
		FromKey: t.core.boxPub,
 | 
			
		||||
		Nonce:   *nonce,
 | 
			
		||||
		Payload: payload,
 | 
			
		||||
	}
 | 
			
		||||
	packet := p.encode()
 | 
			
		||||
	t.core.router.out(packet)
 | 
			
		||||
| 
						 | 
				
			
			@ -404,9 +404,9 @@ func (t *dht) ping(info *dhtInfo, target *NodeID) {
 | 
			
		|||
	loc := t.core.switchTable.getLocator()
 | 
			
		||||
	coords := loc.getCoords()
 | 
			
		||||
	req := dhtReq{
 | 
			
		||||
		key:    t.core.boxPub,
 | 
			
		||||
		coords: coords,
 | 
			
		||||
		dest:   *target,
 | 
			
		||||
		Key:    t.core.boxPub,
 | 
			
		||||
		Coords: coords,
 | 
			
		||||
		Dest:   *target,
 | 
			
		||||
	}
 | 
			
		||||
	info.pings++
 | 
			
		||||
	info.send = time.Now()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -207,16 +207,16 @@ func (p *peer) linkLoop(in <-chan []byte) {
 | 
			
		|||
			switch {
 | 
			
		||||
			case p.msgAnc == nil:
 | 
			
		||||
				update = true
 | 
			
		||||
			case lastRSeq != p.msgAnc.seq:
 | 
			
		||||
			case lastRSeq != p.msgAnc.Seq:
 | 
			
		||||
				update = true
 | 
			
		||||
			case p.msgAnc.rseq != p.myMsg.seq:
 | 
			
		||||
			case p.msgAnc.Rseq != p.myMsg.seq:
 | 
			
		||||
				update = true
 | 
			
		||||
			case counter%4 == 0:
 | 
			
		||||
				update = true
 | 
			
		||||
			}
 | 
			
		||||
			if update {
 | 
			
		||||
				if p.msgAnc != nil {
 | 
			
		||||
					lastRSeq = p.msgAnc.seq
 | 
			
		||||
					lastRSeq = p.msgAnc.Seq
 | 
			
		||||
				}
 | 
			
		||||
				p.sendSwitchAnnounce()
 | 
			
		||||
			}
 | 
			
		||||
| 
						 | 
				
			
			@ -291,8 +291,8 @@ func (p *peer) sendPacket(packet []byte) {
 | 
			
		|||
func (p *peer) sendLinkPacket(packet []byte) {
 | 
			
		||||
	bs, nonce := boxSeal(&p.shared, packet, nil)
 | 
			
		||||
	linkPacket := wire_linkProtoTrafficPacket{
 | 
			
		||||
		nonce:   *nonce,
 | 
			
		||||
		payload: bs,
 | 
			
		||||
		Nonce:   *nonce,
 | 
			
		||||
		Payload: bs,
 | 
			
		||||
	}
 | 
			
		||||
	packet = linkPacket.encode()
 | 
			
		||||
	p.sendPacket(packet)
 | 
			
		||||
| 
						 | 
				
			
			@ -303,7 +303,7 @@ func (p *peer) handleLinkTraffic(bs []byte) {
 | 
			
		|||
	if !packet.decode(bs) {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	payload, isOK := boxOpen(&p.shared, packet.payload, &packet.nonce)
 | 
			
		||||
	payload, isOK := boxOpen(&p.shared, packet.Payload, &packet.Nonce)
 | 
			
		||||
	if !isOK {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -331,9 +331,9 @@ func (p *peer) handleSwitchAnnounce(packet []byte) {
 | 
			
		|||
	}
 | 
			
		||||
	//if p.msgAnc != nil && anc.Seq != p.msgAnc.Seq { p.msgHops = nil }
 | 
			
		||||
	if p.msgAnc == nil ||
 | 
			
		||||
		anc.root != p.msgAnc.root ||
 | 
			
		||||
		anc.tstamp != p.msgAnc.tstamp ||
 | 
			
		||||
		anc.seq != p.msgAnc.seq {
 | 
			
		||||
		anc.Root != p.msgAnc.Root ||
 | 
			
		||||
		anc.Tstamp != p.msgAnc.Tstamp ||
 | 
			
		||||
		anc.Seq != p.msgAnc.Seq {
 | 
			
		||||
		p.msgHops = nil
 | 
			
		||||
	}
 | 
			
		||||
	p.msgAnc = &anc
 | 
			
		||||
| 
						 | 
				
			
			@ -344,10 +344,10 @@ func (p *peer) handleSwitchAnnounce(packet []byte) {
 | 
			
		|||
func (p *peer) requestHop(hop uint64) {
 | 
			
		||||
	//p.core.log.Println("DEBUG requestHop")
 | 
			
		||||
	req := msgHopReq{}
 | 
			
		||||
	req.root = p.msgAnc.root
 | 
			
		||||
	req.tstamp = p.msgAnc.tstamp
 | 
			
		||||
	req.seq = p.msgAnc.seq
 | 
			
		||||
	req.hop = hop
 | 
			
		||||
	req.Root = p.msgAnc.Root
 | 
			
		||||
	req.Tstamp = p.msgAnc.Tstamp
 | 
			
		||||
	req.Seq = p.msgAnc.Seq
 | 
			
		||||
	req.Hop = hop
 | 
			
		||||
	packet := req.encode()
 | 
			
		||||
	p.sendLinkPacket(packet)
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -364,28 +364,28 @@ func (p *peer) handleSwitchHopRequest(packet []byte) {
 | 
			
		|||
	if !req.decode(packet) {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	if req.root != p.myMsg.locator.root {
 | 
			
		||||
	if req.Root != p.myMsg.locator.root {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	if req.tstamp != p.myMsg.locator.tstamp {
 | 
			
		||||
	if req.Tstamp != p.myMsg.locator.tstamp {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	if req.seq != p.myMsg.seq {
 | 
			
		||||
	if req.Seq != p.myMsg.seq {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	if uint64(len(p.myMsg.locator.coords)) <= req.hop {
 | 
			
		||||
	if uint64(len(p.myMsg.locator.coords)) <= req.Hop {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	res := msgHop{}
 | 
			
		||||
	res.root = p.myMsg.locator.root
 | 
			
		||||
	res.tstamp = p.myMsg.locator.tstamp
 | 
			
		||||
	res.seq = p.myMsg.seq
 | 
			
		||||
	res.hop = req.hop
 | 
			
		||||
	res.port = p.myMsg.locator.coords[res.hop]
 | 
			
		||||
	sinfo := p.getSig(res.hop)
 | 
			
		||||
	res.Root = p.myMsg.locator.root
 | 
			
		||||
	res.Tstamp = p.myMsg.locator.tstamp
 | 
			
		||||
	res.Seq = p.myMsg.seq
 | 
			
		||||
	res.Hop = req.Hop
 | 
			
		||||
	res.Port = p.myMsg.locator.coords[res.Hop]
 | 
			
		||||
	sinfo := p.getSig(res.Hop)
 | 
			
		||||
	//p.core.log.Println("DEBUG sig:", sinfo)
 | 
			
		||||
	res.next = sinfo.next
 | 
			
		||||
	res.sig = sinfo.sig
 | 
			
		||||
	res.Next = sinfo.next
 | 
			
		||||
	res.Sig = sinfo.sig
 | 
			
		||||
	packet = res.encode()
 | 
			
		||||
	p.sendLinkPacket(packet)
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -402,31 +402,31 @@ func (p *peer) handleSwitchHop(packet []byte) {
 | 
			
		|||
	if !res.decode(packet) {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	if res.root != p.msgAnc.root {
 | 
			
		||||
	if res.Root != p.msgAnc.Root {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	if res.tstamp != p.msgAnc.tstamp {
 | 
			
		||||
	if res.Tstamp != p.msgAnc.Tstamp {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	if res.seq != p.msgAnc.seq {
 | 
			
		||||
	if res.Seq != p.msgAnc.Seq {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	if res.hop != uint64(len(p.msgHops)) {
 | 
			
		||||
	if res.Hop != uint64(len(p.msgHops)) {
 | 
			
		||||
		return
 | 
			
		||||
	} // always process in order
 | 
			
		||||
	loc := switchLocator{coords: make([]switchPort, 0, len(p.msgHops)+1)}
 | 
			
		||||
	loc.root = res.root
 | 
			
		||||
	loc.tstamp = res.tstamp
 | 
			
		||||
	loc.root = res.Root
 | 
			
		||||
	loc.tstamp = res.Tstamp
 | 
			
		||||
	for _, hop := range p.msgHops {
 | 
			
		||||
		loc.coords = append(loc.coords, hop.port)
 | 
			
		||||
		loc.coords = append(loc.coords, hop.Port)
 | 
			
		||||
	}
 | 
			
		||||
	loc.coords = append(loc.coords, res.port)
 | 
			
		||||
	thisHopKey := &res.root
 | 
			
		||||
	if res.hop != 0 {
 | 
			
		||||
		thisHopKey = &p.msgHops[res.hop-1].next
 | 
			
		||||
	loc.coords = append(loc.coords, res.Port)
 | 
			
		||||
	thisHopKey := &res.Root
 | 
			
		||||
	if res.Hop != 0 {
 | 
			
		||||
		thisHopKey = &p.msgHops[res.Hop-1].Next
 | 
			
		||||
	}
 | 
			
		||||
	bs := getBytesForSig(&res.next, &loc)
 | 
			
		||||
	if p.core.sigs.check(thisHopKey, &res.sig, bs) {
 | 
			
		||||
	bs := getBytesForSig(&res.Next, &loc)
 | 
			
		||||
	if p.core.sigs.check(thisHopKey, &res.Sig, bs) {
 | 
			
		||||
		p.msgHops = append(p.msgHops, &res)
 | 
			
		||||
		p.processSwitchMessage()
 | 
			
		||||
	} else {
 | 
			
		||||
| 
						 | 
				
			
			@ -442,12 +442,12 @@ func (p *peer) processSwitchMessage() {
 | 
			
		|||
	if p.msgAnc == nil {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	if uint64(len(p.msgHops)) < p.msgAnc.len {
 | 
			
		||||
	if uint64(len(p.msgHops)) < p.msgAnc.Len {
 | 
			
		||||
		p.requestHop(uint64(len(p.msgHops)))
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	p.throttle++
 | 
			
		||||
	if p.msgAnc.len != uint64(len(p.msgHops)) {
 | 
			
		||||
	if p.msgAnc.Len != uint64(len(p.msgHops)) {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	msg := switchMessage{}
 | 
			
		||||
| 
						 | 
				
			
			@ -455,26 +455,26 @@ func (p *peer) processSwitchMessage() {
 | 
			
		|||
	sigs := make([]sigInfo, 0, len(p.msgHops))
 | 
			
		||||
	for idx, hop := range p.msgHops {
 | 
			
		||||
		// Consistency checks, should be redundant (already checked these...)
 | 
			
		||||
		if hop.root != p.msgAnc.root {
 | 
			
		||||
		if hop.Root != p.msgAnc.Root {
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
		if hop.tstamp != p.msgAnc.tstamp {
 | 
			
		||||
		if hop.Tstamp != p.msgAnc.Tstamp {
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
		if hop.seq != p.msgAnc.seq {
 | 
			
		||||
		if hop.Seq != p.msgAnc.Seq {
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
		if hop.hop != uint64(idx) {
 | 
			
		||||
		if hop.Hop != uint64(idx) {
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
		coords = append(coords, hop.port)
 | 
			
		||||
		sigs = append(sigs, sigInfo{next: hop.next, sig: hop.sig})
 | 
			
		||||
		coords = append(coords, hop.Port)
 | 
			
		||||
		sigs = append(sigs, sigInfo{next: hop.Next, sig: hop.Sig})
 | 
			
		||||
	}
 | 
			
		||||
	msg.from = p.sig
 | 
			
		||||
	msg.locator.root = p.msgAnc.root
 | 
			
		||||
	msg.locator.tstamp = p.msgAnc.tstamp
 | 
			
		||||
	msg.locator.root = p.msgAnc.Root
 | 
			
		||||
	msg.locator.tstamp = p.msgAnc.Tstamp
 | 
			
		||||
	msg.locator.coords = coords
 | 
			
		||||
	msg.seq = p.msgAnc.seq
 | 
			
		||||
	msg.seq = p.msgAnc.Seq
 | 
			
		||||
	//msg.RSeq = p.msgAnc.RSeq
 | 
			
		||||
	//msg.Degree = p.msgAnc.Deg
 | 
			
		||||
	p.core.switchTable.handleMessage(&msg, p.port, sigs)
 | 
			
		||||
| 
						 | 
				
			
			@ -493,13 +493,13 @@ func (p *peer) processSwitchMessage() {
 | 
			
		|||
 | 
			
		||||
func (p *peer) sendSwitchAnnounce() {
 | 
			
		||||
	anc := msgAnnounce{}
 | 
			
		||||
	anc.root = p.myMsg.locator.root
 | 
			
		||||
	anc.tstamp = p.myMsg.locator.tstamp
 | 
			
		||||
	anc.seq = p.myMsg.seq
 | 
			
		||||
	anc.len = uint64(len(p.myMsg.locator.coords))
 | 
			
		||||
	anc.Root = p.myMsg.locator.root
 | 
			
		||||
	anc.Tstamp = p.myMsg.locator.tstamp
 | 
			
		||||
	anc.Seq = p.myMsg.seq
 | 
			
		||||
	anc.Len = uint64(len(p.myMsg.locator.coords))
 | 
			
		||||
	//anc.Deg = p.myMsg.Degree
 | 
			
		||||
	if p.msgAnc != nil {
 | 
			
		||||
		anc.rseq = p.msgAnc.seq
 | 
			
		||||
		anc.Rseq = p.msgAnc.Seq
 | 
			
		||||
	}
 | 
			
		||||
	packet := anc.encode()
 | 
			
		||||
	p.sendLinkPacket(packet)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -266,7 +266,7 @@ func (r *router) handleTraffic(packet []byte) {
 | 
			
		|||
	if !p.decode(packet) {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	sinfo, isIn := r.core.sessions.getSessionForHandle(&p.handle)
 | 
			
		||||
	sinfo, isIn := r.core.sessions.getSessionForHandle(&p.Handle)
 | 
			
		||||
	if !isIn {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -283,13 +283,13 @@ func (r *router) handleProto(packet []byte) {
 | 
			
		|||
	// Now try to open the payload
 | 
			
		||||
	var sharedKey *boxSharedKey
 | 
			
		||||
	//var theirPermPub *boxPubKey
 | 
			
		||||
	if p.toKey == r.core.boxPub {
 | 
			
		||||
	if p.ToKey == r.core.boxPub {
 | 
			
		||||
		// Try to open using our permanent key
 | 
			
		||||
		sharedKey = r.core.sessions.getSharedKey(&r.core.boxPriv, &p.fromKey)
 | 
			
		||||
		sharedKey = r.core.sessions.getSharedKey(&r.core.boxPriv, &p.FromKey)
 | 
			
		||||
	} else {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	bs, isOK := boxOpen(sharedKey, p.payload, &p.nonce)
 | 
			
		||||
	bs, isOK := boxOpen(sharedKey, p.Payload, &p.Nonce)
 | 
			
		||||
	if !isOK {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -303,13 +303,13 @@ func (r *router) handleProto(packet []byte) {
 | 
			
		|||
	//fmt.Println("RECV bytes:", bs)
 | 
			
		||||
	switch bsType {
 | 
			
		||||
	case wire_SessionPing:
 | 
			
		||||
		r.handlePing(bs, &p.fromKey)
 | 
			
		||||
		r.handlePing(bs, &p.FromKey)
 | 
			
		||||
	case wire_SessionPong:
 | 
			
		||||
		r.handlePong(bs, &p.fromKey)
 | 
			
		||||
		r.handlePong(bs, &p.FromKey)
 | 
			
		||||
	case wire_DHTLookupRequest:
 | 
			
		||||
		r.handleDHTReq(bs, &p.fromKey)
 | 
			
		||||
		r.handleDHTReq(bs, &p.FromKey)
 | 
			
		||||
	case wire_DHTLookupResponse:
 | 
			
		||||
		r.handleDHTRes(bs, &p.fromKey)
 | 
			
		||||
		r.handleDHTRes(bs, &p.FromKey)
 | 
			
		||||
	case wire_SearchRequest:
 | 
			
		||||
		r.handleSearchReq(bs)
 | 
			
		||||
	case wire_SearchResponse:
 | 
			
		||||
| 
						 | 
				
			
			@ -324,7 +324,7 @@ func (r *router) handlePing(bs []byte, fromKey *boxPubKey) {
 | 
			
		|||
	if !ping.decode(bs) {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	ping.sendPermPub = *fromKey
 | 
			
		||||
	ping.SendPermPub = *fromKey
 | 
			
		||||
	r.core.sessions.handlePing(&ping)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -337,7 +337,7 @@ func (r *router) handleDHTReq(bs []byte, fromKey *boxPubKey) {
 | 
			
		|||
	if !req.decode(bs) {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	req.key = *fromKey
 | 
			
		||||
	req.Key = *fromKey
 | 
			
		||||
	r.core.dht.handleReq(&req)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -346,7 +346,7 @@ func (r *router) handleDHTRes(bs []byte, fromKey *boxPubKey) {
 | 
			
		|||
	if !res.decode(bs) {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	res.key = *fromKey
 | 
			
		||||
	res.Key = *fromKey
 | 
			
		||||
	r.core.dht.handleRes(&res)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -62,7 +62,7 @@ func (s *searches) createSearch(dest *NodeID, mask *NodeID) *searchInfo {
 | 
			
		|||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
func (s *searches) handleDHTRes(res *dhtRes) {
 | 
			
		||||
	sinfo, isIn := s.searches[res.dest]
 | 
			
		||||
	sinfo, isIn := s.searches[res.Dest]
 | 
			
		||||
	if !isIn || s.checkDHTRes(sinfo, res) {
 | 
			
		||||
		// Either we don't recognize this search, or we just finished it
 | 
			
		||||
		return
 | 
			
		||||
| 
						 | 
				
			
			@ -75,12 +75,12 @@ func (s *searches) handleDHTRes(res *dhtRes) {
 | 
			
		|||
 | 
			
		||||
func (s *searches) addToSearch(sinfo *searchInfo, res *dhtRes) {
 | 
			
		||||
	// Add responses to toVisit if closer to dest than the res node
 | 
			
		||||
	from := dhtInfo{key: res.key, coords: res.coords}
 | 
			
		||||
	for _, info := range res.infos {
 | 
			
		||||
	from := dhtInfo{key: res.Key, coords: res.Coords}
 | 
			
		||||
	for _, info := range res.Infos {
 | 
			
		||||
		if sinfo.visited[*info.getNodeID()] {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
		if dht_firstCloserThanThird(info.getNodeID(), &res.dest, from.getNodeID()) {
 | 
			
		||||
		if dht_firstCloserThanThird(info.getNodeID(), &res.Dest, from.getNodeID()) {
 | 
			
		||||
			sinfo.toVisit = append(sinfo.toVisit, info)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -95,7 +95,7 @@ func (s *searches) addToSearch(sinfo *searchInfo, res *dhtRes) {
 | 
			
		|||
	}
 | 
			
		||||
	// Sort
 | 
			
		||||
	sort.SliceStable(sinfo.toVisit, func(i, j int) bool {
 | 
			
		||||
		return dht_firstCloserThanThird(sinfo.toVisit[i].getNodeID(), &res.dest, sinfo.toVisit[j].getNodeID())
 | 
			
		||||
		return dht_firstCloserThanThird(sinfo.toVisit[i].getNodeID(), &res.Dest, sinfo.toVisit[j].getNodeID())
 | 
			
		||||
	})
 | 
			
		||||
	// Truncate to some maximum size
 | 
			
		||||
	if len(sinfo.toVisit) > search_MAX_SEARCH_SIZE {
 | 
			
		||||
| 
						 | 
				
			
			@ -147,7 +147,7 @@ func (s *searches) newIterSearch(dest *NodeID, mask *NodeID) *searchInfo {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
func (s *searches) checkDHTRes(info *searchInfo, res *dhtRes) bool {
 | 
			
		||||
	them := getNodeID(&res.key)
 | 
			
		||||
	them := getNodeID(&res.Key)
 | 
			
		||||
	var destMasked NodeID
 | 
			
		||||
	var themMasked NodeID
 | 
			
		||||
	for idx := 0; idx < NodeIDLen; idx++ {
 | 
			
		||||
| 
						 | 
				
			
			@ -158,20 +158,20 @@ func (s *searches) checkDHTRes(info *searchInfo, res *dhtRes) bool {
 | 
			
		|||
		return false
 | 
			
		||||
	}
 | 
			
		||||
	// They match, so create a session and send a sessionRequest
 | 
			
		||||
	sinfo, isIn := s.core.sessions.getByTheirPerm(&res.key)
 | 
			
		||||
	sinfo, isIn := s.core.sessions.getByTheirPerm(&res.Key)
 | 
			
		||||
	if !isIn {
 | 
			
		||||
		sinfo = s.core.sessions.createSession(&res.key)
 | 
			
		||||
		_, isIn := s.core.sessions.getByTheirPerm(&res.key)
 | 
			
		||||
		sinfo = s.core.sessions.createSession(&res.Key)
 | 
			
		||||
		_, isIn := s.core.sessions.getByTheirPerm(&res.Key)
 | 
			
		||||
		if !isIn {
 | 
			
		||||
			panic("This should never happen")
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	// FIXME (!) replay attacks could mess with coords? Give it a handle (tstamp)?
 | 
			
		||||
	sinfo.coords = res.coords
 | 
			
		||||
	sinfo.coords = res.Coords
 | 
			
		||||
	sinfo.packet = info.packet
 | 
			
		||||
	s.core.sessions.ping(sinfo)
 | 
			
		||||
	// Cleanup
 | 
			
		||||
	delete(s.searches, res.dest)
 | 
			
		||||
	delete(s.searches, res.Dest)
 | 
			
		||||
	return true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -230,12 +230,12 @@ func (s *searches) forwardSearch(req *searchReq, next *dhtInfo) {
 | 
			
		|||
	shared := s.core.sessions.getSharedKey(&s.core.boxPriv, &next.key)
 | 
			
		||||
	payload, nonce := boxSeal(shared, bs, nil)
 | 
			
		||||
	p := wire_protoTrafficPacket{
 | 
			
		||||
		ttl:     ^uint64(0),
 | 
			
		||||
		coords:  next.coords,
 | 
			
		||||
		toKey:   next.key,
 | 
			
		||||
		fromKey: s.core.boxPub,
 | 
			
		||||
		nonce:   *nonce,
 | 
			
		||||
		payload: payload,
 | 
			
		||||
		TTL:     ^uint64(0),
 | 
			
		||||
		Coords:  next.coords,
 | 
			
		||||
		ToKey:   next.key,
 | 
			
		||||
		FromKey: s.core.boxPub,
 | 
			
		||||
		Nonce:   *nonce,
 | 
			
		||||
		Payload: payload,
 | 
			
		||||
	}
 | 
			
		||||
	packet := p.encode()
 | 
			
		||||
	s.core.router.out(packet)
 | 
			
		||||
| 
						 | 
				
			
			@ -254,12 +254,12 @@ func (s *searches) sendSearchRes(req *searchReq) {
 | 
			
		|||
	shared := s.core.sessions.getSharedKey(&s.core.boxPriv, &req.key)
 | 
			
		||||
	payload, nonce := boxSeal(shared, bs, nil)
 | 
			
		||||
	p := wire_protoTrafficPacket{
 | 
			
		||||
		ttl:     ^uint64(0),
 | 
			
		||||
		coords:  req.coords,
 | 
			
		||||
		toKey:   req.key,
 | 
			
		||||
		fromKey: s.core.boxPub,
 | 
			
		||||
		nonce:   *nonce,
 | 
			
		||||
		payload: payload,
 | 
			
		||||
		TTL:     ^uint64(0),
 | 
			
		||||
		Coords:  req.coords,
 | 
			
		||||
		ToKey:   req.key,
 | 
			
		||||
		FromKey: s.core.boxPub,
 | 
			
		||||
		Nonce:   *nonce,
 | 
			
		||||
		Payload: payload,
 | 
			
		||||
	}
 | 
			
		||||
	packet := p.encode()
 | 
			
		||||
	s.core.router.out(packet)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -38,40 +38,40 @@ type sessionInfo struct {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
type sessionPing struct {
 | 
			
		||||
	sendPermPub boxPubKey // Sender's permanent key
 | 
			
		||||
	handle      handle    // Random number to ID session
 | 
			
		||||
	sendSesPub  boxPubKey // Session key to use
 | 
			
		||||
	coords      []byte
 | 
			
		||||
	tstamp      int64 // unix time, but the only real requirement is that it increases
 | 
			
		||||
	isPong      bool
 | 
			
		||||
	mtu         uint16
 | 
			
		||||
	SendPermPub boxPubKey // Sender's permanent key
 | 
			
		||||
	Handle      handle    // Random number to ID session
 | 
			
		||||
	SendSesPub  boxPubKey // Session key to use
 | 
			
		||||
	Coords      []byte
 | 
			
		||||
	Tstamp      int64 // unix time, but the only real requirement is that it increases
 | 
			
		||||
	IsPong      bool
 | 
			
		||||
	MTU         uint16
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Returns true if the session was updated, false otherwise
 | 
			
		||||
func (s *sessionInfo) update(p *sessionPing) bool {
 | 
			
		||||
	if !(p.tstamp > s.tstamp) {
 | 
			
		||||
	if !(p.Tstamp > s.tstamp) {
 | 
			
		||||
		// To protect against replay attacks
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
	if p.sendPermPub != s.theirPermPub {
 | 
			
		||||
	if p.SendPermPub != s.theirPermPub {
 | 
			
		||||
		// Should only happen if two sessions got the same handle
 | 
			
		||||
		// That shouldn't be allowed anyway, but if it happens then let one time out
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
	if p.sendSesPub != s.theirSesPub {
 | 
			
		||||
		s.theirSesPub = p.sendSesPub
 | 
			
		||||
		s.theirHandle = p.handle
 | 
			
		||||
	if p.SendSesPub != s.theirSesPub {
 | 
			
		||||
		s.theirSesPub = p.SendSesPub
 | 
			
		||||
		s.theirHandle = p.Handle
 | 
			
		||||
		s.sharedSesKey = *getSharedKey(&s.mySesPriv, &s.theirSesPub)
 | 
			
		||||
		s.theirNonce = boxNonce{}
 | 
			
		||||
		s.nonceMask = 0
 | 
			
		||||
	}
 | 
			
		||||
	if p.mtu >= 1280 || p.mtu == 0 {
 | 
			
		||||
		s.theirMTU = p.mtu
 | 
			
		||||
	if p.MTU >= 1280 || p.MTU == 0 {
 | 
			
		||||
		s.theirMTU = p.MTU
 | 
			
		||||
	}
 | 
			
		||||
	s.coords = append([]byte{}, p.coords...)
 | 
			
		||||
	s.coords = append([]byte{}, p.Coords...)
 | 
			
		||||
	now := time.Now()
 | 
			
		||||
	s.time = now
 | 
			
		||||
	s.tstamp = p.tstamp
 | 
			
		||||
	s.tstamp = p.Tstamp
 | 
			
		||||
	s.init = true
 | 
			
		||||
	return true
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -215,12 +215,12 @@ func (ss *sessions) getPing(sinfo *sessionInfo) sessionPing {
 | 
			
		|||
	loc := ss.core.switchTable.getLocator()
 | 
			
		||||
	coords := loc.getCoords()
 | 
			
		||||
	ref := sessionPing{
 | 
			
		||||
		sendPermPub: ss.core.boxPub,
 | 
			
		||||
		handle:      sinfo.myHandle,
 | 
			
		||||
		sendSesPub:  sinfo.mySesPub,
 | 
			
		||||
		tstamp:      time.Now().Unix(),
 | 
			
		||||
		coords:      coords,
 | 
			
		||||
		mtu:         sinfo.myMTU,
 | 
			
		||||
		SendPermPub: ss.core.boxPub,
 | 
			
		||||
		Handle:      sinfo.myHandle,
 | 
			
		||||
		SendSesPub:  sinfo.mySesPub,
 | 
			
		||||
		Tstamp:      time.Now().Unix(),
 | 
			
		||||
		Coords:      coords,
 | 
			
		||||
		MTU:         sinfo.myMTU,
 | 
			
		||||
	}
 | 
			
		||||
	sinfo.myNonce.update()
 | 
			
		||||
	return ref
 | 
			
		||||
| 
						 | 
				
			
			@ -250,17 +250,17 @@ func (ss *sessions) ping(sinfo *sessionInfo) {
 | 
			
		|||
 | 
			
		||||
func (ss *sessions) sendPingPong(sinfo *sessionInfo, isPong bool) {
 | 
			
		||||
	ping := ss.getPing(sinfo)
 | 
			
		||||
	ping.isPong = isPong
 | 
			
		||||
	ping.IsPong = isPong
 | 
			
		||||
	bs := ping.encode()
 | 
			
		||||
	shared := ss.getSharedKey(&ss.core.boxPriv, &sinfo.theirPermPub)
 | 
			
		||||
	payload, nonce := boxSeal(shared, bs, nil)
 | 
			
		||||
	p := wire_protoTrafficPacket{
 | 
			
		||||
		ttl:     ^uint64(0),
 | 
			
		||||
		coords:  sinfo.coords,
 | 
			
		||||
		toKey:   sinfo.theirPermPub,
 | 
			
		||||
		fromKey: ss.core.boxPub,
 | 
			
		||||
		nonce:   *nonce,
 | 
			
		||||
		payload: payload,
 | 
			
		||||
		TTL:     ^uint64(0),
 | 
			
		||||
		Coords:  sinfo.coords,
 | 
			
		||||
		ToKey:   sinfo.theirPermPub,
 | 
			
		||||
		FromKey: ss.core.boxPub,
 | 
			
		||||
		Nonce:   *nonce,
 | 
			
		||||
		Payload: payload,
 | 
			
		||||
	}
 | 
			
		||||
	packet := p.encode()
 | 
			
		||||
	ss.core.router.out(packet)
 | 
			
		||||
| 
						 | 
				
			
			@ -271,13 +271,13 @@ func (ss *sessions) sendPingPong(sinfo *sessionInfo, isPong bool) {
 | 
			
		|||
 | 
			
		||||
func (ss *sessions) handlePing(ping *sessionPing) {
 | 
			
		||||
	// Get the corresponding session (or create a new session)
 | 
			
		||||
	sinfo, isIn := ss.getByTheirPerm(&ping.sendPermPub)
 | 
			
		||||
	sinfo, isIn := ss.getByTheirPerm(&ping.SendPermPub)
 | 
			
		||||
	if !isIn || sinfo.timedout() {
 | 
			
		||||
		if isIn {
 | 
			
		||||
			sinfo.close()
 | 
			
		||||
		}
 | 
			
		||||
		ss.createSession(&ping.sendPermPub)
 | 
			
		||||
		sinfo, isIn = ss.getByTheirPerm(&ping.sendPermPub)
 | 
			
		||||
		ss.createSession(&ping.SendPermPub)
 | 
			
		||||
		sinfo, isIn = ss.getByTheirPerm(&ping.SendPermPub)
 | 
			
		||||
		if !isIn {
 | 
			
		||||
			panic("This should not happen")
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -286,7 +286,7 @@ func (ss *sessions) handlePing(ping *sessionPing) {
 | 
			
		|||
	if !sinfo.update(ping) { /*panic("Should not happen in testing")*/
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	if !ping.isPong {
 | 
			
		||||
	if !ping.IsPong {
 | 
			
		||||
		ss.sendPingPong(sinfo, true)
 | 
			
		||||
	}
 | 
			
		||||
	if sinfo.packet != nil {
 | 
			
		||||
| 
						 | 
				
			
			@ -383,11 +383,11 @@ func (sinfo *sessionInfo) doSend(bs []byte) {
 | 
			
		|||
	payload, nonce := boxSeal(&sinfo.sharedSesKey, bs, &sinfo.myNonce)
 | 
			
		||||
	defer util_putBytes(payload)
 | 
			
		||||
	p := wire_trafficPacket{
 | 
			
		||||
		ttl:     ^uint64(0),
 | 
			
		||||
		coords:  sinfo.coords,
 | 
			
		||||
		handle:  sinfo.theirHandle,
 | 
			
		||||
		nonce:   *nonce,
 | 
			
		||||
		payload: payload,
 | 
			
		||||
		TTL:     ^uint64(0),
 | 
			
		||||
		Coords:  sinfo.coords,
 | 
			
		||||
		Handle:  sinfo.theirHandle,
 | 
			
		||||
		Nonce:   *nonce,
 | 
			
		||||
		Payload: payload,
 | 
			
		||||
	}
 | 
			
		||||
	packet := p.encode()
 | 
			
		||||
	sinfo.bytesSent += uint64(len(bs))
 | 
			
		||||
| 
						 | 
				
			
			@ -395,12 +395,12 @@ func (sinfo *sessionInfo) doSend(bs []byte) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
func (sinfo *sessionInfo) doRecv(p *wire_trafficPacket) {
 | 
			
		||||
	defer util_putBytes(p.payload)
 | 
			
		||||
	payloadSize := uint16(len(p.payload))
 | 
			
		||||
	if !sinfo.nonceIsOK(&p.nonce) {
 | 
			
		||||
	defer util_putBytes(p.Payload)
 | 
			
		||||
	payloadSize := uint16(len(p.Payload))
 | 
			
		||||
	if !sinfo.nonceIsOK(&p.Nonce) {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	bs, isOK := boxOpen(&sinfo.sharedSesKey, p.payload, &p.nonce)
 | 
			
		||||
	bs, isOK := boxOpen(&sinfo.sharedSesKey, p.Payload, &p.Nonce)
 | 
			
		||||
	if !isOK {
 | 
			
		||||
		// We're going to guess that the session MTU is too large
 | 
			
		||||
		// Set myMTU to the largest value we think we can receive
 | 
			
		||||
| 
						 | 
				
			
			@ -433,7 +433,7 @@ func (sinfo *sessionInfo) doRecv(p *wire_trafficPacket) {
 | 
			
		|||
		}
 | 
			
		||||
	}
 | 
			
		||||
	go func() { sinfo.core.router.admin <- fixSessionMTU }()
 | 
			
		||||
	sinfo.updateNonce(&p.nonce)
 | 
			
		||||
	sinfo.updateNonce(&p.Nonce)
 | 
			
		||||
	sinfo.time = time.Now()
 | 
			
		||||
	sinfo.bytesRecvd += uint64(len(bs))
 | 
			
		||||
	sinfo.core.router.recvPacket(bs, &sinfo.theirAddr, &sinfo.theirSubnet)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -121,21 +121,21 @@ func wire_decode_coords(packet []byte) ([]byte, int) {
 | 
			
		|||
 | 
			
		||||
// Announces that we can send parts of a Message with a particular seq
 | 
			
		||||
type msgAnnounce struct {
 | 
			
		||||
	root   sigPubKey
 | 
			
		||||
	tstamp int64
 | 
			
		||||
	seq    uint64
 | 
			
		||||
	len    uint64
 | 
			
		||||
	Root   sigPubKey
 | 
			
		||||
	Tstamp int64
 | 
			
		||||
	Seq    uint64
 | 
			
		||||
	Len    uint64
 | 
			
		||||
	//Deg uint64
 | 
			
		||||
	rseq uint64
 | 
			
		||||
	Rseq uint64
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (m *msgAnnounce) encode() []byte {
 | 
			
		||||
	bs := wire_encode_uint64(wire_SwitchAnnounce)
 | 
			
		||||
	bs = append(bs, m.root[:]...)
 | 
			
		||||
	bs = append(bs, wire_encode_uint64(wire_intToUint(m.tstamp))...)
 | 
			
		||||
	bs = append(bs, wire_encode_uint64(m.seq)...)
 | 
			
		||||
	bs = append(bs, wire_encode_uint64(m.len)...)
 | 
			
		||||
	bs = append(bs, wire_encode_uint64(m.rseq)...)
 | 
			
		||||
	bs = append(bs, m.Root[:]...)
 | 
			
		||||
	bs = append(bs, wire_encode_uint64(wire_intToUint(m.Tstamp))...)
 | 
			
		||||
	bs = append(bs, wire_encode_uint64(m.Seq)...)
 | 
			
		||||
	bs = append(bs, wire_encode_uint64(m.Len)...)
 | 
			
		||||
	bs = append(bs, wire_encode_uint64(m.Rseq)...)
 | 
			
		||||
	return bs
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -147,34 +147,34 @@ func (m *msgAnnounce) decode(bs []byte) bool {
 | 
			
		|||
		return false
 | 
			
		||||
	case pType != wire_SwitchAnnounce:
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_slice(m.root[:], &bs):
 | 
			
		||||
	case !wire_chop_slice(m.Root[:], &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_uint64(&tstamp, &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_uint64(&m.seq, &bs):
 | 
			
		||||
	case !wire_chop_uint64(&m.Seq, &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_uint64(&m.len, &bs):
 | 
			
		||||
	case !wire_chop_uint64(&m.Len, &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_uint64(&m.rseq, &bs):
 | 
			
		||||
	case !wire_chop_uint64(&m.Rseq, &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
	m.tstamp = wire_intFromUint(tstamp)
 | 
			
		||||
	m.Tstamp = wire_intFromUint(tstamp)
 | 
			
		||||
	return true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type msgHopReq struct {
 | 
			
		||||
	root   sigPubKey
 | 
			
		||||
	tstamp int64
 | 
			
		||||
	seq    uint64
 | 
			
		||||
	hop    uint64
 | 
			
		||||
	Root   sigPubKey
 | 
			
		||||
	Tstamp int64
 | 
			
		||||
	Seq    uint64
 | 
			
		||||
	Hop    uint64
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (m *msgHopReq) encode() []byte {
 | 
			
		||||
	bs := wire_encode_uint64(wire_SwitchHopRequest)
 | 
			
		||||
	bs = append(bs, m.root[:]...)
 | 
			
		||||
	bs = append(bs, wire_encode_uint64(wire_intToUint(m.tstamp))...)
 | 
			
		||||
	bs = append(bs, wire_encode_uint64(m.seq)...)
 | 
			
		||||
	bs = append(bs, wire_encode_uint64(m.hop)...)
 | 
			
		||||
	bs = append(bs, m.Root[:]...)
 | 
			
		||||
	bs = append(bs, wire_encode_uint64(wire_intToUint(m.Tstamp))...)
 | 
			
		||||
	bs = append(bs, wire_encode_uint64(m.Seq)...)
 | 
			
		||||
	bs = append(bs, wire_encode_uint64(m.Hop)...)
 | 
			
		||||
	return bs
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -186,38 +186,38 @@ func (m *msgHopReq) decode(bs []byte) bool {
 | 
			
		|||
		return false
 | 
			
		||||
	case pType != wire_SwitchHopRequest:
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_slice(m.root[:], &bs):
 | 
			
		||||
	case !wire_chop_slice(m.Root[:], &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_uint64(&tstamp, &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_uint64(&m.seq, &bs):
 | 
			
		||||
	case !wire_chop_uint64(&m.Seq, &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_uint64(&m.hop, &bs):
 | 
			
		||||
	case !wire_chop_uint64(&m.Hop, &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
	m.tstamp = wire_intFromUint(tstamp)
 | 
			
		||||
	m.Tstamp = wire_intFromUint(tstamp)
 | 
			
		||||
	return true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type msgHop struct {
 | 
			
		||||
	root   sigPubKey
 | 
			
		||||
	tstamp int64
 | 
			
		||||
	seq    uint64
 | 
			
		||||
	hop    uint64
 | 
			
		||||
	port   switchPort
 | 
			
		||||
	next   sigPubKey
 | 
			
		||||
	sig    sigBytes
 | 
			
		||||
	Root   sigPubKey
 | 
			
		||||
	Tstamp int64
 | 
			
		||||
	Seq    uint64
 | 
			
		||||
	Hop    uint64
 | 
			
		||||
	Port   switchPort
 | 
			
		||||
	Next   sigPubKey
 | 
			
		||||
	Sig    sigBytes
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (m *msgHop) encode() []byte {
 | 
			
		||||
	bs := wire_encode_uint64(wire_SwitchHop)
 | 
			
		||||
	bs = append(bs, m.root[:]...)
 | 
			
		||||
	bs = append(bs, wire_encode_uint64(wire_intToUint(m.tstamp))...)
 | 
			
		||||
	bs = append(bs, wire_encode_uint64(m.seq)...)
 | 
			
		||||
	bs = append(bs, wire_encode_uint64(m.hop)...)
 | 
			
		||||
	bs = append(bs, wire_encode_uint64(uint64(m.port))...)
 | 
			
		||||
	bs = append(bs, m.next[:]...)
 | 
			
		||||
	bs = append(bs, m.sig[:]...)
 | 
			
		||||
	bs = append(bs, m.Root[:]...)
 | 
			
		||||
	bs = append(bs, wire_encode_uint64(wire_intToUint(m.Tstamp))...)
 | 
			
		||||
	bs = append(bs, wire_encode_uint64(m.Seq)...)
 | 
			
		||||
	bs = append(bs, wire_encode_uint64(m.Hop)...)
 | 
			
		||||
	bs = append(bs, wire_encode_uint64(uint64(m.Port))...)
 | 
			
		||||
	bs = append(bs, m.Next[:]...)
 | 
			
		||||
	bs = append(bs, m.Sig[:]...)
 | 
			
		||||
	return bs
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -229,22 +229,22 @@ func (m *msgHop) decode(bs []byte) bool {
 | 
			
		|||
		return false
 | 
			
		||||
	case pType != wire_SwitchHop:
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_slice(m.root[:], &bs):
 | 
			
		||||
	case !wire_chop_slice(m.Root[:], &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_uint64(&tstamp, &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_uint64(&m.seq, &bs):
 | 
			
		||||
	case !wire_chop_uint64(&m.Seq, &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_uint64(&m.hop, &bs):
 | 
			
		||||
	case !wire_chop_uint64(&m.Hop, &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_uint64((*uint64)(&m.port), &bs):
 | 
			
		||||
	case !wire_chop_uint64((*uint64)(&m.Port), &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_slice(m.next[:], &bs):
 | 
			
		||||
	case !wire_chop_slice(m.Next[:], &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_slice(m.sig[:], &bs):
 | 
			
		||||
	case !wire_chop_slice(m.Sig[:], &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
	m.tstamp = wire_intFromUint(tstamp)
 | 
			
		||||
	m.Tstamp = wire_intFromUint(tstamp)
 | 
			
		||||
	return true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -292,22 +292,22 @@ func wire_chop_uint64(toUInt64 *uint64, fromSlice *[]byte) bool {
 | 
			
		|||
// Wire traffic packets
 | 
			
		||||
 | 
			
		||||
type wire_trafficPacket struct {
 | 
			
		||||
	ttl     uint64
 | 
			
		||||
	coords  []byte
 | 
			
		||||
	handle  handle
 | 
			
		||||
	nonce   boxNonce
 | 
			
		||||
	payload []byte
 | 
			
		||||
	TTL     uint64
 | 
			
		||||
	Coords  []byte
 | 
			
		||||
	Handle  handle
 | 
			
		||||
	Nonce   boxNonce
 | 
			
		||||
	Payload []byte
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// This is basically MarshalBinary, but decode doesn't allow that...
 | 
			
		||||
func (p *wire_trafficPacket) encode() []byte {
 | 
			
		||||
	bs := util_getBytes()
 | 
			
		||||
	bs = wire_put_uint64(wire_Traffic, bs)
 | 
			
		||||
	bs = wire_put_uint64(p.ttl, bs)
 | 
			
		||||
	bs = wire_put_coords(p.coords, bs)
 | 
			
		||||
	bs = append(bs, p.handle[:]...)
 | 
			
		||||
	bs = append(bs, p.nonce[:]...)
 | 
			
		||||
	bs = append(bs, p.payload...)
 | 
			
		||||
	bs = wire_put_uint64(p.TTL, bs)
 | 
			
		||||
	bs = wire_put_coords(p.Coords, bs)
 | 
			
		||||
	bs = append(bs, p.Handle[:]...)
 | 
			
		||||
	bs = append(bs, p.Nonce[:]...)
 | 
			
		||||
	bs = append(bs, p.Payload...)
 | 
			
		||||
	return bs
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -319,37 +319,37 @@ func (p *wire_trafficPacket) decode(bs []byte) bool {
 | 
			
		|||
		return false
 | 
			
		||||
	case pType != wire_Traffic:
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_uint64(&p.ttl, &bs):
 | 
			
		||||
	case !wire_chop_uint64(&p.TTL, &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_coords(&p.coords, &bs):
 | 
			
		||||
	case !wire_chop_coords(&p.Coords, &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_slice(p.handle[:], &bs):
 | 
			
		||||
	case !wire_chop_slice(p.Handle[:], &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_slice(p.nonce[:], &bs):
 | 
			
		||||
	case !wire_chop_slice(p.Nonce[:], &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
	p.payload = append(util_getBytes(), bs...)
 | 
			
		||||
	p.Payload = append(util_getBytes(), bs...)
 | 
			
		||||
	return true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type wire_protoTrafficPacket struct {
 | 
			
		||||
	ttl     uint64
 | 
			
		||||
	coords  []byte
 | 
			
		||||
	toKey   boxPubKey
 | 
			
		||||
	fromKey boxPubKey
 | 
			
		||||
	nonce   boxNonce
 | 
			
		||||
	payload []byte
 | 
			
		||||
	TTL     uint64
 | 
			
		||||
	Coords  []byte
 | 
			
		||||
	ToKey   boxPubKey
 | 
			
		||||
	FromKey boxPubKey
 | 
			
		||||
	Nonce   boxNonce
 | 
			
		||||
	Payload []byte
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (p *wire_protoTrafficPacket) encode() []byte {
 | 
			
		||||
	coords := wire_encode_coords(p.coords)
 | 
			
		||||
	coords := wire_encode_coords(p.Coords)
 | 
			
		||||
	bs := wire_encode_uint64(wire_ProtocolTraffic)
 | 
			
		||||
	bs = append(bs, wire_encode_uint64(p.ttl)...)
 | 
			
		||||
	bs = append(bs, wire_encode_uint64(p.TTL)...)
 | 
			
		||||
	bs = append(bs, coords...)
 | 
			
		||||
	bs = append(bs, p.toKey[:]...)
 | 
			
		||||
	bs = append(bs, p.fromKey[:]...)
 | 
			
		||||
	bs = append(bs, p.nonce[:]...)
 | 
			
		||||
	bs = append(bs, p.payload...)
 | 
			
		||||
	bs = append(bs, p.ToKey[:]...)
 | 
			
		||||
	bs = append(bs, p.FromKey[:]...)
 | 
			
		||||
	bs = append(bs, p.Nonce[:]...)
 | 
			
		||||
	bs = append(bs, p.Payload...)
 | 
			
		||||
	return bs
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -360,30 +360,30 @@ func (p *wire_protoTrafficPacket) decode(bs []byte) bool {
 | 
			
		|||
		return false
 | 
			
		||||
	case pType != wire_ProtocolTraffic:
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_uint64(&p.ttl, &bs):
 | 
			
		||||
	case !wire_chop_uint64(&p.TTL, &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_coords(&p.coords, &bs):
 | 
			
		||||
	case !wire_chop_coords(&p.Coords, &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_slice(p.toKey[:], &bs):
 | 
			
		||||
	case !wire_chop_slice(p.ToKey[:], &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_slice(p.fromKey[:], &bs):
 | 
			
		||||
	case !wire_chop_slice(p.FromKey[:], &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_slice(p.nonce[:], &bs):
 | 
			
		||||
	case !wire_chop_slice(p.Nonce[:], &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
	p.payload = bs
 | 
			
		||||
	p.Payload = bs
 | 
			
		||||
	return true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type wire_linkProtoTrafficPacket struct {
 | 
			
		||||
	nonce   boxNonce
 | 
			
		||||
	payload []byte
 | 
			
		||||
	Nonce   boxNonce
 | 
			
		||||
	Payload []byte
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (p *wire_linkProtoTrafficPacket) encode() []byte {
 | 
			
		||||
	bs := wire_encode_uint64(wire_LinkProtocolTraffic)
 | 
			
		||||
	bs = append(bs, p.nonce[:]...)
 | 
			
		||||
	bs = append(bs, p.payload...)
 | 
			
		||||
	bs = append(bs, p.Nonce[:]...)
 | 
			
		||||
	bs = append(bs, p.Payload...)
 | 
			
		||||
	return bs
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -394,10 +394,10 @@ func (p *wire_linkProtoTrafficPacket) decode(bs []byte) bool {
 | 
			
		|||
		return false
 | 
			
		||||
	case pType != wire_LinkProtocolTraffic:
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_slice(p.nonce[:], &bs):
 | 
			
		||||
	case !wire_chop_slice(p.Nonce[:], &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
	p.payload = bs
 | 
			
		||||
	p.Payload = bs
 | 
			
		||||
	return true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -405,19 +405,19 @@ func (p *wire_linkProtoTrafficPacket) decode(bs []byte) bool {
 | 
			
		|||
 | 
			
		||||
func (p *sessionPing) encode() []byte {
 | 
			
		||||
	var pTypeVal uint64
 | 
			
		||||
	if p.isPong {
 | 
			
		||||
	if p.IsPong {
 | 
			
		||||
		pTypeVal = wire_SessionPong
 | 
			
		||||
	} else {
 | 
			
		||||
		pTypeVal = wire_SessionPing
 | 
			
		||||
	}
 | 
			
		||||
	bs := wire_encode_uint64(pTypeVal)
 | 
			
		||||
	//p.sendPermPub used in top level (crypto), so skipped here
 | 
			
		||||
	bs = append(bs, p.handle[:]...)
 | 
			
		||||
	bs = append(bs, p.sendSesPub[:]...)
 | 
			
		||||
	bs = append(bs, wire_encode_uint64(wire_intToUint(p.tstamp))...)
 | 
			
		||||
	coords := wire_encode_coords(p.coords)
 | 
			
		||||
	bs = append(bs, p.Handle[:]...)
 | 
			
		||||
	bs = append(bs, p.SendSesPub[:]...)
 | 
			
		||||
	bs = append(bs, wire_encode_uint64(wire_intToUint(p.Tstamp))...)
 | 
			
		||||
	coords := wire_encode_coords(p.Coords)
 | 
			
		||||
	bs = append(bs, coords...)
 | 
			
		||||
	bs = append(bs, wire_encode_uint64(uint64(p.mtu))...)
 | 
			
		||||
	bs = append(bs, wire_encode_uint64(uint64(p.MTU))...)
 | 
			
		||||
	return bs
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -430,33 +430,33 @@ func (p *sessionPing) decode(bs []byte) bool {
 | 
			
		|||
		return false
 | 
			
		||||
	case pType != wire_SessionPing && pType != wire_SessionPong:
 | 
			
		||||
		return false
 | 
			
		||||
	//p.sendPermPub used in top level (crypto), so skipped here
 | 
			
		||||
	case !wire_chop_slice(p.handle[:], &bs):
 | 
			
		||||
		//p.sendPermPub used in top level (crypto), so skipped here
 | 
			
		||||
	case !wire_chop_slice(p.Handle[:], &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_slice(p.sendSesPub[:], &bs):
 | 
			
		||||
	case !wire_chop_slice(p.SendSesPub[:], &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_uint64(&tstamp, &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_coords(&p.coords, &bs):
 | 
			
		||||
	case !wire_chop_coords(&p.Coords, &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_uint64(&mtu, &bs):
 | 
			
		||||
		mtu = 1280
 | 
			
		||||
	}
 | 
			
		||||
	p.tstamp = wire_intFromUint(tstamp)
 | 
			
		||||
	p.Tstamp = wire_intFromUint(tstamp)
 | 
			
		||||
	if pType == wire_SessionPong {
 | 
			
		||||
		p.isPong = true
 | 
			
		||||
		p.IsPong = true
 | 
			
		||||
	}
 | 
			
		||||
	p.mtu = uint16(mtu)
 | 
			
		||||
	p.MTU = uint16(mtu)
 | 
			
		||||
	return true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
func (r *dhtReq) encode() []byte {
 | 
			
		||||
	coords := wire_encode_coords(r.coords)
 | 
			
		||||
	coords := wire_encode_coords(r.Coords)
 | 
			
		||||
	bs := wire_encode_uint64(wire_DHTLookupRequest)
 | 
			
		||||
	bs = append(bs, coords...)
 | 
			
		||||
	bs = append(bs, r.dest[:]...)
 | 
			
		||||
	bs = append(bs, r.Dest[:]...)
 | 
			
		||||
	return bs
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -467,9 +467,9 @@ func (r *dhtReq) decode(bs []byte) bool {
 | 
			
		|||
		return false
 | 
			
		||||
	case pType != wire_DHTLookupRequest:
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_coords(&r.coords, &bs):
 | 
			
		||||
	case !wire_chop_coords(&r.Coords, &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_slice(r.dest[:], &bs):
 | 
			
		||||
	case !wire_chop_slice(r.Dest[:], &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	default:
 | 
			
		||||
		return true
 | 
			
		||||
| 
						 | 
				
			
			@ -477,11 +477,11 @@ func (r *dhtReq) decode(bs []byte) bool {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
func (r *dhtRes) encode() []byte {
 | 
			
		||||
	coords := wire_encode_coords(r.coords)
 | 
			
		||||
	coords := wire_encode_coords(r.Coords)
 | 
			
		||||
	bs := wire_encode_uint64(wire_DHTLookupResponse)
 | 
			
		||||
	bs = append(bs, coords...)
 | 
			
		||||
	bs = append(bs, r.dest[:]...)
 | 
			
		||||
	for _, info := range r.infos {
 | 
			
		||||
	bs = append(bs, r.Dest[:]...)
 | 
			
		||||
	for _, info := range r.Infos {
 | 
			
		||||
		coords = wire_encode_coords(info.coords)
 | 
			
		||||
		bs = append(bs, info.key[:]...)
 | 
			
		||||
		bs = append(bs, coords...)
 | 
			
		||||
| 
						 | 
				
			
			@ -496,9 +496,9 @@ func (r *dhtRes) decode(bs []byte) bool {
 | 
			
		|||
		return false
 | 
			
		||||
	case pType != wire_DHTLookupResponse:
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_coords(&r.coords, &bs):
 | 
			
		||||
	case !wire_chop_coords(&r.Coords, &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	case !wire_chop_slice(r.dest[:], &bs):
 | 
			
		||||
	case !wire_chop_slice(r.Dest[:], &bs):
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
	for len(bs) > 0 {
 | 
			
		||||
| 
						 | 
				
			
			@ -509,7 +509,7 @@ func (r *dhtRes) decode(bs []byte) bool {
 | 
			
		|||
		case !wire_chop_coords(&info.coords, &bs):
 | 
			
		||||
			return false
 | 
			
		||||
		}
 | 
			
		||||
		r.infos = append(r.infos, &info)
 | 
			
		||||
		r.Infos = append(r.Infos, &info)
 | 
			
		||||
	}
 | 
			
		||||
	return true
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue