Make the SSB network key configurable by command-line argument.

This commit is contained in:
2024-03-02 15:01:09 -05:00
parent f0a871e1f8
commit 42994f8977
6 changed files with 88 additions and 62 deletions

View File

@ -166,7 +166,7 @@ static int _tf_command_import(const char* file, int argc, char* argv[])
return EXIT_FAILURE;
}
tf_ssb_t* ssb = tf_ssb_create(NULL, NULL, db_path);
tf_ssb_t* ssb = tf_ssb_create(NULL, NULL, db_path, NULL);
if (optind < argc)
{
for (int i = optind; i < argc; i++)
@ -232,7 +232,7 @@ static int _tf_command_export(const char* file, int argc, char* argv[])
return EXIT_FAILURE;
}
tf_ssb_t* ssb = tf_ssb_create(NULL, NULL, db_path);
tf_ssb_t* ssb = tf_ssb_create(NULL, NULL, db_path, NULL);
if (optind < argc)
{
for (int i = optind; i < argc; i++)
@ -270,6 +270,7 @@ static int _tf_command_export(const char* file, int argc, char* argv[])
typedef struct tf_run_args_t
{
const char* script;
const char* network_key;
int ssb_port;
int http_port;
int https_port;
@ -296,6 +297,7 @@ static int _tf_run_task(const tf_run_args_t* args, int index)
tf_task_set_trusted(task, true);
tf_printf("setting zip path to %s\n", args->zip);
tf_task_set_zip_path(task, args->zip);
tf_task_set_ssb_network_key(task, args->network_key);
tf_task_set_ssb_port(task, args->ssb_port ? args->ssb_port + index : 0);
tf_task_set_http_port(task, args->http_port ? args->http_port + index : 0);
tf_task_set_https_port(task, args->https_port ? args->https_port + index : 0);
@ -419,6 +421,7 @@ static int _tf_command_run(const char* file, int argc, char* argv[])
static const struct option k_options[] = {
{ "script", required_argument, NULL, 's' },
{ "ssb-port", required_argument, NULL, 'b' },
{ "ssb-network-key", required_argument, NULL, 'k' },
{ "http-port", required_argument, NULL, 'p' },
{ "https-port", required_argument, NULL, 'q' },
{ "db-path", required_argument, NULL, 'd' },
@ -429,7 +432,7 @@ static int _tf_command_run(const char* file, int argc, char* argv[])
{ "verbose", no_argument, NULL, 'v' },
{ "help", no_argument, NULL, 'h' },
};
int c = getopt_long(argc, argv, "s:b:p:q:d:n:a:oz:vh", k_options, NULL);
int c = getopt_long(argc, argv, "s:b:k:p:q:d:n:a:oz:vh", k_options, NULL);
if (c == -1)
{
break;
@ -445,6 +448,9 @@ static int _tf_command_run(const char* file, int argc, char* argv[])
case 's':
args.script = optarg;
break;
case 'k':
args.network_key = optarg;
break;
case 'b':
args.ssb_port = atoi(optarg);
break;