mirror of
https://github.com/yarrick/iodine.git
synced 2025-04-11 04:50:55 +00:00
Merge 93d83c7553
into acd6c37ac1
This commit is contained in:
commit
21b1d61131
10 changed files with 46 additions and 44 deletions
10
.gitignore
vendored
10
.gitignore
vendored
|
@ -1,5 +1,7 @@
|
||||||
bin/*
|
/bin/
|
||||||
*.o
|
*.o
|
||||||
src/base64u.c
|
/src/base64u.c
|
||||||
src/base64u.h
|
/src/base64u.h
|
||||||
tests/test
|
/tests/test
|
||||||
|
/src/iodine
|
||||||
|
/src/iodined
|
||||||
|
|
4
Makefile
4
Makefile
|
@ -14,7 +14,7 @@ MKDIR_FLAGS=-p
|
||||||
RM=rm
|
RM=rm
|
||||||
RM_FLAGS=-f
|
RM_FLAGS=-f
|
||||||
|
|
||||||
TARGETOS = `uname`
|
TARGETOS := $(shell uname)
|
||||||
|
|
||||||
all:
|
all:
|
||||||
@(cd src; $(MAKE) TARGETOS=$(TARGETOS) all)
|
@(cd src; $(MAKE) TARGETOS=$(TARGETOS) all)
|
||||||
|
@ -66,7 +66,7 @@ uninstall:
|
||||||
$(RM) $(RM_FLAGS) $(DESTDIR)$(sbindir)/iodine
|
$(RM) $(RM_FLAGS) $(DESTDIR)$(sbindir)/iodine
|
||||||
$(RM) $(RM_FLAGS) $(DESTDIR)$(sbindir)/iodined
|
$(RM) $(RM_FLAGS) $(DESTDIR)$(sbindir)/iodined
|
||||||
$(RM) $(RM_FLAGS) $(DESTDIR)$(mandir)/man8/iodine.8
|
$(RM) $(RM_FLAGS) $(DESTDIR)$(mandir)/man8/iodine.8
|
||||||
|
|
||||||
test: all
|
test: all
|
||||||
@echo "!! The check library is required for compiling and running the tests"
|
@echo "!! The check library is required for compiling and running the tests"
|
||||||
@echo "!! Get it at http://check.sf.net"
|
@echo "!! Get it at http://check.sf.net"
|
||||||
|
|
1
README
1
README
|
@ -251,6 +251,7 @@ quence, assuming at most one client will be connected at any time. A small
|
||||||
DNSCACHE_LEN is still advised, preferably 2 or higher, however you can also
|
DNSCACHE_LEN is still advised, preferably 2 or higher, however you can also
|
||||||
undefine it to save a few more kilobytes.
|
undefine it to save a few more kilobytes.
|
||||||
|
|
||||||
|
For systemd support on Debian, compile with libsystemd-daemon-dev installed.
|
||||||
|
|
||||||
PERFORMANCE:
|
PERFORMANCE:
|
||||||
|
|
||||||
|
|
11
man/iodine.8
11
man/iodine.8
|
@ -156,7 +156,7 @@ Usable range ca. 100 to 255.
|
||||||
Use this option to scale back upstream bandwidth in favor of downstream
|
Use this option to scale back upstream bandwidth in favor of downstream
|
||||||
bandwidth.
|
bandwidth.
|
||||||
Also useful for DNS servers that perform unreliably when using full-length
|
Also useful for DNS servers that perform unreliably when using full-length
|
||||||
hostnames, noticable when fragment size autoprobe returns very
|
hostnames, noticeable when fragment size autoprobe returns very
|
||||||
different results each time.
|
different results each time.
|
||||||
.TP
|
.TP
|
||||||
.B -T dnstype
|
.B -T dnstype
|
||||||
|
@ -235,7 +235,7 @@ connection after 60 seconds of inactivity.
|
||||||
.TP
|
.TP
|
||||||
.B -c
|
.B -c
|
||||||
Disable checking the client IP address on all incoming requests.
|
Disable checking the client IP address on all incoming requests.
|
||||||
By default, requests originating from non-matching IP adresses will be
|
By default, requests originating from non-matching IP addresses will be
|
||||||
rejected, however this will cause problems when requests are routed
|
rejected, however this will cause problems when requests are routed
|
||||||
via a cluster of DNS servers.
|
via a cluster of DNS servers.
|
||||||
.TP
|
.TP
|
||||||
|
@ -249,10 +249,10 @@ Increase debug level. Level 1 prints info about each RX/TX packet.
|
||||||
Implies the
|
Implies the
|
||||||
.B -f
|
.B -f
|
||||||
option.
|
option.
|
||||||
On level 2 (-DD) or higher, DNS queries will be printed literally.
|
On level 2 (\-DD) or higher, DNS queries will be printed literally.
|
||||||
When using Base128 upstream encoding, this is best viewed as
|
When using Base128 upstream encoding, this is best viewed as
|
||||||
ISO Latin-1 text instead of (illegal) UTF-8.
|
ISO Latin-1 text instead of (illegal) UTF-8.
|
||||||
This is easily done with : "LC_ALL=C luit iodined -DD ..."
|
This is easily done with : "LC_ALL=C luit iodined \-DD ..."
|
||||||
(see luit(1)).
|
(see luit(1)).
|
||||||
.TP
|
.TP
|
||||||
.B -m mtu
|
.B -m mtu
|
||||||
|
@ -312,7 +312,7 @@ must be the same on both the client and the server.
|
||||||
.B tunnel_ip[/netmask]
|
.B tunnel_ip[/netmask]
|
||||||
This is the server's ip address on the tun interface. The client will be
|
This is the server's ip address on the tun interface. The client will be
|
||||||
given the next ip number in the range. It is recommended to use the
|
given the next ip number in the range. It is recommended to use the
|
||||||
10.0.0.0 or 172.16.0.0 ranges. The default netmask is /27, can be overriden
|
10.0.0.0 or 172.16.0.0 ranges. The default netmask is /27, can be overridden
|
||||||
by specifying it here. Using a smaller network will limit the number of
|
by specifying it here. Using a smaller network will limit the number of
|
||||||
concurrent users.
|
concurrent users.
|
||||||
.TP
|
.TP
|
||||||
|
@ -354,7 +354,6 @@ is set, iodined will use the value it is set to as password instead of asking
|
||||||
for one. The
|
for one. The
|
||||||
.B -P
|
.B -P
|
||||||
option still has precedence.
|
option still has precedence.
|
||||||
.El
|
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
The README file in the source distribution contains some more elaborate
|
The README file in the source distribution contains some more elaborate
|
||||||
information.
|
information.
|
||||||
|
|
45
src/Makefile
45
src/Makefile
|
@ -4,45 +4,40 @@ CLIENT = ../bin/iodine
|
||||||
SERVEROBJS = iodined.o user.o fw_query.o
|
SERVEROBJS = iodined.o user.o fw_query.o
|
||||||
SERVER = ../bin/iodined
|
SERVER = ../bin/iodined
|
||||||
|
|
||||||
OS = `echo $(TARGETOS) | tr "a-z" "A-Z"`
|
OS := $(shell echo $(TARGETOS) | tr "a-z" "A-Z")
|
||||||
ARCH = `uname -m`
|
ARCH := $(shell uname -m)
|
||||||
HEAD_COMMIT = `git rev-parse --short HEAD`
|
HEAD_COMMIT := $(shell git rev-parse --short HEAD)
|
||||||
|
|
||||||
LIBPATH = -L.
|
LIBPATH = -L.
|
||||||
LDFLAGS += -lz `sh osflags $(TARGETOS) link` $(LIBPATH)
|
OS_CPPFLAGS := $(shell sh osflags $(TARGETOS) cppflags)
|
||||||
CFLAGS += -c -g -Wall -D$(OS) -pedantic `sh osflags $(TARGETOS) cflags` -DGITREVISION=\"$(HEAD_COMMIT)\"
|
OS_CFLAGS := $(shell sh osflags $(TARGETOS) cflags)
|
||||||
|
OS_LDFLAGS := $(shell sh osflags $(TARGETOS) link)
|
||||||
|
CPPFLAGS = -D$(OS) -DGITREVISION=\"$(HEAD_COMMIT)\" $(OS_CPPFLAGS)
|
||||||
|
CFLAGS += -g -Wall -pedantic $(OS_CFLAGS)
|
||||||
|
LDFLAGS += -lz $(OS_LDFLAGS) $(LIBPATH)
|
||||||
|
|
||||||
all: stateos $(CLIENT) $(SERVER)
|
all: stateos $(CLIENT) $(SERVER)
|
||||||
|
|
||||||
stateos:
|
stateos:
|
||||||
@echo OS is $(OS), arch is $(ARCH)
|
@echo OS is $(OS), arch is $(ARCH)
|
||||||
|
|
||||||
$(CLIENT): $(COMMONOBJS) $(CLIENTOBJS)
|
iodine: $(COMMONOBJS) $(CLIENTOBJS)
|
||||||
@echo LD $@
|
iodined: $(COMMONOBJS) $(SERVEROBJS)
|
||||||
@mkdir -p ../bin
|
$(CLIENT): iodine; mkdir -p ../bin && cp -a $< $@
|
||||||
@$(CC) $(COMMONOBJS) $(CLIENTOBJS) -o $(CLIENT) $(LDFLAGS)
|
$(SERVER): iodined; mkdir -p ../bin && cp -a $< $@
|
||||||
|
|
||||||
$(SERVER): $(COMMONOBJS) $(SERVEROBJS)
|
|
||||||
@echo LD $@
|
|
||||||
@mkdir -p ../bin
|
|
||||||
@$(CC) $(COMMONOBJS) $(SERVEROBJS) -o $(SERVER) $(LDFLAGS)
|
|
||||||
|
|
||||||
.c.o:
|
|
||||||
@echo CC $<
|
|
||||||
@$(CC) $(CFLAGS) $< -o $@
|
|
||||||
|
|
||||||
base64u.o client.o iodined.o: base64u.h
|
base64u.o client.o iodined.o: base64u.h
|
||||||
base64u.c: base64.c
|
base64u.c: base64.c
|
||||||
@echo Making $@
|
@echo Making $@
|
||||||
@echo '/* No use in editing, produced by Makefile! */' > $@
|
echo '/* No use in editing, produced by Makefile! */' > $@
|
||||||
@sed -e 's/\([Bb][Aa][Ss][Ee]64\)/\1u/g ; s/0123456789+/0123456789_/' < base64.c >> $@
|
sed -e 's/\([Bb][Aa][Ss][Ee]64\)/\1u/g ; s/0123456789+/0123456789_/' < base64.c >> $@
|
||||||
base64u.h: base64.h
|
base64u.h: base64.h
|
||||||
@echo Making $@
|
@echo Making $@
|
||||||
@echo '/* No use in editing, produced by Makefile! */' > $@
|
echo '/* No use in editing, produced by Makefile! */' > $@
|
||||||
@sed -e 's/\([Bb][Aa][Ss][Ee]64\)/\1u/g ; s/0123456789+/0123456789_/' < base64.h >> $@
|
sed -e 's/\([Bb][Aa][Ss][Ee]64\)/\1u/g ; s/0123456789+/0123456789_/' < base64.h >> $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@echo "Cleaning src/"
|
@echo "Cleaning src/"
|
||||||
@rm -f $(CLIENT){,.exe} $(SERVER){,.exe} *~ *.o *.core base64u.*
|
rm -f iodine iodined
|
||||||
@rm -rf obj libs #android stuff
|
rm -f $(CLIENT){,.exe} $(SERVER){,.exe} *~ *.o *.core base64u.*
|
||||||
|
rm -rf obj libs #android stuff
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
|
|
||||||
int dnsc_use_edns0 = 1;
|
int dnsc_use_edns0 = 1;
|
||||||
|
|
||||||
#define CHECKLEN(x) if (buflen - (p-buf) < (x)) return 0
|
#define CHECKLEN(x) if (buflen < (x) + (unsigned)(p-buf)) return 0
|
||||||
|
|
||||||
int
|
int
|
||||||
dns_encode(char *buf, size_t buflen, struct query *q, qr_t qr, char *data, size_t datalen)
|
dns_encode(char *buf, size_t buflen, struct query *q, qr_t qr, char *data, size_t datalen)
|
||||||
|
@ -391,7 +391,7 @@ dns_get_id(char *packet, size_t packetlen)
|
||||||
return ntohs(header->id);
|
return ntohs(header->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHECKLEN(x) if (packetlen - (data-packet) < (x)) return 0
|
#define CHECKLEN(x) if (packetlen < (x) + (unsigned)(data-packet)) return 0
|
||||||
|
|
||||||
int
|
int
|
||||||
dns_decode(char *buf, size_t buflen, struct query *q, qr_t qr, char *packet, size_t packetlen)
|
dns_decode(char *buf, size_t buflen, struct query *q, qr_t qr, char *packet, size_t packetlen)
|
||||||
|
|
|
@ -26,7 +26,7 @@ build_hostname(char *buf, size_t buflen,
|
||||||
size_t space;
|
size_t space;
|
||||||
char *b;
|
char *b;
|
||||||
|
|
||||||
space = MIN(maxlen, buflen) - strlen(topdomain) - 8;
|
space = MIN((size_t)maxlen, buflen) - strlen(topdomain) - 8;
|
||||||
/* 8 = 5 max header length + 1 dot before topdomain + 2 safety */
|
/* 8 = 5 max header length + 1 dot before topdomain + 2 safety */
|
||||||
|
|
||||||
if (!encoder->places_dots())
|
if (!encoder->places_dots())
|
||||||
|
|
|
@ -25,6 +25,8 @@ link)
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
cflags)
|
cflags)
|
||||||
|
;;
|
||||||
|
cppflags)
|
||||||
case $1 in
|
case $1 in
|
||||||
windows32)
|
windows32)
|
||||||
echo '-DWINVER=0x0501';
|
echo '-DWINVER=0x0501';
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
#include "encoding.h"
|
#include "encoding.h"
|
||||||
#include "user.h"
|
#include "user.h"
|
||||||
|
|
||||||
struct tun_user *users;
|
struct _user *users;
|
||||||
unsigned usercount;
|
unsigned usercount;
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -59,7 +59,7 @@ init_users(in_addr_t my_ip, int netbits)
|
||||||
maxusers = (1 << (32-netbits)) - 3; /* 3: Net addr, broadcast addr, iodined addr */
|
maxusers = (1 << (32-netbits)) - 3; /* 3: Net addr, broadcast addr, iodined addr */
|
||||||
usercount = MIN(maxusers, USERS);
|
usercount = MIN(maxusers, USERS);
|
||||||
|
|
||||||
users = calloc(usercount, sizeof(struct tun_user));
|
users = calloc(usercount, sizeof(struct _user));
|
||||||
for (i = 0; i < usercount; i++) {
|
for (i = 0; i < usercount; i++) {
|
||||||
in_addr_t ip;
|
in_addr_t ip;
|
||||||
users[i].id = i;
|
users[i].id = i;
|
||||||
|
|
|
@ -33,7 +33,10 @@
|
||||||
#define QMEMDATA_LEN 15
|
#define QMEMDATA_LEN 15
|
||||||
/* Max advisable: 36/2 = 18. Total mem usage: QMEMDATA_LEN * USERS * 6 bytes */
|
/* Max advisable: 36/2 = 18. Total mem usage: QMEMDATA_LEN * USERS * 6 bytes */
|
||||||
|
|
||||||
struct tun_user {
|
/* Renamed to struct _user to avoid naming conflict with struct user found in <sys/user.h>
|
||||||
|
* which gets included in some builds (armel) */
|
||||||
|
|
||||||
|
struct _user {
|
||||||
char id;
|
char id;
|
||||||
int active;
|
int active;
|
||||||
int disabled;
|
int disabled;
|
||||||
|
@ -73,7 +76,7 @@ struct tun_user {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct tun_user *users;
|
extern struct _user *users;
|
||||||
|
|
||||||
int init_users(in_addr_t, int);
|
int init_users(in_addr_t, int);
|
||||||
const char* users_get_first_ip();
|
const char* users_get_first_ip();
|
||||||
|
|
Loading…
Add table
Reference in a new issue