Compare commits

..

16 Commits

Author SHA1 Message Date
Adrien Gallouët
cfd7af9241 Add .build.sh 2016-07-11 11:13:29 +00:00
Adrien Gallouët
c81592fcc5 Don't fd_set_nonblock(-1) 2016-06-23 12:15:01 +00:00
Adrien Gallouët
b4a311cdc8 Check for clock_gettime() 2016-06-15 14:12:21 +00:00
Adrien Gallouët
08617d0017 Fix macosx build 2016-06-15 14:01:20 +00:00
Adrien Gallouët
38cd3b0371 Try to do a more accurate bench 2016-06-15 09:20:18 +00:00
Adrien Gallouët
5944e61dfe Fix bench output 2016-06-15 09:10:57 +00:00
Adrien Gallouët
585b2b08bc Be more verbose on kx errors 2016-06-06 13:37:05 +00:00
angt
a3aa6fc4fb Add option bench 2016-06-02 13:44:24 +00:00
angt
6f36424d12 Code cleanup 2016-04-26 06:18:12 +00:00
angt
fa9301da16 Show tun_name in all states and fix state_send() 2016-04-26 06:13:14 +00:00
angt
c154a00358 Use a bigger timeout when buffers are empty 2016-04-12 14:11:16 +00:00
Adrien Gallouët
4246b510d2 Never trust frank :) 2016-03-30 15:41:53 +02:00
Adrien Gallouët
c71db48ae1 Add a nice geek logo for glorytun 2016-03-23 17:44:40 +01:00
Adrien Gallouët
e3cce8aeb9 AES-NI is no longer mandatory 2016-03-18 21:19:24 +01:00
angt
ad0d205ff3 Add option chacha20
Chacha20 will be automatically used if aesni is not available.
2016-03-18 14:43:30 +00:00
angt
030087cb27 Add mptcp option 2016-02-25 14:38:51 +00:00
9 changed files with 1356 additions and 268 deletions

3
.gitmodules vendored
View File

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

View File

@@ -20,11 +20,6 @@ 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 \

View File

