diff options
| author | 2025-09-14 15:20:59 +0330 | |
|---|---|---|
| committer | 2025-09-14 15:20:59 +0330 | |
| commit | d54aabd5d0d55331a6d9b74e99ef311c347abb82 (patch) | |
| tree | c26db0c47bfd9fe547e6bcaba776cd1c79ece6bd /src/common.c | |
| parent | add custom port support (diff) | |
query packets by author feature
Diffstat (limited to 'src/common.c')
| -rw-r--r-- | src/common.c | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/src/common.c b/src/common.c index 771c3e6..0fef6da 100644 --- a/src/common.c +++ b/src/common.c @@ -26,27 +26,35 @@ const uint16_t default_port = 8040; enum client_input { // ask server for its information (responds with audit_response) - audit_server = 0x9a, + audit_server = 0x10, // ask server for a random set of neighbors // (input uint8_t neighbor_count, responds with neighbors_info) - get_neighbors = 0x20, + get_neighbors = 0x11, // monitor incoming packets // (input struct firehose_request, responds with firehose_reply) - firehose = 0xf1, + firehose = 0x12, // give a packet to the relay // (input struct data_packet, responds with push_packet_result) - push_packet = 0x88, + push_packet = 0x13, // get a packet from the server // (input hash, responds with get_packet_result) - get_packet = 0x87, + get_packet = 0x14, // register a new neighbor relay to this server // (input struct relay_neighbor, responds with register_neighbor_result) - register_neighbor = 0x73, + register_neighbor = 0x15, + + // query packets for a specific author + // 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 author'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_packets = 0x16 }; enum server_reply { @@ -54,17 +62,19 @@ enum server_reply { error = 0x1, // type `struct relay_info` - audit_response = 0xaf, + audit_response = 0x17, // type `struct relay_neighbor[ neighbor_count ]` - neighbors_info = 0x43, + neighbors_info = 0x18, // type `uint64_t new_offset, struct data_packet[ count ]` - firehose_reply = 0x6c, + firehose_reply = 0x19, // type `bool result_code` - push_packet_result = 0x4a, + push_packet_result = 0x1a, // type `struct data_packet` - get_packet_result = 0x42, + get_packet_result = 0x1b, // type `bool result_code` - register_neighbor_result = 0x6e, + register_neighbor_result = 0x1c, + // type `u16 count, u64 new_offset, struct data_packet[ count ]` + queried_author_packets = 0x1d }; typedef uint8_t get_neighbors_request; @@ -221,7 +231,8 @@ struct relay_info s2relay_info(size_t len, byte *stream, bool *success) { for (int i = 0; i < 4; i++) { bool ok; - out.statistics.quick_connect[ i ] = s2relay_neighbor(1 + 1 + 1 + 4 + 16 + 2, stream + off, &ok); + out.statistics.quick_connect[ i ] + = s2relay_neighbor(1 + 1 + 1 + 4 + 16 + 2, stream + off, &ok); if (!ok) { *success = false; return (struct relay_info) { 0 }; |
