Compare commits

...

55 Commits

Author SHA1 Message Date
Adrien Gallouët
378316bd68 Add mtu option 2016-06-13 15:43:45 +00:00
angt
286d6abf2d Update mud 2016-05-10 10:46:15 +00:00
angt
1f1464e90d Update mud 2016-05-09 14:23:17 +00:00
angt
55d9dd9277 Update mud 2016-05-02 09:18:44 +00:00
angt
2f290dbf85 Update mud and merge from master 2016-04-26 06:54:30 +00:00
angt
39e3f53139 Add v{4,6}only option 2016-04-25 16:29:20 +00:00
angt
babe14d544 Quit on tun error 2016-04-25 10:24:42 +00:00
angt
278fc69789 Update mud 2016-04-21 15:35:35 +00:00
angt
99262777fc Update mud 2016-04-17 10:16:13 +00:00
angt
b0f60caab2 Update mud 2016-04-14 20:12:45 +00:00
angt
efd5e0bb36 Remove down-timeout and use timeout for send-timeout 2016-04-08 14:38:07 +00:00
angt
ade4617d53 Update mud 2016-04-08 13:00:52 +00:00
angt
64a5fd8227 Update mud 2016-04-05 14:23:45 +00:00
angt
eba968797c Add {down,send,pong}-timeout and time-tolerance option 2016-04-05 14:17:07 +00:00
angt
d60f28a7fe Update mud 2016-04-05 06:42:03 +00:00
angt
32069eb104 Print tun device on STARTED and STOPPED too 2016-04-04 20:05:33 +00:00
angt
a6adcefc25 Update mud 2016-04-04 16:48:11 +00:00
angt
743b0ee0da Don't check AES-NI 2016-04-01 16:50:04 +00:00
angt
ba06a6fc10 Update mud 2016-04-01 16:37:02 +00:00
Adrien Gallouët
80d4c2814f Update README.md 2016-03-24 18:52:18 +01:00
angt
b0d5007bfb Restore STARTED and STOPPED states 2016-03-24 14:45:15 +00:00
angt
d2046eb00b Revert "Add branch name in version"
This reverts commit 03cd87df1c.
2016-03-09 11:42:51 +00:00
angt
d04acc9c0f Update mud 2016-03-09 10:59:52 +00:00
angt
03cd87df1c Add branch name in version 2016-03-09 10:20:01 +00:00
angt
8e8ad7178d Update mud 2016-03-04 11:32:42 +00:00
angt
0e26b4def7 Update mud 2016-03-04 11:20:15 +00:00
angt
f800985766 Update mud 2016-03-04 11:01:43 +00:00
angt
7b88c28a45 Update mud 2016-03-03 10:49:28 +00:00
angt
194dfe17d3 Update mud 2016-03-02 12:59:33 +00:00
angt
664160e0cc Add bind-port option 2016-03-01 15:11:16 +00:00
angt
1dd760e382 Code cleanup 2016-03-01 08:13:05 +00:00
angt
05219b81f7 Update README.md 2016-02-29 16:14:08 +00:00
angt
0bb7e4f1d0 Update mud 2016-02-29 15:35:57 +00:00
angt
a7fbf806fb Use a list to setup mud_bind() 2016-02-29 15:28:37 +00:00
angt
e750c46665 Update mud 2016-02-25 15:22:47 +00:00
angt
935111cfea Fix Makefile.am 2016-02-04 11:31:02 +01:00
angt
c4b2512df4 Add .gitmodules 2016-02-04 10:44:53 +01:00
angt
27970e24fb Import and use mud 2016-02-04 10:39:36 +01:00
angt
acc3ee3461 Encrypt only one packet at a time 2016-01-26 12:18:00 +01:00
angt
eefa7722c5 Use timeout in connect() too 2016-01-21 16:22:31 +01:00
angt
17547f555d Add SECRETKEY state 2016-01-18 18:07:35 +01:00
angt
ec9c59ce69 Code cleanup 2016-01-18 18:00:41 +01:00
angt
679927a684 Show device name in INITIALIZED state 2016-01-18 17:58:20 +01:00
angt
2999faf5d7 Move up state_init() 2016-01-18 17:26:42 +01:00
angt
219384b7e5 Remove the old school daemon option 2016-01-18 16:09:29 +01:00
angt
3649e46b03 Remove the absolute path restriction on statefile 2016-01-18 16:02:29 +01:00
angt
88f314bc75 Add state.[ch] 2016-01-18 15:59:18 +01:00
angt
e2b3dc1b46 Use only v[0-9].* tags to get VERSION 2016-01-17 10:56:55 +01:00
angt
1815ea519f Create a tcp_entry only on ACK 2016-01-17 10:18:39 +01:00
angt
33356d5d35 Don't work too much 2016-01-17 09:40:56 +01:00
angt
4a5d07ec45 Merge pull request #11 from jedisct1/notag
Cope with branches that don't have tags
2016-01-16 16:16:05 +01:00
Frank Denis
a50882e1ac Cope with branches that don't have tags
`version.sh` used to return only the hash of the last commit, causing
VERSION_MAJOR to possibly contain non-numeric junk.
2016-01-16 15:37:42 +01:00
angt
b2cb8ebcbe The minimum value for buffer-size option is GT_PKT_MAX 2016-01-15 17:02:11 +01:00
angt
6fd6cf8c4a Merge pull request #10 from jedisct1/socket
Include <sys/socket.h> for AF_INET/AF_INET6 definitions
2016-01-14 17:14:56 +01:00
Frank Denis
f0fc2751e5 Include <sys/socket.h> for AF_INET/AF_INET6 definitions
Required on OpenBSD
2016-01-14 17:11:27 +01:00
12 changed files with 286 additions and 1230 deletions

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "mud"]
path = mud
url = https://github.com/angt/mud.git

