mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	Export fields of wire structs
This commit is contained in:
		
							parent
							
								
									0f96fea3fc
								
							
						
					
					
						commit
						49af65296d
					
				
					 9 changed files with 194 additions and 194 deletions
				
			
		| 
						 | 
					@ -172,7 +172,7 @@ func (c *Core) GetAddress() *net.IP {
 | 
				
			||||||
func (c *Core) GetSubnet() *net.IPNet {
 | 
					func (c *Core) GetSubnet() *net.IPNet {
 | 
				
			||||||
	subnet := address_subnetForNodeID(c.GetNodeID())[:]
 | 
						subnet := address_subnetForNodeID(c.GetNodeID())[:]
 | 
				
			||||||
	subnet = append(subnet, 0, 0, 0, 0, 0, 0, 0, 0)
 | 
						subnet = append(subnet, 0, 0, 0, 0, 0, 0, 0, 0)
 | 
				
			||||||
	return &net.IPNet{ IP: subnet, Mask: net.CIDRMask(64, 128) }
 | 
						return &net.IPNet{IP: subnet, Mask: net.CIDRMask(64, 128)}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Sets the output logger of the Yggdrasil node after startup. This may be
 | 
					// Sets the output logger of the Yggdrasil node after startup. This may be
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -318,12 +318,12 @@ func (t *dht) sendReq(req *dhtReq, dest *dhtInfo) {
 | 
				
			||||||
	shared := t.core.sessions.getSharedKey(&t.core.boxPriv, &dest.key)
 | 
						shared := t.core.sessions.getSharedKey(&t.core.boxPriv, &dest.key)
 | 
				
			||||||
	payload, nonce := boxSeal(shared, bs, nil)
 | 
						payload, nonce := boxSeal(shared, bs, nil)
 | 
				
			||||||
	p := wire_protoTrafficPacket{
 | 
						p := wire_protoTrafficPacket{
 | 
				
			||||||
		ttl:     ^uint64(0),
 | 
							TTL:     ^uint64(0),
 | 
				
			||||||
		coords:  dest.coords,
 | 
							Coords:  dest.coords,
 | 
				
			||||||
		toKey:   dest.key,
 | 
							ToKey:   dest.key,
 | 
				
			||||||
		fromKey: t.core.boxPub,
 | 
							FromKey: t.core.boxPub,
 | 
				
			||||||
		nonce:   *nonce,
 | 
							Nonce:   *nonce,
 | 
				
			||||||
		payload: payload,
 | 
							Payload: payload,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	packet := p.encode()
 | 
						packet := p.encode()
 | 
				
			||||||
	t.core.router.out(packet)
 | 
						t.core.router.out(packet)
 | 
				
			||||||
| 
						 | 
					@ -344,12 +344,12 @@ func (t *dht) sendRes(res *dhtRes, req *dhtReq) {
 | 
				
			||||||
	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)
 | 
						payload, nonce := boxSeal(shared, bs, nil)
 | 
				
			||||||
	p := wire_protoTrafficPacket{
 | 
						p := wire_protoTrafficPacket{
 | 
				
			||||||
		ttl:     ^uint64(0),
 | 
							TTL:     ^uint64(0),
 | 
				
			||||||
		coords:  req.coords,
 | 
							Coords:  req.coords,
 | 
				
			||||||
		toKey:   req.key,
 | 
							ToKey:   req.key,
 | 
				
			||||||
		fromKey: t.core.boxPub,
 | 
							FromKey: t.core.boxPub,
 | 
				
			||||||
		nonce:   *nonce,
 | 
							Nonce:   *nonce,
 | 
				
			||||||
		payload: payload,
 | 
							Payload: payload,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	packet := p.encode()
 | 
						packet := p.encode()
 | 
				
			||||||
	t.core.router.out(packet)
 | 
						t.core.router.out(packet)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -207,16 +207,16 @@ func (p *peer) linkLoop(in <-chan []byte) {
 | 
				
			||||||
			switch {
 | 
								switch {
 | 
				
			||||||
			case p.msgAnc == nil:
 | 
								case p.msgAnc == nil:
 | 
				
			||||||
				update = true
 | 
									update = true
 | 
				
			||||||
			case lastRSeq != p.msgAnc.seq:
 | 
								case lastRSeq != p.msgAnc.Seq:
 | 
				
			||||||
				update = true
 | 
									update = true
 | 
				
			||||||
			case p.msgAnc.rseq != p.myMsg.seq:
 | 
								case p.msgAnc.Rseq != p.myMsg.seq:
 | 
				
			||||||
				update = true
 | 
									update = true
 | 
				
			||||||
			case counter%4 == 0:
 | 
								case counter%4 == 0:
 | 
				
			||||||
				update = true
 | 
									update = true
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			if update {
 | 
								if update {
 | 
				
			||||||
				if p.msgAnc != nil {
 | 
									if p.msgAnc != nil {
 | 
				
			||||||
					lastRSeq = p.msgAnc.seq
 | 
										lastRSeq = p.msgAnc.Seq
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				p.sendSwitchAnnounce()
 | 
									p.sendSwitchAnnounce()
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
| 
						 | 
					@ -291,8 +291,8 @@ func (p *peer) sendPacket(packet []byte) {
 | 
				
			||||||
func (p *peer) sendLinkPacket(packet []byte) {
 | 
					func (p *peer) sendLinkPacket(packet []byte) {
 | 
				
			||||||
	bs, nonce := boxSeal(&p.shared, packet, nil)
 | 
						bs, nonce := boxSeal(&p.shared, packet, nil)
 | 
				
			||||||
	linkPacket := wire_linkProtoTrafficPacket{
 | 
						linkPacket := wire_linkProtoTrafficPacket{
 | 
				
			||||||
		nonce:   *nonce,
 | 
							Nonce:   *nonce,
 | 
				
			||||||
		payload: bs,
 | 
							Payload: bs,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	packet = linkPacket.encode()
 | 
						packet = linkPacket.encode()
 | 
				
			||||||
	p.sendPacket(packet)
 | 
						p.sendPacket(packet)
 | 
				
			||||||
| 
						 | 
					@ -303,7 +303,7 @@ func (p *peer) handleLinkTraffic(bs []byte) {
 | 
				
			||||||
	if !packet.decode(bs) {
 | 
						if !packet.decode(bs) {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	payload, isOK := boxOpen(&p.shared, packet.payload, &packet.nonce)
 | 
						payload, isOK := boxOpen(&p.shared, packet.Payload, &packet.Nonce)
 | 
				
			||||||
	if !isOK {
 | 
						if !isOK {
 | 
				
			||||||
		return
 | 
							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.Seq != p.msgAnc.Seq { p.msgHops = nil }
 | 
				
			||||||
	if p.msgAnc == nil ||
 | 
						if p.msgAnc == nil ||
 | 
				
			||||||
		anc.root != p.msgAnc.root ||
 | 
							anc.Root != p.msgAnc.Root ||
 | 
				
			||||||
		anc.tstamp != p.msgAnc.tstamp ||
 | 
							anc.Tstamp != p.msgAnc.Tstamp ||
 | 
				
			||||||
		anc.seq != p.msgAnc.seq {
 | 
							anc.Seq != p.msgAnc.Seq {
 | 
				
			||||||
		p.msgHops = nil
 | 
							p.msgHops = nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	p.msgAnc = &anc
 | 
						p.msgAnc = &anc
 | 
				
			||||||
| 
						 | 
					@ -344,10 +344,10 @@ func (p *peer) handleSwitchAnnounce(packet []byte) {
 | 
				
			||||||
func (p *peer) requestHop(hop uint64) {
 | 
					func (p *peer) requestHop(hop uint64) {
 | 
				
			||||||
	//p.core.log.Println("DEBUG requestHop")
 | 
						//p.core.log.Println("DEBUG requestHop")
 | 
				
			||||||
	req := msgHopReq{}
 | 
						req := msgHopReq{}
 | 
				
			||||||
	req.root = p.msgAnc.root
 | 
						req.Root = p.msgAnc.Root
 | 
				
			||||||
	req.tstamp = p.msgAnc.tstamp
 | 
						req.Tstamp = p.msgAnc.Tstamp
 | 
				
			||||||
	req.seq = p.msgAnc.seq
 | 
						req.Seq = p.msgAnc.Seq
 | 
				
			||||||
	req.hop = hop
 | 
						req.Hop = hop
 | 
				
			||||||
	packet := req.encode()
 | 
						packet := req.encode()
 | 
				
			||||||
	p.sendLinkPacket(packet)
 | 
						p.sendLinkPacket(packet)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -364,28 +364,28 @@ func (p *peer) handleSwitchHopRequest(packet []byte) {
 | 
				
			||||||
	if !req.decode(packet) {
 | 
						if !req.decode(packet) {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if req.root != p.myMsg.locator.root {
 | 
						if req.Root != p.myMsg.locator.root {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if req.tstamp != p.myMsg.locator.tstamp {
 | 
						if req.Tstamp != p.myMsg.locator.tstamp {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if req.seq != p.myMsg.seq {
 | 
						if req.Seq != p.myMsg.seq {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if uint64(len(p.myMsg.locator.coords)) <= req.hop {
 | 
						if uint64(len(p.myMsg.locator.coords)) <= req.Hop {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	res := msgHop{}
 | 
						res := msgHop{}
 | 
				
			||||||
	res.root = p.myMsg.locator.root
 | 
						res.Root = p.myMsg.locator.root
 | 
				
			||||||
	res.tstamp = p.myMsg.locator.tstamp
 | 
						res.Tstamp = p.myMsg.locator.tstamp
 | 
				
			||||||
	res.seq = p.myMsg.seq
 | 
						res.Seq = p.myMsg.seq
 | 
				
			||||||
	res.hop = req.hop
 | 
						res.Hop = req.Hop
 | 
				
			||||||
	res.port = p.myMsg.locator.coords[res.hop]
 | 
						res.Port = p.myMsg.locator.coords[res.Hop]
 | 
				
			||||||
	sinfo := p.getSig(res.hop)
 | 
						sinfo := p.getSig(res.Hop)
 | 
				
			||||||
	//p.core.log.Println("DEBUG sig:", sinfo)
 | 
						//p.core.log.Println("DEBUG sig:", sinfo)
 | 
				
			||||||
	res.next = sinfo.next
 | 
						res.Next = sinfo.next
 | 
				
			||||||
	res.sig = sinfo.sig
 | 
						res.Sig = sinfo.sig
 | 
				
			||||||
	packet = res.encode()
 | 
						packet = res.encode()
 | 
				
			||||||
	p.sendLinkPacket(packet)
 | 
						p.sendLinkPacket(packet)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -402,31 +402,31 @@ func (p *peer) handleSwitchHop(packet []byte) {
 | 
				
			||||||
	if !res.decode(packet) {
 | 
						if !res.decode(packet) {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if res.root != p.msgAnc.root {
 | 
						if res.Root != p.msgAnc.Root {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if res.tstamp != p.msgAnc.tstamp {
 | 
						if res.Tstamp != p.msgAnc.Tstamp {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if res.seq != p.msgAnc.seq {
 | 
						if res.Seq != p.msgAnc.Seq {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if res.hop != uint64(len(p.msgHops)) {
 | 
						if res.Hop != uint64(len(p.msgHops)) {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	} // always process in order
 | 
						} // always process in order
 | 
				
			||||||
	loc := switchLocator{coords: make([]switchPort, 0, len(p.msgHops)+1)}
 | 
						loc := switchLocator{coords: make([]switchPort, 0, len(p.msgHops)+1)}
 | 
				
			||||||
	loc.root = res.root
 | 
						loc.root = res.Root
 | 
				
			||||||
	loc.tstamp = res.tstamp
 | 
						loc.tstamp = res.Tstamp
 | 
				
			||||||
	for _, hop := range p.msgHops {
 | 
						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)
 | 
						loc.coords = append(loc.coords, res.Port)
 | 
				
			||||||
	thisHopKey := &res.root
 | 
						thisHopKey := &res.Root
 | 
				
			||||||
	if res.hop != 0 {
 | 
						if res.Hop != 0 {
 | 
				
			||||||
		thisHopKey = &p.msgHops[res.hop-1].next
 | 
							thisHopKey = &p.msgHops[res.Hop-1].Next
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	bs := getBytesForSig(&res.next, &loc)
 | 
						bs := getBytesForSig(&res.Next, &loc)
 | 
				
			||||||
	if p.core.sigs.check(thisHopKey, &res.sig, bs) {
 | 
						if p.core.sigs.check(thisHopKey, &res.Sig, bs) {
 | 
				
			||||||
		p.msgHops = append(p.msgHops, &res)
 | 
							p.msgHops = append(p.msgHops, &res)
 | 
				
			||||||
		p.processSwitchMessage()
 | 
							p.processSwitchMessage()
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
| 
						 | 
					@ -442,12 +442,12 @@ func (p *peer) processSwitchMessage() {
 | 
				
			||||||
	if p.msgAnc == nil {
 | 
						if p.msgAnc == nil {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if uint64(len(p.msgHops)) < p.msgAnc.len {
 | 
						if uint64(len(p.msgHops)) < p.msgAnc.Len {
 | 
				
			||||||
		p.requestHop(uint64(len(p.msgHops)))
 | 
							p.requestHop(uint64(len(p.msgHops)))
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	p.throttle++
 | 
						p.throttle++
 | 
				
			||||||
	if p.msgAnc.len != uint64(len(p.msgHops)) {
 | 
						if p.msgAnc.Len != uint64(len(p.msgHops)) {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	msg := switchMessage{}
 | 
						msg := switchMessage{}
 | 
				
			||||||
| 
						 | 
					@ -455,26 +455,26 @@ func (p *peer) processSwitchMessage() {
 | 
				
			||||||
	sigs := make([]sigInfo, 0, len(p.msgHops))
 | 
						sigs := make([]sigInfo, 0, len(p.msgHops))
 | 
				
			||||||
	for idx, hop := range p.msgHops {
 | 
						for idx, hop := range p.msgHops {
 | 
				
			||||||
		// Consistency checks, should be redundant (already checked these...)
 | 
							// Consistency checks, should be redundant (already checked these...)
 | 
				
			||||||
		if hop.root != p.msgAnc.root {
 | 
							if hop.Root != p.msgAnc.Root {
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if hop.tstamp != p.msgAnc.tstamp {
 | 
							if hop.Tstamp != p.msgAnc.Tstamp {
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if hop.seq != p.msgAnc.seq {
 | 
							if hop.Seq != p.msgAnc.Seq {
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if hop.hop != uint64(idx) {
 | 
							if hop.Hop != uint64(idx) {
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		coords = append(coords, hop.port)
 | 
							coords = append(coords, hop.Port)
 | 
				
			||||||
		sigs = append(sigs, sigInfo{next: hop.next, sig: hop.sig})
 | 
							sigs = append(sigs, sigInfo{next: hop.Next, sig: hop.Sig})
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	msg.from = p.sig
 | 
						msg.from = p.sig
 | 
				
			||||||
	msg.locator.root = p.msgAnc.root
 | 
						msg.locator.root = p.msgAnc.Root
 | 
				
			||||||
	msg.locator.tstamp = p.msgAnc.tstamp
 | 
						msg.locator.tstamp = p.msgAnc.Tstamp
 | 
				
			||||||
	msg.locator.coords = coords
 | 
						msg.locator.coords = coords
 | 
				
			||||||
	msg.seq = p.msgAnc.seq
 | 
						msg.seq = p.msgAnc.Seq
 | 
				
			||||||
	//msg.RSeq = p.msgAnc.RSeq
 | 
						//msg.RSeq = p.msgAnc.RSeq
 | 
				
			||||||
	//msg.Degree = p.msgAnc.Deg
 | 
						//msg.Degree = p.msgAnc.Deg
 | 
				
			||||||
	p.core.switchTable.handleMessage(&msg, p.port, sigs)
 | 
						p.core.switchTable.handleMessage(&msg, p.port, sigs)
 | 
				
			||||||
| 
						 | 
					@ -493,13 +493,13 @@ func (p *peer) processSwitchMessage() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (p *peer) sendSwitchAnnounce() {
 | 
					func (p *peer) sendSwitchAnnounce() {
 | 
				
			||||||
	anc := msgAnnounce{}
 | 
						anc := msgAnnounce{}
 | 
				
			||||||
	anc.root = p.myMsg.locator.root
 | 
						anc.Root = p.myMsg.locator.root
 | 
				
			||||||
	anc.tstamp = p.myMsg.locator.tstamp
 | 
						anc.Tstamp = p.myMsg.locator.tstamp
 | 
				
			||||||
	anc.seq = p.myMsg.seq
 | 
						anc.Seq = p.myMsg.seq
 | 
				
			||||||
	anc.len = uint64(len(p.myMsg.locator.coords))
 | 
						anc.Len = uint64(len(p.myMsg.locator.coords))
 | 
				
			||||||
	//anc.Deg = p.myMsg.Degree
 | 
						//anc.Deg = p.myMsg.Degree
 | 
				
			||||||
	if p.msgAnc != nil {
 | 
						if p.msgAnc != nil {
 | 
				
			||||||
		anc.rseq = p.msgAnc.seq
 | 
							anc.Rseq = p.msgAnc.Seq
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	packet := anc.encode()
 | 
						packet := anc.encode()
 | 
				
			||||||
	p.sendLinkPacket(packet)
 | 
						p.sendLinkPacket(packet)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -266,7 +266,7 @@ func (r *router) handleTraffic(packet []byte) {
 | 
				
			||||||
	if !p.decode(packet) {
 | 
						if !p.decode(packet) {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	sinfo, isIn := r.core.sessions.getSessionForHandle(&p.handle)
 | 
						sinfo, isIn := r.core.sessions.getSessionForHandle(&p.Handle)
 | 
				
			||||||
	if !isIn {
 | 
						if !isIn {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -283,13 +283,13 @@ func (r *router) handleProto(packet []byte) {
 | 
				
			||||||
	// Now try to open the payload
 | 
						// Now try to open the payload
 | 
				
			||||||
	var sharedKey *boxSharedKey
 | 
						var sharedKey *boxSharedKey
 | 
				
			||||||
	//var theirPermPub *boxPubKey
 | 
						//var theirPermPub *boxPubKey
 | 
				
			||||||
	if p.toKey == r.core.boxPub {
 | 
						if p.ToKey == r.core.boxPub {
 | 
				
			||||||
		// Try to open using our permanent key
 | 
							// 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 {
 | 
						} else {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	bs, isOK := boxOpen(sharedKey, p.payload, &p.nonce)
 | 
						bs, isOK := boxOpen(sharedKey, p.Payload, &p.Nonce)
 | 
				
			||||||
	if !isOK {
 | 
						if !isOK {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -303,13 +303,13 @@ func (r *router) handleProto(packet []byte) {
 | 
				
			||||||
	//fmt.Println("RECV bytes:", bs)
 | 
						//fmt.Println("RECV bytes:", bs)
 | 
				
			||||||
	switch bsType {
 | 
						switch bsType {
 | 
				
			||||||
	case wire_SessionPing:
 | 
						case wire_SessionPing:
 | 
				
			||||||
		r.handlePing(bs, &p.fromKey)
 | 
							r.handlePing(bs, &p.FromKey)
 | 
				
			||||||
	case wire_SessionPong:
 | 
						case wire_SessionPong:
 | 
				
			||||||
		r.handlePong(bs, &p.fromKey)
 | 
							r.handlePong(bs, &p.FromKey)
 | 
				
			||||||
	case wire_DHTLookupRequest:
 | 
						case wire_DHTLookupRequest:
 | 
				
			||||||
		r.handleDHTReq(bs, &p.fromKey)
 | 
							r.handleDHTReq(bs, &p.FromKey)
 | 
				
			||||||
	case wire_DHTLookupResponse:
 | 
						case wire_DHTLookupResponse:
 | 
				
			||||||
		r.handleDHTRes(bs, &p.fromKey)
 | 
							r.handleDHTRes(bs, &p.FromKey)
 | 
				
			||||||
	case wire_SearchRequest:
 | 
						case wire_SearchRequest:
 | 
				
			||||||
		r.handleSearchReq(bs)
 | 
							r.handleSearchReq(bs)
 | 
				
			||||||
	case wire_SearchResponse:
 | 
						case wire_SearchResponse:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -108,12 +108,12 @@ func (s *searches) forwardSearch(req *searchReq, next *dhtInfo) {
 | 
				
			||||||
	shared := s.core.sessions.getSharedKey(&s.core.boxPriv, &next.key)
 | 
						shared := s.core.sessions.getSharedKey(&s.core.boxPriv, &next.key)
 | 
				
			||||||
	payload, nonce := boxSeal(shared, bs, nil)
 | 
						payload, nonce := boxSeal(shared, bs, nil)
 | 
				
			||||||
	p := wire_protoTrafficPacket{
 | 
						p := wire_protoTrafficPacket{
 | 
				
			||||||
		ttl:     ^uint64(0),
 | 
							TTL:     ^uint64(0),
 | 
				
			||||||
		coords:  next.coords,
 | 
							Coords:  next.coords,
 | 
				
			||||||
		toKey:   next.key,
 | 
							ToKey:   next.key,
 | 
				
			||||||
		fromKey: s.core.boxPub,
 | 
							FromKey: s.core.boxPub,
 | 
				
			||||||
		nonce:   *nonce,
 | 
							Nonce:   *nonce,
 | 
				
			||||||
		payload: payload,
 | 
							Payload: payload,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	packet := p.encode()
 | 
						packet := p.encode()
 | 
				
			||||||
	s.core.router.out(packet)
 | 
						s.core.router.out(packet)
 | 
				
			||||||
| 
						 | 
					@ -132,12 +132,12 @@ func (s *searches) sendSearchRes(req *searchReq) {
 | 
				
			||||||
	shared := s.core.sessions.getSharedKey(&s.core.boxPriv, &req.key)
 | 
						shared := s.core.sessions.getSharedKey(&s.core.boxPriv, &req.key)
 | 
				
			||||||
	payload, nonce := boxSeal(shared, bs, nil)
 | 
						payload, nonce := boxSeal(shared, bs, nil)
 | 
				
			||||||
	p := wire_protoTrafficPacket{
 | 
						p := wire_protoTrafficPacket{
 | 
				
			||||||
		ttl:     ^uint64(0),
 | 
							TTL:     ^uint64(0),
 | 
				
			||||||
		coords:  req.coords,
 | 
							Coords:  req.coords,
 | 
				
			||||||
		toKey:   req.key,
 | 
							ToKey:   req.key,
 | 
				
			||||||
		fromKey: s.core.boxPub,
 | 
							FromKey: s.core.boxPub,
 | 
				
			||||||
		nonce:   *nonce,
 | 
							Nonce:   *nonce,
 | 
				
			||||||
		payload: payload,
 | 
							Payload: payload,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	packet := p.encode()
 | 
						packet := p.encode()
 | 
				
			||||||
	s.core.router.out(packet)
 | 
						s.core.router.out(packet)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -255,12 +255,12 @@ func (ss *sessions) sendPingPong(sinfo *sessionInfo, isPong bool) {
 | 
				
			||||||
	shared := ss.getSharedKey(&ss.core.boxPriv, &sinfo.theirPermPub)
 | 
						shared := ss.getSharedKey(&ss.core.boxPriv, &sinfo.theirPermPub)
 | 
				
			||||||
	payload, nonce := boxSeal(shared, bs, nil)
 | 
						payload, nonce := boxSeal(shared, bs, nil)
 | 
				
			||||||
	p := wire_protoTrafficPacket{
 | 
						p := wire_protoTrafficPacket{
 | 
				
			||||||
		ttl:     ^uint64(0),
 | 
							TTL:     ^uint64(0),
 | 
				
			||||||
		coords:  sinfo.coords,
 | 
							Coords:  sinfo.coords,
 | 
				
			||||||
		toKey:   sinfo.theirPermPub,
 | 
							ToKey:   sinfo.theirPermPub,
 | 
				
			||||||
		fromKey: ss.core.boxPub,
 | 
							FromKey: ss.core.boxPub,
 | 
				
			||||||
		nonce:   *nonce,
 | 
							Nonce:   *nonce,
 | 
				
			||||||
		payload: payload,
 | 
							Payload: payload,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	packet := p.encode()
 | 
						packet := p.encode()
 | 
				
			||||||
	ss.core.router.out(packet)
 | 
						ss.core.router.out(packet)
 | 
				
			||||||
| 
						 | 
					@ -383,11 +383,11 @@ func (sinfo *sessionInfo) doSend(bs []byte) {
 | 
				
			||||||
	payload, nonce := boxSeal(&sinfo.sharedSesKey, bs, &sinfo.myNonce)
 | 
						payload, nonce := boxSeal(&sinfo.sharedSesKey, bs, &sinfo.myNonce)
 | 
				
			||||||
	defer util_putBytes(payload)
 | 
						defer util_putBytes(payload)
 | 
				
			||||||
	p := wire_trafficPacket{
 | 
						p := wire_trafficPacket{
 | 
				
			||||||
		ttl:     ^uint64(0),
 | 
							TTL:     ^uint64(0),
 | 
				
			||||||
		coords:  sinfo.coords,
 | 
							Coords:  sinfo.coords,
 | 
				
			||||||
		handle:  sinfo.theirHandle,
 | 
							Handle:  sinfo.theirHandle,
 | 
				
			||||||
		nonce:   *nonce,
 | 
							Nonce:   *nonce,
 | 
				
			||||||
		payload: payload,
 | 
							Payload: payload,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	packet := p.encode()
 | 
						packet := p.encode()
 | 
				
			||||||
	sinfo.bytesSent += uint64(len(bs))
 | 
						sinfo.bytesSent += uint64(len(bs))
 | 
				
			||||||
| 
						 | 
					@ -395,12 +395,12 @@ func (sinfo *sessionInfo) doSend(bs []byte) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (sinfo *sessionInfo) doRecv(p *wire_trafficPacket) {
 | 
					func (sinfo *sessionInfo) doRecv(p *wire_trafficPacket) {
 | 
				
			||||||
	defer util_putBytes(p.payload)
 | 
						defer util_putBytes(p.Payload)
 | 
				
			||||||
	payloadSize := uint16(len(p.payload))
 | 
						payloadSize := uint16(len(p.Payload))
 | 
				
			||||||
	if !sinfo.nonceIsOK(&p.nonce) {
 | 
						if !sinfo.nonceIsOK(&p.Nonce) {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	bs, isOK := boxOpen(&sinfo.sharedSesKey, p.payload, &p.nonce)
 | 
						bs, isOK := boxOpen(&sinfo.sharedSesKey, p.Payload, &p.Nonce)
 | 
				
			||||||
	if !isOK {
 | 
						if !isOK {
 | 
				
			||||||
		// We're going to guess that the session MTU is too large
 | 
							// We're going to guess that the session MTU is too large
 | 
				
			||||||
		// Set myMTU to the largest value we think we can receive
 | 
							// 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 }()
 | 
						go func() { sinfo.core.router.admin <- fixSessionMTU }()
 | 
				
			||||||
	sinfo.updateNonce(&p.nonce)
 | 
						sinfo.updateNonce(&p.Nonce)
 | 
				
			||||||
	sinfo.time = time.Now()
 | 
						sinfo.time = time.Now()
 | 
				
			||||||
	sinfo.bytesRecvd += uint64(len(bs))
 | 
						sinfo.bytesRecvd += uint64(len(bs))
 | 
				
			||||||
	sinfo.core.router.recvPacket(bs, &sinfo.theirAddr, &sinfo.theirSubnet)
 | 
						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
 | 
					// Announces that we can send parts of a Message with a particular seq
 | 
				
			||||||
type msgAnnounce struct {
 | 
					type msgAnnounce struct {
 | 
				
			||||||
	root   sigPubKey
 | 
						Root   sigPubKey
 | 
				
			||||||
	tstamp int64
 | 
						Tstamp int64
 | 
				
			||||||
	seq    uint64
 | 
						Seq    uint64
 | 
				
			||||||
	len    uint64
 | 
						Len    uint64
 | 
				
			||||||
	//Deg uint64
 | 
						//Deg uint64
 | 
				
			||||||
	rseq uint64
 | 
						Rseq uint64
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (m *msgAnnounce) encode() []byte {
 | 
					func (m *msgAnnounce) encode() []byte {
 | 
				
			||||||
	bs := wire_encode_uint64(wire_SwitchAnnounce)
 | 
						bs := wire_encode_uint64(wire_SwitchAnnounce)
 | 
				
			||||||
	bs = append(bs, m.root[:]...)
 | 
						bs = append(bs, m.Root[:]...)
 | 
				
			||||||
	bs = append(bs, wire_encode_uint64(wire_intToUint(m.tstamp))...)
 | 
						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.Seq)...)
 | 
				
			||||||
	bs = append(bs, wire_encode_uint64(m.len)...)
 | 
						bs = append(bs, wire_encode_uint64(m.Len)...)
 | 
				
			||||||
	bs = append(bs, wire_encode_uint64(m.rseq)...)
 | 
						bs = append(bs, wire_encode_uint64(m.Rseq)...)
 | 
				
			||||||
	return bs
 | 
						return bs
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -147,34 +147,34 @@ func (m *msgAnnounce) decode(bs []byte) bool {
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case pType != wire_SwitchAnnounce:
 | 
						case pType != wire_SwitchAnnounce:
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case !wire_chop_slice(m.root[:], &bs):
 | 
						case !wire_chop_slice(m.Root[:], &bs):
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case !wire_chop_uint64(&tstamp, &bs):
 | 
						case !wire_chop_uint64(&tstamp, &bs):
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case !wire_chop_uint64(&m.seq, &bs):
 | 
						case !wire_chop_uint64(&m.Seq, &bs):
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case !wire_chop_uint64(&m.len, &bs):
 | 
						case !wire_chop_uint64(&m.Len, &bs):
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case !wire_chop_uint64(&m.rseq, &bs):
 | 
						case !wire_chop_uint64(&m.Rseq, &bs):
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	m.tstamp = wire_intFromUint(tstamp)
 | 
						m.Tstamp = wire_intFromUint(tstamp)
 | 
				
			||||||
	return true
 | 
						return true
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type msgHopReq struct {
 | 
					type msgHopReq struct {
 | 
				
			||||||
	root   sigPubKey
 | 
						Root   sigPubKey
 | 
				
			||||||
	tstamp int64
 | 
						Tstamp int64
 | 
				
			||||||
	seq    uint64
 | 
						Seq    uint64
 | 
				
			||||||
	hop    uint64
 | 
						Hop    uint64
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (m *msgHopReq) encode() []byte {
 | 
					func (m *msgHopReq) encode() []byte {
 | 
				
			||||||
	bs := wire_encode_uint64(wire_SwitchHopRequest)
 | 
						bs := wire_encode_uint64(wire_SwitchHopRequest)
 | 
				
			||||||
	bs = append(bs, m.root[:]...)
 | 
						bs = append(bs, m.Root[:]...)
 | 
				
			||||||
	bs = append(bs, wire_encode_uint64(wire_intToUint(m.tstamp))...)
 | 
						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.Seq)...)
 | 
				
			||||||
	bs = append(bs, wire_encode_uint64(m.hop)...)
 | 
						bs = append(bs, wire_encode_uint64(m.Hop)...)
 | 
				
			||||||
	return bs
 | 
						return bs
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -186,38 +186,38 @@ func (m *msgHopReq) decode(bs []byte) bool {
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case pType != wire_SwitchHopRequest:
 | 
						case pType != wire_SwitchHopRequest:
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case !wire_chop_slice(m.root[:], &bs):
 | 
						case !wire_chop_slice(m.Root[:], &bs):
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case !wire_chop_uint64(&tstamp, &bs):
 | 
						case !wire_chop_uint64(&tstamp, &bs):
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case !wire_chop_uint64(&m.seq, &bs):
 | 
						case !wire_chop_uint64(&m.Seq, &bs):
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case !wire_chop_uint64(&m.hop, &bs):
 | 
						case !wire_chop_uint64(&m.Hop, &bs):
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	m.tstamp = wire_intFromUint(tstamp)
 | 
						m.Tstamp = wire_intFromUint(tstamp)
 | 
				
			||||||
	return true
 | 
						return true
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type msgHop struct {
 | 
					type msgHop struct {
 | 
				
			||||||
	root   sigPubKey
 | 
						Root   sigPubKey
 | 
				
			||||||
	tstamp int64
 | 
						Tstamp int64
 | 
				
			||||||
	seq    uint64
 | 
						Seq    uint64
 | 
				
			||||||
	hop    uint64
 | 
						Hop    uint64
 | 
				
			||||||
	port   switchPort
 | 
						Port   switchPort
 | 
				
			||||||
	next   sigPubKey
 | 
						Next   sigPubKey
 | 
				
			||||||
	sig    sigBytes
 | 
						Sig    sigBytes
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (m *msgHop) encode() []byte {
 | 
					func (m *msgHop) encode() []byte {
 | 
				
			||||||
	bs := wire_encode_uint64(wire_SwitchHop)
 | 
						bs := wire_encode_uint64(wire_SwitchHop)
 | 
				
			||||||
	bs = append(bs, m.root[:]...)
 | 
						bs = append(bs, m.Root[:]...)
 | 
				
			||||||
	bs = append(bs, wire_encode_uint64(wire_intToUint(m.tstamp))...)
 | 
						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.Seq)...)
 | 
				
			||||||
	bs = append(bs, wire_encode_uint64(m.hop)...)
 | 
						bs = append(bs, wire_encode_uint64(m.Hop)...)
 | 
				
			||||||
	bs = append(bs, wire_encode_uint64(uint64(m.port))...)
 | 
						bs = append(bs, wire_encode_uint64(uint64(m.Port))...)
 | 
				
			||||||
	bs = append(bs, m.next[:]...)
 | 
						bs = append(bs, m.Next[:]...)
 | 
				
			||||||
	bs = append(bs, m.sig[:]...)
 | 
						bs = append(bs, m.Sig[:]...)
 | 
				
			||||||
	return bs
 | 
						return bs
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -229,22 +229,22 @@ func (m *msgHop) decode(bs []byte) bool {
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case pType != wire_SwitchHop:
 | 
						case pType != wire_SwitchHop:
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case !wire_chop_slice(m.root[:], &bs):
 | 
						case !wire_chop_slice(m.Root[:], &bs):
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case !wire_chop_uint64(&tstamp, &bs):
 | 
						case !wire_chop_uint64(&tstamp, &bs):
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case !wire_chop_uint64(&m.seq, &bs):
 | 
						case !wire_chop_uint64(&m.Seq, &bs):
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case !wire_chop_uint64(&m.hop, &bs):
 | 
						case !wire_chop_uint64(&m.Hop, &bs):
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case !wire_chop_uint64((*uint64)(&m.port), &bs):
 | 
						case !wire_chop_uint64((*uint64)(&m.Port), &bs):
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case !wire_chop_slice(m.next[:], &bs):
 | 
						case !wire_chop_slice(m.Next[:], &bs):
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case !wire_chop_slice(m.sig[:], &bs):
 | 
						case !wire_chop_slice(m.Sig[:], &bs):
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	m.tstamp = wire_intFromUint(tstamp)
 | 
						m.Tstamp = wire_intFromUint(tstamp)
 | 
				
			||||||
	return true
 | 
						return true
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -292,22 +292,22 @@ func wire_chop_uint64(toUInt64 *uint64, fromSlice *[]byte) bool {
 | 
				
			||||||
// Wire traffic packets
 | 
					// Wire traffic packets
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type wire_trafficPacket struct {
 | 
					type wire_trafficPacket struct {
 | 
				
			||||||
	ttl     uint64
 | 
						TTL     uint64
 | 
				
			||||||
	coords  []byte
 | 
						Coords  []byte
 | 
				
			||||||
	handle  handle
 | 
						Handle  handle
 | 
				
			||||||
	nonce   boxNonce
 | 
						Nonce   boxNonce
 | 
				
			||||||
	payload []byte
 | 
						Payload []byte
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// This is basically MarshalBinary, but decode doesn't allow that...
 | 
					// This is basically MarshalBinary, but decode doesn't allow that...
 | 
				
			||||||
func (p *wire_trafficPacket) encode() []byte {
 | 
					func (p *wire_trafficPacket) encode() []byte {
 | 
				
			||||||
	bs := util_getBytes()
 | 
						bs := util_getBytes()
 | 
				
			||||||
	bs = wire_put_uint64(wire_Traffic, bs)
 | 
						bs = wire_put_uint64(wire_Traffic, bs)
 | 
				
			||||||
	bs = wire_put_uint64(p.ttl, bs)
 | 
						bs = wire_put_uint64(p.TTL, bs)
 | 
				
			||||||
	bs = wire_put_coords(p.coords, bs)
 | 
						bs = wire_put_coords(p.Coords, bs)
 | 
				
			||||||
	bs = append(bs, p.handle[:]...)
 | 
						bs = append(bs, p.Handle[:]...)
 | 
				
			||||||
	bs = append(bs, p.nonce[:]...)
 | 
						bs = append(bs, p.Nonce[:]...)
 | 
				
			||||||
	bs = append(bs, p.payload...)
 | 
						bs = append(bs, p.Payload...)
 | 
				
			||||||
	return bs
 | 
						return bs
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -319,37 +319,37 @@ func (p *wire_trafficPacket) decode(bs []byte) bool {
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case pType != wire_Traffic:
 | 
						case pType != wire_Traffic:
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case !wire_chop_uint64(&p.ttl, &bs):
 | 
						case !wire_chop_uint64(&p.TTL, &bs):
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case !wire_chop_coords(&p.coords, &bs):
 | 
						case !wire_chop_coords(&p.Coords, &bs):
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case !wire_chop_slice(p.handle[:], &bs):
 | 
						case !wire_chop_slice(p.Handle[:], &bs):
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case !wire_chop_slice(p.nonce[:], &bs):
 | 
						case !wire_chop_slice(p.Nonce[:], &bs):
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	p.payload = append(util_getBytes(), bs...)
 | 
						p.Payload = append(util_getBytes(), bs...)
 | 
				
			||||||
	return true
 | 
						return true
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type wire_protoTrafficPacket struct {
 | 
					type wire_protoTrafficPacket struct {
 | 
				
			||||||
	ttl     uint64
 | 
						TTL     uint64
 | 
				
			||||||
	coords  []byte
 | 
						Coords  []byte
 | 
				
			||||||
	toKey   boxPubKey
 | 
						ToKey   boxPubKey
 | 
				
			||||||
	fromKey boxPubKey
 | 
						FromKey boxPubKey
 | 
				
			||||||
	nonce   boxNonce
 | 
						Nonce   boxNonce
 | 
				
			||||||
	payload []byte
 | 
						Payload []byte
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (p *wire_protoTrafficPacket) encode() []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 := 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, coords...)
 | 
				
			||||||
	bs = append(bs, p.toKey[:]...)
 | 
						bs = append(bs, p.ToKey[:]...)
 | 
				
			||||||
	bs = append(bs, p.fromKey[:]...)
 | 
						bs = append(bs, p.FromKey[:]...)
 | 
				
			||||||
	bs = append(bs, p.nonce[:]...)
 | 
						bs = append(bs, p.Nonce[:]...)
 | 
				
			||||||
	bs = append(bs, p.payload...)
 | 
						bs = append(bs, p.Payload...)
 | 
				
			||||||
	return bs
 | 
						return bs
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -360,30 +360,30 @@ func (p *wire_protoTrafficPacket) decode(bs []byte) bool {
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case pType != wire_ProtocolTraffic:
 | 
						case pType != wire_ProtocolTraffic:
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case !wire_chop_uint64(&p.ttl, &bs):
 | 
						case !wire_chop_uint64(&p.TTL, &bs):
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case !wire_chop_coords(&p.coords, &bs):
 | 
						case !wire_chop_coords(&p.Coords, &bs):
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case !wire_chop_slice(p.toKey[:], &bs):
 | 
						case !wire_chop_slice(p.ToKey[:], &bs):
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case !wire_chop_slice(p.fromKey[:], &bs):
 | 
						case !wire_chop_slice(p.FromKey[:], &bs):
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case !wire_chop_slice(p.nonce[:], &bs):
 | 
						case !wire_chop_slice(p.Nonce[:], &bs):
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	p.payload = bs
 | 
						p.Payload = bs
 | 
				
			||||||
	return true
 | 
						return true
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type wire_linkProtoTrafficPacket struct {
 | 
					type wire_linkProtoTrafficPacket struct {
 | 
				
			||||||
	nonce   boxNonce
 | 
						Nonce   boxNonce
 | 
				
			||||||
	payload []byte
 | 
						Payload []byte
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (p *wire_linkProtoTrafficPacket) encode() []byte {
 | 
					func (p *wire_linkProtoTrafficPacket) encode() []byte {
 | 
				
			||||||
	bs := wire_encode_uint64(wire_LinkProtocolTraffic)
 | 
						bs := wire_encode_uint64(wire_LinkProtocolTraffic)
 | 
				
			||||||
	bs = append(bs, p.nonce[:]...)
 | 
						bs = append(bs, p.Nonce[:]...)
 | 
				
			||||||
	bs = append(bs, p.payload...)
 | 
						bs = append(bs, p.Payload...)
 | 
				
			||||||
	return bs
 | 
						return bs
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -394,10 +394,10 @@ func (p *wire_linkProtoTrafficPacket) decode(bs []byte) bool {
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case pType != wire_LinkProtocolTraffic:
 | 
						case pType != wire_LinkProtocolTraffic:
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case !wire_chop_slice(p.nonce[:], &bs):
 | 
						case !wire_chop_slice(p.Nonce[:], &bs):
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	p.payload = bs
 | 
						p.Payload = bs
 | 
				
			||||||
	return true
 | 
						return true
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue