Compare commits
39 Commits
v0.0.34
...
v0.0.43-mu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
378316bd68 | ||
|
|
286d6abf2d | ||
|
|
1f1464e90d | ||
|
|
55d9dd9277 | ||
|
|
2f290dbf85 | ||
|
|
39e3f53139 | ||
|
|
babe14d544 | ||
|
|
278fc69789 | ||
|
|
99262777fc | ||
|
|
b0f60caab2 | ||
|
|
efd5e0bb36 | ||
|
|
ade4617d53 | ||
|
|
64a5fd8227 | ||
|
|
eba968797c | ||
|
|
d60f28a7fe | ||
|
|
32069eb104 | ||
|
|
a6adcefc25 | ||
|
|
743b0ee0da | ||
|
|
ba06a6fc10 | ||
|
|
80d4c2814f | ||
|
|
b0d5007bfb | ||
|
|
d2046eb00b | ||
|
|
d04acc9c0f | ||
|
|
03cd87df1c | ||
|
|
8e8ad7178d | ||
|
|
0e26b4def7 | ||
|
|
f800985766 | ||
|
|
7b88c28a45 | ||
|
|
194dfe17d3 | ||
|
|
664160e0cc | ||
|
|
1dd760e382 | ||
|
|
05219b81f7 | ||
|
|
0bb7e4f1d0 | ||
|
|
a7fbf806fb | ||
|
|
e750c46665 | ||
|
|
935111cfea | ||
|
|
c4b2512df4 | ||
|
|
27970e24fb | ||
|
|
acc3ee3461 |
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
[submodule "mud"]
|
||||
path = mud
|
||||
url = https://github.com/angt/mud.git
|
||||
@@ -20,6 +20,11 @@ glorytun_SOURCES = \
|
||||
src/state.c \
|
||||
src/state.h
|
||||
|
||||
glorytun_CFLAGS += -I$(srcdir)/mud
|
||||
glorytun_SOURCES += \
|
||||
mud/mud.h \
|
||||
mud/mud.c
|
||||
|
||||
EXTRA_DIST = \
|
||||
LICENSE \
|
||||
README.md \
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Glorytun
|
||||
# π₁(Glorytun)=ℤ²
|
||||
|
||||
Small, Simple and Stupid TCP VPN.
|
||||
Small, Simple and Stupid VPN over [mud](https://github.com/angt/mud).
|
||||
|
||||
#### Work In Progress
|
||||
|
||||
@@ -13,7 +13,7 @@ and needs an AES-NI capable CPU.
|
||||
|
||||
To build and install the latest version:
|
||||
|
||||
$ git clone https://github.com/angt/glorytun
|
||||
$ git clone https://github.com/angt/glorytun --recursive --branch mud
|
||||
$ cd glorytun
|
||||
$ ./autogen.sh
|
||||
$ ./configure
|
||||
|
||||
1
mud
Submodule
1
mud
Submodule
Submodule mud added at 2c4443a823
1275
src/main.c
1275
src/main.c
File diff suppressed because it is too large
Load Diff
41
src/state.c
41
src/state.c
@@ -7,16 +7,14 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
static int state_fd = -1;
|
||||
|
||||
int state_init (const char *filename)
|
||||
int state_create (const char *filename)
|
||||
{
|
||||
if (str_empty(filename))
|
||||
return 0;
|
||||
return -1;
|
||||
|
||||
state_fd = open(filename, O_WRONLY);
|
||||
int fd = open(filename, O_WRONLY);
|
||||
|
||||
if (state_fd==-1) {
|
||||
if (fd==-1) {
|
||||
if (errno!=EINTR)
|
||||
perror("open");
|
||||
return -1;
|
||||
@@ -24,38 +22,41 @@ int state_init (const char *filename)
|
||||
|
||||
struct stat st = {0};
|
||||
|
||||
if (fstat(state_fd, &st)==-1) {
|
||||
if (fstat(fd, &st)==-1) {
|
||||
perror("fstat");
|
||||
close(state_fd);
|
||||
state_fd = -1;
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!S_ISFIFO(st.st_mode)) {
|
||||
gt_log("`%s' is not a fifo\n", filename);
|
||||
close(state_fd);
|
||||
state_fd = -1;
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return fd;
|
||||
}
|
||||
|
||||
void state (const char *state, const char *info)
|
||||
void state_send (int fd, const char *state, const char *info)
|
||||
{
|
||||
if (str_empty(state))
|
||||
return;
|
||||
|
||||
if (fd==-1) {
|
||||
gt_print("%s %s\n", state, info);
|
||||
return;
|
||||
}
|
||||
|
||||
const char *strs[] = { state, " ", info, "\n" };
|
||||
char *str = str_cat(strs, COUNT(strs));
|
||||
|
||||
if (!str)
|
||||
if (!str) {
|
||||
perror("str_cat");
|
||||
return;
|
||||
|
||||
if (state_fd==-1) {
|
||||
gt_print("%s", str);
|
||||
} else {
|
||||
if (write(state_fd, str, str_len(str))==-1 && errno!=EINTR)
|
||||
perror("write");
|
||||
}
|
||||
|
||||
if (write(fd, str, str_len(str))==-1 && errno!=EINTR)
|
||||
perror("write");
|
||||
|
||||
free(str);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
int state_init (const char *);
|
||||
void state (const char *, const char *);
|
||||
int state_create (const char *);
|
||||
void state_send (int, const char *, const char *);
|
||||
|
||||
Reference in New Issue
Block a user