Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a78089ba10 | ||
|
|
128aaae368 | ||
|
|
230c9fa26a |
@@ -1,5 +1,5 @@
|
|||||||
AC_PREREQ([2.65])
|
AC_PREREQ([2.65])
|
||||||
AC_INIT([glorytun], [0.0.4], [https://github.com/angt/glorytun/issues],
|
AC_INIT([glorytun], [0.0.5], [https://github.com/angt/glorytun/issues],
|
||||||
[glorytun], [https://github.com/angt/glorytun])
|
[glorytun], [https://github.com/angt/glorytun])
|
||||||
AC_CONFIG_SRCDIR([src/common.h])
|
AC_CONFIG_SRCDIR([src/common.h])
|
||||||
AC_CONFIG_AUX_DIR([build-aux])
|
AC_CONFIG_AUX_DIR([build-aux])
|
||||||
|
|||||||
26
src/main.c
26
src/main.c
@@ -655,6 +655,7 @@ int main (int argc, char **argv)
|
|||||||
{ "multiqueue", NULL, option_option },
|
{ "multiqueue", NULL, option_option },
|
||||||
{ "keepalive", ka_opts, option_option },
|
{ "keepalive", ka_opts, option_option },
|
||||||
{ "buffer-size", &buffer_size, option_long },
|
{ "buffer-size", &buffer_size, option_long },
|
||||||
|
{ "daemon", NULL, option_option },
|
||||||
{ "debug", NULL, option_option },
|
{ "debug", NULL, option_option },
|
||||||
{ "version", NULL, option_option },
|
{ "version", NULL, option_option },
|
||||||
{ NULL },
|
{ NULL },
|
||||||
@@ -723,6 +724,20 @@ int main (int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (option_is_set(opts, "daemon")) {
|
||||||
|
switch (fork()) {
|
||||||
|
case -1:
|
||||||
|
perror("fork");
|
||||||
|
return 1;
|
||||||
|
case 0:
|
||||||
|
if (setsid()==-1)
|
||||||
|
perror("setsid");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while (!gt_close) {
|
while (!gt_close) {
|
||||||
sock.fd = listener?sk_accept(fd):sk_create(ai, sk_connect);
|
sock.fd = listener?sk_accept(fd):sk_create(ai, sk_connect);
|
||||||
|
|
||||||
@@ -773,7 +788,7 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (gt_close)
|
if (gt_close)
|
||||||
stop_loop = 1;
|
stop_loop |= 1;
|
||||||
|
|
||||||
if (stop_loop) {
|
if (stop_loop) {
|
||||||
if (((stop_loop&(1<<2)) || !buffer_read_size(&sock.write)) &&
|
if (((stop_loop&(1<<2)) || !buffer_read_size(&sock.write)) &&
|
||||||
@@ -799,6 +814,9 @@ int main (int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FD_CLR(sock.fd, &wfds);
|
||||||
|
FD_CLR(tun.fd, &wfds);
|
||||||
|
|
||||||
#ifdef TCP_INFO
|
#ifdef TCP_INFO
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
gettimeofday(&now, NULL);
|
gettimeofday(&now, NULL);
|
||||||
@@ -848,9 +866,6 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
gt_encrypt(&ctx, &sock.write, &tun.read);
|
gt_encrypt(&ctx, &sock.write, &tun.read);
|
||||||
|
|
||||||
if (FD_ISSET(sock.fd, &wfds))
|
|
||||||
FD_CLR(sock.fd, &wfds);
|
|
||||||
|
|
||||||
if (buffer_read_size(&sock.write)) {
|
if (buffer_read_size(&sock.write)) {
|
||||||
ssize_t r = fd_write(sock.fd, sock.write.read,
|
ssize_t r = fd_write(sock.fd, sock.write.read,
|
||||||
buffer_read_size(&sock.write));
|
buffer_read_size(&sock.write));
|
||||||
@@ -889,9 +904,6 @@ int main (int argc, char **argv)
|
|||||||
goto restart;
|
goto restart;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FD_ISSET(tun.fd, &wfds))
|
|
||||||
FD_CLR(tun.fd, &wfds);
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
size_t size = buffer_read_size(&tun.write);
|
size_t size = buffer_read_size(&tun.write);
|
||||||
ssize_t ip_size = ip_get_size(tun.write.read, size);
|
ssize_t ip_size = ip_get_size(tun.write.read, size);
|
||||||
|
|||||||
Reference in New Issue
Block a user