ucentral: various updates and fixes

* Gateway and client are now talking jsonrpc on the wire.
* update the datamodel to the latest version.
* add github workflow
* add zero touch on-boarding

Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
John Crispin
2021-03-29 16:02:59 +02:00
parent 528a778e38
commit bc13ab4544
35 changed files with 408 additions and 91 deletions

View File

@@ -14,7 +14,9 @@ validate_rtty_section() {
'port:port' \
'ssl:bool:0' \
'token:maxlength(32)' \
'verbose:bool:0'
'verbose:bool:0' \
'enable:bool:0' \
'interval:uinteger:0'
}
start_rtty() {
@@ -27,6 +29,8 @@ start_rtty() {
return 1
}
[ $enable -eq 0 -a $interval -eq 0 ] && return 1
[ -n "$interface" ] && network_get_device ifname "$interface"
[ -z "$ifname" -a -z "$id" ] && {
@@ -50,7 +54,8 @@ start_rtty() {
[ "$ssl" = "1" ] && procd_append_param command -s
[ -n "$token" ] && procd_append_param command -t "$token"
[ "$verbose" = "1" ] && procd_append_param command -v
procd_set_param respawn
[ "$interval" -eq "0" ] || procd_append_param command -e $interval
[ "$interval" -eq "0" ] && procd_set_param respawn
procd_close_instance
}

View File

@@ -0,0 +1,68 @@
Index: rtty-7.1.4/src/main.c
===================================================================
--- rtty-7.1.4.orig/src/main.c
+++ rtty-7.1.4/src/main.c
@@ -37,6 +37,8 @@ enum {
LONG_OPT_HELP = 1
};
+static int force_exit;
+
static void signal_cb(struct ev_loop *loop, ev_signal *w, int revents)
{
if (w->signum == SIGINT) {
@@ -53,6 +55,7 @@ static struct option long_options[] = {
{"token", required_argument, NULL, 't'},
{"verbose", no_argument, NULL, 'v'},
{"version", no_argument, NULL, 'V'},
+ {"exit", required_argument, NULL, 'V'},
{"help", no_argument, NULL, LONG_OPT_HELP},
{0, 0, 0, 0}
};
@@ -79,10 +82,16 @@ static void usage(const char *prog)
exit(1);
}
+static void timeout_cb(EV_P_ ev_timer *w, int revents)
+{
+ exit(1);
+}
+
int main(int argc, char **argv)
{
struct ev_loop *loop = EV_DEFAULT;
struct ev_signal signal_watcher;
+ struct ev_timer timeout_watcher;
bool background = false;
bool verbose = false;
struct rtty rtty = {
@@ -95,7 +104,7 @@ int main(int argc, char **argv)
int c;
while (true) {
- c = getopt_long(argc, argv, "I:h:p:d:asDt:f:RS:vV", long_options, &option_index);
+ c = getopt_long(argc, argv, "I:h:p:d:asDt:f:RS:vVe:", long_options, &option_index);
if (c == -1)
break;
@@ -146,6 +155,9 @@ int main(int argc, char **argv)
case LONG_OPT_HELP:
usage(argv[0]);
break;
+ case 'e':
+ force_exit = atoi(optarg);
+ break;
default: /* '?' */
usage(argv[0]);
break;
@@ -167,6 +179,10 @@ int main(int argc, char **argv)
ev_signal_init(&signal_watcher, signal_cb, SIGINT);
ev_signal_start(loop, &signal_watcher);
+ if (force_exit) {
+ ev_timer_init(&timeout_watcher, timeout_cb, force_exit, 0.);
+ ev_timer_start(loop, &timeout_watcher);
+ }
if (rtty_start(&rtty) < 0)
return -1;

View File

@@ -1,65 +0,0 @@
Index: rtty-7.1.4/src/rtty.c
===================================================================
--- rtty-7.1.4.orig/src/rtty.c
+++ rtty-7.1.4/src/rtty.c
@@ -308,7 +308,8 @@ static void parse_msg(struct rtty *rtty)
case MSG_TYPE_LOGOUT:
tty_logout(rtty, buffer_pull_u8(rb));
- break;
+ exit(1);
+ break;
case MSG_TYPE_TERMDATA:
write_data_to_tty(rtty, buffer_pull_u8(rb), msglen - 1);
@@ -429,12 +430,12 @@ static void rtty_timer_cb(struct ev_loop
return;
}
- if (now - rtty->active > RTTY_HEARTBEAT_INTEVAL * 3 / 2) {
+/* if (now - rtty->active > RTTY_HEARTBEAT_INTEVAL * 3 / 2) {
log_err("Inactive too long time\n");
rtty_exit(rtty);
return;
}
-
+*/
if (now - rtty->last_heartbeat > RTTY_HEARTBEAT_INTEVAL - 1) {
rtty->last_heartbeat = now;
rtty_send_msg(rtty, MSG_TYPE_HEARTBEAT, NULL, 0);
Index: rtty-7.1.4/src/main.c
===================================================================
--- rtty-7.1.4.orig/src/main.c
+++ rtty-7.1.4/src/main.c
@@ -95,7 +95,7 @@ int main(int argc, char **argv)
int c;
while (true) {
- c = getopt_long(argc, argv, "I:h:p:d:asDt:f:RS:vV", long_options, &option_index);
+ c = getopt_long(argc, argv, "I:h:p:d:asDt:f:RS:vVT:", long_options, &option_index);
if (c == -1)
break;
@@ -109,6 +109,9 @@ int main(int argc, char **argv)
case 'p':
rtty.port = atoi(optarg);
break;
+ case 'T':
+ rtty.timeout = atoi(optarg);
+ break;
case 'd':
if (strlen(optarg) > 126) {
log_err("Description too long\n");
Index: rtty-7.1.4/src/rtty.h
===================================================================
--- rtty-7.1.4.orig/src/rtty.h
+++ rtty-7.1.4/src/rtty.h
@@ -79,6 +79,8 @@ struct rtty {
void *ssl; /* Context wrap of openssl, wolfssl and mbedtls */
struct tty *ttys[RTTY_MAX_TTY];
struct file_context file_context;
+ int timeout;
+ struct ev_timer kill_timer;
};
int rtty_start(struct rtty *rtty);