Fix deadcode / warnings / minor bugs

This commit is contained in:
Vladimir Dubrovin 2026-07-31 18:55:59 +03:00
parent 44c47ee7d9
commit 4877b39f2c
24 changed files with 49 additions and 145 deletions

View File

@ -236,6 +236,12 @@ else()
) )
endif() endif()
# Unix domain sockets off: NO_UN also undefines WITH_UN if it arrives from
# elsewhere, e.g. CFLAGS
if(NOT 3PROXY_USE_UNIX_SOCKETS)
add_compile_definitions(NO_UN)
endif()
# Common definitions # Common definitions
if(WIN32) if(WIN32)
# Windows: use WSAPOLL # Windows: use WSAPOLL

View File

@ -8,7 +8,7 @@ BUILDDIR = ../bin/
PREFIX = 3proxy_ PREFIX = 3proxy_
CRYPT_PREFIX = 3proxy_ CRYPT_PREFIX = 3proxy_
CC = cl CC = cl
CFLAGS = /nologo /Ox /MT /D "NOIPV6" /D "NODEBUG" /D "NORADIUS" /D"WATCOM" /D "MSVC" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "PRId64=\"I64d\"" /D "PRIu64=\"I64u\"" /D "SCNu64=\"I64u\"" /D "SCNx64=\"I64x\"" /D "SCNd64=\"I64d\"" /D "PRIx64=\"I64x\"" /c $(VERSION) $(BUILDDATE) CFLAGS = /nologo /Ox /MT /D "NOIPV6" /D "NO_UN" /D "NODEBUG" /D "NORADIUS" /D"WATCOM" /D "MSVC" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "PRId64=\"I64d\"" /D "PRIu64=\"I64u\"" /D "SCNu64=\"I64u\"" /D "SCNx64=\"I64x\"" /D "SCNd64=\"I64d\"" /D "PRIx64=\"I64x\"" /c $(VERSION) $(BUILDDATE)
COUT = /Fo COUT = /Fo
LN = link LN = link
LDFLAGS = /nologo /subsystem:console /incremental:no LDFLAGS = /nologo /subsystem:console /incremental:no

View File

