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,
22 k_ssb_rpc_flag_end_error = 0x4,
23 k_ssb_rpc_flag_stream = 0x8,
24 k_ssb_rpc_mask_message = 0xC,
26 k_ssb_rpc_mask_send = 0xf,
28 k_ssb_rpc_flag_new_request = 0x10,
30 k_ssb_blob_bytes_max = 5 * 1024 * 1024,
32 k_ssb_peer_exchange_expires_seconds = 60 * 60,
34 k_max_private_message_recipients = 8,
42 k_tf_ssb_verify_flag_debug = 1,
50 k_tf_ssb_change_create,
51 k_tf_ssb_change_connect,
52 k_tf_ssb_change_remove,
53 k_tf_ssb_change_update,
61 k_tf_ssb_broadcast_origin_discovery,
62 k_tf_ssb_broadcast_origin_room,
63 k_tf_ssb_broadcast_origin_peer_exchange,
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,
91typedef struct _tf_ssb_connection_t tf_ssb_connection_t;
93typedef struct _tf_ssb_ebt_t tf_ssb_ebt_t;
105 k_id_base64_len = 57,
133 int connections_changed;
136 int broadcasts_changed;
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),
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);
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);
841 void* user_data, tf_ssb_connection_t* dependent_connection);
883 void (*after_work_callback)(tf_ssb_connection_t* connection,
int result,
void* user_data),
void* user_data);
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);
1137bool tf_ssb_hmacsha256_verify(
const char* public_key,
const void* payload,
size_t payload_length,
const char* signature,
bool signature_is_urlb64);
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
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
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
void * tail
Definition: ssb.h:161
void * head
Definition: ssb.h:159
bool running
Definition: ssb.h:163