@@ -1,6 +1,6 @@
# π₁(Glorytun)=ℤ²
Small, Simple and Stupid VPN over [mud](https://github.com/angt/mud).
Small, Simple and Stupid TCP VPN.
#### Work In Progress
@@ -8,12 +8,11 @@ This code will probably format your harddisk!
#### Build and Install
Glorytun depends on [libsodium](https://github.com/jedisct1/libsodium) version >= 1.0.4
and needs an AES-NI capable CPU.
Glorytun depends on [libsodium](https://github.com/jedisct1/libsodium) version >= 1.0.4.
To build and install the latest version:
$ git clone https://github.com/angt/glorytun --recursive --branch mud
$ git clone https://github.com/angt/glorytun
$ cd glorytun
$ ./autogen.sh
$ ./configure

View File

@@ -14,6 +14,7 @@ AM_SILENT_RULES([yes])
AM_PROG_CC_C_O
AC_PROG_CC_C99
AC_USE_SYSTEM_EXTENSIONS
AC_SEARCH_LIBS([getaddrinfo], [resolv nsl])
AC_SEARCH_LIBS([socket], [socket])
AC_CHECK_LIB([rt], [clock_gettime])
AC_CHECK_FUNCS([clock_gettime])

1
mud

Submodule mud deleted from e1fd7f8b0d

View File

@@ -4,7 +4,6 @@
struct ip_common {
uint8_t version;
uint8_t tc;
uint8_t proto;
uint8_t hdr_size;
uint16_t size;
@@ -25,13 +24,11 @@ static inline int ip_get_common (struct ip_common *ic, const uint8_t *data, size
switch (ic->version) {
case 4:
ic->tc = data[1];
ic->proto = data[9];
ic->hdr_size = (data[0]&0xF)<<2;
ic->size = ((data[2]<<8)|data[3]);
return 0;
case 6:
ic->tc = ((data[0]&0xF)<<4)|(data[1]>>4);
ic->proto = data[6];
ic->hdr_size = 40;
ic->size = ((data[4]<<8)|data[5])+40;

1541
src/main.c

File diff suppressed because it is too large Load Diff

View File

@@ -11,9 +11,8 @@
#include <sys/socket.h>
#include <sys/uio.h>
#include <net/if.h>
#ifdef __linux__
#include <linux/if.h>
#include <linux/if_tun.h>
#endif
@@ -29,7 +28,7 @@
#ifdef __APPLE__
static int tun_create_by_id (char *name, size_t size, unsigned id)
static int tun_create_by_id (char *name, size_t size, unsigned id, _unused_ int mq)
{
int fd = socket(PF_SYSTEM, SOCK_DGRAM, SYSPROTO_CONTROL);
@@ -64,21 +63,21 @@ static int tun_create_by_id (char *name, size_t size, unsigned id)
return fd;
}
static int tun_create_by_name (char *name, size_t size, char *dev_name)
static int tun_create_by_name (char *name, size_t size, char *dev_name, int mq)
{
unsigned id = 0;
if (sscanf(dev_name, "utun%u", &id)!=1)
return -1;
return tun_create_by_id(name, size, id);
return tun_create_by_id(name, size, id, mq);
}
#else /* not __APPLE__ */
#ifdef __linux__
static int tun_create_by_name (char *name, size_t size, char *dev_name)
static int tun_create_by_name (char *name, size_t size, char *dev_name, int mq)
{
int fd = open("/dev/net/tun", O_RDWR);
@@ -89,6 +88,12 @@ static int tun_create_by_name (char *name, size_t size, char *dev_name)
.ifr_flags = IFF_TUN|IFF_NO_PI,
};
if (mq) {
#ifdef IFF_MULTI_QUEUE
ifr.ifr_flags |= IFF_MULTI_QUEUE;
#endif
}
str_cpy(ifr.ifr_name, dev_name, IFNAMSIZ-1);
if (ioctl(fd, TUNSETIFF, &ifr)) {
@@ -103,7 +108,7 @@ static int tun_create_by_name (char *name, size_t size, char *dev_name)
#else /* not __linux__ not __APPLE__ */
static int tun_create_by_name (char *name, size_t size, char *dev_name)
static int tun_create_by_name (char *name, size_t size, char *dev_name, _unused_ int mq)
{
char path[64];
@@ -115,27 +120,32 @@ static int tun_create_by_name (char *name, size_t size, char *dev_name)
#endif /* not __APPLE__ */
static int tun_create_by_id (char *name, size_t size, unsigned id)
static int tun_create_by_id (char *name, size_t size, unsigned id, int mq)
{
char dev_name[64];
snprintf(dev_name, sizeof(dev_name), "tun%u", id);
return tun_create_by_name(name, size, dev_name);
return tun_create_by_name(name, size, dev_name, mq);
}
#endif
int tun_create (char *dev_name, char **ret_name)
int tun_create (char *dev_name, char **ret_name, int mq)
{
char name[64] = {0};
int fd = -1;
#ifndef IFF_MULTI_QUEUE
if (mq)
gt_na("IFF_MULTI_QUEUE");
#endif
if (str_empty(dev_name)) {
for (unsigned id=0; id<32 && fd==-1; id++)
fd = tun_create_by_id(name, sizeof(name), id);
fd = tun_create_by_id(name, sizeof(name), id, mq);
} else {
fd = tun_create_by_name(name, sizeof(name), dev_name);
fd = tun_create_by_name(name, sizeof(name), dev_name, mq);
}
if (fd!=-1 && ret_name)
@@ -230,25 +240,3 @@ ssize_t tun_write (int fd, const void *data, size_t size)
return ret;
#endif
}
int tun_set_mtu (char *dev_name, int mtu)
{
struct ifreq ifr = {
.ifr_mtu = mtu,
};
str_cpy(ifr.ifr_name, dev_name, IFNAMSIZ-1);
int fd = socket(AF_INET, SOCK_DGRAM, 0);
if (fd==-1)
return -1;
int ret = ioctl(fd, SIOCSIFMTU, &ifr);
int err = errno;
close(fd);
errno = err;
return ret;
}

View File

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