Compare commits

...
25 Commits
Author SHA1 Message Date
z3APA3A db169c48c3 commit as 3proxy-0.7.1.3 2015-09-16 00:55:00 +03:00
z3APA3A 206e00c933 avoid potential race condition on configuration reload 2015-09-16 00:54:34 +03:00
z3APA3A 98961ced0d Fix FTP over HTTP authentication request parsing
Conflicts:
	src/version.h
2015-09-11 23:10:40 +03:00
z3APA3A de8de757f6 Fix FTP over HTTP authentication
Send WWW-Authenticate instead of Proxy-Authenticate

Conflicts:
	src/version.h
2015-09-11 23:08:57 +03:00
z3APA3A e935d1f6d1 fix static memory free() attempt
Conflicts:
	src/version.h
2015-09-11 23:06:30 +03:00
z3APA3A 1be182c65f Fix potential inithashtable() race condition
potential race condition on configuration reload.
2015-09-11 22:59:40 +03:00
z3APA3A 5ef18c48f1 bugfix: archiver doesn't add suffix if logname contains macro 2015-06-05 15:55:43 +03:00
z3APA3A c3871caf2a traffic displayed incorrectly 2015-06-03 15:35:33 +03:00
z3APA3A f649c7d4de publish as 0.7.1.2 2015-02-27 16:52:46 +03:00
z3APA3A 0a14a3bcdb Increase maximum request / header length limit 2015-02-17 16:09:13 +03:00
z3APA3A 17665e1f8e Correct error handling for thread creation
Error handling corrected for thread creation in case of e.g.
insufficient system resources.
2014-08-15 18:48:06 +04:00
z3APA3A bf04b9465b publishing as 0.7.1.1 2014-07-02 13:57:05 +04:00
z3APA3A 4e92e71349 Resolver linux compilation issues
Do not compile SSLPlugin by default due to external dependencies
add #include <sys/resources.h>
2014-07-02 13:46:00 +04:00
z3APA3A f25c501cb4 publishing as 0.7.1 2014-06-28 18:02:42 +04:00
z3APA3A 1ce4a496f6 Do not ignore version.h
version.h is required to build from sources
2014-06-28 17:29:26 +04:00
Vladimir Dubrovin b41d6590cb Moving icons compilation to Makefiles 2014-06-28 17:15:44 +04:00
Vladimir Dubrovin eb8522bb8f ldapauth memory leak fixed
Привет !
Исправил старую багу по утечки памяти в плагине .. теперь вообще не
течет ,
глупая ошибка.. Вот так 3,5  года не попрограммируеш , срузу ошибку
найдеш :)

--
Kirill Lopuchov
2014-06-28 17:12:21 +04:00
Vladimir Dubrovin 1a27fd88a9 FTP proxy debugging output removed, bind to same IP with control connection for active FTP
FTP proxy debugging output removed, bind to same IP with control
connection for active FTP
2014-06-28 17:09:27 +04:00
z3APA3A 443a4c02d0 better EINTR handling 2014-06-28 17:04:43 +04:00
z3APA3A 40d03b8a4a minor fixes + overlapping memcpy replaced with memmove 2014-06-11 00:54:58 +04:00
Vladimir Dubrovin 53098814f0 Removing Changelog 2014-04-21 01:26:33 +04:00
Vladimir Dubrovin 8f4243ffe1 ftppr NLSD command added 2014-04-21 01:17:23 +04:00
Vladimir Dubrovin 618673c335 Ignore NTLM handshake unless NTLM is configured 2014-04-15 02:10:41 +04:00
z3APA3A f452009079 Some useful warnings added
Checks for most common misconfigurations
2014-04-14 01:50:17 +04:00
Vladimir Dubrovin 2b0f8bbcfc Add icon, resolve MinGW compilation issues 2014-04-13 18:26:32 +04:00
25 changed files with 127 additions and 2313 deletions

No files matched your search

+2 -2
View File
@@ -14,17 +14,17 @@ tmp/
*.bat *.bat
*.swp *.swp
*.o *.o
3proxy.res
*.idb *.idb
src/version.h
src/res src/res
version.c version.c
3proxy.res
doc/html/man3/ doc/html/man3/
doc/html/man8/ doc/html/man8/
doc/html/index.html doc/html/index.html
*.var *.var
verfile.sh verfile.sh
Makefile Makefile
Changelog
copytgz.sh copytgz.sh
*~.nib *~.nib
local.properties local.properties
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

