Commit Graph

22 Commits

Author SHA1 Message Date
b1def25c69 move aux funcs back into the union
also move the body of the base64 handling back to the only place it is used now
2025-04-06 13:08:09 -04:00
d60d1fd335 Remove redundant comptime
Move edge together at the end of the switch
2025-04-06 13:08:09 -04:00
ef36894c70 Properly initialize the SaprusMessage fromBytes
Will actually use the provided packet type inline.
2025-04-06 13:08:09 -04:00
a0f6e08794 dedup some
Still need to clean up fromBytesAux
2025-04-06 13:08:09 -04:00
53d7e62054 Break out encoding and decoding into its own functions 2025-04-06 13:08:09 -04:00
3bd955f0bf Add decoding connection messages 2025-04-06 13:08:09 -04:00
6b8d2ec1bd Add packet decoding
Big bug where I was setting the payload length do be the pre-encoded size rather than the encoded size.
2025-04-06 13:08:09 -04:00
2d1beef44a Small cleanup
Rename allocator to gpa (general purpose allocator) and move DebugAllocator type out of main
2025-04-06 13:08:09 -04:00
cc94c77cfb Remove unnecessary explicit cast
Remove unnecessary Self declaration.
2025-04-06 13:08:09 -04:00
e38c2b421d Specify endianness when writing the header struct 2025-04-06 13:08:09 -04:00
f5f268baf7 Explicitly specify the size of connection options
This makes it so specifying the wrong number of options would actually throw a compile time error.
2025-04-06 13:08:09 -04:00
08e5376fa0 Clean up string handling 2025-04-06 13:08:09 -04:00
055539af7d Make header always a packed struct
This lets us easily use the same writeStructe(header) pattern to write the header for each message type.
2025-04-06 13:08:09 -04:00
46ac234c80 Base64 encode relay message
write the packed connection struct directly instead of each of the fields.
2025-04-06 13:08:09 -04:00
741f1efc46 Add connection message type 2025-04-06 13:08:09 -04:00
0c0a678811 Remove tests 2025-04-06 13:08:09 -04:00
c391b4da55 Working with nice union
This let's us easily use a single type for all Saprus messages, and unwrap the specific type with a switch.
2025-04-06 13:08:09 -04:00
0eda295e0c it works! 2025-04-06 13:08:09 -04:00
3e265aeadb Getting some data but malformed
This is what the data shows up in the sentinal looking like:

2025/04/02 22:36:32 Error decoding message: Hello darkness my old friend::48656c6c6f206461726b6e657373206d79206f6c6420667269656e64aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
2025/04/02 22:36:32 INFO: Relay message received: Hello darkness my old friend
2025-04-06 13:08:09 -04:00
3b5c8e397e Add msgs with toBytes functions 2025-04-06 13:08:09 -04:00
ffcade6088 Remove lib 2025-04-06 13:08:08 -04:00
c9b37c250c Initial commit 2025-04-06 13:08:08 -04:00