Remove old sync command
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
This commit is contained in:
@@ -24,7 +24,6 @@ glorytun_SOURCES = \
|
||||
src/set.c \
|
||||
src/show.c \
|
||||
src/str.h \
|
||||
src/sync.c \
|
||||
src/tun.c \
|
||||
src/tun.h
|
||||
|
||||
|
||||
@@ -81,7 +81,6 @@ available commands:
|
||||
bench start a crypto bench
|
||||
bind start a new tunnel
|
||||
set change tunnel properties
|
||||
sync re-sync tunnels
|
||||
keygen generate a new secret key
|
||||
path manage paths
|
||||
version show version
|
||||
|
||||
@@ -33,7 +33,6 @@ executable('glorytun', install: true,
|
||||
'src/path.c',
|
||||
'src/set.c',
|
||||
'src/show.c',
|
||||
'src/sync.c',
|
||||
'src/tun.c',
|
||||
],
|
||||
dependencies: [
|
||||
|
||||
2
mud
2
mud
Submodule mud updated: f67a5b4fed...7a5bb0690e
@@ -300,9 +300,6 @@ gt_bind(int argc, char **argv)
|
||||
res.status.bind = bind_addr;
|
||||
res.status.peer = peer_addr;
|
||||
break;
|
||||
case CTL_SYNC:
|
||||
res.ms = mud_sync(mud);
|
||||
break;
|
||||
}
|
||||
if (sendto(ctl_fd, &res, sizeof(res), 0,
|
||||
(const struct sockaddr *)&ss, sl) == -1)
|
||||
|
||||
@@ -74,4 +74,3 @@ int gt_path (int, char **);
|
||||
int gt_keygen (int, char **);
|
||||
int gt_bench (int, char **);
|
||||
int gt_set (int, char **);
|
||||
int gt_sync (int, char **);
|
||||
|
||||
@@ -13,7 +13,6 @@ enum ctl_type {
|
||||
CTL_KXTIMEOUT,
|
||||
CTL_TIMETOLERANCE,
|
||||
CTL_PATH_STATUS,
|
||||
CTL_SYNC,
|
||||
};
|
||||
|
||||
struct ctl_msg {
|
||||
|
||||
@@ -64,7 +64,6 @@ main(int argc, char **argv)
|
||||
{"bench", "start a crypto bench", gt_bench},
|
||||
{"bind", "start a new tunnel", gt_bind},
|
||||
{"set", "change tunnel properties", gt_set},
|
||||
{"sync", "re-sync tunnels", gt_sync},
|
||||
{"keygen", "generate a new secret key", gt_keygen},
|
||||
{"path", "manage paths", gt_path},
|
||||
{"version", "show version", gt_version},
|
||||
|
||||
76
src/sync.c
76
src/sync.c
@@ -1,76 +0,0 @@
|
||||
#include "common.h"
|
||||
#include "ctl.h"
|
||||
#include "str.h"
|
||||
|
||||
#include "../argz/argz.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
|
||||
static int
|
||||
gt_sync_dev(const char *dev, unsigned long timeout)
|
||||
{
|
||||
const int fd = ctl_connect(GT_RUNDIR, dev);
|
||||
|
||||
if (fd < 0) {
|
||||
if (fd == -1)
|
||||
perror("sync");
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct ctl_msg res, req = {
|
||||
.type = CTL_SYNC,
|
||||
};
|
||||
|
||||
int ret = ctl_reply(fd, &res, &req);
|
||||
|
||||
if (!ret) {
|
||||
if (res.ms > timeout)
|
||||
ret = 1;
|
||||
} else {
|
||||
perror("sync");
|
||||
}
|
||||
|
||||
ctl_delete(fd);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
gt_sync(int argc, char **argv)
|
||||
{
|
||||
const char *dev = NULL;
|
||||
unsigned long timeout = 20000;
|
||||
|
||||
struct argz syncz[] = {
|
||||
{"dev", "NAME", &dev, argz_str},
|
||||
{"timeout", "SECONDS", &timeout, argz_time},
|
||||
{NULL}};
|
||||
|
||||
if (argz(syncz, argc, argv))
|
||||
return 1;
|
||||
|
||||
if (dev)
|
||||
return !!gt_sync_dev(dev, timeout);
|
||||
|
||||
DIR *dp = opendir(GT_RUNDIR);
|
||||
|
||||
if (!dp) {
|
||||
if (errno == ENOENT)
|
||||
return 0;
|
||||
perror("sync");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ret = 0;
|
||||
struct dirent *d = NULL;
|
||||
|
||||
while (d = readdir(dp), d) {
|
||||
if (d->d_name[0] != '.')
|
||||
ret |= !!gt_sync_dev(d->d_name, timeout);
|
||||
}
|
||||
|
||||
closedir(dp);
|
||||
|
||||
return ret;
|
||||
}
|
||||
Reference in New Issue
Block a user