mirror of
https://github.com/haad/proxychains.git
synced 2026-09-13 18:45:50 +05:00
Add some more code checking to CCFLAGS, remove unnecessary ifdef's
This commit is contained in:
parent
1471c5756f
commit
d9341a8c74
6
Makefile
6
Makefile
@ -16,7 +16,7 @@ SRCS = $(sort $(wildcard src/*.c))
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
LOBJS = src/core.o src/libproxychains.o
|
||||
|
||||
CFLAGS += -Wall -O0 -g -std=c99 -D_GNU_SOURCE -pipe -DTHREAD_SAFE
|
||||
CCFLAGS = -Wall -O0 -g -std=c99 -D_GNU_SOURCE -pipe -DTHREAD_SAFE -Werror -Wextra
|
||||
LDFLAGS = -shared -fPIC -ldl -lpthread
|
||||
INC =
|
||||
PIC = -fPIC
|
||||
@ -32,7 +32,7 @@ ALL_TOOLS = $(PXCHAINS)
|
||||
|
||||
-include config.mak
|
||||
|
||||
CFLAGS+=$(USER_CFLAGS)
|
||||
CCFLAGS+=$(USER_CFLAGS)
|
||||
CFLAGS_MAIN=-DLIB_DIR=\"$(libdir)\"
|
||||
|
||||
|
||||
@ -50,7 +50,7 @@ clean:
|
||||
rm -f $(OBJS)
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) $(CFLAGS_MAIN) $(INC) $(PIC) -c -o $@ $<
|
||||
$(CC) $(CCFLAGS) $(CFLAGS_MAIN) $(INC) $(PIC) -c -o $@ $<
|
||||
|
||||
$(LDSO_PATHNAME): $(LOBJS)
|
||||
$(CC) $(LDFLAGS) -Wl,-soname=$(LDSO_PATHNAME) -o $@ $(LOBJS)
|
||||
|
||||
@ -112,7 +112,6 @@ int connect_proxy_chain (
|
||||
int proxychains_write_log(char *str,...);
|
||||
struct hostent* proxy_gethostbyname(const char *name);
|
||||
|
||||
|
||||
typedef int (*connect_t)(int, const struct sockaddr *, socklen_t);
|
||||
connect_t true_connect;
|
||||
|
||||
|
||||
@ -18,20 +18,21 @@
|
||||
#undef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <netdb.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <netdb.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <fcntl.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
|
||||
#include "core.h"
|
||||
#include "common.h"
|
||||
@ -45,21 +46,27 @@
|
||||
|
||||
int tcp_read_time_out;
|
||||
int tcp_connect_time_out;
|
||||
chain_type proxychains_ct;
|
||||
proxy_data proxychains_pd[MAX_CHAIN];
|
||||
unsigned int proxychains_proxy_count = 0;
|
||||
int proxychains_got_chain_data = 0;
|
||||
unsigned int proxychains_max_chain = 1;
|
||||
int proxychains_quiet_mode = 0;
|
||||
int proxychains_resolver = 0;
|
||||
static int init_l = 0;
|
||||
|
||||
unsigned int proxychains_proxy_count = 0;
|
||||
unsigned int proxychains_max_chain = 1;
|
||||
|
||||
localaddr_arg localnet_addr[MAX_LOCALNET];
|
||||
chain_type proxychains_ct;
|
||||
proxy_data proxychains_pd[MAX_CHAIN];
|
||||
|
||||
size_t num_localnet_addr = 0;
|
||||
|
||||
static inline void get_chain_data(proxy_data *pd, unsigned int *proxy_count,
|
||||
chain_type *ct);
|
||||
static void init_lib(void);
|
||||
|
||||
/*
|
||||
* Initialize libproxychains.
|
||||
*/
|
||||
static void init_lib(void)
|
||||
{
|
||||
#ifdef THREAD_SAFE
|
||||
@ -76,16 +83,12 @@ static void init_lib(void)
|
||||
fprintf(stderr, "Cannot load symbol 'connect' %s\n", dlerror());
|
||||
exit(1);
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
PDEBUG( "loaded symbol 'connect'"
|
||||
" real addr %p wrapped addr %p\n",
|
||||
true_connect, connect);
|
||||
#endif
|
||||
PDEBUG( "loaded symbol 'connect' real addr %p wrapped addr %p\n",
|
||||
true_connect, connect);
|
||||
}
|
||||
|
||||
if(connect==true_connect) {
|
||||
#ifdef DEBUG
|
||||
PDEBUG("circular reference detected, aborting!\n");
|
||||
#endif
|
||||
abort();
|
||||
}
|
||||
|
||||
@ -97,11 +100,9 @@ static void init_lib(void)
|
||||
dlerror());
|
||||
exit(1);
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
PDEBUG( "loaded symbol 'gethostbyname'"
|
||||
" real addr %p wrapped addr %p\n",
|
||||
true_gethostbyname, gethostbyname);
|
||||
#endif
|
||||
" real addr %p wrapped addr %p\n",
|
||||
true_gethostbyname, gethostbyname);
|
||||
}
|
||||
true_getaddrinfo = (getaddrinfo_t)
|
||||
dlsym(RTLD_NEXT, "getaddrinfo");
|
||||
@ -111,11 +112,9 @@ static void init_lib(void)
|
||||
dlerror());
|
||||
exit(1);
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
PDEBUG( "loaded symbol 'getaddrinfo'"
|
||||
" real addr %p wrapped addr %p\n",
|
||||
true_getaddrinfo, getaddrinfo);
|
||||
#endif
|
||||
}
|
||||
true_freeaddrinfo = (freeaddrinfo_t)
|
||||
dlsym(RTLD_NEXT, "freeaddrinfo");
|
||||
@ -125,11 +124,9 @@ static void init_lib(void)
|
||||
dlerror());
|
||||
exit(1);
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
PDEBUG( "loaded symbol 'freeaddrinfo'"
|
||||
" real addr %p wrapped addr %p\n",
|
||||
true_freeaddrinfo, freeaddrinfo);
|
||||
#endif
|
||||
}
|
||||
true_gethostbyaddr = (gethostbyaddr_t)
|
||||
dlsym(RTLD_NEXT, "gethostbyaddr");
|
||||
@ -139,11 +136,9 @@ static void init_lib(void)
|
||||
dlerror());
|
||||
exit(1);
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
PDEBUG( "loaded symbol 'gethostbyaddr'"
|
||||
" real addr %p wrapped addr %p\n",
|
||||
true_gethostbyaddr, gethostbyaddr);
|
||||
#endif
|
||||
}
|
||||
true_getnameinfo = (getnameinfo_t)
|
||||
dlsym(RTLD_NEXT, "getnameinfo");
|
||||
@ -153,11 +148,9 @@ static void init_lib(void)
|
||||
dlerror());
|
||||
exit(1);
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
PDEBUG( "loaded symbol 'getnameinfo'"
|
||||
" real addr %p wrapped addr %p\n",
|
||||
true_getnameinfo, getnameinfo);
|
||||
#endif
|
||||
}
|
||||
init_l = 1;
|
||||
}
|
||||
@ -254,10 +247,10 @@ static inline void get_chain_data(
|
||||
|
||||
if (sscanf(local_in_addr_port, "%15[^:]:%5s",
|
||||
local_in_addr, local_in_port) < 2) {
|
||||
PDEBUG("added localnet: netaddr=%s, port=%s\n",
|
||||
local_in_addr, local_netmask);
|
||||
PDEBUG("added localnet: netaddr=%s, port=%s\n",
|
||||
local_in_addr, local_netmask);
|
||||
} else {
|
||||
PDEBUG("added localnet: netaddr=%s, port=%s, netmask=%s\n",
|
||||
PDEBUG("added localnet: netaddr=%s, port=%s, netmask=%s\n",
|
||||
local_in_addr, local_in_port, local_netmask);
|
||||
}
|
||||
if (num_localnet_addr < MAX_LOCALNET)
|
||||
@ -306,7 +299,7 @@ static inline void get_chain_data(
|
||||
|
||||
|
||||
|
||||
int connect (int sock, const struct sockaddr *addr, unsigned int len)
|
||||
int connect (int sock, const struct sockaddr *addr, socklen_t len)
|
||||
{
|
||||
int socktype=0, flags=0, ret=0;
|
||||
socklen_t optlen = 0;
|
||||
@ -501,4 +494,3 @@ struct hostent *gethostbyaddr (const void *addr, socklen_t len, int type)
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -18,12 +18,15 @@
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#undef _XOPEN_SOURCE
|
||||
#define _XOPEN_SOURCE 700
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
extern char *optarg;
|
||||
@ -45,6 +48,7 @@ int check_path(char* path) {
|
||||
return access(path, R_OK) != -1;
|
||||
}
|
||||
|
||||
/* XXX This shouldn't be defined here */
|
||||
static const char* dll_name = "libproxychains4.so";
|
||||
|
||||
static char own_dir[256];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user