Export fields of wire structs

This commit is contained in:
Neil Alexander 2018-06-02 21:21:05 +01:00
parent 0f96fea3fc
commit 49af65296d
9 changed files with 194 additions and 194 deletions

View File

@ -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 {

View File

@ -172,7 +172,7 @@ func (c *Core) GetAddress() *net.IP {
func (c *Core) GetSubnet() *net.IPNet {
subnet := address_subnetForNodeID(c.GetNodeID())[:]
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

View File

@ -318,12 +318,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)
@ -344,12 +344,12 @@ func (t *dht) sendRes(res *dhtRes, req *dhtReq) {
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)

View File

@ -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)

View File

@ -8,5 +8,5 @@ import "log"
// Starts the function profiler. This is only supported when built with
// '-tags build'.
func StartProfiler(_ *log.Logger) error {
return errors.New("Release builds do not support -pprof, build using '-tags debug'")
return errors.New("Release builds do not support -pprof, build using '-tags debug'")
}

View File

@ -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:

View File

@ -108,12 +108,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)
@ -132,12 +132,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)

View File

@ -255,12 +255,12 @@ func (ss *sessions) sendPingPong(sinfo *sessionInfo, isPong bool) {
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)
@ -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)

View File

@ -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
}