Compare commits
39 Commits
v0.0.23
...
v0.0.31-mu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6adcefc25 | ||
|
|
743b0ee0da | ||
|
|
ba06a6fc10 | ||
|
|
80d4c2814f | ||
|
|
b0d5007bfb | ||
|
|
d2046eb00b | ||
|
|
d04acc9c0f | ||
|
|
03cd87df1c | ||
|
|
8e8ad7178d | ||
|
|
0e26b4def7 | ||
|
|
f800985766 | ||
|
|
7b88c28a45 | ||
|
|
194dfe17d3 | ||
|
|
664160e0cc | ||
|
|
1dd760e382 | ||
|
|
05219b81f7 | ||
|
|
0bb7e4f1d0 | ||
|
|
a7fbf806fb | ||
|
|
e750c46665 | ||
|
|
935111cfea | ||
|
|
c4b2512df4 | ||
|
|
27970e24fb | ||
|
|
acc3ee3461 | ||
|
|
eefa7722c5 | ||
|
|
17547f555d | ||
|
|
ec9c59ce69 | ||
|
|
679927a684 | ||
|
|
2999faf5d7 | ||
|
|
219384b7e5 | ||
|
|
3649e46b03 | ||
|
|
88f314bc75 | ||
|
|
e2b3dc1b46 | ||
|
|
1815ea519f | ||
|
|
33356d5d35 | ||
|
|
4a5d07ec45 | ||
|
|
a50882e1ac | ||
|
|
b2cb8ebcbe | ||
|
|
6fd6cf8c4a | ||
|
|
f0fc2751e5 |
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
|
||||
@@ -16,7 +16,14 @@ glorytun_SOURCES = \
|
||||
src/tun.c \
|
||||
src/tun.h \
|
||||
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 = \
|
||||
LICENSE \
|
||||
|
||||
@@ -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 85367eff80
19
src/buffer.h
19
src/buffer.h
@@ -49,15 +49,18 @@ static inline size_t buffer_read_size (buffer_t *buffer)
|
||||
|
||||
static inline void buffer_shift (buffer_t *buffer)
|
||||
{
|
||||
if (buffer->read==buffer->data)
|
||||
return;
|
||||
|
||||
if (buffer->read==buffer->write) {
|
||||
buffer_format(buffer);
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const size_t size = buffer_read_size(buffer);
|
||||
|
||||
memmove(buffer->data, buffer->read, size);
|
||||
|
||||
buffer->read = buffer->data;
|
||||
buffer->write = buffer->data+size;
|
||||
}
|
||||
|
||||
1270
src/main.c
1270
src/main.c
File diff suppressed because it is too large
Load Diff
61
src/state.c
Normal file
61
src/state.c
Normal file
@@ -0,0 +1,61 @@
|
||||
#include "common.h"
|
||||
|
||||
#include "state.h"
|
||||
#include "str.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
static int state_fd = -1;
|
||||
|
||||
int state_init (const char *filename)
|
||||
{
|
||||
if (str_empty(filename))
|
||||
return 0;
|
||||
|
||||
state_fd = open(filename, O_WRONLY);
|
||||
|
||||
if (state_fd==-1) {
|
||||
if (errno!=EINTR)
|
||||
perror("open");
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct stat st = {0};
|
||||
|
||||
if (fstat(state_fd, &st)==-1) {
|
||||
perror("fstat");
|
||||
close(state_fd);
|
||||
state_fd = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!S_ISFIFO(st.st_mode)) {
|
||||
gt_log("`%s' is not a fifo\n", filename);
|
||||
close(state_fd);
|
||||
state_fd = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void state (const char *state, const char *info)
|
||||
{
|
||||
if (str_empty(state))
|
||||
return;
|
||||
|
||||
const char *strs[] = { state, " ", info, "\n" };
|
||||
char *str = str_cat(strs, COUNT(strs));
|
||||
|
||||
if (!str)
|
||||
return;
|
||||
|
||||
if (state_fd==-1) {
|
||||
gt_print("%s", str);
|
||||
} else {
|
||||
if (write(state_fd, str, str_len(str))==-1 && errno!=EINTR)
|
||||
perror("write");
|
||||
}
|
||||
}
|
||||
4
src/state.h
Normal file
4
src/state.h
Normal file
@@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
int state_init (const char *);
|
||||
void state (const char *, const char *);
|
||||
@@ -47,7 +47,7 @@ static inline size_t str_len (const char *restrict 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;
|
||||
|
||||
|
||||
@@ -131,9 +131,9 @@ static int tun_create_by_id (char *name, size_t size, unsigned id, int mq)
|
||||
|
||||
#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;
|
||||
|
||||
#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);
|
||||
}
|
||||
|
||||
if (fd!=-1)
|
||||
gt_print("tun name: %s\n", name);
|
||||
if (fd!=-1 && ret_name)
|
||||
*ret_name = strdup(name);
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
#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_write (int, const void *, size_t);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/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}
|
||||
|
||||
[ -z "${VERSION}" ] && VERSION=`cat VERSION 2>/dev/null`
|
||||
|
||||
Reference in New Issue
Block a user