Tilde Friends
ssb.h
1#pragma once
2
9#include "quickjs.h"
10
11#include <stdbool.h>
12#include <stddef.h>
13#include <stdint.h>
14
15enum
16{
17 k_ssb_rpc_flag_binary = 0x0,
18 k_ssb_rpc_flag_utf8 = 0x1,
19 k_ssb_rpc_flag_json = 0x2,
20 k_ssb_rpc_mask_type = 0x3,
21
22 k_ssb_rpc_flag_end_error = 0x4,
23 k_ssb_rpc_flag_stream = 0x8,
24 k_ssb_rpc_mask_message = 0xC,
25
26 k_ssb_rpc_mask_send = 0xf,
27
28 k_ssb_rpc_flag_new_request = 0x10,
29
30 k_ssb_blob_bytes_max = 5 * 1024 * 1024,
31
32 k_ssb_peer_exchange_expires_seconds = 60 * 60,
33
34 k_max_private_message_recipients = 8,
35};
36
41{
42 k_tf_ssb_verify_flag_debug = 1,
44
48typedef enum _tf_ssb_change_t
49{
50 k_tf_ssb_change_create,
51 k_tf_ssb_change_connect,
52 k_tf_ssb_change_remove,
53 k_tf_ssb_change_update,
55
60{
61 k_tf_ssb_broadcast_origin_discovery,
62 k_tf_ssb_broadcast_origin_room,
63 k_tf_ssb_broadcast_origin_peer_exchange,
65
70{
77
82{
83 k_tf_ssb_connect_flag_one_shot = 0x1,
84 k_tf_ssb_connect_flag_do_not_store = 0x2,
85 k_tf_ssb_connect_flag_use_invite = 0x4,
87
89typedef struct _tf_ssb_t tf_ssb_t;
91typedef struct _tf_ssb_connection_t tf_ssb_connection_t;
93typedef struct _tf_ssb_ebt_t tf_ssb_ebt_t;
95typedef struct _tf_trace_t tf_trace_t;
97typedef struct sqlite3 sqlite3;
99typedef struct uv_loop_s uv_loop_t;
101struct sockaddr_in;
102
103enum
104{
105 k_id_base64_len = 57,
106 k_id_bin_len = 32,
107 k_blob_id_len = 53,
108};
109
113typedef struct _tf_ssb_stats_t
114{
130 struct
131 {
132 int rpc;
133 int connections_changed;
134 int message_added;
135 int blob_want_added;
136 int broadcasts_changed;
139
144{
150 char last_id[k_blob_id_len];
152
157{
159 void* head;
161 void* tail;
165
173tf_ssb_t* tf_ssb_create(uv_loop_t* loop, JSContext* context, const char* db_path, const char* network_key);
174
180
187
193
199void tf_ssb_set_verbose(tf_ssb_t* ssb, bool verbose);
200
206void tf_ssb_set_quiet(tf_ssb_t* ssb, bool quiet);
207
214
222
230
238
245
252
258
266void tf_ssb_generate_keys_buffer(char* out_public, size_t public_size, char* out_private, size_t private_size);
267
274void tf_ssb_get_private_key(tf_ssb_t* ssb, uint8_t* out_private, size_t private_size);
275
282
289
296
303
309
315
326JSValue tf_ssb_sign_message(tf_ssb_t* ssb, const char* author, const uint8_t* private_key, JSValue message, const char* previous_id, int32_t previous_sequence);
327
335bool tf_ssb_whoami(tf_ssb_t* ssb, char* out_id, size_t out_id_size);
336
344 void (*callback)(const char* host, const struct sockaddr_in* addr, tf_ssb_broadcast_origin_t origin, tf_ssb_connection_t* tunnel, const uint8_t* pub, void* user_data),
345 void* user_data);
346
354void tf_ssb_add_broadcast(tf_ssb_t* ssb, const char* connection, tf_ssb_broadcast_origin_t origin, int64_t expires_seconds);
355
362
370int tf_ssb_get_connections(tf_ssb_t* ssb, tf_ssb_connection_t** out_connections, int out_connections_count);
371
378typedef void(tf_ssb_connect_callback_t)(tf_ssb_connection_t* connection, const char* reason, void* user_data);
379
390void tf_ssb_connect(tf_ssb_t* ssb, const char* host, int port, const uint8_t* key, int connect_flags, tf_ssb_connect_callback_t* callback, void* user_data);
391
400void tf_ssb_connect_str(tf_ssb_t* ssb, const char* address, int connect_flags, tf_ssb_connect_callback_t* callback, void* user_data);
401
408int tf_ssb_server_open(tf_ssb_t* ssb, int port);
409
416
422
428void tf_ssb_close_all(tf_ssb_t* ssb, const char* reason);
429
435
442bool tf_ssb_id_str_to_bin(uint8_t* bin, const char* str);
443
451bool tf_ssb_id_bin_to_str(char* str, size_t str_size, const uint8_t* bin);
452
466 JSContext* context, JSValue val, int verify_flags, char* out_id, size_t out_id_size, char* out_signature, size_t out_signature_size, int* out_flags);
467
475void tf_ssb_calculate_message_id(JSContext* context, JSValue message, char* out_id, size_t out_id_size);
476
484typedef void(tf_ssb_verify_strip_store_callback_t)(const char* id, bool verified, bool is_new, void* user_data);
485
493void tf_ssb_verify_strip_and_store_message(tf_ssb_t* ssb, JSValue value, tf_ssb_verify_strip_store_callback_t* callback, void* user_data);
494
500bool tf_ssb_connection_is_client(tf_ssb_connection_t* connection);
501
507const char* tf_ssb_connection_get_host(tf_ssb_connection_t* connection);
508
514int tf_ssb_connection_get_port(tf_ssb_connection_t* connection);
515
521tf_ssb_connection_t* tf_ssb_connection_get_tunnel(tf_ssb_connection_t* connection);
522
528tf_ssb_t* tf_ssb_connection_get_ssb(tf_ssb_connection_t* connection);
529
535JSContext* tf_ssb_connection_get_context(tf_ssb_connection_t* connection);
536
542void tf_ssb_connection_close(tf_ssb_connection_t* connection, const char* reason);
543
549bool tf_ssb_connection_is_connected(tf_ssb_connection_t* connection);
550
556bool tf_ssb_connection_is_closing(tf_ssb_connection_t* connection);
557
563int32_t tf_ssb_connection_next_request_number(tf_ssb_connection_t* connection);
564
571tf_ssb_connection_t* tf_ssb_connection_get(tf_ssb_t* ssb, const char* id);
572
580bool tf_ssb_connection_get_id(tf_ssb_connection_t* connection, char* out_id, size_t out_id_size);
581
587JSValue tf_ssb_connection_get_object(tf_ssb_connection_t* connection);
588
594typedef void(tf_ssb_callback_cleanup_t)(tf_ssb_t* ssb, void* user_data);
595
603typedef void(tf_ssb_connections_changed_callback_t)(tf_ssb_t* ssb, tf_ssb_change_t change, tf_ssb_connection_t* connection, void* user_data);
604
613
621
627typedef void(tf_ssb_broadcasts_changed_callback_t)(tf_ssb_t* ssb, void* user_data);
628
637
645
654typedef void(tf_ssb_message_added_callback_t)(tf_ssb_t* ssb, const char* author, int32_t sequence, const char* id, void* user_data);
655
664
672
681void tf_ssb_notify_message_added(tf_ssb_t* ssb, const char* author, int32_t sequence, const char* id, JSValue message_with_keys);
682
689typedef void(tf_ssb_blob_stored_callback_t)(tf_ssb_t* ssb, const char* id, void* user_data);
690
699
707
713void tf_ssb_notify_blob_stored(tf_ssb_t* ssb, const char* id);
714
721typedef void(tf_ssb_blob_want_added_callback_t)(tf_ssb_t* ssb, const char* id, void* user_data);
722
731
739
745void tf_ssb_notify_blob_want_added(tf_ssb_t* ssb, const char* id);
746
757typedef void(tf_ssb_rpc_callback_t)(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, JSValue args, const uint8_t* message, size_t size, void* user_data);
758
767void tf_ssb_add_rpc_callback(tf_ssb_t* ssb, const char* name, tf_ssb_rpc_callback_t* callback, tf_ssb_callback_cleanup_t* cleanup, void* user_data);
768
776void tf_ssb_remove_rpc_callback(tf_ssb_t* ssb, const char** name, tf_ssb_rpc_callback_t* callback, void* user_data);
777
791bool tf_ssb_connection_rpc_send(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, const char* new_request_name, const uint8_t* message, size_t size,
792 tf_ssb_rpc_callback_t* callback, tf_ssb_callback_cleanup_t* cleanup, void* user_data);
793
806bool tf_ssb_connection_rpc_send_json(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, const char* new_request_name, JSValue message,
807 tf_ssb_rpc_callback_t* callback, tf_ssb_callback_cleanup_t* cleanup, void* user_data);
808
817bool tf_ssb_connection_rpc_send_error(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, const char* error);
818
827bool tf_ssb_connection_rpc_send_error_method_not_allowed(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, const char* name);
828
840void tf_ssb_connection_add_request(tf_ssb_connection_t* connection, int32_t request_number, const char* name, tf_ssb_rpc_callback_t* callback, tf_ssb_callback_cleanup_t* cleanup,
841 void* user_data, tf_ssb_connection_t* dependent_connection);
842
849void tf_ssb_connection_remove_request(tf_ssb_connection_t* connection, int32_t request_number);
850
856JSValue tf_ssb_connection_requests_to_object(tf_ssb_connection_t* connection);
857
864typedef void(tf_ssb_scheduled_callback_t)(tf_ssb_connection_t* connection, bool skip, void* user_data);
865
873void tf_ssb_connection_schedule_idle(tf_ssb_connection_t* connection, const char* key, tf_ssb_scheduled_callback_t* callback, void* user_data);
874
882void tf_ssb_connection_run_work(tf_ssb_connection_t* connection, void (*work_callback)(tf_ssb_connection_t* connection, void* user_data),
883 void (*after_work_callback)(tf_ssb_connection_t* connection, int result, void* user_data), void* user_data);
884
893 tf_ssb_t* ssb, void (*work_callback)(tf_ssb_t* ssb, void* user_data), void (*after_work_callback)(tf_ssb_t* ssb, int result, void* user_data), void* user_data);
894
902void tf_ssb_connection_add_new_message_request(tf_ssb_connection_t* connection, const char* author, int32_t request_number, bool keys);
903
909void tf_ssb_connection_remove_new_message_request(tf_ssb_connection_t* connection, const char* author);
910
916bool tf_ssb_connection_is_attendant(tf_ssb_connection_t* connection);
917
923int32_t tf_ssb_connection_get_attendant_request_number(tf_ssb_connection_t* connection);
924
931void tf_ssb_connection_set_attendant(tf_ssb_connection_t* connection, bool attendant, int request_number);
932
939void tf_ssb_connection_set_endpoint(tf_ssb_connection_t* connection, bool endpoint, int request_number);
940
946bool tf_ssb_connection_is_endpoint(tf_ssb_connection_t* connection);
947
953int32_t tf_ssb_connection_get_endpoint_request_number(tf_ssb_connection_t* connection);
954
959void tf_ssb_connection_clear_room_attendants(tf_ssb_connection_t* connection);
960
966void tf_ssb_connection_add_room_attendant(tf_ssb_connection_t* connection, const char* id);
967
973void tf_ssb_connection_remove_room_attendant(tf_ssb_connection_t* connection, const char* id);
974
984tf_ssb_connection_t* tf_ssb_connection_tunnel_create(tf_ssb_t* ssb, const char* portal_id, int32_t request_number, const char* target_id, int connect_flags);
985
991int32_t tf_ssb_connection_get_ebt_request_number(tf_ssb_connection_t* connection);
992
998void tf_ssb_connection_set_ebt_request_number(tf_ssb_connection_t* connection, int32_t request_number);
999
1005
1012
1019
1026
1033
1040
1047
1054
1061void tf_ssb_set_main_thread(tf_ssb_t* ssb, bool main_thread);
1062
1069
1075void tf_ssb_set_is_room(tf_ssb_t* ssb, bool is_room);
1076
1083
1089void tf_ssb_set_is_replicator(tf_ssb_t* ssb, bool is_replicator);
1090
1097
1103void tf_ssb_set_is_peer_exchange(tf_ssb_t* ssb, bool is_peer_exchange);
1104
1111
1117void tf_ssb_set_room_name(tf_ssb_t* ssb, const char* room_name);
1118
1126void tf_ssb_schedule_work(tf_ssb_t* ssb, int delay_ms, void (*callback)(tf_ssb_t* ssb, void* user_data), void* user_data);
1127
1137bool tf_ssb_hmacsha256_verify(const char* public_key, const void* payload, size_t payload_length, const char* signature, bool signature_is_urlb64);
1138
1146void tf_ssb_connection_adjust_read_backpressure(tf_ssb_connection_t* connection, int delta);
1147
1155void tf_ssb_connection_adjust_write_count(tf_ssb_connection_t* connection, int delta);
1156
1162const char* tf_ssb_connection_get_destroy_reason(tf_ssb_connection_t* connection);
1163
1172bool tf_ssb_tunnel_create(tf_ssb_t* ssb, const char* portal_id, const char* target_id, int connect_flags);
1173
1179
1184int tf_ssb_connection_get_flags(tf_ssb_connection_t* connection);
1185
1191tf_ssb_ebt_t* tf_ssb_connection_get_ebt(tf_ssb_connection_t* connection);
1192
1202char* tf_ssb_private_message_encrypt(uint8_t* private_key, const char** recipients, int recipients_count, const char* message, size_t message_size);
1203
struct JSContext JSContext
Definition: api.js.h:10
struct _tf_trace_t tf_trace_t
Definition: http.h:30
struct uv_loop_s uv_loop_t
Definition: http.h:33
struct _tf_ssb_t tf_ssb_t
Definition: httpd.js.h:38
void tf_ssb_connection_clear_room_attendants(tf_ssb_connection_t *connection)
void tf_ssb_destroy(tf_ssb_t *ssb)
void tf_ssb_connection_add_room_attendant(tf_ssb_connection_t *connection, const char *id)
void tf_ssb_connection_set_endpoint(tf_ssb_connection_t *connection, bool endpoint, int request_number)
void tf_ssb_server_close(tf_ssb_t *ssb)
bool tf_ssb_connection_rpc_send_json(tf_ssb_connection_t *connection, uint8_t flags, int32_t request_number, const char *new_request_name, JSValue message, tf_ssb_rpc_callback_t *callback, tf_ssb_callback_cleanup_t *cleanup, void *user_data)
struct sqlite3 sqlite3
Definition: ssb.h:97
int tf_ssb_connection_get_port(tf_ssb_connection_t *connection)
bool tf_ssb_is_peer_exchange(tf_ssb_t *ssb)
JSValue tf_ssb_connection_get_object(tf_ssb_connection_t *connection)
void tf_ssb_add_blob_want_added_callback(tf_ssb_t *ssb, tf_ssb_blob_want_added_callback_t *callback, tf_ssb_callback_cleanup_t *cleanup, void *user_data)
void tf_ssb_broadcast_listener_start(tf_ssb_t *ssb, bool linger)
void tf_ssb_add_connections_changed_callback(tf_ssb_t *ssb, tf_ssb_connections_changed_callback_t *callback, tf_ssb_callback_cleanup_t *cleanup, void *user_data)
void tf_ssb_add_message_added_callback(tf_ssb_t *ssb, tf_ssb_message_added_callback_t *callback, tf_ssb_callback_cleanup_t *cleanup, void *user_data)
struct _tf_ssb_store_queue_t tf_ssb_store_queue_t
int tf_ssb_connection_get_flags(tf_ssb_connection_t *connection)
void tf_ssb_connection_remove_request(tf_ssb_connection_t *connection, int32_t request_number)
void tf_ssb_run_work(tf_ssb_t *ssb, void(*work_callback)(tf_ssb_t *ssb, void *user_data), void(*after_work_callback)(tf_ssb_t *ssb, int result, void *user_data), void *user_data)
void tf_ssb_connection_adjust_write_count(tf_ssb_connection_t *connection, int delta)
JSClassID tf_ssb_get_connection_class_id()
tf_ssb_ebt_t * tf_ssb_connection_get_ebt(tf_ssb_connection_t *connection)
JSContext * tf_ssb_get_context(tf_ssb_t *ssb)
void tf_ssb_connection_close(tf_ssb_connection_t *connection, const char *reason)
void() tf_ssb_blob_stored_callback_t(tf_ssb_t *ssb, const char *id, void *user_data)
Definition: ssb.h:689
bool tf_ssb_verify_and_strip_signature(JSContext *context, JSValue val, int verify_flags, char *out_id, size_t out_id_size, char *out_signature, size_t out_signature_size, int *out_flags)
void tf_ssb_remove_connections_changed_callback(tf_ssb_t *ssb, tf_ssb_connections_changed_callback_t *callback, void *user_data)
void tf_ssb_verify_strip_and_store_message(tf_ssb_t *ssb, JSValue value, tf_ssb_verify_strip_store_callback_t *callback, void *user_data)
bool tf_ssb_connection_is_closing(tf_ssb_connection_t *connection)
bool tf_ssb_tunnel_create(tf_ssb_t *ssb, const char *portal_id, const char *target_id, int connect_flags)
void tf_ssb_remove_blob_stored_callback(tf_ssb_t *ssb, tf_ssb_blob_stored_callback_t *callback, void *user_data)
void tf_ssb_connection_remove_new_message_request(tf_ssb_connection_t *connection, const char *author)
bool tf_ssb_is_shutting_down(tf_ssb_t *ssb)
tf_ssb_store_queue_t * tf_ssb_get_store_queue(tf_ssb_t *ssb)
void tf_ssb_visit_broadcasts(tf_ssb_t *ssb, void(*callback)(const char *host, const struct sockaddr_in *addr, tf_ssb_broadcast_origin_t origin, tf_ssb_connection_t *tunnel, const uint8_t *pub, void *user_data), void *user_data)
tf_ssb_connection_t * tf_ssb_connection_get_tunnel(tf_ssb_connection_t *connection)
void tf_ssb_notify_blob_stored(tf_ssb_t *ssb, const char *id)
_tf_ssb_verify_flags_t
Definition: ssb.h:41
const char ** tf_ssb_get_connection_ids(tf_ssb_t *ssb)
const char * tf_ssb_connection_get_destroy_reason(tf_ssb_connection_t *connection)
struct _tf_ssb_stats_t tf_ssb_stats_t
void tf_ssb_remove_blob_want_added_callback(tf_ssb_t *ssb, tf_ssb_blob_want_added_callback_t *callback, void *user_data)
void tf_ssb_generate_keys(tf_ssb_t *ssb)
void tf_ssb_connect_str(tf_ssb_t *ssb, const char *address, int connect_flags, tf_ssb_connect_callback_t *callback, void *user_data)
float tf_ssb_get_average_thread_percent(tf_ssb_t *ssb)
bool tf_ssb_id_str_to_bin(uint8_t *bin, const char *str)
void tf_ssb_record_thread_busy(tf_ssb_t *ssb, bool busy)
void tf_ssb_connection_run_work(tf_ssb_connection_t *connection, void(*work_callback)(tf_ssb_connection_t *connection, void *user_data), void(*after_work_callback)(tf_ssb_connection_t *connection, int result, void *user_data), void *user_data)
tf_ssb_t * tf_ssb_connection_get_ssb(tf_ssb_connection_t *connection)
_tf_ssb_message_flags_t
Definition: ssb.h:70
JSValue tf_ssb_sign_message(tf_ssb_t *ssb, const char *author, const uint8_t *private_key, JSValue message, const char *previous_id, int32_t previous_sequence)
void tf_ssb_connection_schedule_idle(tf_ssb_connection_t *connection, const char *key, tf_ssb_scheduled_callback_t *callback, void *user_data)
void tf_ssb_add_blob_stored_callback(tf_ssb_t *ssb, tf_ssb_blob_stored_callback_t *callback, tf_ssb_callback_cleanup_t *cleanup, void *user_data)
void tf_ssb_set_quiet(tf_ssb_t *ssb, bool quiet)
int32_t tf_ssb_connection_get_endpoint_request_number(tf_ssb_connection_t *connection)
_tf_ssb_change_t
Definition: ssb.h:49
void tf_ssb_connection_set_ebt_request_number(tf_ssb_connection_t *connection, int32_t request_number)
enum _tf_ssb_verify_flags_t tf_ssb_verify_flags_t
void tf_ssb_add_broadcast(tf_ssb_t *ssb, const char *connection, tf_ssb_broadcast_origin_t origin, int64_t expires_seconds)
void tf_ssb_connect(tf_ssb_t *ssb, const char *host, int port, const uint8_t *key, int connect_flags, tf_ssb_connect_callback_t *callback, void *user_data)
void tf_ssb_set_is_replicator(tf_ssb_t *ssb, bool is_replicator)
tf_ssb_t * tf_ssb_create(uv_loop_t *loop, JSContext *context, const char *db_path, const char *network_key)
bool tf_ssb_is_room(tf_ssb_t *ssb)
void tf_ssb_get_stats(tf_ssb_t *ssb, tf_ssb_stats_t *out_stats)
bool tf_ssb_connection_rpc_send_error_method_not_allowed(tf_ssb_connection_t *connection, uint8_t flags, int32_t request_number, const char *name)
void() tf_ssb_broadcasts_changed_callback_t(tf_ssb_t *ssb, void *user_data)
Definition: ssb.h:627
void tf_ssb_sync_start(tf_ssb_t *ssb)
void tf_ssb_get_private_key(tf_ssb_t *ssb, uint8_t *out_private, size_t private_size)
void tf_ssb_generate_keys_buffer(char *out_public, size_t public_size, char *out_private, size_t private_size)
tf_ssb_connection_t * tf_ssb_connection_get(tf_ssb_t *ssb, const char *id)
void tf_ssb_notify_message_added(tf_ssb_t *ssb, const char *author, int32_t sequence, const char *id, JSValue message_with_keys)
tf_ssb_blob_wants_t * tf_ssb_connection_get_blob_wants_state(tf_ssb_connection_t *connection)
sqlite3 * tf_ssb_acquire_db_reader_restricted(tf_ssb_t *ssb)
void() tf_ssb_connect_callback_t(tf_ssb_connection_t *connection, const char *reason, void *user_data)
Definition: ssb.h:378
_tf_ssb_broadcast_origin_t
Definition: ssb.h:60
bool tf_ssb_connection_rpc_send(tf_ssb_connection_t *connection, uint8_t flags, int32_t request_number, const char *new_request_name, const uint8_t *message, size_t size, tf_ssb_rpc_callback_t *callback, tf_ssb_callback_cleanup_t *cleanup, void *user_data)
const char * tf_ssb_connection_get_host(tf_ssb_connection_t *connection)
void tf_ssb_ref(tf_ssb_t *ssb)
sqlite3 * tf_ssb_acquire_db_reader(tf_ssb_t *ssb)
void tf_ssb_set_main_thread(tf_ssb_t *ssb, bool main_thread)
void tf_ssb_set_is_peer_exchange(tf_ssb_t *ssb, bool is_peer_exchange)
tf_trace_t * tf_ssb_get_trace(tf_ssb_t *ssb)
void tf_ssb_set_verbose(tf_ssb_t *ssb, bool verbose)
bool tf_ssb_whoami(tf_ssb_t *ssb, char *out_id, size_t out_id_size)
struct _tf_ssb_blob_wants_t tf_ssb_blob_wants_t
bool tf_ssb_connection_rpc_send_error(tf_ssb_connection_t *connection, uint8_t flags, int32_t request_number, const char *error)
void tf_ssb_remove_message_added_callback(tf_ssb_t *ssb, tf_ssb_message_added_callback_t *callback, void *user_data)
void tf_ssb_schedule_work(tf_ssb_t *ssb, int delay_ms, void(*callback)(tf_ssb_t *ssb, void *user_data), void *user_data)
void() tf_ssb_message_added_callback_t(tf_ssb_t *ssb, const char *author, int32_t sequence, const char *id, void *user_data)
Definition: ssb.h:654
JSValue tf_ssb_connection_requests_to_object(tf_ssb_connection_t *connection)
void tf_ssb_add_broadcasts_changed_callback(tf_ssb_t *ssb, tf_ssb_broadcasts_changed_callback_t *callback, tf_ssb_callback_cleanup_t *cleanup, void *user_data)
void tf_ssb_release_db_reader(tf_ssb_t *ssb, sqlite3 *db)
enum _tf_ssb_message_flags_t tf_ssb_message_flags_t
void tf_ssb_start_periodic(tf_ssb_t *ssb)
sqlite3 * tf_ssb_acquire_db_writer(tf_ssb_t *ssb)
void() tf_ssb_callback_cleanup_t(tf_ssb_t *ssb, void *user_data)
Definition: ssb.h:594
void tf_ssb_run(tf_ssb_t *ssb)
void tf_ssb_broadcast_sender_start(tf_ssb_t *ssb)
void tf_ssb_send_close(tf_ssb_t *ssb)
void() tf_ssb_verify_strip_store_callback_t(const char *id, bool verified, bool is_new, void *user_data)
Definition: ssb.h:484
uv_loop_t * tf_ssb_get_loop(tf_ssb_t *ssb)
void() tf_ssb_connections_changed_callback_t(tf_ssb_t *ssb, tf_ssb_change_t change, tf_ssb_connection_t *connection, void *user_data)
Definition: ssb.h:603
void tf_ssb_close_all(tf_ssb_t *ssb, const char *reason)
int32_t tf_ssb_connection_get_attendant_request_number(tf_ssb_connection_t *connection)
bool tf_ssb_connection_is_attendant(tf_ssb_connection_t *connection)
bool tf_ssb_hmacsha256_verify(const char *public_key, const void *payload, size_t payload_length, const char *signature, bool signature_is_urlb64)
JSContext * tf_ssb_connection_get_context(tf_ssb_connection_t *connection)
int32_t tf_ssb_connection_next_request_number(tf_ssb_connection_t *connection)
void tf_ssb_connection_adjust_read_backpressure(tf_ssb_connection_t *connection, int delta)
void tf_ssb_notify_blob_want_added(tf_ssb_t *ssb, const char *id)
int tf_ssb_get_connections(tf_ssb_t *ssb, tf_ssb_connection_t **out_connections, int out_connections_count)
char * tf_ssb_private_message_encrypt(uint8_t *private_key, const char **recipients, int recipients_count, const char *message, size_t message_size)
bool tf_ssb_connection_is_client(tf_ssb_connection_t *connection)
int tf_ssb_server_get_port(tf_ssb_t *ssb)
bool tf_ssb_connection_is_connected(tf_ssb_connection_t *connection)
bool tf_ssb_id_bin_to_str(char *str, size_t str_size, const uint8_t *bin)
void tf_ssb_connection_add_request(tf_ssb_connection_t *connection, int32_t request_number, const char *name, tf_ssb_rpc_callback_t *callback, tf_ssb_callback_cleanup_t *cleanup, void *user_data, tf_ssb_connection_t *dependent_connection)
enum _tf_ssb_broadcast_origin_t tf_ssb_broadcast_origin_t
void tf_ssb_unref(tf_ssb_t *ssb)
void tf_ssb_remove_rpc_callback(tf_ssb_t *ssb, const char **name, tf_ssb_rpc_callback_t *callback, void *user_data)
bool tf_ssb_connection_is_endpoint(tf_ssb_connection_t *connection)
void tf_ssb_set_trace(tf_ssb_t *ssb, tf_trace_t *trace)
tf_ssb_connection_t * tf_ssb_connection_tunnel_create(tf_ssb_t *ssb, const char *portal_id, int32_t request_number, const char *target_id, int connect_flags)
void tf_ssb_set_room_name(tf_ssb_t *ssb, const char *room_name)
_tf_ssb_connect_flags_t
Definition: ssb.h:82
int32_t tf_ssb_connection_get_ebt_request_number(tf_ssb_connection_t *connection)
void tf_ssb_connection_add_new_message_request(tf_ssb_connection_t *connection, const char *author, int32_t request_number, bool keys)
void tf_ssb_calculate_message_id(JSContext *context, JSValue message, char *out_id, size_t out_id_size)
enum _tf_ssb_connect_flags_t tf_ssb_connect_flags_t
void tf_ssb_set_is_room(tf_ssb_t *ssb, bool is_room)
void() tf_ssb_scheduled_callback_t(tf_ssb_connection_t *connection, bool skip, void *user_data)
Definition: ssb.h:864
bool tf_ssb_connection_get_id(tf_ssb_connection_t *connection, char *out_id, size_t out_id_size)
void tf_ssb_connection_set_attendant(tf_ssb_connection_t *connection, bool attendant, int request_number)
void tf_ssb_remove_broadcasts_changed_callback(tf_ssb_t *ssb, tf_ssb_broadcasts_changed_callback_t *callback, void *user_data)
void() tf_ssb_blob_want_added_callback_t(tf_ssb_t *ssb, const char *id, void *user_data)
Definition: ssb.h:721
void tf_ssb_connection_remove_room_attendant(tf_ssb_connection_t *connection, const char *id)
const char * tf_ssb_get_room_name(tf_ssb_t *ssb)
void tf_ssb_add_rpc_callback(tf_ssb_t *ssb, const char *name, tf_ssb_rpc_callback_t *callback, tf_ssb_callback_cleanup_t *cleanup, void *user_data)
int tf_ssb_server_open(tf_ssb_t *ssb, int port)
bool tf_ssb_is_replicator(tf_ssb_t *ssb)
enum _tf_ssb_change_t tf_ssb_change_t
void tf_ssb_release_db_writer(tf_ssb_t *ssb, sqlite3 *db)
void() tf_ssb_rpc_callback_t(tf_ssb_connection_t *connection, uint8_t flags, int32_t request_number, JSValue args, const uint8_t *message, size_t size, void *user_data)
Definition: ssb.h:757
@ k_tf_ssb_message_flag_sequence_before_author
Definition: ssb.h:75
function trace()
Definition: client.js:910
function message(event)
Definition: client.js:1458
Definition: ssb.h:144
int32_t request_number
Definition: ssb.h:146
int wants_sent
Definition: ssb.h:148
char last_id[k_blob_id_len]
Definition: ssb.h:150
Definition: ssb.h:114
int connections
Definition: ssb.h:116
struct _tf_ssb_stats_t::@3 callbacks
int rpc_in
Definition: ssb.h:124
int blobs_stored
Definition: ssb.h:122
int messages_stored
Definition: ssb.h:120
int rpc_out
Definition: ssb.h:126
int request_count
Definition: ssb.h:128
int broadcasts
Definition: ssb.h:118
Definition: ssb.h:157
void * tail
Definition: ssb.h:161
void * head
Definition: ssb.h:159
bool running
Definition: ssb.h:163