+4 -5
View File
@@ -1,7 +1,6 @@
#include "src/version.h" #include "src/version.h"
#include "afxres.h"
LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT LANGUAGE 0x09, 0x01
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,7,0,0 FILEVERSION 0,7,0,0
@@ -18,9 +17,9 @@ BEGIN
VALUE "FileDescription", "3proxy - tiny proxy server" VALUE "FileDescription", "3proxy - tiny proxy server"
VALUE "FileVersion", VERSION "-" BUILDDATE VALUE "FileVersion", VERSION "-" BUILDDATE
VALUE "InternalName", "3proxy" VALUE "InternalName", "3proxy"
VALUE "LegalCopyright", "Copyright (C) 2002-2009 Vladimir Dubrovin" VALUE "LegalCopyright", "Copyright (C) 2002-2014 Vladimir Dubrovin"
VALUE "OriginalFilename", "3proxy.exe" VALUE "OriginalFilename", "3proxy.exe"
VALUE "ProductName", "3proxy" VALUE "ProductName", "3proxy - tiny proxy server"
VALUE "ProductVersion", VERSION VALUE "ProductVersion", VERSION
END END
END END
@@ -29,4 +28,4 @@ BEGIN
VALUE "Translation", 0x0, 1200 VALUE "Translation", 0x0, 1200
END END
END END
0 ICON DISCARDABLE "3proxy.ico"
-2215
View File
File diff suppressed because it is too large. Load diff
+6 -2
View File
@@ -19,7 +19,9 @@ LDFLAGS = -Wall -O2 -pthread
DLFLAGS = -shared DLFLAGS = -shared
DLSUFFICS = .ld.so DLSUFFICS = .ld.so
# -lpthreads may be reuqired on some platforms instead of -pthreads # -lpthreads may be reuqired on some platforms instead of -pthreads
LIBS = -lcrypto -lssl -ldl #LIBS = -lcrypto -lssl -ldl
# libcrypto and libssl are required for SSLPlugin
LIBS = -ldl
LNOUT = -o LNOUT = -o
EXESUFFICS = EXESUFFICS =
OBJSUFFICS = .o OBJSUFFICS = .o
@@ -29,7 +31,9 @@ REMOVECOMMAND = rm -f
TYPECOMMAND = cat TYPECOMMAND = cat
COMPATLIBS = COMPATLIBS =
MAKEFILE = Makefile.Linux MAKEFILE = Makefile.Linux
PLUGINS = SSLPlugin StringsPlugin TrafficPlugin PCREPlugin TransparentPlugin #PLUGINS = SSLPlugin StringsPlugin TrafficPlugin PCREPlugin TransparentPlugin
# SSLPlugin is not built by default because of external dependencies
PLUGINS = StringsPlugin TrafficPlugin PCREPlugin TransparentPlugin
include Makefile.inc include Makefile.inc
+9 -2
View File
@@ -15,7 +15,8 @@ LN = link
LDFLAGS = /nologo /subsystem:console /incremental:no /machine:I386 LDFLAGS = /nologo /subsystem:console /incremental:no /machine:I386
DLFLAGS = /DLL DLFLAGS = /DLL
DLSUFFICS = .dll DLSUFFICS = .dll
LIBS = ws2_32.lib advapi32.lib odbc32.lib user32.lib kernel32.lib Gdi32.lib libeay32MT.lib ssleay32MT.lib LIBS = ws2_32.lib advapi32.lib odbc32.lib user32.lib kernel32.lib Gdi32.lib
LIBSOLD = libeay32MT.lib ssleay32MT.lib
LIBEXT = .lib LIBEXT = .lib
LNOUT = /out: LNOUT = /out:
EXESUFFICS = .exe EXESUFFICS = .exe
@@ -27,10 +28,16 @@ TYPECOMMAND = type
COMPATLIBS = COMPATLIBS =
MAKEFILE = Makefile.msvc MAKEFILE = Makefile.msvc
PLUGINS = utf8tocp1251 WindowsAuthentication TrafficPlugin StringsPlugin PCREPlugin lastFripper FilePlugin PLUGINS = utf8tocp1251 WindowsAuthentication TrafficPlugin StringsPlugin PCREPlugin lastFripper FilePlugin
VERFILE = 3proxyres.obj $(VERFILE)
include Makefile.inc include Makefile.inc
../3proxy.res:
rc /fo../3proxy.res ../3proxy.rc
3proxyres.obj: ../3proxy.res
cvtres /out:3proxyres.obj /MACHINE:X86 ../3proxy.res
allplugins: allplugins:
for /D %%i in ($(PLUGINS)) do (copy Makefile plugins\%%i && copy Makefile.var plugins\%%i && cd plugins\%%i && nmake && del *.obj *.idb &&cd ..\..) for /D %%i in ($(PLUGINS)) do (copy Makefile plugins\%%i && copy Makefile.var plugins\%%i && cd plugins\%%i && nmake && del *.obj *.idb &&cd ..\..)
+9 -1
View File
@@ -15,7 +15,8 @@ LN = link
LDFLAGS = /nologo /subsystem:console /incremental:no /machine:x64 LDFLAGS = /nologo /subsystem:console /incremental:no /machine:x64
DLFLAGS = /DLL DLFLAGS = /DLL
DLSUFFICS = .dll DLSUFFICS = .dll
LIBS = ws2_32.lib advapi32.lib odbc32.lib user32.lib kernel32.lib Gdi32.lib libeay32MT.lib ssleay32MT.lib LIBS = ws2_32.lib advapi32.lib odbc32.lib user32.lib kernel32.lib Gdi32.lib
LIBSOLD = libeay32MT.lib ssleay32MT.lib
LIBEXT = .lib LIBEXT = .lib
LNOUT = /out: LNOUT = /out:
EXESUFFICS = .exe EXESUFFICS = .exe
@@ -27,9 +28,16 @@ TYPECOMMAND = type
COMPATLIBS = COMPATLIBS =
MAKEFILE = Makefile.msvc64 MAKEFILE = Makefile.msvc64
PLUGINS = utf8tocp1251 WindowsAuthentication TrafficPlugin StringsPlugin PCREPlugin PLUGINS = utf8tocp1251 WindowsAuthentication TrafficPlugin StringsPlugin PCREPlugin
VERFILE = 3proxyres.obj $(VERFILE)
include Makefile.inc include Makefile.inc
../3proxy.res:
rc /fo../3proxy.res ../3proxy.rc
3proxyres.obj: ../3proxy.res
cvtres /out:3proxyres.obj /MACHINE:X64 ../3proxy.res
allplugins: allplugins:
for /D %%i in ($(PLUGINS)) do (copy Makefile plugins\%%i && copy Makefile.var plugins\%%i && cd plugins\%%i && nmake && del *.obj *.idb &&cd ..\..) for /D %%i in ($(PLUGINS)) do (copy Makefile plugins\%%i && copy Makefile.var plugins\%%i && cd plugins\%%i && nmake && del *.obj *.idb &&cd ..\..)
+23 -2
View File
@@ -9,6 +9,7 @@
#include "proxy.h" #include "proxy.h"
#ifndef _WIN32 #ifndef _WIN32
#include <sys/resource.h>
#ifndef NOPLUGINS #ifndef NOPLUGINS
#include <dlfcn.h> #include <dlfcn.h>
#endif #endif
@@ -359,9 +360,8 @@ unsigned char * dologname (unsigned char *buf, unsigned char *name, const unsign
memset(&fakecli, 0, sizeof(fakecli)); memset(&fakecli, 0, sizeof(fakecli));
dobuf2(&fakecli, buf, NULL, NULL, ts, (char *)name); dobuf2(&fakecli, buf, NULL, NULL, ts, (char *)name);
return buf;
} }
switch(lt){ else switch(lt){
case NONE: case NONE:
sprintf((char *)buf, "%s", name); sprintf((char *)buf, "%s", name);
break; break;
@@ -647,6 +647,9 @@ static int h_proxy(int argc, unsigned char ** argv){
childdef.isudp = 0; childdef.isudp = 0;
childdef.service = S_PROXY; childdef.service = S_PROXY;
childdef.helpmessage = " -n - no NTLM support\n"; childdef.helpmessage = " -n - no NTLM support\n";
if(!resolvfunc || (resolvfunc == myresolver && !dns_table.hashsize)){
fprintf(stderr, "[line %d] Warning: no nserver/nscache configured, proxy may run very slow\n", linenum);
}
} }
else if(!strcmp((char *)argv[0], "pop3p")) { else if(!strcmp((char *)argv[0], "pop3p")) {
childdef.pf = pop3pchild; childdef.pf = pop3pchild;
@@ -675,6 +678,9 @@ static int h_proxy(int argc, unsigned char ** argv){
childdef.isudp = 0; childdef.isudp = 0;
childdef.service = S_SOCKS; childdef.service = S_SOCKS;
childdef.helpmessage = " -n - no NTLM support\n"; childdef.helpmessage = " -n - no NTLM support\n";
if(!resolvfunc || (resolvfunc == myresolver && !dns_table.hashsize)){
fprintf(stderr, "[line %d] Warning: no nserver/nscache configured, socks may run very slow\n", linenum);
}
} }
else if(!strcmp((char *)argv[0], "tcppm")) { else if(!strcmp((char *)argv[0], "tcppm")) {
childdef.pf = tcppmchild; childdef.pf = tcppmchild;
@@ -715,6 +721,9 @@ static int h_proxy(int argc, unsigned char ** argv){
childdef.port = 53; childdef.port = 53;
childdef.isudp = 1; childdef.isudp = 1;
childdef.service = S_DNSPR; childdef.service = S_DNSPR;
if(!resolvfunc || (resolvfunc == myresolver && !dns_table.hashsize) || resolvfunc == fakeresolver){
fprintf(stderr, "[line %d] Warning: no nserver/nscache configured, dnspr will not work as expected\n", linenum);
}
} }
return start_proxy_thread(&ch); return start_proxy_thread(&ch);
} }
@@ -954,6 +963,18 @@ static int h_maxconn(int argc, unsigned char **argv){
if(!conf.maxchild) { if(!conf.maxchild) {
return(1); return(1);
} }
#ifndef _WIN32
{
struct rlimit rl;
if(!getrlimit(RLIMIT_NOFILE, &rl)){
if((conf.maxchild<<1) > rl.rlim_cur)
fprintf(stderr, "[line %d] Warning: current open file ulimits are too low (cur: %d/max: %d),"
" maxconn requires at least %d for every running service."
" Configure ulimits according to system documentation\n",
linenum, (int)rl.rlim_cur, (int)rl.rlim_max, (conf.maxchild<<1));
}
}
#endif
return 0; return 0;
} }
+1 -1
View File
@@ -3,7 +3,7 @@
# 3 proxy common Makefile # 3 proxy common Makefile
# #
all: pre $(BUILDDIR)3proxy$(EXESUFFICS) $(BUILDDIR)mycrypt$(EXESUFFICS) $(BUILDDIR)dighosts$(EXESUFFICS) $(BUILDDIR)pop3p$(EXESUFFICS) $(BUILDDIR)smtpp$(EXESUFFICS) $(BUILDDIR)ftppr$(EXESUFFICS) $(BUILDDIR)tcppm$(EXESUFFICS) $(BUILDDIR)icqpr$(EXESUFFICS) $(BUILDDIR)msnpr$(EXESUFFICS) $(BUILDDIR)udppm$(EXESUFFICS) $(BUILDDIR)socks$(EXESUFFICS) $(BUILDDIR)proxy$(EXESUFFICS) $(BUILDDIR)countersutil$(EXESUFFICS) allplugins all: pre $(VERFILE) $(BUILDDIR)3proxy$(EXESUFFICS) $(BUILDDIR)mycrypt$(EXESUFFICS) $(BUILDDIR)dighosts$(EXESUFFICS) $(BUILDDIR)pop3p$(EXESUFFICS) $(BUILDDIR)smtpp$(EXESUFFICS) $(BUILDDIR)ftppr$(EXESUFFICS) $(BUILDDIR)tcppm$(EXESUFFICS) $(BUILDDIR)icqpr$(EXESUFFICS) $(BUILDDIR)msnpr$(EXESUFFICS) $(BUILDDIR)udppm$(EXESUFFICS) $(BUILDDIR)socks$(EXESUFFICS) $(BUILDDIR)proxy$(EXESUFFICS) $(BUILDDIR)countersutil$(EXESUFFICS) allplugins
pre: pre:
+8 -15
View File
@@ -882,20 +882,6 @@ struct auth authfuncs[] = {
}; };
struct hashentry {
unsigned char hash[sizeof(unsigned)*4];
unsigned long value;
time_t expires;
struct hashentry *next;
};
struct hashtable {
unsigned hashsize;
struct hashentry ** hashtable;
struct hashentry * hashvalues;
struct hashentry * hashempty;
};
struct hashtable dns_table = {0, NULL, NULL, NULL}; struct hashtable dns_table = {0, NULL, NULL, NULL};
@@ -936,6 +922,7 @@ int inithashtable(struct hashtable *ht, unsigned nhashsize){
unsigned i; unsigned i;
if(nhashsize<4) return 1; if(nhashsize<4) return 1;
pthread_mutex_lock(&hash_mutex);
if(ht->hashtable){ if(ht->hashtable){
myfree(ht->hashtable); myfree(ht->hashtable);
ht->hashtable = NULL; ht->hashtable = NULL;
@@ -946,11 +933,13 @@ int inithashtable(struct hashtable *ht, unsigned nhashsize){
} }
ht->hashsize = 0; ht->hashsize = 0;
if(!(ht->hashtable = myalloc((nhashsize>>2) * sizeof(struct hashentry *)))){ if(!(ht->hashtable = myalloc((nhashsize>>2) * sizeof(struct hashentry *)))){
pthread_mutex_unlock(&hash_mutex);
return 2; return 2;
} }
if(!(ht->hashvalues = myalloc(nhashsize * sizeof(struct hashentry)))){ if(!(ht->hashvalues = myalloc(nhashsize * sizeof(struct hashentry)))){
myfree(ht->hashtable); myfree(ht->hashtable);
ht->hashtable = NULL; ht->hashtable = NULL;
pthread_mutex_unlock(&hash_mutex);
return 3; return 3;
} }
ht->hashsize = nhashsize; ht->hashsize = nhashsize;
@@ -960,6 +949,7 @@ int inithashtable(struct hashtable *ht, unsigned nhashsize){
(ht->hashvalues + i)->next = ht->hashvalues + i + 1; (ht->hashvalues + i)->next = ht->hashvalues + i + 1;
} }
ht->hashempty = ht->hashvalues; ht->hashempty = ht->hashvalues;
pthread_mutex_unlock(&hash_mutex);
return 0; return 0;
} }
@@ -971,8 +961,11 @@ void hashadd(struct hashtable *ht, const unsigned char* name, unsigned long valu
struct hashentry * he; struct hashentry * he;
unsigned index; unsigned index;
if(!value||!name||!ht->hashtable||!ht->hashempty) return;
pthread_mutex_lock(&hash_mutex); pthread_mutex_lock(&hash_mutex);
if(!value||!name||!ht->hashtable||!ht->hashempty){
pthread_mutex_unlock(&hash_mutex);
return;
}
he = ht->hashempty; he = ht->hashempty;
ht->hashempty = ht->hashempty->next; ht->hashempty = ht->hashempty->next;
nametohash(name, he->hash); nametohash(name, he->hash);
+4 -6
View File
@@ -42,8 +42,6 @@ void * ftpprchild(struct clientparam* param) {
if (req) myfree (req); if (req) myfree (req);
req = NULL; req = NULL;
(*param->srv->logfunc)(param, buf);
if (!strncasecmp((char *)buf, "OPEN ", 5)){ if (!strncasecmp((char *)buf, "OPEN ", 5)){
if(parsehostname((char *)buf+5, param, 21)){RETURN(803);} if(parsehostname((char *)buf+5, param, 21)){RETURN(803);}
if(param->remsock != INVALID_SOCKET) { if(param->remsock != INVALID_SOCKET) {
@@ -123,10 +121,10 @@ void * ftpprchild(struct clientparam* param) {
} }
if ((clidatasock=socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) {RETURN(821);} if ((clidatasock=socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) {RETURN(821);}
sasize = sizeof(struct sockaddr_in); sasize = sizeof(struct sockaddr_in);
if(so._getsockname(param->ctrlsock, (struct sockaddr *)&param->sinc, &sasize)){RETURN(824);}
param->sinc.sin_port = 0;
if(so._bind(clidatasock, (struct sockaddr *)&param->sinc, sasize)){RETURN(822);}
if (pasv) { if (pasv) {
if(so._getsockname(param->ctrlsock, (struct sockaddr *)&param->sinc, &sasize)){RETURN(824);}
param->sinc.sin_port = 0;
if(so._bind(clidatasock, (struct sockaddr *)&param->sinc, sasize)){RETURN(822);}
if(so._listen(clidatasock, 1)) {RETURN(823);} if(so._listen(clidatasock, 1)) {RETURN(823);}
if(so._getsockname(clidatasock, (struct sockaddr *)&param->sinc, &sasize)){RETURN(824);} if(so._getsockname(clidatasock, (struct sockaddr *)&param->sinc, &sasize)){RETURN(824);}
sprintf((char *)buf, "227 OK (%u,%u,%u,%u,%u,%u)\r\n", sprintf((char *)buf, "227 OK (%u,%u,%u,%u,%u,%u)\r\n",
@@ -137,7 +135,6 @@ void * ftpprchild(struct clientparam* param) {
(unsigned)(((unsigned char *)(&param->sinc.sin_port))[0]), (unsigned)(((unsigned char *)(&param->sinc.sin_port))[0]),
(unsigned)(((unsigned char *)(&param->sinc.sin_port))[1]) (unsigned)(((unsigned char *)(&param->sinc.sin_port))[1])
); );
param->srv->logfunc(param,buf);
} }
else { else {
unsigned long b1, b2, b3, b4; unsigned long b1, b2, b3, b4;
@@ -174,6 +171,7 @@ param->srv->logfunc(param,buf);
!(strncasecmp((char *)buf, "RETR ", 5) && (param->operation = FTP_GET)) || !(strncasecmp((char *)buf, "RETR ", 5) && (param->operation = FTP_GET)) ||
!(strncasecmp((char *)buf, "LIST", 4) && (param->operation = FTP_LIST))|| !(strncasecmp((char *)buf, "LIST", 4) && (param->operation = FTP_LIST))||
!(strncasecmp((char *)buf, "NLST ", 5) && (param->operation = FTP_LIST)) || !(strncasecmp((char *)buf, "NLST ", 5) && (param->operation = FTP_LIST)) ||
!(strncasecmp((char *)buf, "MLSD", 4) && (param->operation = FTP_LIST)) ||
!(strncasecmp((char *)buf, "APPE ", 5) && (param->operation = FTP_PUT)) || !(strncasecmp((char *)buf, "APPE ", 5) && (param->operation = FTP_PUT)) ||
!(strncasecmp((char *)buf, "STOR ", 5) && (param->operation = FTP_PUT)) !(strncasecmp((char *)buf, "STOR ", 5) && (param->operation = FTP_PUT))
)){ )){
+7 -5
View File
@@ -49,7 +49,7 @@ static pthread_mutex_t file_mutex;
unsigned long preview = 0; unsigned long preview = 0;
char path[256]; char path[300];
static int counter = 0; static int counter = 0;
static int timeo = 0; static int timeo = 0;
@@ -876,13 +876,15 @@ __declspec(dllexport)
fp_symbols[1].next = pl->symbols.next; fp_symbols[1].next = pl->symbols.next;
pl->symbols.next = fp_symbols; pl->symbols.next = fp_symbols;
} }
if(path) free(path);
dirp = (argc > 1)? argv[1] : getenv("TEMP"); dirp = (argc > 1)? argv[1] : getenv("TEMP");
if(strlen(dirp) > 200 || strchr(dirp, '%')) return (13001); if(strlen(dirp) > 200 || strchr(dirp, '%')) {
fprintf(stderr, "FilePlugin: invalid directory path: %s\n", dirp);
return (13001);
}
#ifdef _WIN32 #ifdef _WIN32
sprintf(path, "%s\\%%d.tmp", dirp); sprintf(path, "%.256s\\%%07d.tmp", dirp);
#else #else
sprintf(path, "%s/%%d.tmp", dirp); sprintf(path, "%.256s/%%07d.tmp", dirp);
#endif #endif
if(argc > 2) preview = atoi(argv[2]); if(argc > 2) preview = atoi(argv[2]);
if(!preview) preview = 32768; if(!preview) preview = 32768;
+11 -10
View File
@@ -105,13 +105,6 @@ int savecouters(void)
#ifdef _WIN32 #ifdef _WIN32
__declspec(dllexport) int start(struct pluginlink * pluginlink, __declspec(dllexport) int start(struct pluginlink * pluginlink,
int argc, char** argv); int argc, char** argv);
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
#else #else
int start(struct pluginlink * pluginlink, int start(struct pluginlink * pluginlink,
@@ -128,6 +121,9 @@ static int ldapfunc(struct clientparam *param)
int rc = -1; int rc = -1;
char tmpbuf[1024]; char tmpbuf[1024];
/* test proxy user auth ------------------------*/
if(!param->username || !param->password) return 4;
if(strlen(param->password)==0) return 4;
/* init ldap ---------------------- */ /* init ldap ---------------------- */
ld = ldap_init( ldap_serv, 389 ); ld = ldap_init( ldap_serv, 389 );
@@ -138,9 +134,6 @@ static int ldapfunc(struct clientparam *param)
return 7; return 7;
} }
/* test proxy user auth ------------------------*/
if(!param->username || !param->password) return 4;
if(strlen(param->password)==0) return 4;
/* this code for Active Directory LDAP catalog :( /* this code for Active Directory LDAP catalog :(
detail see documentation for plugin */ detail see documentation for plugin */
@@ -168,6 +161,14 @@ static int ldapfunc(struct clientparam *param)
ldap_unbind_s(ld); ldap_unbind_s(ld);
ld = ldap_init( ldap_serv, 389 ); ld = ldap_init( ldap_serv, 389 );
if ( ld == NULL )
{
param->srv->logfunc(param,"Error ldap_init: No init lib ldap");
/*ldap_perror( ld, "Error ldap_init" ); */
return 7;
}
rc = ldap_bind_s( ld, ldap_user, ldap_pass, LDAP_AUTH_SIMPLE ); rc = ldap_bind_s( ld, ldap_user, ldap_pass, LDAP_AUTH_SIMPLE );
if ( rc != LDAP_SUCCESS ) if ( rc != LDAP_SUCCESS )
-10
View File
@@ -27,11 +27,6 @@ http://lucas.bergmans.us/hacks/openldap/
под unix подобной ОС (Freebsd) использовался стандартный gcc. под unix подобной ОС (Freebsd) использовался стандартный gcc.
и библиотеки openldap-client. и библиотеки openldap-client.
!!!! Внимание при работе плагина возможна утечка памяти !!!!
У меня на Win 2000 Serv и окола 600 пользователях при канале 500 кбит/сек .
процесс 3proxy за сутки выростает до 40 мб . Лечится рестартом сервиса.
Если кто то знает хорошо Open Ldap api и может указать на ошибку в плагине
с радостью выслушаю :) .
2. Настройка плагина. 2. Настройка плагина.
@@ -328,11 +323,6 @@ http://lucas.bergmans.us/hacks/openldap/
РПД unix РПДПВОПК пу (Freebsd) ЙУРПМШЪПЧБМУС УФБОДБТФОЩК gcc. РПД unix РПДПВОПК пу (Freebsd) ЙУРПМШЪПЧБМУС УФБОДБТФОЩК gcc.
Й ВЙВМЙПФЕЛЙ openldap-client. Й ВЙВМЙПФЕЛЙ openldap-client.
!!!! чОЙНБОЙЕ РТЙ ТБВПФЕ РМБЗЙОБ ЧПЪНПЦОБ ХФЕЮЛБ РБНСФЙ !!!!
х НЕОС ОБ Win 2000 Serv Й ПЛПМБ 600 РПМШЪПЧБФЕМСИ РТЙ ЛБОБМЕ 500 ЛВЙФ/УЕЛ .
РТПГЕУУ 3proxy ЪБ УХФЛЙ ЧЩТПУФБЕФ ДП 40 НВ . мЕЮЙФУС ТЕУФБТФПН УЕТЧЙУБ.
еУМЙ ЛФП ФП ЪОБЕФ ИПТПЫП Open Ldap api Й НПЦЕФ ХЛБЪБФШ ОБ ПЫЙВЛХ Ч РМБЗЙОЕ
У ТБДПУФША ЧЩУМХЫБА :) .
2. оБУФТПКЛБ РМБЗЙОБ. 2. оБУФТПКЛБ РМБЗЙОБ.
+1 -1
View File
@@ -153,7 +153,7 @@ static int restore_old_table(void * v)
#ifdef _WIN32 #ifdef _WIN32
__declspec(dllexport) int start(struct pluginlink * pluginlink, __declspec(dllexport) int start(struct pluginlink * pluginlink,
int argc, char** argv); int argc, char** argv);
BOOL APIENTRY DllMain( HMODULE hModule, BOOL WINAPI DllMain( HINSTANCE hModule,
DWORD ul_reason_for_call, DWORD ul_reason_for_call,
LPVOID lpReserved LPVOID lpReserved
) )
+1 -1
View File
@@ -229,7 +229,7 @@ void mylogfunc(struct clientparam * param, const unsigned char * pz) {
#ifdef _WIN32 #ifdef _WIN32
BOOL APIENTRY DllMain( HANDLE hModule, BOOL WINAPI DllMain( HINSTANCE hModule,
DWORD ul_reason_for_call, DWORD ul_reason_for_call,
LPVOID lpReserved LPVOID lpReserved
) )
@@ -20,14 +20,6 @@ extern "C" {
int argc, char** argv); int argc, char** argv);
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
static struct auth alwaysauth; static struct auth alwaysauth;
static char sidbuf[4096]; static char sidbuf[4096];
-9
View File
@@ -18,15 +18,6 @@ extern "C" {
__declspec(dllexport) int utf8tocp1251(struct pluginlink * pluginlink, __declspec(dllexport) int utf8tocp1251(struct pluginlink * pluginlink,
int argc, char** argv); int argc, char** argv);
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
static struct auth alwaysauth; static struct auth alwaysauth;
+6 -6
View File
@@ -119,7 +119,7 @@ char * proxy_stringtable[] = {
"<body><h2>503 Service Unavailable</h2><h3>Your request violates configured policy</h3></body></html>\r\n", "<body><h2>503 Service Unavailable</h2><h3>Your request violates configured policy</h3></body></html>\r\n",
/* 16*/ "HTTP/1.0 401 Authentication Required\r\n" /* 16*/ "HTTP/1.0 401 Authentication Required\r\n"
"Proxy-Authenticate: basic realm=\"FTP Server\"\r\n" "WWW-Authenticate: basic realm=\"FTP Server\"\r\n"
"Proxy-Connection: close\r\n" "Proxy-Connection: close\r\n"
"Content-type: text/html; charset=us-ascii\r\n" "Content-type: text/html; charset=us-ascii\r\n"
"\r\n" "\r\n"
@@ -132,8 +132,8 @@ char * proxy_stringtable[] = {
NULL NULL
}; };
#define BUFSIZE 4096 #define LINESIZE 4096
#define LINESIZE 2048 #define BUFSIZE (LINESIZE*2)
static void logurl(struct clientparam * param, char * buf, char * req, int ftp){ static void logurl(struct clientparam * param, char * buf, char * req, int ftp){
char *sb; char *sb;
@@ -339,7 +339,7 @@ for(;;){
if(!isconnect){ if(!isconnect){
if(se==sg)*se-- = ' '; if(se==sg)*se-- = ' ';
*se = '/'; *se = '/';
memcpy(ss, se, i - (se - sb) + 1); memmove(ss, se, i - (se - sb) + 1);
} }
} }
reqlen = i = (int)strlen((char *)buf); reqlen = i = (int)strlen((char *)buf);
@@ -377,7 +377,7 @@ for(;;){
continue; continue;
} }
#ifndef NOCRYPT #ifndef NOCRYPT
if(!strncasecmp((char *)sb, "ntlm", 4)){ if(param->srv->usentlm && !strncasecmp((char *)sb, "ntlm", 4)){
sb+=4; sb+=4;
while(isspace(*sb))sb++; while(isspace(*sb))sb++;
i = de64(sb, username, 1023); i = de64(sb, username, 1023);
@@ -464,7 +464,7 @@ for(;;){
} }
if(se)*se = '\r'; if(se)*se = '\r';
} }
if(ftp && i > 19 && (!strncasecmp((char *)(buf+inbuf), "authorization", 19))){ if(ftp && i > 13 && (!strncasecmp((char *)(buf+inbuf), "authorization", 13))){
sb = (unsigned char *)strchr((char *)(buf+inbuf), ':'); sb = (unsigned char *)strchr((char *)(buf+inbuf), ':');
if(!sb)continue; if(!sb)continue;
++sb; ++sb;
+9 -5
View File
@@ -460,22 +460,26 @@ int MODULEMAINFUNC (int argc, char** argv){
#else #else
h = (HANDLE)CreateThread((LPSECURITY_ATTRIBUTES )NULL, (unsigned)32768, (BEGINTHREADFUNC)srv.pf, (void *) newparam, 0, &thread); h = (HANDLE)CreateThread((LPSECURITY_ATTRIBUTES )NULL, (unsigned)32768, (BEGINTHREADFUNC)srv.pf, (void *) newparam, 0, &thread);
#endif #endif
newparam->threadid = (unsigned)thread; srv.childcount++;
if (h) { if (h) {
srv.childcount++; newparam->threadid = (unsigned)thread;
CloseHandle(h); CloseHandle(h);
} }
else { else {
myfree(newparam); sprintf((char *)buf, "_beginthreadex(): %s", _strerror(NULL));
if(!srv.silent)(*srv.logfunc)(&defparam, buf);
freeparam(newparam);
} }
#else #else
if((error = pthread_create(&thread, &pa, (PTHREADFUNC)srv.pf, (void *)newparam))){
error = pthread_create(&thread, &pa, (PTHREADFUNC)srv.pf, (void *)newparam);
srv.childcount++;
if(error){
sprintf((char *)buf, "pthread_create(): %s", strerror(error)); sprintf((char *)buf, "pthread_create(): %s", strerror(error));
if(!srv.silent)(*srv.logfunc)(&defparam, buf); if(!srv.silent)(*srv.logfunc)(&defparam, buf);
freeparam(newparam); freeparam(newparam);
} }
else { else {
srv.childcount++;
newparam->threadid = (unsigned)thread; newparam->threadid = (unsigned)thread;
} }
#endif #endif
+1 -1
View File
@@ -47,7 +47,7 @@ int socksendto(SOCKET sock, struct sockaddr_in * sin, unsigned char * buf, int b
if(res < 1) break; if(res < 1) break;
res = so._sendto(sock, buf + sent, bufsize - sent, 0, (struct sockaddr *)sin, sizeof(struct sockaddr_in)); res = so._sendto(sock, buf + sent, bufsize - sent, 0, (struct sockaddr *)sin, sizeof(struct sockaddr_in));
if(res < 0) { if(res < 0) {
if(errno != EAGAIN) break; if(errno != EAGAIN && errno != EINTR) break;
continue; continue;
} }
sent += res; sent += res;
+8 -4
View File
@@ -130,7 +130,8 @@ int sockmap(struct clientparam * param, int timeo){
} }
res = so._sendto(param->clisock, param->srvbuf + param->srvoffset,(!param->waitserver || ((unsigned)param->waitserver - received) > (param->srvinbuf - param->srvoffset))? param->srvinbuf - param->srvoffset : param->waitserver - received, 0, (struct sockaddr*)&param->sinc, sasize); res = so._sendto(param->clisock, param->srvbuf + param->srvoffset,(!param->waitserver || ((unsigned)param->waitserver - received) > (param->srvinbuf - param->srvoffset))? param->srvinbuf - param->srvoffset : param->waitserver - received, 0, (struct sockaddr*)&param->sinc, sasize);
if(res < 0) { if(res < 0) {
if(errno != EAGAIN) return 96; if(errno != EAGAIN && errno != EINTR) return 96;
if(errno == EINTR) usleep(SLEEPTIME);
continue; continue;
} }
param->srvoffset += res; param->srvoffset += res;
@@ -155,7 +156,8 @@ int sockmap(struct clientparam * param, int timeo){
} }
res = so._sendto(param->remsock, param->clibuf + param->clioffset, (!param->waitclient || ((unsigned)param->waitclient - sent) > (param->cliinbuf - param->clioffset))? param->cliinbuf - param->clioffset : param->waitclient - sent, 0, (struct sockaddr*)&param->sins, sasize); res = so._sendto(param->remsock, param->clibuf + param->clioffset, (!param->waitclient || ((unsigned)param->waitclient - sent) > (param->cliinbuf - param->clioffset))? param->cliinbuf - param->clioffset : param->waitclient - sent, 0, (struct sockaddr*)&param->sins, sasize);
if(res < 0) { if(res < 0) {
if(errno != EAGAIN) return 97; if(errno != EAGAIN && errno != EINTR) return 97;
if(errno == EINTR) usleep(SLEEPTIME);
continue; continue;
} }
param->clioffset += res; param->clioffset += res;
@@ -180,7 +182,8 @@ int sockmap(struct clientparam * param, int timeo){
} }
else { else {
if (res < 0){ if (res < 0){
if( errno != EAGAIN) return (94); if(errno != EAGAIN && errno != EINTR) return 94;
if(errno == EINTR) usleep(SLEEPTIME);
continue; continue;
} }
param->cliinbuf += res; param->cliinbuf += res;
@@ -210,7 +213,8 @@ int sockmap(struct clientparam * param, int timeo){
} }
else { else {
if (res < 0){ if (res < 0){
if( errno != EAGAIN) return (93); if(errno != EAGAIN && errno != EINTR) return 93;
if(errno == EINTR) usleep(SLEEPTIME);
continue; continue;
} }
param->srvinbuf += res; param->srvinbuf += res;
+13
View File
@@ -657,6 +657,19 @@ typedef enum {
TYPE_SERVER TYPE_SERVER
}DATA_TYPE; }DATA_TYPE;
struct hashentry {
unsigned char hash[sizeof(unsigned)*4];
unsigned long value;
time_t expires;
struct hashentry *next;
};
struct hashtable {
unsigned hashsize;
struct hashentry ** hashtable;
struct hashentry * hashvalues;
struct hashentry * hashempty;
};
#ifdef __cplusplus #ifdef __cplusplus
} }
+2
View File
@@ -0,0 +1,2 @@
#define VERSION "3proxy-0.7.1.3"
#define BUILDDATE "150916004303"
+2 -2
View File
@@ -480,9 +480,9 @@ void * adminchild(struct clientparam* param) {
"<td>MB%s</td>" "<td>MB%s</td>"
"<td>%.3f MB</td>" "<td>%.3f MB</td>"
"<td>%s</td>", "<td>%s</td>",
(1024.0 * (float)cp->traflimgb) + (float)cp->traflim/1048576.0, (4 * 1024.0 * (float)cp->traflimgb) + (float)cp->traflim/(1024.*1024.),
rotations[cp->type], rotations[cp->type],
(1024.0 * (float)cp->trafgb) + (float)cp->traf/1048576.0, (4 * 1024.0 * (float)cp->trafgb) + (float)cp->traf/(1024.*1024.),
cp->cleared?ctime(&cp->cleared):"never" cp->cleared?ctime(&cp->cleared):"never"
); );
inbuf += sprintf(buf + inbuf, inbuf += sprintf(buf + inbuf,