forked from cory/tildefriends
No more secrets in ~/.config, and speed up some tests.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4002 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
14
src/main.c
14
src/main.c
@ -213,7 +213,7 @@ static int _tf_command_import(const char* file, int argc, char* argv[])
|
||||
{
|
||||
sqlite3_open(args.db_path, &db);
|
||||
}
|
||||
tf_ssb_t* ssb = tf_ssb_create(NULL, NULL, db, NULL);
|
||||
tf_ssb_t* ssb = tf_ssb_create(NULL, NULL, db);
|
||||
if (extra_count)
|
||||
{
|
||||
for (int i = 0; i < extra_count; i++)
|
||||
@ -280,7 +280,7 @@ static int _tf_command_export(const char* file, int argc, char* argv[])
|
||||
{
|
||||
sqlite3_open(args.db_path, &db);
|
||||
}
|
||||
tf_ssb_t* ssb = tf_ssb_create(NULL, NULL, db, NULL);
|
||||
tf_ssb_t* ssb = tf_ssb_create(NULL, NULL, db);
|
||||
if (extra_count)
|
||||
{
|
||||
for (int i = 0; i < extra_count; i++)
|
||||
@ -333,7 +333,6 @@ typedef struct tf_run_args_t {
|
||||
int http_port;
|
||||
int https_port;
|
||||
const char* db_path;
|
||||
const char* secrets_path;
|
||||
int count;
|
||||
const char* args;
|
||||
bool help;
|
||||
@ -356,18 +355,13 @@ static int _tf_run_task(const tf_run_args_t* args, int index)
|
||||
tf_task_set_https_port(task, args->https_port ? args->https_port + index : 0);
|
||||
tf_task_set_args(task, args->args);
|
||||
const char* db_path = args->db_path;
|
||||
const char* secrets_path = args->secrets_path;
|
||||
char db_path_buffer[256];
|
||||
char secrets_path_buffer[256];
|
||||
if (index)
|
||||
{
|
||||
snprintf(db_path_buffer, sizeof(db_path_buffer), "%s.%d", args->db_path, index);
|
||||
db_path = db_path_buffer;
|
||||
snprintf(secrets_path_buffer, sizeof(secrets_path_buffer), "%s.%d", args->secrets_path, index);
|
||||
secrets_path = secrets_path_buffer;
|
||||
}
|
||||
tf_task_set_db_path(task, db_path);
|
||||
tf_task_set_secrets_path(task, secrets_path);
|
||||
tf_task_activate(task);
|
||||
if (args->ssb_port)
|
||||
{
|
||||
@ -396,7 +390,6 @@ static int _tf_command_run(const char* file, int argc, char* argv[])
|
||||
{ "http-port", 'p', offsetof(tf_run_args_t, http_port), NULL, XOPT_TYPE_INT, NULL, "Port on which to run Tilde Friends web server (default: 12345)." },
|
||||
{ "https-port", 'q', offsetof(tf_run_args_t, https_port), NULL, XOPT_TYPE_INT, NULL, "Port on which to run secure Tilde Friends web server (default: 12346)." },
|
||||
{ "db-path", 'd', offsetof(tf_run_args_t, db_path), NULL, XOPT_TYPE_STRING, NULL, "Sqlite database path (default: db.sqlite)." },
|
||||
{ "secrets-path", 'i', offsetof(tf_run_args_t, secrets_path), NULL, XOPT_TYPE_STRING, NULL, "Secrets/identity path." },
|
||||
{ "count", 'n', offsetof(tf_run_args_t, count), NULL, XOPT_TYPE_INT, NULL, "Number of instances to run." },
|
||||
{ "args", 'a', offsetof(tf_run_args_t, args), NULL, XOPT_TYPE_STRING, NULL, "Arguments of the form key=value,foo=bar,verbose=true." },
|
||||
{ "help", 'h', offsetof(tf_run_args_t, help), NULL, XOPT_TYPE_BOOL, NULL, "Shows this help message." },
|
||||
@ -411,7 +404,6 @@ static int _tf_command_run(const char* file, int argc, char* argv[])
|
||||
.https_port = 12346,
|
||||
.ssb_port = 8009,
|
||||
.db_path = "db.sqlite",
|
||||
.secrets_path = "/.config/tildefriends/secret",
|
||||
};
|
||||
const char** extras = NULL;
|
||||
int extra_count = 0;
|
||||
@ -555,7 +547,7 @@ static int _tf_command_post(const char* file, int argc, char* argv[])
|
||||
return 2;
|
||||
}
|
||||
|
||||
tf_ssb_t* ssb = tf_ssb_create(NULL, NULL, NULL, NULL);
|
||||
tf_ssb_t* ssb = tf_ssb_create(NULL, NULL, NULL);
|
||||
tf_ssb_broadcast_listener_start(ssb, false);
|
||||
tf_ssb_append_post(ssb, args.message);
|
||||
tf_ssb_destroy(ssb);
|
||||
|
Reference in New Issue
Block a user