Tilde Friends
|
Classes | |
struct | _tf_ssb_stats_t |
struct | _tf_ssb_blob_wants_t |
struct | _tf_ssb_store_queue_t |
Typedefs | |
typedef enum _tf_ssb_verify_flags_t | tf_ssb_verify_flags_t |
typedef enum _tf_ssb_change_t | tf_ssb_change_t |
typedef enum _tf_ssb_broadcast_origin_t | tf_ssb_broadcast_origin_t |
typedef enum _tf_ssb_message_flags_t | tf_ssb_message_flags_t |
typedef enum _tf_ssb_connect_flags_t | tf_ssb_connect_flags_t |
typedef struct _tf_ssb_t | tf_ssb_t |
typedef struct _tf_ssb_connection_t | tf_ssb_connection_t |
typedef struct _tf_ssb_ebt_t | tf_ssb_ebt_t |
typedef struct _tf_trace_t | tf_trace_t |
typedef struct sqlite3 | sqlite3 |
typedef struct uv_loop_s | uv_loop_t |
typedef struct _tf_ssb_stats_t | tf_ssb_stats_t |
typedef struct _tf_ssb_blob_wants_t | tf_ssb_blob_wants_t |
typedef struct _tf_ssb_store_queue_t | tf_ssb_store_queue_t |
typedef void() | tf_ssb_connect_callback_t(tf_ssb_connection_t *connection, const char *reason, void *user_data) |
typedef void() | tf_ssb_verify_strip_store_callback_t(const char *id, bool verified, bool is_new, void *user_data) |
typedef void() | tf_ssb_callback_cleanup_t(tf_ssb_t *ssb, void *user_data) |
typedef void() | tf_ssb_connections_changed_callback_t(tf_ssb_t *ssb, tf_ssb_change_t change, tf_ssb_connection_t *connection, void *user_data) |
typedef void() | tf_ssb_broadcasts_changed_callback_t(tf_ssb_t *ssb, void *user_data) |
typedef void() | tf_ssb_message_added_callback_t(tf_ssb_t *ssb, const char *author, int32_t sequence, const char *id, void *user_data) |
typedef void() | tf_ssb_blob_stored_callback_t(tf_ssb_t *ssb, const char *id, void *user_data) |
typedef void() | tf_ssb_blob_want_added_callback_t(tf_ssb_t *ssb, const char *id, void *user_data) |
typedef 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) |
typedef void() | tf_ssb_scheduled_callback_t(tf_ssb_connection_t *connection, bool skip, void *user_data) |
Enumerations | |
enum | { k_ssb_rpc_flag_binary = 0x0 , k_ssb_rpc_flag_utf8 = 0x1 , k_ssb_rpc_flag_json = 0x2 , k_ssb_rpc_mask_type = 0x3 , k_ssb_rpc_flag_end_error = 0x4 , k_ssb_rpc_flag_stream = 0x8 , k_ssb_rpc_mask_message = 0xC , k_ssb_rpc_mask_send = 0xf , k_ssb_rpc_flag_new_request = 0x10 , k_ssb_blob_bytes_max = 5 * 1024 * 1024 , k_ssb_peer_exchange_expires_seconds = 60 * 60 , k_max_private_message_recipients = 8 } |
enum | _tf_ssb_verify_flags_t { k_tf_ssb_verify_flag_debug = 1 } |
enum | _tf_ssb_change_t { k_tf_ssb_change_create , k_tf_ssb_change_connect , k_tf_ssb_change_remove , k_tf_ssb_change_update } |
enum | _tf_ssb_broadcast_origin_t { k_tf_ssb_broadcast_origin_discovery , k_tf_ssb_broadcast_origin_room , k_tf_ssb_broadcast_origin_peer_exchange } |
enum | _tf_ssb_message_flags_t { k_tf_ssb_message_flag_sequence_before_author = 1 } |
enum | _tf_ssb_connect_flags_t { k_tf_ssb_connect_flag_one_shot = 0x1 , k_tf_ssb_connect_flag_do_not_store = 0x2 , k_tf_ssb_connect_flag_use_invite = 0x4 } |
enum | { k_id_base64_len = 57 , k_id_bin_len = 32 , k_blob_id_len = 53 } |
Everything about SSB, SHS, and MUXRPC happens here.
typedef void() tf_ssb_blob_stored_callback_t(tf_ssb_t *ssb, const char *id, void *user_data) |
A callback called when a blob is added to the database.
ssb | The SSB instance. |
id | The blob identifier. |
user_data | The user data. |
typedef void() tf_ssb_blob_want_added_callback_t(tf_ssb_t *ssb, const char *id, void *user_data) |
A callback called when a blob is newly requested.
ssb | The SSB instance. |
id | The blob identity. |
user_data | The user data. |
typedef struct _tf_ssb_blob_wants_t tf_ssb_blob_wants_t |
State about requesting blobs.
typedef enum _tf_ssb_broadcast_origin_t tf_ssb_broadcast_origin_t |
The origin of a broadcast entry.
typedef void() tf_ssb_broadcasts_changed_callback_t(tf_ssb_t *ssb, void *user_data) |
A callback called when a new broadcast is received or one expires.
ssb | The SSB instance. |
user_data | The user data. |
typedef void() tf_ssb_callback_cleanup_t(tf_ssb_t *ssb, void *user_data) |
A callback called when a callback is cleaned up.
ssb | The SSB instance. |
user_data | User data. |
typedef enum _tf_ssb_change_t tf_ssb_change_t |
The type of change to a set of connections.
typedef void() tf_ssb_connect_callback_t(tf_ssb_connection_t *connection, const char *reason, void *user_data) |
Callback for completing establishing a connection.
connection | The established connection if successful or null. |
reason | The reason for failure if the connection failed. |
user_data | User data. |
typedef enum _tf_ssb_connect_flags_t tf_ssb_connect_flags_t |
Flags affecting an SSB connection.
typedef struct _tf_ssb_connection_t tf_ssb_connection_t |
An SSB connection.
typedef void() tf_ssb_connections_changed_callback_t(tf_ssb_t *ssb, tf_ssb_change_t change, tf_ssb_connection_t *connection, void *user_data) |
A callback called when the connection list changes.
ssb | The SSB instance. |
change | The type of change. |
connection | The connection that changed. |
user_data | User data. |
typedef struct _tf_ssb_ebt_t tf_ssb_ebt_t |
A connection's EBT state.
typedef void() tf_ssb_message_added_callback_t(tf_ssb_t *ssb, const char *author, int32_t sequence, const char *id, void *user_data) |
A callback called when a message is added to the database.
ssb | The SSB instance. |
author | The author identity. |
sequence | The message sequence number. |
id | The message identifier. |
user_data | The user data. |
typedef enum _tf_ssb_message_flags_t tf_ssb_message_flags_t |
Flags describing the structure of a message.
typedef 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) |
A function called when a MUXRPC request is made.
connection | The SSB connection. |
flags | The RPC flags. |
request_number | The request number. |
args | Request arguments. |
message | The raw message data. |
size | The size of the raw message data. |
user_data | User data registered with the callback. |
typedef void() tf_ssb_scheduled_callback_t(tf_ssb_connection_t *connection, bool skip, void *user_data) |
A function scheduled to be run later.
connection | The owning connection. |
skip | Whether the work ought to be skipped, because it is being replaced. |
user_data | User data registered with the callback. |
typedef struct _tf_ssb_stats_t tf_ssb_stats_t |
Statistics about an SSB instance.
typedef struct _tf_ssb_store_queue_t tf_ssb_store_queue_t |
A queue for storing messages.
typedef struct _tf_ssb_t tf_ssb_t |
An SSB instance.
typedef enum _tf_ssb_verify_flags_t tf_ssb_verify_flags_t |
Flags affecting signature verification.
typedef void() tf_ssb_verify_strip_store_callback_t(const char *id, bool verified, bool is_new, void *user_data) |
A function called on completion of tf_ssb_verify_strip_and_store_message().
id | The stored message identifier. |
verified | True if the message was verified successfully. |
is_new | True if the message was newly added to the database. |
user_data | The user data. |
typedef struct _tf_trace_t tf_trace_t |
A trace instance.
typedef struct uv_loop_s uv_loop_t |
An event loop.
The origin of a broadcast entry.
enum _tf_ssb_change_t |
The type of change to a set of connections.
Flags affecting an SSB connection.
Flags affecting signature verification.
Acquire an SQLite database for unrestricted reading. Release qith tf_ssb_release_db_reader().
ssb | The SSB instance. |
Acquire an SQLite database for restricted reading. Release qith tf_ssb_release_db_reader().
ssb | The SSB instance. |
Acquire an SQLite database with full write access to the database. Release with tf_ssb_release_db_writer().
ssb | The SSB instance. |
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 | ||
) |
Register a callback called when a blob is added to the database.
ssb | The SSB instance. |
callback | The callback function. |
cleanup | A function to call when the callback is removed. |
user_data | User data to pass to the callback. |
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 | ||
) |
Register a function to be called when a blob is newly requested.
ssb | The SSB instance. |
callback | The callback. |
cleanup | A function to call when the callback is removed. |
user_data | User data to pass to the callback. |
void tf_ssb_add_broadcast | ( | tf_ssb_t * | ssb, |
const char * | connection, | ||
tf_ssb_broadcast_origin_t | origin, | ||
int64_t | expires_seconds | ||
) |
Add a broadcast entry.
ssb | The SSB instance. |
connection | The connection string to add. |
origin | The origin of the broadcast entry. |
expires_seconds | How long the broadcast entry should last. |
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 | ||
) |
Register a callback when broadcasts change.
ssb | The SSB instance. |
callback | The callback function. |
cleanup | A function to call when the callback is removed. |
user_data | User data to pass to the callback. |
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 | ||
) |
Register a callback when the connection list changes.
ssb | The SSB instance. |
callback | The callback to register. |
cleanup | The cleanup callback to register. |
user_data | User data to pass to the callbacks. |
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 | ||
) |
Register a callback called when a message is added to the database.
ssb | The SSB instance. |
callback | The callback function. |
cleanup | A function to call when the callback is removed. |
user_data | User data to pass to the callback. |
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 | ||
) |
Register a MUXRPC callback by name.
ssb | The SSB instance. |
name | The RPC name as a .-separated string. |
callback | The callback. |
cleanup | A function to be called when the callback is removed. |
user_data | User data to pass to the callback. |
void tf_ssb_broadcast_listener_start | ( | tf_ssb_t * | ssb, |
bool | linger | ||
) |
Begin listening for SSB discovery messages.
ssb | The SSB instance. |
linger | True if listening for broadcasts should keep the event loop alive. |
void tf_ssb_broadcast_sender_start | ( | tf_ssb_t * | ssb | ) |
Begin sending SSB discovevry messages.
ssb | The SSB instance. |
void tf_ssb_calculate_message_id | ( | JSContext * | context, |
JSValue | message, | ||
char * | out_id, | ||
size_t | out_id_size | ||
) |
Determine the message identifier.
context | A JS context. | |
message | The message. | |
[out] | out_id | A buffer to receive the identifier. |
out_id_size | The size of out_id. |
void tf_ssb_close_all | ( | tf_ssb_t * | ssb, |
const char * | reason | ||
) |
Close all active SHS connections.
ssb | The SSB instance. |
reason | Reason for the close. |
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 | ||
) |
Establish an SHS connection with a host.
ssb | The SSB instance. |
host | The host name or address. |
port | The host's SHS port. |
key | The host's SSB identity. |
connect_flags | Flags affecting the connection. |
callback | Completion callback. |
user_data | User data to be passed to the callback. |
void tf_ssb_connect_str | ( | tf_ssb_t * | ssb, |
const char * | address, | ||
int | connect_flags, | ||
tf_ssb_connect_callback_t * | callback, | ||
void * | user_data | ||
) |
Establish an SHS connection with a host by string address.
ssb | The SSB instance. |
address | The address. |
connect_flags | Flags affecting the connection. |
callback | Completion callback. |
user_data | User data to be passed to the callback. |
void tf_ssb_connection_add_new_message_request | ( | tf_ssb_connection_t * | connection, |
const char * | author, | ||
int32_t | request_number, | ||
bool | keys | ||
) |
Register for new messages on a connection.
connection | The SHS connection. |
author | The author for whom to request new messages. |
request_number | The MUXRPC request on which to send new messages. |
keys | Whether to send with keys. |
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 | ||
) |
Register a callback to be called when a message is received for the given request number.
connection | The connection on which to register the callback. |
request_number | The request number. |
name | The name of the RPC request. |
callback | The callback. |
cleanup | The function to call when the callback is removed. |
user_data | User data to pass to the callback. |
dependent_connection | A connection, which, if removed, invalidates this request. |
void tf_ssb_connection_add_room_attendant | ( | tf_ssb_connection_t * | connection, |
const char * | id | ||
) |
Add a room attendant.
connection | The SHS connection. |
id | The attendant identifier. |
void tf_ssb_connection_adjust_read_backpressure | ( | tf_ssb_connection_t * | connection, |
int | delta | ||
) |
Adjust read backpressure. If it gets too high, TCP receive will be paused until it lowers.
connection | The connection on which to affect backpressure. |
delta | The change in backpressure. Higher will eventually pause receive. Lower will resume it. |
void tf_ssb_connection_adjust_write_count | ( | tf_ssb_connection_t * | connection, |
int | delta | ||
) |
Adjust write count. Work scheduled by tf_ssb_connection_schedule_idle will only start when this reaches zero.
connection | The connection on which to affect backpressure. |
delta | The change in write count. Higher will pause processing scheduled idle work queue. Lower will resume it. |
void tf_ssb_connection_clear_room_attendants | ( | tf_ssb_connection_t * | connection | ) |
Clear all attendants from a room.
connection | The SHS connection. |
void tf_ssb_connection_close | ( | tf_ssb_connection_t * | connection, |
const char * | reason | ||
) |
Close a connection.
connection | The connection. |
reason | Human-readable reason for closing the connection. |
tf_ssb_connection_t * tf_ssb_connection_get | ( | tf_ssb_t * | ssb, |
const char * | id | ||
) |
Get an active connection by its identity.
ssb | The SSB instance. |
id | The SSB identity. |
int32_t tf_ssb_connection_get_attendant_request_number | ( | tf_ssb_connection_t * | connection | ) |
Get the request number used to notify of room attendant changes.
connection | the SHS connection. |
tf_ssb_blob_wants_t * tf_ssb_connection_get_blob_wants_state | ( | tf_ssb_connection_t * | connection | ) |
Get information about requested blobs.
connection | An SHS connection. |
JSContext * tf_ssb_connection_get_context | ( | tf_ssb_connection_t * | connection | ) |
Get a connection's JS context.
connection | The connection. |
const char * tf_ssb_connection_get_destroy_reason | ( | tf_ssb_connection_t * | connection | ) |
Get the reason why a connection is going away.
connection | The connection. |
tf_ssb_ebt_t * tf_ssb_connection_get_ebt | ( | tf_ssb_connection_t * | connection | ) |
Get a connection's EBT state.
connection | The connection. |
int32_t tf_ssb_connection_get_ebt_request_number | ( | tf_ssb_connection_t * | connection | ) |
Get the request number on which to send EBT responses.
connection | The SHS connection. |
int32_t tf_ssb_connection_get_endpoint_request_number | ( | tf_ssb_connection_t * | connection | ) |
Get the request number used to notify of tunnel endpoint changes.
connection | the SHS connection. |
int tf_ssb_connection_get_flags | ( | tf_ssb_connection_t * | connection | ) |
Get a connection's flags.
connection | The connection. |
const char * tf_ssb_connection_get_host | ( | tf_ssb_connection_t * | connection | ) |
Get the hostname of the remote end of a connection.
connection | The connection. |
bool tf_ssb_connection_get_id | ( | tf_ssb_connection_t * | connection, |
char * | out_id, | ||
size_t | out_id_size | ||
) |
Get the SSB identity of a connection.
connection | The connection. | |
[out] | out_id | A buffer to be populated with the identity. |
out_id_size | The size of out_id. |
JSValue tf_ssb_connection_get_object | ( | tf_ssb_connection_t * | connection | ) |
Get the JS object representing a connection.
connection | The connection. |
int tf_ssb_connection_get_port | ( | tf_ssb_connection_t * | connection | ) |
Get a connection's remote port number.
connection | The connection. |
tf_ssb_t * tf_ssb_connection_get_ssb | ( | tf_ssb_connection_t * | connection | ) |
Get a connection's SSB instance.
connection | The connection. |
tf_ssb_connection_t * tf_ssb_connection_get_tunnel | ( | tf_ssb_connection_t * | connection | ) |
If a connection is a tunnel, get its parent connection.
connection | The connection. |
bool tf_ssb_connection_is_attendant | ( | tf_ssb_connection_t * | connection | ) |
Get whether we are an attendant on a room connection.
connection | The SHS connection. |
bool tf_ssb_connection_is_client | ( | tf_ssb_connection_t * | connection | ) |
Check if a connection is an outgoing connection.
connection | The connection. |
bool tf_ssb_connection_is_closing | ( | tf_ssb_connection_t * | connection | ) |
Check whether a connection is in the process of closing.
connection | The connection. |
bool tf_ssb_connection_is_connected | ( | tf_ssb_connection_t * | connection | ) |
Check whether a connection is connected.
connection | The connection. |
bool tf_ssb_connection_is_endpoint | ( | tf_ssb_connection_t * | connection | ) |
Get whether we are a potential tunnel endpoint.
connection | The SHS connection. |
int32_t tf_ssb_connection_next_request_number | ( | tf_ssb_connection_t * | connection | ) |
Get the next outgoing request number for a connection.
connection | The connection. |
void tf_ssb_connection_remove_new_message_request | ( | tf_ssb_connection_t * | connection, |
const char * | author | ||
) |
Remove a request for new messages on a connection.
connection | the SHS connection. |
author | The author for whom to no longer request new messages. |
void tf_ssb_connection_remove_request | ( | tf_ssb_connection_t * | connection, |
int32_t | request_number | ||
) |
Remove a callback registered to be called when a message is received for the given request number.
connection | The connection. |
request_number | The request number. |
void tf_ssb_connection_remove_room_attendant | ( | tf_ssb_connection_t * | connection, |
const char * | id | ||
) |
Remove a room attendant.
connection | The SHS connection. |
id | The attendanr identifier. |
JSValue tf_ssb_connection_requests_to_object | ( | tf_ssb_connection_t * | connection | ) |
Get a debug representation of active requests.
connection | The connection. |
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 | ||
) |
Send a MUXRPC message.
connection | The connection on which to send the message. |
flags | The message flags. |
request_number | The request number. |
new_request_name | The name of the request if it is new. |
message | The message payload. |
size | The size of the message. |
callback | A callback to call if a response is received. |
cleanup | A callback to call if the callback is removed. |
user_data | User data to pass to the callback. |
bool tf_ssb_connection_rpc_send_error | ( | tf_ssb_connection_t * | connection, |
uint8_t | flags, | ||
int32_t | request_number, | ||
const char * | error | ||
) |
Send a MUXRPC error message.
connection | The connection on which to send the message. |
flags | The message flags. |
request_number | The request number. |
error | The error string. |
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 | ||
) |
Send a MUXRPC "method not allowed" error message.
connection | The connection on which to send the message. |
flags | The message flags. |
request_number | The request number. |
name | The name of the not-allowed method. |
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 | ||
) |
Send a JSON MUXRPC message.
connection | The connection on which to send the message. |
flags | The message flags. |
request_number | The request number. |
new_request_name | The name of the request if it is new. |
message | The JS message payload. |
callback | A callback to call if a response is received. |
cleanup | A callback to call if the callback is removed. |
user_data | User data to pass to the callback. |
void tf_ssb_connection_run_work | ( | tf_ssb_connection_t * | connection, |
void(*)(tf_ssb_connection_t *connection, void *user_data) | work_callback, | ||
void(*)(tf_ssb_connection_t *connection, int result, void *user_data) | after_work_callback, | ||
void * | user_data | ||
) |
Schedule work to run on a worker thread.
connection | The owning connection. |
work_callback | The callback to run on a thread. |
after_work_callback | The callback to run on the main thread when the work is complete. |
user_data | User data to pass to the callback. |
void tf_ssb_connection_schedule_idle | ( | tf_ssb_connection_t * | connection, |
const char * | key, | ||
tf_ssb_scheduled_callback_t * | callback, | ||
void * | user_data | ||
) |
Schedule work to be run when the connection is next idle.
connection | The owning connection. |
key | A key identifying the work. If work by the same key already exists, the new request will be discarded. |
callback | The callback to call. |
user_data | User data to pass to the callback. |
void tf_ssb_connection_set_attendant | ( | tf_ssb_connection_t * | connection, |
bool | attendant, | ||
int | request_number | ||
) |
Register for attendant change notifications on a connection.
connection | The SHS connection. |
attendant | Whether this connection will be an attendant. |
request_number | The request number on which to send attendant changes. |
void tf_ssb_connection_set_ebt_request_number | ( | tf_ssb_connection_t * | connection, |
int32_t | request_number | ||
) |
Set the request number on which to send EBT responses.
connection | The SHS connection. |
request_number | The request number. |
void tf_ssb_connection_set_endpoint | ( | tf_ssb_connection_t * | connection, |
bool | endpoint, | ||
int | request_number | ||
) |
Register for endpoint change notifications on a connection.
connection | The SHS connection. |
endpoint | Whether this connection will be an endpoint. |
request_number | The request number on which to send endpoint changes. |
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 | ||
) |
Create a tunnel.
ssb | The SSB instance. |
portal_id | The identity of the tunnel intermediary. |
request_number | The tunnel request. |
target_id | The identity being tunneled to. |
connect_flags | Flags affecting the connection. |
tf_ssb_t * tf_ssb_create | ( | uv_loop_t * | loop, |
JSContext * | context, | ||
const char * | db_path, | ||
const char * | network_key | ||
) |
Create an SSB instance.
loop | The event loop to use or NULL to create a new one. |
context | The JS context to use or NULL to create a new one. |
db_path | The path to the SQLite database to use. |
network_key | The SSB network key to use or NULL to use the standard key. |
void tf_ssb_destroy | ( | tf_ssb_t * | ssb | ) |
Destroy an SSB instance.
ssb | The SSB instance to destroy. |
void tf_ssb_generate_keys | ( | tf_ssb_t * | ssb | ) |
Generate a public/private key pair for the SSB instance.
ssb | The SSB instance. |
void tf_ssb_generate_keys_buffer | ( | char * | out_public, |
size_t | public_size, | ||
char * | out_private, | ||
size_t | private_size | ||
) |
Generate a public/private key pair and store in buffers.
[out] | out_public | Buffer to receive the public key. |
public_size | Size of the public key buffer. | |
[out] | out_private | Buffer to receive the private key. |
private_size | Size of the private key buffer. |
float tf_ssb_get_average_thread_percent | ( | tf_ssb_t * | ssb | ) |
Get an estimate of utilization of all running threads.
ssb | The SSB instance. |
JSClassID tf_ssb_get_connection_class_id | ( | ) |
Get the JS class ID of the SSB connection class.
const char ** tf_ssb_get_connection_ids | ( | tf_ssb_t * | ssb | ) |
Get the identities of all active connections.
ssb | The SSB instance. |
int tf_ssb_get_connections | ( | tf_ssb_t * | ssb, |
tf_ssb_connection_t ** | out_connections, | ||
int | out_connections_count | ||
) |
Retrieve a list of active connections.
ssb | The SSB instance. | |
[out] | out_connections | An array to be populated with the connections. |
out_connections_count | The size of the connections array. |
Get the SSB istance's JS context.
ssb | The SSB instance. |
Get the SSB instance's event loop.
ssb | The SSB instance. |
void tf_ssb_get_private_key | ( | tf_ssb_t * | ssb, |
uint8_t * | out_private, | ||
size_t | private_size | ||
) |
Get the private key of the SSB instance.
ssb | The SSB instance. | |
[out] | out_private | Buffer to receive the private key. |
private_size | The size of the private key buffer. |
const char * tf_ssb_get_room_name | ( | tf_ssb_t * | ssb | ) |
Get the name of the room hosted by the running server.
ssb | The SSB instance. |
void tf_ssb_get_stats | ( | tf_ssb_t * | ssb, |
tf_ssb_stats_t * | out_stats | ||
) |
Get general statistics about an SSB instance.
ssb | The SSB instance. | |
[out] | out_stats | Populated with performance statistics. |
tf_ssb_store_queue_t * tf_ssb_get_store_queue | ( | tf_ssb_t * | ssb | ) |
Get the queue of messages in the progress of being stored.
ssb | The SSB instance. |
tf_trace_t * tf_ssb_get_trace | ( | tf_ssb_t * | ssb | ) |
Get the SSB instance's trace instance.
ssb | The SSB instance. |
bool tf_ssb_hmacsha256_verify | ( | const char * | public_key, |
const void * | payload, | ||
size_t | payload_length, | ||
const char * | signature, | ||
bool | signature_is_urlb64 | ||
) |
Verify a signature.
public_key | The public key for which the message was signed. |
payload | The signed payload. |
payload_length | The length of the signed payload in bytes. |
signature | The signature. |
signature_is_urlb64 | True if the signature is in URL base64 format, otherwise standard base64. |
bool tf_ssb_id_bin_to_str | ( | char * | str, |
size_t | str_size, | ||
const uint8_t * | bin | ||
) |
Convert an SSB identity from binary to string.
[out] | str | A buffer to receive the identity string. |
str_size | The size of the string buffer. | |
bin | The binary identity. |
bool tf_ssb_id_str_to_bin | ( | uint8_t * | bin, |
const char * | str | ||
) |
Convert an SSB identity from string to binary.
[out] | bin | A buffer to receive the binary identity. |
str | The string identity. |
bool tf_ssb_is_peer_exchange | ( | tf_ssb_t * | ssb | ) |
Get whether the running server participates in peer exchange.
ssb | The SSB instance. |
bool tf_ssb_is_replicator | ( | tf_ssb_t * | ssb | ) |
Get whether the running server supports replication of messages and blobs.
ssb | The SSB instance. |
bool tf_ssb_is_room | ( | tf_ssb_t * | ssb | ) |
Get whether the running server is operating a room.
ssb | The SSB instance. |
bool tf_ssb_is_shutting_down | ( | tf_ssb_t * | ssb | ) |
Checking if the SSB instance is in the process of shutting down.
ssb | The SSB instance. |
void tf_ssb_notify_blob_stored | ( | tf_ssb_t * | ssb, |
const char * | id | ||
) |
Record that a new blob was stored.
ssb | The SSB instance. |
id | The identity of the newly stored blob. |
void tf_ssb_notify_blob_want_added | ( | tf_ssb_t * | ssb, |
const char * | id | ||
) |
Call all callbacks registered for when a blob is newly requested.
ssb | The SSB instance. |
id | The requested blob identity. |
void tf_ssb_notify_message_added | ( | tf_ssb_t * | ssb, |
const char * | author, | ||
int32_t | sequence, | ||
const char * | id, | ||
JSValue | message_with_keys | ||
) |
Call all callbacks registered for when a message is added to the database.
ssb | The SSB instance. |
author | The message author's identity. |
sequence | The message sequence number. |
id | The message identity added. |
message_with_keys | The message added in the format required if keys are requested. |
char * tf_ssb_private_message_encrypt | ( | uint8_t * | private_key, |
const char ** | recipients, | ||
int | recipients_count, | ||
const char * | message, | ||
size_t | message_size | ||
) |
Encrypt a private message to a set of recipients.
private_key | The private key of the author. |
recipients | A list of recipient identities. |
recipients_count | The number of recipients in recipients. |
message | The plain text to post. |
message_size | The length in bytes of message. |
void tf_ssb_record_thread_busy | ( | tf_ssb_t * | ssb, |
bool | busy | ||
) |
Record whether the calling thread is busy.
ssb | The SSB instance. |
busy | True if the calling thread is now busy. |
void tf_ssb_ref | ( | tf_ssb_t * | ssb | ) |
Increment the SSB instance's ref count. Prevents it from being destroyed until it reaches zero.
ssb | The SSB instance. |
Release a database acquired with tf_ssb_acquire_db_reader() or tf_ssb_acquire_db_reader_restricted().
ssb | The SSB instance. |
db | The database. |
Release a database acquired with tf_ssb_acquire_db_writer().
ssb | The SSB instance. |
db | The database. |
void tf_ssb_remove_blob_stored_callback | ( | tf_ssb_t * | ssb, |
tf_ssb_blob_stored_callback_t * | callback, | ||
void * | user_data | ||
) |
Remove a callback registered for when a blob is added to the database.
ssb | The SSB instance. |
callback | The callback function. |
user_data | User data registered with the callback. |
void tf_ssb_remove_blob_want_added_callback | ( | tf_ssb_t * | ssb, |
tf_ssb_blob_want_added_callback_t * | callback, | ||
void * | user_data | ||
) |
Remove a callback registered for when a blob is newly requested.
ssb | The SSB instance. |
callback | The callback to remove. |
user_data | The user data registered with the callback. |
void tf_ssb_remove_broadcasts_changed_callback | ( | tf_ssb_t * | ssb, |
tf_ssb_broadcasts_changed_callback_t * | callback, | ||
void * | user_data | ||
) |
Remove a callback registered for when broadcasts changed.
ssb | The SSB instance. |
callback | The callback function. |
user_data | The user data registered with the callback. |
void tf_ssb_remove_connections_changed_callback | ( | tf_ssb_t * | ssb, |
tf_ssb_connections_changed_callback_t * | callback, | ||
void * | user_data | ||
) |
Remove a callback when the connection list changes.
ssb | The SSB instance. |
callback | The callback. |
user_data | The user data registered with the callback. |
void tf_ssb_remove_message_added_callback | ( | tf_ssb_t * | ssb, |
tf_ssb_message_added_callback_t * | callback, | ||
void * | user_data | ||
) |
Remove a callback registered for when a message is added to the database.
ssb | The SSB instance. |
callback | The callback function. |
user_data | User data registered with the callback. |
void tf_ssb_remove_rpc_callback | ( | tf_ssb_t * | ssb, |
const char ** | name, | ||
tf_ssb_rpc_callback_t * | callback, | ||
void * | user_data | ||
) |
Remove a MUXRPC callback.
ssb | The SSB instance. |
name | The NULL-terminated name. |
callback | The callback to remove. |
user_data | The user data registered with the callback. |
void tf_ssb_run | ( | tf_ssb_t * | ssb | ) |
Run the SSB instance until there is no work to do or stopped.
ssb | The SSB instance. |
void tf_ssb_run_work | ( | tf_ssb_t * | ssb, |
void(*)(tf_ssb_t *ssb, void *user_data) | work_callback, | ||
void(*)(tf_ssb_t *ssb, int result, void *user_data) | after_work_callback, | ||
void * | user_data | ||
) |
Schedule work to run on a worker thread.
ssb | The owning SSB instance. |
work_callback | The callback to run on a thread. |
after_work_callback | The callback to run on the main thread when the work is complete. |
user_data | User data to pass to the callback. |
void tf_ssb_schedule_work | ( | tf_ssb_t * | ssb, |
int | delay_ms, | ||
void(*)(tf_ssb_t *ssb, void *user_data) | callback, | ||
void * | user_data | ||
) |
Schedule work to be run after a time delay.
ssb | The SSB instance. |
delay_ms | The duration to wait in milliseconds. |
callback | The callback to call to run the work. |
user_data | User data to pass to the callback. |
void tf_ssb_send_close | ( | tf_ssb_t * | ssb | ) |
Send a graceful close message to all active SHS connections.
ssb | The SSB instance. |
void tf_ssb_server_close | ( | tf_ssb_t * | ssb | ) |
Stop listening for SHS connections.
ssb | The SSB instance. |
int tf_ssb_server_get_port | ( | tf_ssb_t * | ssb | ) |
Determine the port that a server is listening on.
ssb | The SSB instance. |
int tf_ssb_server_open | ( | tf_ssb_t * | ssb, |
int | port | ||
) |
Begin listening for SHS connections on the given port.
ssb | The SSB instance. |
port | The port number. |
void tf_ssb_set_is_peer_exchange | ( | tf_ssb_t * | ssb, |
bool | is_peer_exchange | ||
) |
Set whether the running server participates in peer exchange.
ssb | The SSB instance. |
is_peer_exchange | Whether to participate in peer exchange. |
void tf_ssb_set_is_replicator | ( | tf_ssb_t * | ssb, |
bool | is_replicator | ||
) |
Set whether the running server supports replication of messages and blobs.
ssb | The SSB instance. |
is_replicator | Whether to support replication. |
void tf_ssb_set_is_room | ( | tf_ssb_t * | ssb, |
bool | is_room | ||
) |
Set whether the running server is operating a room.
ssb | The SSB instance. |
is_room | Whether to run a room. |
void tf_ssb_set_main_thread | ( | tf_ssb_t * | ssb, |
bool | main_thread | ||
) |
Record whether the calling thread is the main thread or not. Some operations are disallowed on the main thread for performance.
ssb | The SSB instance. |
main_thread | Whether the calling thread is the main thread. |
void tf_ssb_set_quiet | ( | tf_ssb_t * | ssb, |
bool | quiet | ||
) |
Reduce logging verbosity.
ssb | The SSB instance. |
quiet | Disable unnecessary messages. |
void tf_ssb_set_room_name | ( | tf_ssb_t * | ssb, |
const char * | room_name | ||
) |
Set the name of the room hosted by the running server.
ssb | The SSB instance. |
room_name | The name of the room. |
void tf_ssb_set_trace | ( | tf_ssb_t * | ssb, |
tf_trace_t * | trace | ||
) |
Set the trace instance to use for the SSB instance.
ssb | The SSB instance. |
trace | The trace instance to use. |
void tf_ssb_set_verbose | ( | tf_ssb_t * | ssb, |
bool | verbose | ||
) |
Control logging verbosity.
ssb | The SSB instance. |
verbose | True to log messages for every RPC message sent and received. |
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 | ||
) |
Sign an SSB message.
ssb | The SSB instance. |
author | The author's public key. |
private_key | The author's private key. |
message | The message to sign. |
previous_id | The ID of the previous message in the feed. Optional. |
previous_sequence | The sequence number of the previous message in the feed. Optional. |
void tf_ssb_start_periodic | ( | tf_ssb_t * | ssb | ) |
Start optional periodic work.
ssb | The SSB instance. |
void tf_ssb_sync_start | ( | tf_ssb_t * | ssb | ) |
Initiate a one time sync operation.
ssb | The SSB instance. |
bool tf_ssb_tunnel_create | ( | tf_ssb_t * | ssb, |
const char * | portal_id, | ||
const char * | target_id, | ||
int | connect_flags | ||
) |
Initiate a tunnel connection.
ssb | The SSB instance. |
portal_id | The public key of the instance through which to tunnel. |
target_id | The public key of the instance with which to establish a connection. |
connect_flags | Flags affecting the connection. |
void tf_ssb_unref | ( | tf_ssb_t * | ssb | ) |
Decrement the SSB instance's ref count. May destroy the instance when the count returns to zero.
ssb | The SSB instance. |
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 | ||
) |
Verify a message's signature and remove the signature if successful.
context | A JS context. | |
val | The message. | |
verify_flags | Verification options of type tf_ssb_verify_flags_t. | |
[out] | out_id | A buffer to receive the message's identity. |
out_id_size | The size of out_id. | |
[out] | out_signature | A buffer to receive the message's signature. |
out_signature_size | The size of out_signature. | |
[out] | out_flags | tf_ssb_message_flags_t describing the message. |
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 | ||
) |
Verify a message's signature, remove the signature, and store the message in the database.
ssb | The SSB instance. |
value | The message. |
callback | A callback called when the operation completed. |
user_data | User data to pass to the callback. |
void tf_ssb_visit_broadcasts | ( | tf_ssb_t * | ssb, |
void(*)(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) | callback, | ||
void * | user_data | ||
) |
Call a callback for each active host discovered by network discovery broadcast.
ssb | The SSB instance. |
callback | The callback. |
user_data | User data for the callback. |
bool tf_ssb_whoami | ( | tf_ssb_t * | ssb, |
char * | out_id, | ||
size_t | out_id_size | ||
) |
Get the server's identity.
ssb | The SSB instance. | |
[out] | out_id | A buffer populated with the identity. |
out_id_size | The size of the identity buffer. |