View File

@@ -16,7 +16,14 @@ glorytun_SOURCES = \
src/tun.c \ src/tun.c \
src/tun.h \ src/tun.h \
src/db.c \ src/db.c \
src/db.h src/db.h \
src/state.c \
src/state.h
glorytun_CFLAGS += -I$(srcdir)/mud
glorytun_SOURCES += \
mud/mud.h \
mud/mud.c
EXTRA_DIST = \ EXTRA_DIST = \
LICENSE \ LICENSE \

View File

@@ -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 #### Work In Progress
@@ -13,7 +13,7 @@ and needs an AES-NI capable CPU.
To build and install the latest version: 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 $ cd glorytun
$ ./autogen.sh $ ./autogen.sh
$ ./configure $ ./configure

1
mud Submodule

Submodule mud added at 2c4443a823

View File

@@ -49,15 +49,18 @@ static inline size_t buffer_read_size (buffer_t *buffer)
static inline void buffer_shift (buffer_t *buffer) static inline void buffer_shift (buffer_t *buffer)
{ {
if (buffer->read==buffer->data)
return;
if (buffer->read==buffer->write) { if (buffer->read==buffer->write) {
buffer_format(buffer); buffer_format(buffer);
} else { return;
const uint8_t *src = PALIGN_DOWN(buffer->read);
const size_t size = ALIGN(buffer->write-src);
if (buffer->data+size<src) {
memcpy(buffer->data, src, size);
buffer->read -= src-buffer->data;
buffer->write -= src-buffer->data;
}
} }
const size_t size = buffer_read_size(buffer);
memmove(buffer->data, buffer->read, size);
buffer->read = buffer->data;
buffer->write = buffer->data+size;
} }

1398
src/main.c

File diff suppressed because it is too large Load Diff

62
src/state.c Normal file
View File

@@ -0,0 +1,62 @@
#include "common.h"
#include "state.h"
#include "str.h"
#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
int state_create (const char *filename)
{
if (str_empty(filename))
return -1;
int fd = open(filename, O_WRONLY);
if (fd==-1) {
if (errno!=EINTR)
perror("open");
return -1;
}
struct stat st = {0};
if (fstat(fd, &st)==-1) {
perror("fstat");
close(fd);
return -1;
}
if (!S_ISFIFO(st.st_mode)) {
gt_log("`%s' is not a fifo\n", filename);
close(fd);
return -1;
}
return fd;
}
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) {
perror("str_cat");
return;
}
if (write(fd, str, str_len(str))==-1 && errno!=EINTR)
perror("write");
free(str);
}

4
src/state.h Normal file
View File

@@ -0,0 +1,4 @@
#pragma once
int state_create (const char *);
void state_send (int, const char *, const char *);

View File

@@ -47,7 +47,7 @@ static inline size_t str_len (const char *restrict str)
return strlen(str); return strlen(str);
} }
static inline char *str_cat (const char *const strs[], size_t count) static inline char *str_cat (const char **strs, size_t count)
{ {
size_t size = 1; size_t size = 1;

View File

@@ -131,9 +131,9 @@ static int tun_create_by_id (char *name, size_t size, unsigned id, int mq)
#endif #endif
int tun_create (char *dev_name, int mq) int tun_create (char *dev_name, char **ret_name, int mq)
{ {
char name[64]; char name[64] = {0};
int fd = -1; int fd = -1;
#ifndef IFF_MULTI_QUEUE #ifndef IFF_MULTI_QUEUE
@@ -148,8 +148,8 @@ int tun_create (char *dev_name, int mq)
fd = tun_create_by_name(name, sizeof(name), dev_name, mq); fd = tun_create_by_name(name, sizeof(name), dev_name, mq);
} }
if (fd!=-1) if (fd!=-1 && ret_name)
gt_print("tun name: %s\n", name); *ret_name = strdup(name);
return fd; return fd;
} }

View File

@@ -2,6 +2,6 @@
#include <unistd.h> #include <unistd.h>
int tun_create (char *, int); int tun_create (char *, char **, int);
ssize_t tun_read (int, void *, size_t); ssize_t tun_read (int, void *, size_t);
ssize_t tun_write (int, const void *, size_t); ssize_t tun_write (int, const void *, size_t);

View File

@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
[ -z "${VERSION}" ] && VERSION=`git describe --tags --always 2>/dev/null` \ [ -z "${VERSION}" ] && VERSION=`git describe --tags --match='v[0-9].*' 2>/dev/null` \
&& VERSION=${VERSION#v} && VERSION=${VERSION#v}
[ -z "${VERSION}" ] && VERSION=`cat VERSION 2>/dev/null` [ -z "${VERSION}" ] && VERSION=`cat VERSION 2>/dev/null`