|
cwist
Modern C web framework with libttak runtime
|
Minimal TCP protocol for shipping encrypted SQLite snapshots between peers. More...
#include <cwist/net/db_sync/db_sync.h>#include <cwist/security/db_crypt/db_crypt.h>#include <sqlite3.h>#include <arpa/inet.h>#include <errno.h>#include <netdb.h>#include <inttypes.h>#include <stdint.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/socket.h>#include <sys/types.h>#include <unistd.h>
Go to the source code of this file.
Macros | |
| #define | _POSIX_C_SOURCE 200809L |
| #define | CWIST_DB_SYNC_MAX_BLOB_SIZE ((uint64_t)4 * 1024 * 1024 * 1024) |
Functions | |
| int | cwist_db_sync_serve (sqlite3 *db, const cwist_db_crypt_ctx_t *ctx, int port) |
| Serialize and encrypt a SQLite database, then serve it to one TCP client. | |
| int | cwist_db_sync_pull (const char *host, int port, const cwist_db_crypt_ctx_t *ctx, unsigned char **out_bytes, size_t *out_len) |
| Connect to a sync server, download the encrypted snapshot, and decrypt it. | |
Minimal TCP protocol for shipping encrypted SQLite snapshots between peers.
Definition in file db_sync.c.
| int cwist_db_sync_pull | ( | const char * | host, |
| int | port, | ||
| const cwist_db_crypt_ctx_t * | ctx, | ||
| unsigned char ** | out_bytes, | ||
| size_t * | out_len | ||
| ) |
Connect to a sync server, download the encrypted snapshot, and decrypt it.
Pull a database from a sync server.
| host | Remote host name or address to connect to. |
| port | Remote TCP port, or the default when <= 0. |
| ctx | Encryption context used to decrypt the transferred blob. |
| out_bytes | Output pointer that receives the decrypted SQLite image. |
| out_len | Output pointer that receives the decrypted byte count. |
Definition at line 163 of file db_sync.c.
References cap, cwist_db_crypt_open(), CWIST_DB_SYNC_DEFAULT_PORT, CWIST_DB_SYNC_ERR_ARGS, CWIST_DB_SYNC_ERR_CRYPTO, CWIST_DB_SYNC_ERR_MEM, CWIST_DB_SYNC_ERR_NET, CWIST_DB_SYNC_ERR_PROTO, CWIST_DB_SYNC_MAX_BLOB_SIZE, and CWIST_DB_SYNC_OK.
| int cwist_db_sync_serve | ( | sqlite3 * | db, |
| const cwist_db_crypt_ctx_t * | ctx, | ||
| int | port | ||
| ) |
Serialize and encrypt a SQLite database, then serve it to one TCP client.
Serve the database once: accept one connection, send the sealed blob, then close.
| db | SQLite connection whose main database should be transferred. |
| ctx | Encryption context used to seal the serialized bytes. |
| port | TCP port to listen on, or the default when <= 0. |
Definition at line 69 of file db_sync.c.
References cap, cwist_db_crypt_seal(), CWIST_DB_SYNC_DEFAULT_PORT, CWIST_DB_SYNC_ERR_ARGS, CWIST_DB_SYNC_ERR_CRYPTO, CWIST_DB_SYNC_ERR_MEM, CWIST_DB_SYNC_ERR_NET, CWIST_DB_SYNC_ERR_PROTO, and CWIST_DB_SYNC_OK.