From 999198a8aad2bb4d321e727e4ef8ee1371c320e6 Mon Sep 17 00:00:00 2001 From: cel Date: Tue, 4 Sep 2018 01:35:10 -0400 Subject: [PATCH] Use key property from config --- sbotc.1 | 2 +- sbotc.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sbotc.1 b/sbotc.1 index 72f34b2..cf6acd9 100644 --- a/sbotc.1 +++ b/sbotc.1 @@ -79,7 +79,7 @@ secret-handshake protocol. .It Pa ~/.ssb/manifest.json A map of method names to method types. .It Pa ~/.ssb/config -JSON file containing host, port, and SHS cap key to use if the +JSON file containing key, host, port, and/or SHS cap key to use if the .Ar -s , .Ar -p or diff --git a/sbotc.c b/sbotc.c index 08e1c47..b770aca 100644 --- a/sbotc.c +++ b/sbotc.c @@ -823,9 +823,11 @@ int main(int argc, char *argv[]) { char config_buf[8192]; len = read_file(config_buf, sizeof(config_buf), "%s/config", app_dir); if (len > 0) { + ssize_t key_len = json_get_value(config_buf, "key", &key); ssize_t host_len = json_get_value(config_buf, "host", &host); ssize_t port_len = json_get_value(config_buf, "port", &port); ssize_t shs_cap_len = json_get_value(config_buf, "caps.shs", &shs_cap_key_str); + if (key_len >= 0) ((char *)key)[key_len] = '\0'; if (host_len >= 0) ((char *)host)[host_len] = '\0'; if (port_len >= 0) ((char *)port)[port_len] = '\0'; if (shs_cap_len >= 0) ((char *)shs_cap_key_str)[shs_cap_len] = '\0';