Compare commits
2 Commits
v0.0.88-mu
...
v0.0.90-mu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
355040f576 | ||
|
|
bbf1c12f7a |
2
mud
2
mud
Submodule mud updated: f67eae0a7f...dfcc08feed
12
src/main.c
12
src/main.c
@@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
volatile sig_atomic_t quit;
|
volatile sig_atomic_t quit;
|
||||||
|
volatile sig_atomic_t reload;
|
||||||
char *dev;
|
char *dev;
|
||||||
char *keyfile;
|
char *keyfile;
|
||||||
char *host;
|
char *host;
|
||||||
@@ -87,6 +88,7 @@ fd_set_nonblock(int fd)
|
|||||||
static void
|
static void
|
||||||
gt_quit_handler(int sig)
|
gt_quit_handler(int sig)
|
||||||
{
|
{
|
||||||
|
gt.reload = (sig == SIGHUP);
|
||||||
gt.quit = 1;
|
gt.quit = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,9 +105,9 @@ gt_set_signal(void)
|
|||||||
sigaction(SIGINT, &sa, NULL);
|
sigaction(SIGINT, &sa, NULL);
|
||||||
sigaction(SIGQUIT, &sa, NULL);
|
sigaction(SIGQUIT, &sa, NULL);
|
||||||
sigaction(SIGTERM, &sa, NULL);
|
sigaction(SIGTERM, &sa, NULL);
|
||||||
|
sigaction(SIGHUP, &sa, NULL);
|
||||||
|
|
||||||
sa.sa_handler = SIG_IGN;
|
sa.sa_handler = SIG_IGN;
|
||||||
sigaction(SIGHUP, &sa, NULL);
|
|
||||||
sigaction(SIGPIPE, &sa, NULL);
|
sigaction(SIGPIPE, &sa, NULL);
|
||||||
sigaction(SIGUSR1, &sa, NULL);
|
sigaction(SIGUSR1, &sa, NULL);
|
||||||
sigaction(SIGUSR2, &sa, NULL);
|
sigaction(SIGUSR2, &sa, NULL);
|
||||||
@@ -292,6 +294,9 @@ main(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tun_set_persist(tun_fd, 0) == -1)
|
||||||
|
perror("tun_set_persist");
|
||||||
|
|
||||||
struct mud *mud = mud_create(gt.bind.port, gt.ipv4, gt.ipv6,
|
struct mud *mud = mud_create(gt.bind.port, gt.ipv4, gt.ipv6,
|
||||||
!gt.chacha20, GT_MTU(gt.mtu));
|
!gt.chacha20, GT_MTU(gt.mtu));
|
||||||
|
|
||||||
@@ -482,5 +487,10 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gt.reload && tun_fd >= 0) {
|
||||||
|
if (tun_set_persist(tun_fd, 1) == -1)
|
||||||
|
perror("tun_set_persist");
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#define IFF_TUN 0x0001
|
#define IFF_TUN 0x0001
|
||||||
#define IFF_NO_PI 0x1000
|
#define IFF_NO_PI 0x1000
|
||||||
#define TUNSETIFF _IOW('T', 202, int)
|
#define TUNSETIFF _IOW('T', 202, int)
|
||||||
|
#define TUNSETPERSIST _IOW('T', 203, int)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
@@ -260,3 +261,9 @@ tun_set_mtu(char *dev_name, int mtu)
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
tun_set_persist(int fd, int on)
|
||||||
|
{
|
||||||
|
return ioctl(fd, TUNSETPERSIST, on);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
int tun_create (char *, char **);
|
int tun_create (char *, char **);
|
||||||
int tun_read (int, void *, size_t);
|
int tun_read (int, void *, size_t);
|
||||||
int tun_write (int, const void *, size_t);
|
int tun_write (int, const void *, size_t);
|
||||||
int tun_set_mtu (char *, int);
|
int tun_set_mtu (char *, int);
|
||||||
|
int tun_set_persist (int, int);
|
||||||
|
|||||||
Reference in New Issue
Block a user