Compare commits

..

71 Commits

Author SHA1 Message Date
Adrien Gallouët
d599e545f7 Update mud 2016-10-25 09:15:34 +00:00
Frank Denis
048870e280 <linux/if.h> is not required any more (#19) 2016-10-24 11:19:43 +02:00
Frank Denis
31045456fe include <net/if.h> for the ifreq structure (#18)
Required on BSD. Doesn't break anything elsewhere.
2016-10-23 12:38:32 +02:00
Adrien Gallouët
0bb5be63b9 Get ICMP type 3 to set the next-hop MTU 2016-10-18 16:44:20 +00:00
Adrien Gallouët
c9f737197c Remove multiqueue (not used with mud) 2016-10-05 09:49:14 +00:00
Adrien Gallouët
d4e70feddc Update mud 2016-10-05 08:02:48 +00:00
Adrien Gallouët
726a3eed13 Add MTU negotiation 2016-10-04 15:27:37 +00:00
Adrien Gallouët
caeed75918 Update mud 2016-09-21 16:17:20 +00:00
Adrien Gallouët
9a6795125d Update mud 2016-09-16 15:13:18 +00:00
Adrien Gallouët
db26fc5676 Update mud 2016-09-06 08:46:23 +00:00
Adrien Gallouët
05cc7b1087 Be more verbose when mud fails 2016-09-06 08:45:53 +00:00
Adrien Gallouët
6df1f9e243 Update mud 2016-09-05 09:31:34 +00:00
Adrien Gallouët
73ce84ccf7 Fixes #15 2016-08-26 11:19:52 +00:00
Adrien Gallouët
91bb0b1231 Forward tos/tclass to mud 2016-07-25 15:15:27 +00:00
Adrien Gallouët
84156a9eba Update mud 2016-07-20 15:15:11 +00:00
Adrien Gallouët
b13501b9fb Update mud 2016-07-19 16:53:53 +00:00
Adrien Gallouët
3363e219a7 Update mud 2016-07-15 18:45:36 +00:00
Adrien Gallouët
00ee23b0b6 Allow IPv4 and IPv6 only on Linux 2016-07-15 18:42:28 +00:00
Adrien Gallouët
1286b0f69e Update mud 2016-07-15 17:35:45 +00:00
Adrien Gallouët
fe5bc5454e Add chacha20 option and AES-NI negotiation 2016-07-12 17:01:41 +00:00
Adrien Gallouët
f4e94a9089 Remove -flto for now 2016-07-11 10:24:47 +00:00
Adrien Gallouët
6a7da371e2 Add .build.sh 2016-07-11 09:34:16 +00:00
Adrien Gallouët
4cf5f7a118 Update mud 2016-07-07 14:39:19 +00:00
Adrien Gallouët
35fd01f9ee Update mud 2016-07-06 13:42:30 +00:00
Adrien Gallouët
04aad57789 Update mud 2016-07-05 15:41:32 +00:00
Adrien Gallouët
7a277a8810 Update configure.ac 2016-06-30 09:52:34 +00:00
Adrien Gallouët
b232a101d2 Update mud 2016-06-30 09:41:32 +00:00
Adrien Gallouët
a01dc81500 Don't wait too long when we have data to send 2016-06-27 11:19:16 +00:00
Adrien Gallouët
1db628d84a Update mud 2016-06-24 13:21:02 +00:00
Adrien Gallouët
f11cd34dc4 Update mud 2016-06-22 17:55:18 +00:00
Adrien Gallouët
d0376e3aa5 Update mud 2016-06-22 09:18:34 +00:00
Adrien Gallouët
a7518c0e5a Update mud 2016-06-21 16:51:24 +00:00
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
10 changed files with 346 additions and 1327 deletions

15
.build.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/sh
export CC="gcc -static"
git clone https://github.com/jedisct1/libsodium --depth=1 --branch stable
cd libsodium || exit 1
./autogen.sh && ./configure --enable-minimal --disable-shared --prefix=/usr && make install
cd ..
./autogen.sh && ./configure && make
[ -x glorytun ] || exit 1
mkdir -p deploy
strip -s glorytun
mv glorytun deploy/glorytun-$(cat VERSION)-$(uname -m).bin

3
.gitmodules vendored Normal file
View File

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

View File

@@ -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 \

View File

@@ -1,6 +1,6 @@
# π₁(Glorytun)=ℤ²
Small, Simple and Stupid TCP VPN.
Small, Simple and Stupid VPN over [mud](https://github.com/angt/mud).
#### Work In Progress
@@ -8,11 +8,12 @@ This code will probably format your harddisk!
#### Build and Install
Glorytun depends on [libsodium](https://github.com/jedisct1/libsodium) version >= 1.0.4.
Glorytun depends on [libsodium](https://github.com/jedisct1/libsodium) version >= 1.0.4
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

View File

@@ -14,8 +14,9 @@ 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])
PKG_CHECK_MODULES([libsodium], [libsodium >= 1.0.4])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

1
mud Submodule

Submodule mud added at df0d941241

View File

@@ -4,6 +4,7 @@
struct ip_common {
uint8_t version;
uint8_t tc;
uint8_t proto;
uint8_t hdr_size;
uint16_t size;
@@ -24,11 +25,13 @@ 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;

1499
src/main.c

File diff suppressed because it is too large Load Diff

View File

@@ -11,8 +11,9 @@
#include <sys/socket.h>
#include <sys/uio.h>
#include <net/if.h>
#ifdef __linux__
#include <linux/if.h>
#include <linux/if_tun.h>
#endif
@@ -28,7 +29,7 @@
#ifdef __APPLE__
static int tun_create_by_id (char *name, size_t size, unsigned id, _unused_ int mq)
static int tun_create_by_id (char *name, size_t size, unsigned id)
{
int fd = socket(PF_SYSTEM, SOCK_DGRAM, SYSPROTO_CONTROL);
@@ -63,21 +64,21 @@ static int tun_create_by_id (char *name, size_t size, unsigned id, _unused_ int
return fd;
}
static int tun_create_by_name (char *name, size_t size, char *dev_name, int mq)
static int tun_create_by_name (char *name, size_t size, char *dev_name)
{
unsigned id = 0;
if (sscanf(dev_name, "utun%u", &id)!=1)
return -1;
return tun_create_by_id(name, size, id, mq);
return tun_create_by_id(name, size, id);
}
#else /* not __APPLE__ */
#ifdef __linux__
static int tun_create_by_name (char *name, size_t size, char *dev_name, int mq)
static int tun_create_by_name (char *name, size_t size, char *dev_name)
{
int fd = open("/dev/net/tun", O_RDWR);
@@ -88,12 +89,6 @@ static int tun_create_by_name (char *name, size_t size, char *dev_name, int mq)
.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)) {
@@ -108,7 +103,7 @@ static int tun_create_by_name (char *name, size_t size, char *dev_name, int mq)
#else /* not __linux__ not __APPLE__ */
static int tun_create_by_name (char *name, size_t size, char *dev_name, _unused_ int mq)
static int tun_create_by_name (char *name, size_t size, char *dev_name)
{
char path[64];
@@ -120,32 +115,27 @@ static int tun_create_by_name (char *name, size_t size, char *dev_name, _unused_
#endif /* not __APPLE__ */
static int tun_create_by_id (char *name, size_t size, unsigned id, int mq)
static int tun_create_by_id (char *name, size_t size, unsigned id)
{
char dev_name[64];
snprintf(dev_name, sizeof(dev_name), "tun%u", id);
return tun_create_by_name(name, size, dev_name, mq);
return tun_create_by_name(name, size, dev_name);
}
#endif
int tun_create (char *dev_name, char **ret_name, int mq)
int tun_create (char *dev_name, char **ret_name)
{
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, mq);
fd = tun_create_by_id(name, sizeof(name), id);
} else {
fd = tun_create_by_name(name, sizeof(name), dev_name, mq);
fd = tun_create_by_name(name, sizeof(name), dev_name);
}
if (fd!=-1 && ret_name)
@@ -240,3 +230,25 @@ 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,6 +2,7 @@
#include <unistd.h>
int tun_create (char *, char **, int);
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);