|
|
|
@ -24,6 +24,7 @@
|
|
|
|
|
#include <sys/select.h>
|
|
|
|
|
#include <sys/socket.h>
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
#include <sys/un.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
|
|
#include <sodium.h>
|
|
|
|
@ -96,7 +97,7 @@ static const unsigned char ssb_cap[] = {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void usage() {
|
|
|
|
|
fputs("usage: sbotc [-j] [-T] [-n] [-c <cap>] [-s <host>] [-p <port>] [-k <key>] [-K <keypair_seed>] \n"
|
|
|
|
|
fputs("usage: sbotc [-j] [-T] [-n] [-c <cap>] [-s <host>] [-p <port>] [-u <socket_path>] [-k <key>] [-K <keypair_seed>]\n"
|
|
|
|
|
" [-t <type>] <method> [<argument>...]\n", stderr);
|
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
}
|
|
|
|
@ -818,6 +819,7 @@ int main(int argc, char *argv[]) {
|
|
|
|
|
const char *port = "8008";
|
|
|
|
|
const char *typestr = NULL, *methodstr;
|
|
|
|
|
const char *shs_cap_key_str = NULL;
|
|
|
|
|
const char *socket_path = NULL;
|
|
|
|
|
size_t argument_len;
|
|
|
|
|
unsigned char private_key[64];
|
|
|
|
|
unsigned char public_key[32];
|
|
|
|
@ -830,6 +832,8 @@ int main(int argc, char *argv[]) {
|
|
|
|
|
ssize_t len;
|
|
|
|
|
bool test = false;
|
|
|
|
|
bool noauth = false;
|
|
|
|
|
bool host_arg = false;
|
|
|
|
|
bool port_arg = false;
|
|
|
|
|
bool shs_cap_key_str_arg = false;
|
|
|
|
|
|
|
|
|
|
get_app_dir(app_dir, sizeof(app_dir));
|
|
|
|
@ -854,10 +858,11 @@ int main(int argc, char *argv[]) {
|
|
|
|
|
case 'c': shs_cap_key_str = argv[++i]; shs_cap_key_str_arg = true; break;
|
|
|
|
|
case 'j': ptype = pkt_type_json; break;
|
|
|
|
|
case 'T': test = true; break;
|
|
|
|
|
case 's': host = argv[++i]; break;
|
|
|
|
|
case 's': host = argv[++i]; host_arg = true; break;
|
|
|
|
|
case 'k': key = argv[++i]; break;
|
|
|
|
|
case 'K': keypair_seed_str = argv[++i]; break;
|
|
|
|
|
case 'p': port = argv[++i]; break;
|
|
|
|
|
case 'p': port = argv[++i]; port_arg = true; break;
|
|
|
|
|
case 'u': socket_path = argv[++i]; break;
|
|
|
|
|
case 't': typestr = argv[++i]; break;
|
|
|
|
|
case 'n': noauth = true; break;
|
|
|
|
|
default: usage();
|
|
|
|
@ -928,6 +933,21 @@ int main(int argc, char *argv[]) {
|
|
|
|
|
infd = STDIN_FILENO;
|
|
|
|
|
outfd = STDOUT_FILENO;
|
|
|
|
|
s = -1;
|
|
|
|
|
|
|
|
|
|
} else if (socket_path) {
|
|
|
|
|
if (port_arg) errx(1, "-p port conflicts with -u socket_path");
|
|
|
|
|
if (host_arg) errx(1, "-s host conflicts with -u socket_path");
|
|
|
|
|
struct sockaddr_un name;
|
|
|
|
|
size_t path_len = strlen(socket_path);
|
|
|
|
|
if (path_len >= sizeof(name.sun_path)-1) errx(1, "socket path too long");
|
|
|
|
|
s = socket(AF_UNIX, SOCK_STREAM, 0);
|
|
|
|
|
if (s < 0) err(1, "socket");
|
|
|
|
|
memset(&name, 0, sizeof(struct sockaddr_un));
|
|
|
|
|
name.sun_family = AF_UNIX;
|
|
|
|
|
strncpy(name.sun_path, socket_path, sizeof(name.sun_path) - 1);
|
|
|
|
|
rc = connect(s, (const struct sockaddr *)&name, sizeof name);
|
|
|
|
|
if (rc < 0) err(1, "connect");
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
s = tcp_connect(host, port);
|
|
|
|
|
if (s < 0) err(1, "tcp_connect");
|
|
|
|
|