52 Commits

Author SHA1 Message Date
683a2015b0 Use FAIL as the default dest if unable to parse 2025-04-27 18:03:06 -04:00
c34748dab3 Add CLI to specify dest for relay messages
The dest can be specified as a 4 char ASCII string, or as an IPv4 address.
2025-04-19 22:26:32 -04:00
5b88f0df6a Rename Saprus to Client internally 2025-04-14 07:13:09 -04:00
23f7ad8f94 Break out the impl to a lib
This will make it easier to make a C library.
2025-04-13 17:14:18 -04:00
8779b29149 Do some things for invy 2025-04-13 16:41:20 -04:00
0f4a7c9bcd Use dynamic array instead of arraylist
we know the size (assuming the len is correct) so we can preallocate the whole array
2025-04-06 21:33:00 -04:00
2302e6930d Depend on clap the same way as network 2025-04-06 13:08:09 -04:00
935e552a59 Don't print help after sending message 2025-04-06 13:08:09 -04:00
3424217539 Add comment for cli example reference 2025-04-06 13:08:09 -04:00
dcb962593d Allow caller to specify what kind of message to send with arg 2025-04-06 13:08:09 -04:00
c2f8c77c52 Nicer message for no response 2025-04-06 13:08:09 -04:00
6eef36e78a Handle network blocking well 2025-04-06 13:08:09 -04:00
8278648ba9 Don't use multi threading where it is not required 2025-04-06 13:08:09 -04:00
6b38d5bb74 Last handshake packet uses non 8888 port 2025-04-06 13:08:09 -04:00
ec94e85ab9 Complete the handshake 2025-04-06 13:08:09 -04:00
a2072436aa Receive and print the response from the sentinel 2025-04-06 13:08:09 -04:00
774d52ad59 Initial awaiting for handshake response
seems like i might be getting my own initial connection?
I get a response even without the sentinal running.
2025-04-06 13:08:09 -04:00
b219fdc1f5 Start proper connection handshake 2025-04-06 13:08:09 -04:00
433a97fe5a Move binary back to zaprus
Also clean up the args for the aux functions by computing the type instead of passing it
2025-04-06 13:08:09 -04:00
3c935698aa Correctly handle the endiness and packedness of the the header reading and writing 2025-04-06 13:08:09 -04:00
bc75e86904 Write the header as a packed int
this seems like the best way to do it.
2025-04-06 13:08:09 -04:00
ac5511e9bd Not using writer
Use direct mem copying into the buf instead of writing to it with the writer interface.
Probably better to use the writer actually, since this suffers from the same issue with the extra two null bytes.
2025-04-06 13:08:09 -04:00
efcd866d6c Initial testing of connection message 2025-04-06 13:08:09 -04:00
7b07520adb Move sendRelay logic to Saprus struct 2025-04-06 13:08:09 -04:00
448e900004 Break relay into a specific program 2025-04-06 13:08:09 -04:00
93161ff4bd Move types to their own file
Make it so I can specify the payload message
2025-04-06 13:08:09 -04:00
58ed9048da GREATLY improve clarity 2025-04-06 13:08:09 -04:00
88b2734886 Move dba to top level scope
This makes it so references to it are lazily compiled, so I can throw a compileError if it is referenced in the wrong mode.
2025-04-06 13:08:09 -04:00
e24220c98b add comments!!!!! 2025-04-06 13:08:09 -04:00
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
a0bea9311f Added network dep 2025-04-06 13:08:09 -04:00