Skip to content

Commit

Permalink
Added config.h support & autogeneration.
Browse files Browse the repository at this point in the history
  • Loading branch information
darkk authored and darkk committed Feb 1, 2008
1 parent 0d815b0 commit c610a14
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions .svnignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
libevent-*
*.o
config.h
tags
redsocks
17 changes: 15 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CFLAGS=-std=gnu99 -Wall -g
CFLAGS=-std=gnu99 -Wall -g -O0

.PHONY: all
redsocks: parser.o main.o redsocks.o log.o http-connect.o socks4.o socks5.o base.o
Expand All @@ -9,11 +9,24 @@ tags: *.c *.h

.PHONY: clean distclean
clean:
rm -f redsocks *.o
rm -f redsocks config.h *.o

distclean: clean
rm -f tags

base.c: config.h

config.h:
case `uname` in \
Linux*) \
echo "#define USE_IPTABLES" > config.h \
;; \
*) \
echo "Unknown system, only generic firewall code is compiled" 1>&2 \
echo "/* Unknown system, only generic firewall code is compiled */" > config.h \
;; \
esac

%.o: %.c
$(CC) $(CFLAGS) -c $*.c -o $*.o

Expand Down
9 changes: 7 additions & 2 deletions base.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
#include <string.h>
#include <pwd.h>
#include <grp.h>
#include "config.h"
#if defined USE_IPTABLES
# include <limits.h>
# include <linux/netfilter_ipv4.h>
#endif
#include "log.h"
#include "main.h"
#include "parser.h"
Expand Down Expand Up @@ -149,7 +154,7 @@ static int getdestaddr_pf(int fd, const struct sockaddr_in *client, const struct
}
#endif

#ifdef __LINUX__
#ifdef USE_IPTABLES
static int getdestaddr_iptables(int fd, const struct sockaddr_in *client, const struct sockaddr_in *bindaddr, struct sockaddr_in *destaddr)
{
socklen_t socklen = sizeof(*destaddr);
Expand Down Expand Up @@ -190,7 +195,7 @@ static redirector_subsys redirector_subsystems[] =
#ifdef __OpenBSD__
{ .name = "pf", .init = redir_init_pf, .fini = redir_close_private, .getdestaddr = getdestaddr_pf },
#endif
#ifdef __LINUX__
#ifdef USE_IPTABLES
{ .name = "iptables", .getdestaddr = getdestaddr_iptables },
#endif
{ .name = "generic", .getdestaddr = getdestaddr_generic },
Expand Down

0 comments on commit c610a14

Please sign in to comment.