summaryrefslogtreecommitdiff
path: root/src/req_res_codes.h
diff options
context:
space:
mode:
authorGravatar moon <moon@coffin.ir> 2025-09-15 03:49:50 +0330
committerGravatar moon <moon@coffin.ir> 2025-09-15 03:49:50 +0330
commit5b10e3d451bd538a7f5c0ac432dcc1b85c157a53 (patch)
tree69b60e5fe9aad5e36dc0a2f47f67c78c616ddea8 /src/req_res_codes.h
parentperf opt in set_data_packet (diff)
add new opcode + firehose change
Diffstat (limited to 'src/req_res_codes.h')
-rw-r--r--src/req_res_codes.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/req_res_codes.h b/src/req_res_codes.h
new file mode 100644
index 0000000..3903401
--- /dev/null
+++ b/src/req_res_codes.h
@@ -0,0 +1,69 @@
+enum client_input {
+ // ask server for its information (responds with audit_response)
+ audit_server = 0x10,
+
+ // ask server for a random set of neighbors
+ // (input uint8_t neighbor_count, responds with neighbors_info)
+ get_neighbors = 0x11,
+
+ // monitor incoming packets
+ // (input struct firehose_request, responds with firehose_reply)
+ firehose = 0x12,
+
+ // give a packet to the relay
+ // (input struct data_packet, responds with push_packet_result)
+ push_packet = 0x13,
+
+ // get a packet from the server
+ // (input hash, responds with get_packet_result)
+ get_packet = 0x14,
+
+ // register a new neighbor relay to this server
+ // (input struct relay_neighbor, responds with register_neighbor_result)
+ register_neighbor = 0x15,
+
+ // query packets for a specific author
+ // (input public_key, pub_sign_key, u16 count, u64 offset)
+ // (responds with queried_author_packets)
+ query_packets = 0x16,
+
+ // query packets for a specific recipient
+ // note: to prevent DoS, you must provide a signature by the requested author to be approved.
+ // the signature needs to be from a struct shaped `public_key + pub_sign_key + u16 count + u64
+ // offset`.
+ // server must verify the signing key is of the recipient's pubkey and signing key by looking at
+ // the packet's metadata.
+ // (input public_key, input pub_sign_key, signature, u16 count, u64 offset)
+ // (responds with queried_author_packets)
+ query_by_recipient = 0x17,
+
+ // query packets by in-memory id and hash.
+ // this is to be used in tandem with firehose, in an effort to reduce traffic usage.
+ // note that this only works for entries currently loaded into memory. (meaning the id can be
+ // invalidated at any time)
+ // (input hash, u64 id)
+ // (responds with get_packet_result)
+ query_by_id_hash = 0x18
+};
+
+enum server_reply {
+ // pretty self-explanatory.
+ error = 0x1,
+
+ // type `struct relay_info`
+ audit_response = 0x19,
+ // type `struct relay_neighbor[ neighbor_count ]`
+ neighbors_info = 0x1a,
+ // type `uint64_t new_offset, struct data_packet[ count ]`
+ firehose_reply = 0x1b,
+ // type `bool result_code`
+ push_packet_result = 0x1c,
+ // type `struct data_packet`
+ get_packet_result = 0x1d,
+ // type `bool result_code`
+ register_neighbor_result = 0x1e,
+ // type `u16 count, u64 new_offset, struct data_packet[ count ]`
+ queried_author_packets = 0x1f,
+ // type `u16 count, u64 new_offset, struct data_packet[ count ]`
+ queried_recipient_packets = 0x20,
+}; \ No newline at end of file