@ -80,7 +80,7 @@ int cacheauth(struct clientparam * param){
((type & 4) && !param->password) || ((type & 4) && !param->password) ||
( (
(type & 1) && *SAFAMILY(&param->sincr) != AF_INET (type & 1) && *SAFAMILY(&param->sincr) != AF_INET
#ifndef NOIPv6 #ifndef NOIPV6
&& *SAFAMILY(&param->sincr) != AF_INET6 && *SAFAMILY(&param->sincr) != AF_INET6
#endif #endif
) || (!hashresolv(&auth_table, param, &ac, &ttl))) { ) || (!hashresolv(&auth_table, param, &ac, &ttl))) {
@ -108,7 +108,6 @@ int cacheauth(struct clientparam * param){
int doauth(struct clientparam * param){ int doauth(struct clientparam * param){
int res = 0; int res = 0;
struct auth *authfuncs; struct auth *authfuncs;
char * tmp;
int ret = 0; int ret = 0;
for(authfuncs=param->srv->authfuncs; authfuncs; authfuncs=authfuncs->next){ for(authfuncs=param->srv->authfuncs; authfuncs; authfuncs=authfuncs->next){
@ -125,7 +124,7 @@ int doauth(struct clientparam * param){
ac.username[63] = 0; ac.username[63] = 0;
} }
if(*SAFAMILY(&param->sincr) == AF_INET if(*SAFAMILY(&param->sincr) == AF_INET
#ifndef NOIPv6 #ifndef NOIPV6
|| *SAFAMILY(&param->sincr) == AF_INET6 || *SAFAMILY(&param->sincr) == AF_INET6
#endif #endif
) { ) {
@ -134,7 +133,7 @@ int doauth(struct clientparam * param){
} }
if(*SAFAMILY(&param->sinsl) == AF_INET if(*SAFAMILY(&param->sinsl) == AF_INET
#ifndef NOIPv6 #ifndef NOIPV6
|| *SAFAMILY(&param->sinsl) == AF_INET6 || *SAFAMILY(&param->sinsl) == AF_INET6
#endif #endif
) { ) {
@ -235,7 +234,6 @@ static int ctstrcmp(const char *a, const char *b, size_t maxlen){
} }
int strongauth(struct clientparam * param){ int strongauth(struct clientparam * param){
static char dummy;
unsigned char buf[256]; unsigned char buf[256];
char pass[256] = {0}; char pass[256] = {0};

View File

@ -174,17 +174,6 @@ void md5_calc(unsigned char *output, unsigned char *input,
unsigned int inputlen); unsigned int inputlen);
char *strNcpy(char *dest, const char *src, int n)
{
if (n > 0)
strncpy(dest, src, n);
else
n = 1;
dest[n - 1] = 0;
return dest;
}
void md5_calc(unsigned char *output, unsigned char *input, void md5_calc(unsigned char *output, unsigned char *input,
unsigned int inlen) unsigned int inlen)
{ {
@ -308,14 +297,12 @@ int radsend(struct clientparam * param, int auth, int stop){
unsigned char *ptr; unsigned char *ptr;
int total_length; int total_length;
int len; int len;
int op;
PROXYSOCKADDRTYPE saremote; PROXYSOCKADDRTYPE saremote;
struct pollfd fds[1]; struct pollfd fds[1];
char vector[AUTH_VECTOR_LEN]; char vector[AUTH_VECTOR_LEN];
radius_packet_t packet, rpacket; radius_packet_t packet, rpacket;
SASIZETYPE salen; SASIZETYPE salen;
int data_len; int data_len;
uint8_t *vendor_len;
int count=0; int count=0;
uint8_t *attr; uint8_t *attr;
long vendor=0; long vendor=0;
@ -613,7 +600,6 @@ int radsend(struct clientparam * param, int auth, int stop){
attr = rpacket.data; attr = rpacket.data;
count = total_length - 20; count = total_length - 20;
vendor_len = 0;
while (count >= 2) { while (count >= 2) {
if (!vendor && attr[0] == 0) { if (!vendor && attr[0] == 0) {

View File

@ -21,6 +21,7 @@ void * autochild(struct clientparam* param) {
if (len != 1){ if (len != 1){
param->res = 801; param->res = 801;
dolog(param, (unsigned char *)""); dolog(param, (unsigned char *)"");
return 0;
} }
if(*param->clibuf == 4 || *param->clibuf == 5) { if(*param->clibuf == 4 || *param->clibuf == 5) {
param->service = S_SOCKS; param->service = S_SOCKS;

View File

@ -681,20 +681,6 @@ int doconnect(struct clientparam * param){
setopts(param->remsock, param->srv->srvsockopts); setopts(param->remsock, param->srv->srvsockopts);
param->srv->so._setsockopt(param->sostate, param->remsock, SOL_SOCKET, SO_LINGER, (char *)&lg, sizeof(lg)); param->srv->so._setsockopt(param->sostate, param->remsock, SOL_SOCKET, SO_LINGER, (char *)&lg, sizeof(lg));
#ifdef REUSE
{
int opt;
#ifdef SO_REUSEADDR
opt = 1;
param->srv->so._setsockopt(param->sostate, param->remsock, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(int));
#endif
#ifdef SO_REUSEPORT
opt = 1;
param->srv->so._setsockopt(param->sostate, param->remsock, SOL_SOCKET, SO_REUSEPORT, (unsigned char *)&opt, sizeof(int));
#endif
}
#endif
#if defined SO_BINDTODEVICE #if defined SO_BINDTODEVICE
if(param->srv->obindtodevice) { if(param->srv->obindtodevice) {
if(param->srv->so._setsockopt(param->sostate, param->remsock, SOL_SOCKET, SO_BINDTODEVICE, param->srv->obindtodevice, strlen(param->srv->obindtodevice) + 1)) if(param->srv->so._setsockopt(param->sostate, param->remsock, SOL_SOCKET, SO_BINDTODEVICE, param->srv->obindtodevice, strlen(param->srv->obindtodevice) + 1))

View File

@ -296,6 +296,7 @@ static int h_external(int argc, unsigned char ** argv){
else conf.extsa6 = sa6; else conf.extsa6 = sa6;
#else #else
res = getip46(46, argv[1], (struct sockaddr *)&conf.extsa); res = getip46(46, argv[1], (struct sockaddr *)&conf.extsa);
if(!res) return 1;
#endif #endif
return 0; return 0;
} }
@ -517,7 +518,6 @@ static int h_auth(int argc, unsigned char **argv){
} }
static int h_users(int argc, unsigned char **argv){ static int h_users(int argc, unsigned char **argv){
static char dummy;
int j; int j;
unsigned char *arg; unsigned char *arg;
char *pw[2]; char *pw[2];

View File

@ -61,13 +61,6 @@ static void pr_ip(struct node *node, CBFUNC cbf, void*cb){
if(node->value)(*cbf)(cb, buf, myinet_ntop(AF_INET, node -> value, buf, 4)); if(node->value)(*cbf)(cb, buf, myinet_ntop(AF_INET, node -> value, buf, 4));
} }
#ifndef NOIPV6
static void pr_ip6(struct node *node, CBFUNC cbf, void*cb){
char buf[64];
if(node->value)(*cbf)(cb, buf, myinet_ntop(AF_INET6, node -> value, buf, 16));
}
#endif
static void pr_sa(struct node *node, CBFUNC cbf, void*cb){ static void pr_sa(struct node *node, CBFUNC cbf, void*cb){
#ifdef NOIPV6 #ifdef NOIPV6
if(node->value)pr_ip(node, cbf, cb); if(node->value)pr_ip(node, cbf, cb);

View File

@ -36,7 +36,6 @@ void destroyhashtable(struct hashtable *ht){
int inithashtable(struct hashtable *ht, unsigned tablesize, unsigned poolsize, unsigned growlimit){ int inithashtable(struct hashtable *ht, unsigned tablesize, unsigned poolsize, unsigned growlimit){
unsigned i; unsigned i;
clock_t c;
#ifdef _WIN32 #ifdef _WIN32
struct timeb tb; struct timeb tb;
@ -48,7 +47,6 @@ int inithashtable(struct hashtable *ht, unsigned tablesize, unsigned poolsize, u
struct timezone tz; struct timezone tz;
gettimeofday(&tb, &tz); gettimeofday(&tb, &tz);
#endif #endif
c = clock();
if(tablesize < 2 || poolsize < tablesize || growlimit < poolsize) return 1; if(tablesize < 2 || poolsize < tablesize || growlimit < poolsize) return 1;
if(ht->ihashtable){ if(ht->ihashtable){
@ -169,7 +167,6 @@ static void hashgrow(struct hashtable *ht){
void hashadd(struct hashtable *ht, void* name, void* value, time_t expires){ void hashadd(struct hashtable *ht, void* name, void* value, time_t expires){
uint32_t hen, he; uint32_t hen, he;
uint32_t *hep; uint32_t *hep;
int overwrite = 0;
uint8_t hash[MAX_HASH_SIZE]; uint8_t hash[MAX_HASH_SIZE];
uint32_t index; uint32_t index;
uint32_t last = 0; uint32_t last = 0;

View File

@ -28,7 +28,7 @@ static void param2hash_add(const struct hashtable *ht, void *index, uint8_t *has
void param2hash_search(const struct hashtable *ht, void *index, uint8_t *hash){ void param2hash_search(const struct hashtable *ht, void *index, uint8_t *hash){
struct clientparam *param = (struct clientparam *)index; struct clientparam *param = (struct clientparam *)index;
unsigned type = param->srv->authcachetype; unsigned type = param->srv->authcachetype;
int len = 0, oplen = 0, acllen = 0, ulen = 0, plen = 0, hlen = 0, a1len = 0, a2len = 0, a3len = 0, p1len=0, p2len = 0; int oplen = 0, acllen = 0, ulen = 0, plen = 0, hlen = 0, a1len = 0, a2len = 0, a3len = 0, p1len=0, p2len = 0;
if((type & 2) && param->username) ulen = strlen((const char *)param->username) + 1; if((type & 2) && param->username) ulen = strlen((const char *)param->username) + 1;
@ -76,19 +76,6 @@ void param2hash_search(const struct hashtable *ht, void *index, uint8_t *hash){
memcpy(param->hash, hash, ht->hash_size); memcpy(param->hash, hash, ht->hash_size);
} }
static void udpparam2hash(const struct hashtable *ht, void *index, uint8_t *hash){
struct clientparam *param = (struct clientparam *)index;
mdh_ctx *bctx = mdh_init(MDH_BLAKE2, ht->hash_size);
unsigned int blen = ht->hash_size;
if(!bctx) return;
mdh_update(bctx, SAADDR(&param->srv->intsa), SAADDRLEN(&param->srv->intsa));
mdh_update(bctx, SAPORT(&param->srv->intsa), 2);
mdh_update(bctx, SAADDR(&param->sincr), SAADDRLEN(&param->sincr));
mdh_update(bctx, SAPORT(&param->sincr), 2);
mdh_final(bctx, hash, &blen);
mdh_free(bctx);
}
struct hashtable dns_table = {char_index2hash, char_index2hash, 4, 32}; struct hashtable dns_table = {char_index2hash, char_index2hash, 4, 32};
struct hashtable dns6_table = {char_index2hash, char_index2hash, 16, 32}; struct hashtable dns6_table = {char_index2hash, char_index2hash, 16, 32};
struct hashtable auth_table = {param2hash_add, param2hash_search, sizeof(struct authcache), 64}; struct hashtable auth_table = {param2hash_add, param2hash_search, sizeof(struct authcache), 64};

View File

@ -52,7 +52,6 @@ unsigned long preview = 0;
char path[300]; char path[300];
static int counter = 0; static int counter = 0;
static int timeo = 0;
static char * fp_stringtable[] = { static char * fp_stringtable[] = {
/* 0 */ "HTTP/1.0 503 Service Unavailable\r\n" /* 0 */ "HTTP/1.0 503 Service Unavailable\r\n"
@ -261,10 +260,6 @@ static void removefps(struct fp_stream * fps){
fps->state = 0; fps->state = 0;
} }
static int WINAPI fp_connect(SOCKET s, const struct sockaddr *name, fp_size_t namelen){
return sso._connect(sso.state, s, name, namelen);
}
void processcallbacks(struct fp_stream *fps, int what, char *msg, int size){ void processcallbacks(struct fp_stream *fps, int what, char *msg, int size){
struct fp_callback *cb; struct fp_callback *cb;
int state; int state;

View File

@ -90,10 +90,7 @@ static int pamfunc(struct clientparam *param)
conv.appdata_ptr = (char *) param->password; conv.appdata_ptr = (char *) param->password;
_3proxy_mutex_lock(&pam_mutex); _3proxy_mutex_lock(&pam_mutex);
if (!pamh)
{
retval = pam_start ((char *)service, (char *)param->username, &conv, &pamh); retval = pam_start ((char *)service, (char *)param->username, &conv, &pamh);
}
if (retval == PAM_SUCCESS) if (retval == PAM_SUCCESS)
retval = pam_set_item (pamh, PAM_USER, param->username); retval = pam_set_item (pamh, PAM_USER, param->username);
/*fprintf(stderr,"pam_set_item1 rc=%d\n",retval);*/ /*fprintf(stderr,"pam_set_item1 rc=%d\n",retval);*/

View File

@ -34,13 +34,12 @@ static void* transparent_filter_open(void * idata, struct srvparam * param){
static FILTER_ACTION transparent_filter_client(void *fo, struct clientparam * param, void** fc){ static FILTER_ACTION transparent_filter_client(void *fo, struct clientparam * param, void** fc){
socklen_t len;
char addrbuf[64]; char addrbuf[64];
int i=0;
len = sizeof(param->req);
#ifdef WITH_NETFILTER #ifdef WITH_NETFILTER
socklen_t len;
len = sizeof(param->req);
#ifdef SO_ORIGINAL_DST #ifdef SO_ORIGINAL_DST
if(getsockopt(param->clisock, if(getsockopt(param->clisock,

View File

@ -247,9 +247,13 @@ void * proxychild(struct clientparam* param) {
int redirect = 0; int redirect = 0;
int prefix = 0, ckeepalive=0; int prefix = 0, ckeepalive=0;
int ftp = 0; int ftp = 0;
#ifndef ANONYMOUS
int anonymous; int anonymous;
#endif
int sleeptime = 0; int sleeptime = 0;
#ifndef WITHMAIN
int reqsize, reqbufsize; int reqsize, reqbufsize;
#endif
int authenticate; int authenticate;
struct pollfd fds[2]; struct pollfd fds[2];
SOCKET ftps; SOCKET ftps;
@ -265,7 +269,9 @@ void * proxychild(struct clientparam* param) {
if(param->remsock != INVALID_SOCKET) haveconnection = 1; if(param->remsock != INVALID_SOCKET) haveconnection = 1;
if(!(buf = malloc(BUFSIZE))) {RETURN(21);} if(!(buf = malloc(BUFSIZE))) {RETURN(21);}
bufsize = BUFSIZE; bufsize = BUFSIZE;
#ifndef ANONYMOUS
anonymous = param->srv->anonymous; anonymous = param->srv->anonymous;
#endif
for(;;){ for(;;){
memset(buf, 0, bufsize); memset(buf, 0, bufsize);
inbuf = 0; inbuf = 0;
@ -548,8 +554,10 @@ for(;;){
buf[inbuf] = 0; buf[inbuf] = 0;
#ifndef WITHMAIN
reqsize = (int)strlen((char *)req); reqsize = (int)strlen((char *)req);
reqbufsize = reqsize + 1; reqbufsize = reqsize + 1;
#endif
if(param->srv->needuser > 1 && !param->username) {RETURN(4);} if(param->srv->needuser > 1 && !param->username) {RETURN(4);}
@ -701,7 +709,6 @@ for(;;){
int sizetoken =-1; int sizetoken =-1;
int modetoken =-1; int modetoken =-1;
int datetoken =-1; int datetoken =-1;
int spaces = 1;
unsigned char * tokens[10]; unsigned char * tokens[10];
unsigned wordlen [10]; unsigned wordlen [10];
unsigned char j=0; unsigned char j=0;
@ -734,7 +741,6 @@ for(;;){
wordlen[datetoken] = ((unsigned)(tokens[1] - tokens[0])) + wordlen[1]; wordlen[datetoken] = ((unsigned)(tokens[1] - tokens[0])) + wordlen[1];
sizetoken = 2; sizetoken = 2;
filetoken = 3; filetoken = 3;
spaces = 10;
} }
else { else {
if(j < 8 || wordlen[0]!=10) continue; if(j < 8 || wordlen[0]!=10) continue;

View File

@ -103,7 +103,6 @@
#include <pthread.h> #include <pthread.h>
#ifndef PTHREAD_STACK_MIN #ifndef PTHREAD_STACK_MIN
#define PTHREAD_STACK_MIN 32768 #define PTHREAD_STACK_MIN 32768
#define sockerror strerror
#endif #endif
void daemonize(void); void daemonize(void);
#define SLEEPTIME 1000 #define SLEEPTIME 1000

View File

@ -165,9 +165,6 @@ struct socketoptions sockopts[] = {
#ifdef TCP_TIMESTAMPS #ifdef TCP_TIMESTAMPS
{TCP_TIMESTAMPS, "TCP_TIMESTAMPS"}, {TCP_TIMESTAMPS, "TCP_TIMESTAMPS"},
#endif #endif
#ifdef USE_TCP_FASTOPEN
{USE_TCP_FASTOPEN, "USE_TCP_FASTOPEN"},
#endif
#ifdef SO_REUSEADDR #ifdef SO_REUSEADDR
{SO_REUSEADDR, "SO_REUSEADDR"}, {SO_REUSEADDR, "SO_REUSEADDR"},
#endif #endif
@ -297,6 +294,7 @@ int MODULEMAINFUNC (int argc, char** argv){
#ifdef __linux__ #ifdef __linux__
int saved_nsfd = -1; int saved_nsfd = -1;
#endif #endif
#if !defined(PORTMAP) || !defined(NOPORTMAP)
char loghelp[] = char loghelp[] =
#ifdef STDMAIN #ifdef STDMAIN
#ifndef _WIN32 #ifndef _WIN32
@ -312,8 +310,8 @@ int MODULEMAINFUNC (int argc, char** argv){
" -Di(DEVICENAME) bind internal interface to device, e.g. eth1\n" " -Di(DEVICENAME) bind internal interface to device, e.g. eth1\n"
" -De(DEVICENAME) bind external interface to device, e.g. eth1\n" " -De(DEVICENAME) bind external interface to device, e.g. eth1\n"
#endif #endif
#ifdef WITHSLICE #ifdef WITHSPLICE
" -s Use slice() - faster proxing, but no filtering for data\n" " -s Use splice() - faster proxing, but no filtering for data\n"
#endif #endif
"-g(GRACE_TRAFF,GRACE_NUM,GRACE_DELAY) - delay GRACE_DELAY milliseconds before polling if average polling size below GRACE_TRAFF bytes and GRACE_NUM read operations in single directions are detected within 1 second to minimize polling\n" "-g(GRACE_TRAFF,GRACE_NUM,GRACE_DELAY) - delay GRACE_DELAY milliseconds before polling if average polling size below GRACE_TRAFF bytes and GRACE_NUM read operations in single directions are detected within 1 second to minimize polling\n"
" -fFORMAT logging format (see documentation)\n" " -fFORMAT logging format (see documentation)\n"
@ -335,6 +333,7 @@ int MODULEMAINFUNC (int argc, char** argv){
" to-client (oc), to-server (os), listening (ol) socket, connect back client\n" " to-client (oc), to-server (os), listening (ol) socket, connect back client\n"
" (or) socket, connect back server (oR) listening socket\n" " (or) socket, connect back server (oR) listening socket\n"
" where possible options are: "; " where possible options are: ";
#endif
#ifdef _WIN32 #ifdef _WIN32
unsigned long ul = 1; unsigned long ul = 1;

View File

@ -56,7 +56,10 @@ int readreply (struct clientparam* param) {
int readcommand (struct clientparam* param) { int readcommand (struct clientparam* param) {
unsigned char * buf; unsigned char * buf;
int res, i, bufsize = 320; int i, bufsize = 320;
#ifndef WITHMAIN
int res;
#endif
int ret = 1; int ret = 1;
if(!(buf = malloc(bufsize))) return 0; if(!(buf = malloc(bufsize))) return 0;
@ -82,7 +85,10 @@ int readcommand (struct clientparam* param) {
int readdata (struct clientparam* param) { int readdata (struct clientparam* param) {
unsigned char * buf; unsigned char * buf;
int res, i, bufsize = 4096; int i, bufsize = 4096;
#ifndef WITHMAIN
int res;
#endif
if(!(buf = malloc(bufsize))) return 0; if(!(buf = malloc(bufsize))) return 0;
while ((i = sockgetlinebuf(param, CLIENT, buf, bufsize-1, '\n', conf.timeouts[STRING_L])) > 0 && !(i==3 && buf[0] == '.')){ while ((i = sockgetlinebuf(param, CLIENT, buf, bufsize-1, '\n', conf.timeouts[STRING_L])) > 0 && !(i==3 && buf[0] == '.')){

View File

@ -14,7 +14,7 @@
#if WITHLOG > 1 #if WITHLOG > 1
char logbuf[1024]; char logbuf[1024];
#endif #endif
#define log(X) dolog(param,X) #define log(X) dolog(param,(const unsigned char *)(X))
#else #else
#define log(X) #define log(X)
#endif #endif
@ -47,13 +47,15 @@ ssize_t splice(int fd_in, loff_t *off_in, int fd_out, loff_t *off_out, size_t le
int sockmap(struct clientparam * param, int timeo, int usesplice){ int sockmap(struct clientparam * param, int timeo, int usesplice){
uint64_t fromclient=0x7fffffffffffffff, fromserver =0x7fffffffffffffff; uint64_t fromclient=0x7fffffffffffffff, fromserver =0x7fffffffffffffff;
uint64_t inclientbuf = 0, inserverbuf = 0; uint64_t inclientbuf = 0, inserverbuf = 0;
int FROMCLIENT = 1, TOCLIENTBUF = 1, FROMCLIENTBUF = 1, TOSERVER = 1, int FROMCLIENT = 1, TOCLIENTBUF = 1, TOSERVER = 1,
FROMSERVER = 1, TOSERVERBUF = 1, FROMSERVERBUF = 1, TOCLIENT = 1; FROMSERVER = 1, TOSERVERBUF = 1, TOCLIENT = 1;
#if WITHLOG > 1
int FROMCLIENTBUF = 1, FROMSERVERBUF = 1;
#endif
int HASERROR=0; int HASERROR=0;
int CLIENTTERMREAD = 0, CLIENTTERMWRITE = 0, SERVERTERMREAD = 0, SERVERTERMWRITE = 0; int CLIENTTERMREAD = 0, CLIENTTERMWRITE = 0, SERVERTERMREAD = 0, SERVERTERMWRITE = 0;
int after = 0; int after = 0;
struct pollfd fds[8]; struct pollfd fds[8];
struct pollfd *fdsp = fds;
int fdsc = 0; int fdsc = 0;
int sleeptime = 0; int sleeptime = 0;
FILTER_ACTION action; FILTER_ACTION action;

View File

@ -53,7 +53,6 @@ void * sockschild(struct clientparam* param) {
int ver=0; int ver=0;
int havepass = 0; int havepass = 0;
PROXYSOCKADDRTYPE sin; PROXYSOCKADDRTYPE sin;
int len;
param->service = S_SOCKS; param->service = S_SOCKS;
@ -212,19 +211,7 @@ void * sockschild(struct clientparam* param) {
param->operation = command == 2?BIND:UDPASSOC; param->operation = command == 2?BIND:UDPASSOC;
if(command == 2){ if(command == 2){
if ((param->remsock=param->srv->so._socket(param->sostate, SASOCK(&param->req), SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) {RETURN (11);} if ((param->remsock=param->srv->so._socket(param->sostate, SASOCK(&param->req), SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) {RETURN (11);}
#ifdef REUSE setopts(param->remsock, param->srv->lissockopts);
{
int opt;
#ifdef SO_REUSEADDR
opt = 1;
param->srv->so._setsockopt(param->sostate, param->remsock, SOL_SOCKET, SO_REUSEADDR, (unsigned char *)&opt, sizeof(int));
#endif
#ifdef SO_REUSEPORT
opt = 1;
param->srv->so._setsockopt(param->sostate, param->remsock, SOL_SOCKET, SO_REUSEPORT, (unsigned char *)&opt, sizeof(int));
#endif
}
#endif
} }
break; break;

View File

@ -53,7 +53,6 @@ static char *client_ca_store = NULL;
static int mitm = 0; static int mitm = 0;
static int serv = 0; static int serv = 0;
static int cli = 0; static int cli = 0;
static int ssl_inited = 0;
static int client_min_proto_version = 0; static int client_min_proto_version = 0;
static int client_max_proto_version = 0; static int client_max_proto_version = 0;
static int server_min_proto_version = 0; static int server_min_proto_version = 0;
@ -486,10 +485,6 @@ EVP_PKEY * getKey(const char *fname){
return key; return key;
} }
static int verify_callback(int preverify_ok, X509_STORE_CTX *ctx){
return preverify_ok;
}
#ifdef WITH_WOLFSSL #ifdef WITH_WOLFSSL
/* wolfSSL's SSL_CTX_use_PrivateKey(EVP_PKEY*) compat is unreliable: it /* wolfSSL's SSL_CTX_use_PrivateKey(EVP_PKEY*) compat is unreliable: it
* silently fails (returns 0, no error queued) for keys loaded via * silently fails (returns 0, no error queued) for keys loaded via

View File

@ -310,29 +310,8 @@ int thread_setup(void)
_3proxy_mutex_init(mutex_buf +i); _3proxy_mutex_init(mutex_buf +i);
CRYPTO_set_id_callback(id_function); CRYPTO_set_id_callback(id_function);
CRYPTO_set_locking_callback(locking_function); CRYPTO_set_locking_callback(locking_function);
return 1;
#else
return 1;
#endif #endif
}
int thread_cleanup(void)
{
#if LEGACY_SSL_THREADING
int i;
if (!mutex_buf)
return 0;
CRYPTO_set_id_callback(NULL);
CRYPTO_set_locking_callback(NULL);
for (i = 0; i < CRYPTO_num_locks( ); i++)
_3proxy_mutex_destroy(mutex_buf +i);
free(mutex_buf);
mutex_buf = NULL;
return 1; return 1;
#else
return 1;
#endif
} }

View File

@ -182,7 +182,7 @@ int
#ifdef WITH_UN #ifdef WITH_UN
#define PROXYSOCKADDRTYPE struct sockaddr_storage #define PROXYSOCKADDRTYPE struct sockaddr_storage
#else #else
#ifndef NOIPv6 #ifndef NOIPV6
#define PROXYSOCKADDRTYPE struct sockaddr_in6 #define PROXYSOCKADDRTYPE struct sockaddr_in6
#else #else
#define PROXYSOCKADDRTYPE struct sockaddr_in #define PROXYSOCKADDRTYPE struct sockaddr_in
@ -798,7 +798,7 @@ extern struct hashtable udp_table;
struct authcache { struct authcache {
unsigned char username[64]; unsigned char username[64];
#ifndef NOIPv6 #ifndef NOIPV6
uint8_t sincr_addr[16]; uint8_t sincr_addr[16];
uint8_t sinsl_addr[16]; uint8_t sinsl_addr[16];
#else #else

View File

@ -19,20 +19,6 @@ unsigned size16(unsigned char *buf){
return res; return res;
} }
int readtls(struct clientparam *param, int direction, unsigned char *buf, int bufsize){
int res = 0;
int len;
if(bufsize < 3) return -1;
res = sockgetlinebuf(param, direction, buf, 3, EOF, conf.timeouts[STRING_S]);
if(res !=3 || buf[0] != 22 || buf[1] != 3) return -2;
len = size16(buf+3);
if((len+3) > bufsize) return -3;
res = sockgetlinebuf(param, direction, buf+3, len, EOF, conf.timeouts[STRING_S]);
if(res != len) return -4;
return len+3;
}
#define BSIZE (4096) #define BSIZE (4096)
#define SNILEN (256) #define SNILEN (256)
#define PROTOLEN (32) #define PROTOLEN (32)