Compare commits
12 Commits
v0.0.94-mu
...
v0.0.97-mu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c06abdbe3c | ||
|
|
b0a589b792 | ||
|
|
66cdcf2ee3 | ||
|
|
7c50a9d162 | ||
|
|
6538d301d1 | ||
|
|
63831d6efc | ||
|
|
cbb498bb74 | ||
|
|
e2706aecdb | ||
|
|
cb8db71e72 | ||
|
|
4fab60ea87 | ||
|
|
b4ec962a3b | ||
|
|
235250e49d |
2
mud
2
mud
Submodule mud updated: 5aeb0a3cb2...ef319d2153
91
src/bind.c
91
src/bind.c
@@ -6,8 +6,8 @@
|
|||||||
#include "tun.h"
|
#include "tun.h"
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <sys/select.h>
|
||||||
|
|
||||||
#include "../argz/argz.h"
|
#include "../argz/argz.h"
|
||||||
#include "../mud/mud.h"
|
#include "../mud/mud.h"
|
||||||
@@ -16,8 +16,6 @@
|
|||||||
#define O_CLOEXEC 0
|
#define O_CLOEXEC 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define GT_MTU(X) ((X)-28)
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fd_set_nonblock(int fd)
|
fd_set_nonblock(int fd)
|
||||||
{
|
{
|
||||||
@@ -90,13 +88,19 @@ gt_setup_secretkey(struct mud *mud, const char *keyfile)
|
|||||||
static size_t
|
static size_t
|
||||||
gt_setup_mtu(struct mud *mud, const char *tun_name)
|
gt_setup_mtu(struct mud *mud, const char *tun_name)
|
||||||
{
|
{
|
||||||
|
static size_t oldmtu = 0;
|
||||||
size_t mtu = mud_get_mtu(mud);
|
size_t mtu = mud_get_mtu(mud);
|
||||||
|
|
||||||
|
if (mtu == oldmtu)
|
||||||
|
return mtu;
|
||||||
|
|
||||||
gt_log("setup MTU to %zu on interface %s\n", mtu, tun_name);
|
gt_log("setup MTU to %zu on interface %s\n", mtu, tun_name);
|
||||||
|
|
||||||
if (iface_set_mtu(tun_name, mtu) == -1)
|
if (iface_set_mtu(tun_name, mtu) == -1)
|
||||||
perror("tun_set_mtu");
|
perror("tun_set_mtu");
|
||||||
|
|
||||||
|
oldmtu = mtu;
|
||||||
|
|
||||||
return mtu;
|
return mtu;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,12 +114,7 @@ gt_bind(int argc, char **argv)
|
|||||||
const char *dev = NULL;
|
const char *dev = NULL;
|
||||||
const char *keyfile = NULL;
|
const char *keyfile = NULL;
|
||||||
size_t bufsize = 64 * 1024 * 1024;
|
size_t bufsize = 64 * 1024 * 1024;
|
||||||
size_t mtu = 1500;
|
size_t mtu = 1330;
|
||||||
|
|
||||||
struct argz mtuz[] = {
|
|
||||||
{"auto", NULL, NULL, argz_option},
|
|
||||||
{NULL, "BYTES", &mtu, argz_bytes},
|
|
||||||
{NULL}};
|
|
||||||
|
|
||||||
struct argz toz[] = {
|
struct argz toz[] = {
|
||||||
{NULL, "IPADDR", &peer_addr, argz_addr},
|
{NULL, "IPADDR", &peer_addr, argz_addr},
|
||||||
@@ -127,7 +126,7 @@ gt_bind(int argc, char **argv)
|
|||||||
{NULL, "PORT", &bind_port, argz_ushort},
|
{NULL, "PORT", &bind_port, argz_ushort},
|
||||||
{"to", NULL, &toz, argz_option},
|
{"to", NULL, &toz, argz_option},
|
||||||
{"dev", "NAME", &dev, argz_str},
|
{"dev", "NAME", &dev, argz_str},
|
||||||
{"mtu", NULL, &mtuz, argz_option},
|
{"mtu", "BYTES", &mtu, argz_bytes},
|
||||||
{"keyfile", "FILE", &keyfile, argz_str},
|
{"keyfile", "FILE", &keyfile, argz_str},
|
||||||
{"chacha", NULL, NULL, argz_option},
|
{"chacha", NULL, NULL, argz_option},
|
||||||
{"persist", NULL, NULL, argz_option},
|
{"persist", NULL, NULL, argz_option},
|
||||||
@@ -147,19 +146,9 @@ gt_bind(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mtu_auto = argz_is_set(mtuz, "auto");
|
|
||||||
int chacha = argz_is_set(bindz, "chacha");
|
int chacha = argz_is_set(bindz, "chacha");
|
||||||
int persist = argz_is_set(bindz, "persist");
|
int persist = argz_is_set(bindz, "persist");
|
||||||
|
|
||||||
int icmp_fd = -1;
|
|
||||||
|
|
||||||
if (mtu_auto && (peer_addr.ss_family == AF_INET)) {
|
|
||||||
icmp_fd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
|
|
||||||
|
|
||||||
if (icmp_fd == -1)
|
|
||||||
gt_log("couldn't create ICMP socket\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
struct mud *mud = mud_create((struct sockaddr *)&bind_addr);
|
struct mud *mud = mud_create((struct sockaddr *)&bind_addr);
|
||||||
|
|
||||||
if (!mud) {
|
if (!mud) {
|
||||||
@@ -182,8 +171,6 @@ gt_bind(int argc, char **argv)
|
|||||||
chacha = 1;
|
chacha = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
mud_set_mtu(mud, GT_MTU(mtu));
|
|
||||||
|
|
||||||
char tun_name[64];
|
char tun_name[64];
|
||||||
int tun_fd = tun_create(tun_name, sizeof(tun_name) - 1, dev);
|
int tun_fd = tun_create(tun_name, sizeof(tun_name) - 1, dev);
|
||||||
|
|
||||||
@@ -192,6 +179,9 @@ gt_bind(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mud_set_mtu(mud, mtu);
|
||||||
|
mtu = gt_setup_mtu(mud, tun_name);
|
||||||
|
|
||||||
if (tun_set_persist(tun_fd, persist) == -1)
|
if (tun_set_persist(tun_fd, persist) == -1)
|
||||||
perror("tun_set_persist");
|
perror("tun_set_persist");
|
||||||
|
|
||||||
@@ -202,9 +192,7 @@ gt_bind(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mtu = gt_setup_mtu(mud, tun_name);
|
int ctl_fd = ctl_create(GT_RUNDIR, tun_name);
|
||||||
|
|
||||||
int ctl_fd = ctl_create("/run/" PACKAGE_NAME, tun_name);
|
|
||||||
|
|
||||||
if (ctl_fd == -1) {
|
if (ctl_fd == -1) {
|
||||||
perror("ctl_create");
|
perror("ctl_create");
|
||||||
@@ -215,7 +203,6 @@ gt_bind(int argc, char **argv)
|
|||||||
|
|
||||||
fd_set_nonblock(tun_fd);
|
fd_set_nonblock(tun_fd);
|
||||||
fd_set_nonblock(mud_fd);
|
fd_set_nonblock(mud_fd);
|
||||||
fd_set_nonblock(icmp_fd);
|
|
||||||
fd_set_nonblock(ctl_fd);
|
fd_set_nonblock(ctl_fd);
|
||||||
|
|
||||||
gt_log("running...\n");
|
gt_log("running...\n");
|
||||||
@@ -223,16 +210,13 @@ gt_bind(int argc, char **argv)
|
|||||||
fd_set rfds;
|
fd_set rfds;
|
||||||
FD_ZERO(&rfds);
|
FD_ZERO(&rfds);
|
||||||
|
|
||||||
int last_fd = 1 + MAX(tun_fd, MAX(mud_fd, MAX(ctl_fd, icmp_fd)));
|
int last_fd = 1 + MAX(tun_fd, MAX(mud_fd, ctl_fd));
|
||||||
|
|
||||||
while (!gt_quit) {
|
while (!gt_quit) {
|
||||||
FD_SET(tun_fd, &rfds);
|
FD_SET(tun_fd, &rfds);
|
||||||
FD_SET(mud_fd, &rfds);
|
FD_SET(mud_fd, &rfds);
|
||||||
FD_SET(ctl_fd, &rfds);
|
FD_SET(ctl_fd, &rfds);
|
||||||
|
|
||||||
if (icmp_fd != -1)
|
|
||||||
FD_SET(icmp_fd, &rfds);
|
|
||||||
|
|
||||||
if (select(last_fd, &rfds, NULL, NULL, NULL) == -1) {
|
if (select(last_fd, &rfds, NULL, NULL, NULL) == -1) {
|
||||||
if (errno != EBADF)
|
if (errno != EBADF)
|
||||||
continue;
|
continue;
|
||||||
@@ -240,22 +224,7 @@ gt_bind(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (icmp_fd != -1 && FD_ISSET(icmp_fd, &rfds)) {
|
mtu = gt_setup_mtu(mud, tun_name);
|
||||||
struct ip_common ic;
|
|
||||||
struct sockaddr_storage ss;
|
|
||||||
socklen_t sl = sizeof(ss);
|
|
||||||
|
|
||||||
ssize_t r = recvfrom(icmp_fd, buf, bufsize, 0,
|
|
||||||
(struct sockaddr *)&ss, &sl);
|
|
||||||
|
|
||||||
if (!ip_get_common(&ic, buf, r)) {
|
|
||||||
size_t mtu = ip_get_mtu(&ic, buf, r);
|
|
||||||
if (mtu > 0) {
|
|
||||||
gt_log("received MTU from ICMP: %zu\n", mtu);
|
|
||||||
mud_set_mtu(mud, GT_MTU(mtu));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (FD_ISSET(ctl_fd, &rfds)) {
|
if (FD_ISSET(ctl_fd, &rfds)) {
|
||||||
struct ctl_msg req, res = {.reply = 1};
|
struct ctl_msg req, res = {.reply = 1};
|
||||||
@@ -288,35 +257,38 @@ gt_bind(int argc, char **argv)
|
|||||||
res.ret = EAGAIN;
|
res.ret = EAGAIN;
|
||||||
|
|
||||||
for (unsigned i = 0; i < count; i++) {
|
for (unsigned i = 0; i < count; i++) {
|
||||||
if (i && sendto(ctl_fd, &res, sizeof(res), 0,
|
|
||||||
(const struct sockaddr *)&ss, sl) == -1)
|
|
||||||
perror("sendto(ctl)");
|
|
||||||
memcpy(&res.path_status, &paths[i], sizeof(struct mud_path));
|
memcpy(&res.path_status, &paths[i], sizeof(struct mud_path));
|
||||||
|
if (sendto(ctl_fd, &res, sizeof(res), 0,
|
||||||
|
(const struct sockaddr *)&ss, sl) == -1)
|
||||||
|
perror("sendto(ctl)");
|
||||||
}
|
}
|
||||||
|
|
||||||
res.ret = 0;
|
res.ret = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CTL_MTU:
|
case CTL_MTU:
|
||||||
mud_set_mtu(mud, GT_MTU((size_t)req.mtu));
|
mud_set_mtu(mud, req.mtu);
|
||||||
res.mtu = gt_setup_mtu(mud, tun_name);
|
mtu = gt_setup_mtu(mud, tun_name);
|
||||||
mtu = res.mtu;
|
res.mtu = mtu;
|
||||||
break;
|
break;
|
||||||
case CTL_TC:
|
case CTL_TC:
|
||||||
if (mud_set_tc(mud, req.tc))
|
if (mud_set_tc(mud, req.tc))
|
||||||
res.ret = errno;
|
res.ret = errno;
|
||||||
break;
|
break;
|
||||||
|
case CTL_KXTIMEOUT:
|
||||||
|
if (mud_set_keyx_timeout(mud, req.ms))
|
||||||
|
res.ret = errno;
|
||||||
|
break;
|
||||||
case CTL_TIMEOUT:
|
case CTL_TIMEOUT:
|
||||||
if (mud_set_send_timeout(mud, req.timeout))
|
if (mud_set_send_timeout(mud, req.ms))
|
||||||
res.ret = errno;
|
res.ret = errno;
|
||||||
break;
|
break;
|
||||||
case CTL_TIMETOLERANCE:
|
case CTL_TIMETOLERANCE:
|
||||||
if (mud_set_time_tolerance(mud, req.timetolerance))
|
if (mud_set_time_tolerance(mud, req.ms))
|
||||||
res.ret = errno;
|
res.ret = errno;
|
||||||
break;
|
break;
|
||||||
case CTL_STATUS:
|
case CTL_STATUS:
|
||||||
res.status.mtu = mtu;
|
res.status.mtu = mtu;
|
||||||
res.status.mtu_auto = (icmp_fd != -1);
|
|
||||||
res.status.chacha = chacha;
|
res.status.chacha = chacha;
|
||||||
res.status.bind = bind_addr;
|
res.status.bind = bind_addr;
|
||||||
res.status.peer = peer_addr;
|
res.status.peer = peer_addr;
|
||||||
@@ -374,11 +346,12 @@ gt_bind(int argc, char **argv)
|
|||||||
|
|
||||||
int r = mud_send(mud, &buf[p], q - p, tc);
|
int r = mud_send(mud, &buf[p], q - p, tc);
|
||||||
|
|
||||||
if (r == -1 && errno == EMSGSIZE) {
|
if (r == -1) {
|
||||||
mtu = gt_setup_mtu(mud, tun_name);
|
if (errno == EMSGSIZE) {
|
||||||
} else {
|
mtu = gt_setup_mtu(mud, tun_name);
|
||||||
if (r == -1 && errno != EAGAIN)
|
} else if (errno != EAGAIN) {
|
||||||
perror("mud_send");
|
perror("mud_send");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p = q;
|
p = q;
|
||||||
|
|||||||
@@ -108,5 +108,6 @@ gt_toaddr(char *str, size_t size, struct sockaddr *sa)
|
|||||||
&((struct sockaddr_in6 *)sa)->sin6_addr, str, size);
|
&((struct sockaddr_in6 *)sa)->sin6_addr, str, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
errno = EAFNOSUPPORT;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,10 @@
|
|||||||
#define PACKAGE_VERSION "0.0.0"
|
#define PACKAGE_VERSION "0.0.0"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef GT_RUNDIR
|
||||||
|
#define GT_RUNDIR "/run/" PACKAGE_NAME
|
||||||
|
#endif
|
||||||
|
|
||||||
#define COUNT(x) (sizeof(x)/sizeof(x[0]))
|
#define COUNT(x) (sizeof(x)/sizeof(x[0]))
|
||||||
|
|
||||||
#define ALIGN_SIZE (1<<4)
|
#define ALIGN_SIZE (1<<4)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ enum ctl_type {
|
|||||||
CTL_STATUS,
|
CTL_STATUS,
|
||||||
CTL_MTU,
|
CTL_MTU,
|
||||||
CTL_TC,
|
CTL_TC,
|
||||||
|
CTL_KXTIMEOUT,
|
||||||
CTL_TIMEOUT,
|
CTL_TIMEOUT,
|
||||||
CTL_TIMETOLERANCE,
|
CTL_TIMETOLERANCE,
|
||||||
CTL_PATH_STATUS,
|
CTL_PATH_STATUS,
|
||||||
@@ -26,15 +27,13 @@ struct ctl_msg {
|
|||||||
struct mud_path path_status;
|
struct mud_path path_status;
|
||||||
struct {
|
struct {
|
||||||
size_t mtu;
|
size_t mtu;
|
||||||
int mtu_auto;
|
|
||||||
int chacha;
|
int chacha;
|
||||||
struct sockaddr_storage bind;
|
struct sockaddr_storage bind;
|
||||||
struct sockaddr_storage peer;
|
struct sockaddr_storage peer;
|
||||||
} status;
|
} status;
|
||||||
int mtu;
|
size_t mtu;
|
||||||
int tc;
|
int tc;
|
||||||
unsigned long timeout;
|
unsigned long ms;
|
||||||
unsigned long timetolerance;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
24
src/path.c
24
src/path.c
@@ -21,11 +21,20 @@ gt_path_status(int fd)
|
|||||||
if (recv(fd, &res, sizeof(struct ctl_msg), 0) == -1)
|
if (recv(fd, &res, sizeof(struct ctl_msg), 0) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if (res.type != req.type)
|
||||||
|
return -2;
|
||||||
|
|
||||||
|
if (!res.ret)
|
||||||
|
return 0;
|
||||||
|
|
||||||
char bindstr[INET6_ADDRSTRLEN] = {0};
|
char bindstr[INET6_ADDRSTRLEN] = {0};
|
||||||
|
char publstr[INET6_ADDRSTRLEN] = {0};
|
||||||
char peerstr[INET6_ADDRSTRLEN] = {0};
|
char peerstr[INET6_ADDRSTRLEN] = {0};
|
||||||
|
|
||||||
if (gt_toaddr(bindstr, sizeof(bindstr),
|
if (gt_toaddr(bindstr, sizeof(bindstr),
|
||||||
(struct sockaddr *)&res.path_status.local_addr) ||
|
(struct sockaddr *)&res.path_status.local_addr) ||
|
||||||
|
gt_toaddr(publstr, sizeof(publstr),
|
||||||
|
(struct sockaddr *)&res.path_status.r_addr) ||
|
||||||
gt_toaddr(peerstr, sizeof(peerstr),
|
gt_toaddr(peerstr, sizeof(peerstr),
|
||||||
(struct sockaddr *)&res.path_status.addr))
|
(struct sockaddr *)&res.path_status.addr))
|
||||||
return -2;
|
return -2;
|
||||||
@@ -40,10 +49,15 @@ gt_path_status(int fd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
printf("path %s\n"
|
printf("path %s\n"
|
||||||
" bind: %s\n"
|
" bind: %s\n"
|
||||||
" peer: %s\n"
|
" public: %s port %"PRIu16"\n"
|
||||||
" rtt: %.3f\n",
|
" peer: %s port %"PRIu16"\n"
|
||||||
statestr, bindstr, peerstr,
|
" mtu: %zu bytes\n"
|
||||||
|
" rtt: %.3f ms\n",
|
||||||
|
statestr, bindstr,
|
||||||
|
publstr, gt_get_port((struct sockaddr *)&res.path_status.r_addr),
|
||||||
|
peerstr, gt_get_port((struct sockaddr *)&res.path_status.addr),
|
||||||
|
res.path_status.mtu.ok + 28U, /* ip+udp hdr */
|
||||||
res.path_status.rtt/(double)1e3);
|
res.path_status.rtt/(double)1e3);
|
||||||
|
|
||||||
} while (res.ret == EAGAIN);
|
} while (res.ret == EAGAIN);
|
||||||
@@ -69,7 +83,7 @@ gt_path(int argc, char **argv)
|
|||||||
if (argz(pathz, argc, argv))
|
if (argz(pathz, argc, argv))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
int fd = ctl_connect("/run/" PACKAGE_NAME, dev);
|
int fd = ctl_connect(GT_RUNDIR, dev);
|
||||||
|
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
perror("path");
|
perror("path");
|
||||||
|
|||||||
37
src/set.c
37
src/set.c
@@ -22,17 +22,35 @@ gt_set_mtu(int fd, size_t mtu)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("mtu set to %i\n", res.mtu);
|
printf("mtu set to %zu\n", res.mtu);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
gt_set_timeout(int fd, unsigned long timeout)
|
gt_set_kxtimeout(int fd, unsigned long ms)
|
||||||
|
{
|
||||||
|
struct ctl_msg res, req = {
|
||||||
|
.type = CTL_KXTIMEOUT,
|
||||||
|
.ms = ms,
|
||||||
|
};
|
||||||
|
|
||||||
|
int ret = ctl_reply(fd, &res, &req);
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
perror("set kxtimeout");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
gt_set_timeout(int fd, unsigned long ms)
|
||||||
{
|
{
|
||||||
struct ctl_msg res, req = {
|
struct ctl_msg res, req = {
|
||||||
.type = CTL_TIMEOUT,
|
.type = CTL_TIMEOUT,
|
||||||
.timeout = timeout,
|
.ms = ms,
|
||||||
};
|
};
|
||||||
|
|
||||||
int ret = ctl_reply(fd, &res, &req);
|
int ret = ctl_reply(fd, &res, &req);
|
||||||
@@ -46,11 +64,11 @@ gt_set_timeout(int fd, unsigned long timeout)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
gt_set_timetolerance(int fd, unsigned long timetolerance)
|
gt_set_timetolerance(int fd, unsigned long ms)
|
||||||
{
|
{
|
||||||
struct ctl_msg res, req = {
|
struct ctl_msg res, req = {
|
||||||
.type = CTL_TIMETOLERANCE,
|
.type = CTL_TIMETOLERANCE,
|
||||||
.timetolerance = timetolerance,
|
.ms = ms,
|
||||||
};
|
};
|
||||||
|
|
||||||
int ret = ctl_reply(fd, &res, &req);
|
int ret = ctl_reply(fd, &res, &req);
|
||||||
@@ -113,13 +131,15 @@ gt_set(int argc, char **argv)
|
|||||||
const char *dev = NULL;
|
const char *dev = NULL;
|
||||||
size_t mtu;
|
size_t mtu;
|
||||||
int tc;
|
int tc;
|
||||||
unsigned long timetolerance;
|
unsigned long kxtimeout;
|
||||||
unsigned long timeout;
|
unsigned long timeout;
|
||||||
|
unsigned long timetolerance;
|
||||||
|
|
||||||
struct argz pathz[] = {
|
struct argz pathz[] = {
|
||||||
{"dev", "NAME", &dev, argz_str},
|
{"dev", "NAME", &dev, argz_str},
|
||||||
{"mtu", "BYTES", &mtu, argz_bytes},
|
{"mtu", "BYTES", &mtu, argz_bytes},
|
||||||
{"tc", "CS|AF|EF", &tc, gt_argz_tc},
|
{"tc", "CS|AF|EF", &tc, gt_argz_tc},
|
||||||
|
{"kxtimeout", "SECONDS", &kxtimeout, argz_time},
|
||||||
{"timeout", "SECONDS", &timeout, argz_time},
|
{"timeout", "SECONDS", &timeout, argz_time},
|
||||||
{"timetolerance", "SECONDS", &timetolerance, argz_time},
|
{"timetolerance", "SECONDS", &timetolerance, argz_time},
|
||||||
{NULL}};
|
{NULL}};
|
||||||
@@ -127,7 +147,7 @@ gt_set(int argc, char **argv)
|
|||||||
if (argz(pathz, argc, argv))
|
if (argz(pathz, argc, argv))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
int fd = ctl_connect("/run/" PACKAGE_NAME, dev);
|
int fd = ctl_connect(GT_RUNDIR, dev);
|
||||||
|
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
perror("set");
|
perror("set");
|
||||||
@@ -142,6 +162,9 @@ gt_set(int argc, char **argv)
|
|||||||
if (argz_is_set(pathz, "tc"))
|
if (argz_is_set(pathz, "tc"))
|
||||||
ret |= gt_set_tc(fd, tc);
|
ret |= gt_set_tc(fd, tc);
|
||||||
|
|
||||||
|
if (argz_is_set(pathz, "kxtimeout"))
|
||||||
|
ret |= gt_set_kxtimeout(fd, kxtimeout);
|
||||||
|
|
||||||
if (argz_is_set(pathz, "timeout"))
|
if (argz_is_set(pathz, "timeout"))
|
||||||
ret |= gt_set_timeout(fd, timeout);
|
ret |= gt_set_timeout(fd, timeout);
|
||||||
|
|
||||||
|
|||||||
@@ -32,25 +32,21 @@ gt_show_dev_status(int fd, const char *dev)
|
|||||||
printf("server %s:\n"
|
printf("server %s:\n"
|
||||||
" bind: %s port %"PRIu16"\n"
|
" bind: %s port %"PRIu16"\n"
|
||||||
" mtu: %zu\n"
|
" mtu: %zu\n"
|
||||||
" auto mtu: %s\n"
|
|
||||||
" cipher: %s\n",
|
" cipher: %s\n",
|
||||||
dev,
|
dev,
|
||||||
bindstr, gt_get_port((struct sockaddr *)&res.status.bind),
|
bindstr, gt_get_port((struct sockaddr *)&res.status.bind),
|
||||||
res.status.mtu,
|
res.status.mtu,
|
||||||
res.status.mtu_auto ? "enabled" : "disabled",
|
|
||||||
res.status.chacha ? "chacha20poly1305" : "aes256gcm");
|
res.status.chacha ? "chacha20poly1305" : "aes256gcm");
|
||||||
} else {
|
} else {
|
||||||
printf("client %s:\n"
|
printf("client %s:\n"
|
||||||
" bind: %s port %"PRIu16"\n"
|
" bind: %s port %"PRIu16"\n"
|
||||||
" peer: %s port %"PRIu16"\n"
|
" peer: %s port %"PRIu16"\n"
|
||||||
" mtu: %zu\n"
|
" mtu: %zu\n"
|
||||||
" auto mtu: %s\n"
|
|
||||||
" cipher: %s\n",
|
" cipher: %s\n",
|
||||||
dev,
|
dev,
|
||||||
bindstr, gt_get_port((struct sockaddr *)&res.status.bind),
|
bindstr, gt_get_port((struct sockaddr *)&res.status.bind),
|
||||||
peerstr, gt_get_port((struct sockaddr *)&res.status.peer),
|
peerstr, gt_get_port((struct sockaddr *)&res.status.peer),
|
||||||
res.status.mtu,
|
res.status.mtu,
|
||||||
res.status.mtu_auto ? "enabled" : "disabled",
|
|
||||||
res.status.chacha ? "chacha20poly1305" : "aes256gcm");
|
res.status.chacha ? "chacha20poly1305" : "aes256gcm");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +56,7 @@ gt_show_dev_status(int fd, const char *dev)
|
|||||||
static int
|
static int
|
||||||
gt_show_dev(const char *dev)
|
gt_show_dev(const char *dev)
|
||||||
{
|
{
|
||||||
int fd = ctl_connect("/run/" PACKAGE_NAME, dev);
|
int fd = ctl_connect(GT_RUNDIR, dev);
|
||||||
|
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
perror(dev);
|
perror(dev);
|
||||||
@@ -97,7 +93,7 @@ gt_show(int argc, char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DIR *dp = opendir("/run/" PACKAGE_NAME);
|
DIR *dp = opendir(GT_RUNDIR);
|
||||||
|
|
||||||
if (!dp) {
|
if (!dp) {
|
||||||
if (errno == ENOENT)
|
if (errno == ENOENT)
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ HOST=$HOST
|
|||||||
PORT=$PORT
|
PORT=$PORT
|
||||||
BIND=$BIND
|
BIND=$BIND
|
||||||
BIND_PORT=$BIND_PORT
|
BIND_PORT=$BIND_PORT
|
||||||
OPTIONS="mtu auto"
|
OPTIONS=
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
( umask 077; echo "$KEY" > "$DIR/key" )
|
( umask 077; echo "$KEY" > "$DIR/key" )
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ Restart=always
|
|||||||
EnvironmentFile=/etc/glorytun/%i/env
|
EnvironmentFile=/etc/glorytun/%i/env
|
||||||
ExecStart=@bindir@/glorytun-run keyfile /etc/glorytun/%i/key $OPTIONS
|
ExecStart=@bindir@/glorytun-run keyfile /etc/glorytun/%i/key $OPTIONS
|
||||||
ExecStartPost=-/etc/glorytun/%i/post.sh
|
ExecStartPost=-/etc/glorytun/%i/post.sh
|
||||||
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_RAW
|
CapabilityBoundingSet=CAP_NET_ADMIN
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|||||||
Reference in New Issue
Block a user