Negotiate Lower Bandwidth / Higher Density Packets for Peers #428
Labels
No Label
applications
BLOCKED
bug
design
duplicate
enhancement
fixed?
funding-needed
help wanted
infrastructure
invalid
payments
qubes
question
ready-for-implementation
refactor
spam
tapir-server
testing
tor
wontfix
No Milestone
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cwtch.im/cwtch#428
Loading…
Reference in New Issue
No description provided.
Delete Branch "fastercwtch"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Backwards compatible version negotiation for PeerApp which allows newer version to use a much higher density packet format.
Drone Build Status: success
https://build.openprivacy.ca/cwtch.im/cwtch/690
@ -42,6 +47,7 @@ func (pa *PeerApp) NewInstance() tapir.Application {
newApp.OnAuth = pa.OnAuth
newApp.OnClose = pa.OnClose
newApp.OnConnecting = pa.OnConnecting
newApp.version.Store(0x01)
constant?
@ -62,0 +76,4 @@
pa.SendMessage(model2.PeerMessage{
ID: event.ContextVersion,
Context: event.ContextGetVal,
Data: []byte{0x02},
constant?
@ -81,0 +104,4 @@
err = json.Unmarshal(message, &packet)
} else if pa.version.Load() == 0x02 {
// assume the encoding is invalid
this is a big chunk, might be best moved to a function?
@ -81,0 +108,4 @@
err = errors.New("invalid message")
// find the identifier prefix
idTerminator := bytes.IndexByte(message, '|')
I'm a little nervous mixing unspecified Ids, event IDs are strings, even tho they should be populated by int -> strings only? its not type specified anywhere so someone could make it binary or strings and either could generate a '|', contexts are strings that right now use '.' as seperators...
we have a lot of string manipulation based on not well documented seperators and we're mixing it with binary data.
could we use Pascal style strings here? neither id nor context should exceed 256 bytes so just have each lead with a byte of length to parse?
@ -84,0 +148,4 @@
// can remove this check all together)
if packet.ID == event.ContextVersion {
if pa.version.Load() == 0x01 && len(packet.Data) == 1 && packet.Data[0] == 0x02 {
log.Debugf("switching to 2")
switching what to 2 :P
@ -95,0 +169,4 @@
var err error
if pa.version.Load() == 0x02 {
// treat data as a pre-serialized string, not as a byte array (which will be base64 encoded and bloat the packet size)
did the json encode to a base64?
yes
@ -95,0 +170,4 @@
if pa.version.Load() == 0x02 {
// treat data as a pre-serialized string, not as a byte array (which will be base64 encoded and bloat the packet size)
serialized = append(append([]byte(message.ID+"|"), []byte(message.Context+"|")...), message.Data...)
this is a new message format, we probably want to document it somewhere. as much as this works as a one liner, we might want to make it a function anyways just for clarity
267283c3a3
toff4249e2bc
86f0db49a4
toea9cf5ca87
@ -42,6 +48,7 @@ func (pa *PeerApp) NewInstance() tapir.Application {
newApp.OnAuth = pa.OnAuth
newApp.OnClose = pa.OnClose
newApp.OnConnecting = pa.OnConnecting
newApp.version.Store(0x01)
Store(Version1)
@ -62,0 +72,4 @@
// we are abusing the context here slightly by sending a "malformed" GetVal request.
// as a rule cwtch ignores getval requests that it cannot deserialize so older clients will ignore this
// message.
// version *must* be the first message sent to prevent race conditions for aut events fired on auth
for 'aut' events?
@ -62,0 +77,4 @@
pa.SendMessage(model2.PeerMessage{
ID: event.ContextVersion,
Context: event.ContextGetVal,
Data: []byte{Version1},
version2?
Drone Build Status: success
https://build.openprivacy.ca/cwtch.im/cwtch/698
Drone Build Status: success
https://build.openprivacy.ca/cwtch.im/cwtch/700