Merge pull request #1 from z3APA3A/master

Pull
This commit is contained in:
ServKit 2018-05-23 02:41:07 +08:00 committed by GitHub
commit 93acdf2c8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 6578 additions and 1806 deletions

View File

@ -2,8 +2,8 @@
1 VERSIONINFO 1 VERSIONINFO
FILEVERSION 0,8,10,0 FILEVERSION 0,8,12,0
PRODUCTVERSION 0,8,10,0 PRODUCTVERSION 0,8,12,0
FILETYPE 1 FILETYPE 1
FILESUBTYPE 0x0L FILESUBTYPE 0x0L
BEGIN BEGIN
@ -14,12 +14,12 @@ BEGIN
VALUE "Comments", "3proxy - tiny proxy server, http://3proxy.ru/\0" VALUE "Comments", "3proxy - tiny proxy server, http://3proxy.ru/\0"
VALUE "CompanyName", "Vladimir Dubrovin\0" VALUE "CompanyName", "Vladimir Dubrovin\0"
VALUE "FileDescription", "3proxy - tiny proxy server\0" VALUE "FileDescription", "3proxy - tiny proxy server\0"
VALUE "FileVersion", "0.8.10\0" VALUE "FileVersion", "0.8.12\0"
VALUE "InternalName", "3proxy\0" VALUE "InternalName", "3proxy\0"
VALUE "LegalCopyright", "Copyright (C) 2002-2017 Vladimir Dubrovin\0" VALUE "LegalCopyright", "Copyright (C) 2002-2018 Vladimir Dubrovin\0"
VALUE "OriginalFilename", "3proxy.exe\0" VALUE "OriginalFilename", "3proxy.exe\0"
VALUE "ProductName", "3proxy\0" VALUE "ProductName", "3proxy\0"
VALUE "ProductVersion", "0.8.10\0" VALUE "ProductVersion", "0.8.12\0"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View File

@ -10,11 +10,11 @@
BUILDDIR = BUILDDIR =
CC = gcc CC = gcc
CFLAGS = -g -O2 -c -pthread -DGETHOSTBYNAME_R -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL CFLAGS = -g -O2 -fno-strict-aliasing -c -pthread -DGETHOSTBYNAME_R -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL
COUT = -o COUT = -o
LN = gcc LN = gcc
DCFLAGS = -fpic DCFLAGS = -fpic
LDFLAGS = -O2 -pthread LDFLAGS = -O2 -fno-strict-aliasing -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

View File

@ -10,7 +10,7 @@
BUILDDIR = BUILDDIR =
CC = gcc CC = gcc
CFLAGS = -O3 -c -D_SOLARIS -D_THREAD_SAFE -DGETHOSTBYNAME_R -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL CFLAGS = -O2 -fno-strict-aliasing -c -D_SOLARIS -D_THREAD_SAFE -DGETHOSTBYNAME_R -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL
COUT = -o ./ COUT = -o ./
LN = gcc LN = gcc
LDFLAGS = -O3 LDFLAGS = -O3

View File

@ -10,10 +10,10 @@
BUILDDIR = ../bin/ BUILDDIR = ../bin/
CC = clang CC = clang
CFLAGS = -O2 -c -pthread -static -DWITH_STD_MALLOC -DNOIPV6 CFLAGS = -O2 -fno-strict-aliasing -c -pthread -static -DWITH_STD_MALLOC -DNOIPV6
COUT = -o COUT = -o
LN = clang LN = clang
LDFLAGS = -O2 -static -s LDFLAGS = -O2 -fno-strict-aliasing -static -s
DLFLAGS = -shared DLFLAGS = -shared
DLSUFFICS = .dll DLSUFFICS = .dll
LIBS = -lws2_32 -lodbc32 -ladvapi32 LIBS = -lws2_32 -lodbc32 -ladvapi32

View File

@ -11,10 +11,10 @@ BUILDDIR =
CC = gcc CC = gcc
# you may need -L/usr/pkg/lib for older NetBSD versions # you may need -L/usr/pkg/lib for older NetBSD versions
CFLAGS = -g -O2 -c -pthread -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL CFLAGS = -g -O2 -fno-strict-aliasing -c -pthread -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL
COUT = -o COUT = -o
LN = gcc LN = gcc
LDFLAGS = -O2 -pthread LDFLAGS = -O2 -fno-strict-aliasing -pthread
# -lpthreads may be reuqired on some platforms instead of -pthreads # -lpthreads may be reuqired on some platforms instead of -pthreads
# -ldl or -lld may be required for some platforms # -ldl or -lld may be required for some platforms
DCFLAGS = -fpic DCFLAGS = -fpic

File diff suppressed because one or more lines are too long

View File

@ -736,6 +736,17 @@ nolog
.br .br
Weight may be used for different purposes. Weight may be used for different purposes.
.br
.B force
.br
.B noforce
.br
If force is specified for service, configuration reload will require all current
sessions of this service to be re-authenticated. If ACL is changed or user account
is removed, old connections which do not match current are closed.
noforce allows to keep previously authenticated connections.
.br .br
.B bandlimin .B bandlimin
<rate> <userlist> <sourcelist> <targetlist> <targetportlist> <operationlist> <rate> <userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>

View File

@ -75,7 +75,7 @@ static void pr_sa(struct node *node, CBFUNC cbf, void*cb){
char buf[64]; char buf[64];
buf[0] = '['; buf[0] = '[';
buf[1] = 0; buf[1] = 0;
inet_ntop(*SAFAMILY(node->value), node->value, buf+1, sizeof(buf)-10); inet_ntop(*SAFAMILY(node->value), SAADDR(node->value), buf+1, sizeof(buf)-10);
sprintf(buf + strlen(buf), "]:%hu", (unsigned short)*SAPORT(node->value)); sprintf(buf + strlen(buf), "]:%hu", (unsigned short)*SAPORT(node->value));
if(node->value)(*cbf)(cb, buf, strlen(buf)); if(node->value)(*cbf)(cb, buf, strlen(buf));
#endif #endif
@ -743,21 +743,23 @@ static struct property prop_server[] = {
{prop_server + 2, "target", ef_server_target, TYPE_STRING, "portmapper target ip"}, {prop_server + 2, "target", ef_server_target, TYPE_STRING, "portmapper target ip"},
{prop_server + 3, "targetport", ef_server_targetport, TYPE_PORT, "portmapper target port"}, {prop_server + 3, "targetport", ef_server_targetport, TYPE_PORT, "portmapper target port"},
{prop_server + 4, "starttime", ef_server_starttime, TYPE_DATETIME, "service started seconds"}, {prop_server + 4, "starttime", ef_server_starttime, TYPE_DATETIME, "service started seconds"},
{prop_server + 5, "intsa", ef_server_intsa, TYPE_SA, "ip address of internal interface"}, {prop_server + 5, "auth", ef_server_auth, TYPE_STRING, "service authentication type"},
{prop_server + 6, "extsa", ef_server_extsa, TYPE_SA, "ip address of external interface"}, {prop_server + 6, "acl", ef_server_acl, TYPE_ACE, "access control list"},
{prop_server + 7, "auth", ef_server_auth, TYPE_STRING, "service authentication type"}, {prop_server + 7, "singlepacket", ef_server_singlepacket, TYPE_INTEGER, "is single packet redirection"},
{prop_server + 8, "acl", ef_server_acl, TYPE_ACE, "access control list"}, {prop_server + 8, "usentlm", ef_server_usentlm, TYPE_INTEGER, "allow NTLM authentication"},
{prop_server + 9, "singlepacket", ef_server_singlepacket, TYPE_INTEGER, "is single packet redirection"}, {prop_server + 9, "log", ef_server_log, TYPE_STRING, "type of logging"},
{prop_server + 10, "usentlm", ef_server_usentlm, TYPE_INTEGER, "allow NTLM authentication"}, {prop_server + 10, "logtarget", ef_server_logtarget, TYPE_STRING, "log target options"},
{prop_server + 11, "log", ef_server_log, TYPE_STRING, "type of logging"}, {prop_server + 11, "logformat", ef_server_logformat, TYPE_STRING, "logging format string"},
{prop_server + 12, "logtarget", ef_server_logtarget, TYPE_STRING, "log target options"}, {prop_server + 12, "nonprintable", ef_server_nonprintable, TYPE_STRING, "non printable characters"},
{prop_server + 13, "logformat", ef_server_logformat, TYPE_STRING, "logging format string"}, {prop_server + 13, "replacement", ef_server_replacement, TYPE_CHAR, "replacement character"},
{prop_server + 14, "nonprintable", ef_server_nonprintable, TYPE_STRING, "non printable characters"}, {prop_server + 14, "childcount", ef_server_childcount, TYPE_INTEGER, "number of servers connected"},
{prop_server + 15, "replacement", ef_server_replacement, TYPE_CHAR, "replacement character"}, {prop_server + 15, "intsa", ef_server_intsa, TYPE_SA, "ip address of internal interface"},
{prop_server + 16, "childcount", ef_server_childcount, TYPE_INTEGER, "number of servers connected"}, {prop_server + 16, "extsa", ef_server_extsa, TYPE_SA, "ip address of external interface"},
{prop_server + 17, "child", ef_server_child, TYPE_CLIENT, "connected clients"},
#ifndef NOIPV6 #ifndef NOIPV6
{prop_server + 18, "extsa6", ef_server_extsa6, TYPE_SA, "ipv6 address of external interface"}, {prop_server + 17, "extsa6", ef_server_extsa6, TYPE_SA, "ipv6 address of external interface"},
{prop_server + 18, "child", ef_server_child, TYPE_CLIENT, "connected clients"},
#else
{prop_server + 17, "child", ef_server_child, TYPE_CLIENT, "connected clients"},
#endif #endif
{NULL, "next", ef_server_next, TYPE_SERVER, "next"} {NULL, "next", ef_server_next, TYPE_SERVER, "next"}
}; };
@ -776,8 +778,8 @@ static struct property prop_client[] = {
{prop_client + 10, "username", ef_client_username, TYPE_STRING, "client username"}, {prop_client + 10, "username", ef_client_username, TYPE_STRING, "client username"},
{prop_client + 11, "password", ef_client_password, TYPE_STRING, "client password"}, {prop_client + 11, "password", ef_client_password, TYPE_STRING, "client password"},
{prop_client + 12, "clisa", ef_client_clisa, TYPE_SA, "client sa"}, {prop_client + 12, "clisa", ef_client_clisa, TYPE_SA, "client sa"},
{prop_client + 13, "srvsa", ef_client_srvsa, TYPE_IP, "target server sa"}, {prop_client + 13, "srvsa", ef_client_srvsa, TYPE_SA, "target server sa"},
{prop_client + 14, "reqsa", ef_client_reqsa, TYPE_IP, "requested server sa"}, {prop_client + 14, "reqsa", ef_client_reqsa, TYPE_SA, "requested server sa"},
{prop_client + 15, "bytesin", ef_client_bytesin64, TYPE_UNSIGNED64, "bytes from server to client"}, {prop_client + 15, "bytesin", ef_client_bytesin64, TYPE_UNSIGNED64, "bytes from server to client"},
{prop_client + 16, "bytesout", ef_client_bytesout64, TYPE_UNSIGNED64, "bytes from client to server"}, {prop_client + 16, "bytesout", ef_client_bytesout64, TYPE_UNSIGNED64, "bytes from client to server"},
{prop_client + 17, "maxtrafin", ef_client_maxtrafin64, TYPE_UNSIGNED64, "maximum traffic allowed for download"}, {prop_client + 17, "maxtrafin", ef_client_maxtrafin64, TYPE_UNSIGNED64, "maximum traffic allowed for download"},

View File

@ -4,4 +4,4 @@ ldapauth$(OBJSUFFICS): ldapauth.c
$(CC) $(DCFLAGS) $(CFLAGS) ldapauth.c $(CC) $(DCFLAGS) $(CFLAGS) ldapauth.c
$(BUILDDIR)ldapauth$(DLSUFFICS): ldapauth$(OBJSUFFICS) $(BUILDDIR)ldapauth$(DLSUFFICS): ldapauth$(OBJSUFFICS)
$(LN) $(LNOUT)../../$(BUILDDIR)ldapauth$(DLSUFFICS) $(LDFLAGS) $(DLFLAGS) $(LIBSPREFIX)ladp$(LIBSSUFFIX) ldapauth$(OBJSUFFICS) $(LN) $(LNOUT)../../$(BUILDDIR)ldapauth$(DLSUFFICS) $(LDFLAGS) $(DLFLAGS) $(LIBSPREFIX)ldap$(LIBSSUFFIX) ldapauth$(OBJSUFFICS)

View File

@ -1,25 +1,15 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdlib.h>
#include <time.h> #include <time.h>
#include <ldap.h>
#ifndef _WIN32 #ifndef _WIN32
#include <ctype.h> #include <ctype.h>
#endif #endif
#include "../../proxy.h"
#include "../../structures.h" #include "../../structures.h"
#define LDAP_DEPRECATED 1
struct counter_record #include <ldap.h>
{
unsigned long traf;
unsigned long trafgb;
time_t cleared;
time_t updated;
};
int already_loaded = 0; int already_loaded = 0;
@ -62,7 +52,7 @@ void lower (char *string)
#endif #endif
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
int savecouters(void) int savecounters(void)
{ {
struct trafcount *tc=mypluginlink->conf->trafcounter; struct trafcount *tc=mypluginlink->conf->trafcounter;
struct trafcount *tcd; struct trafcount *tcd;
@ -82,8 +72,8 @@ int savecouters(void)
sprintf(tmpbuf,pat_file,ldap_dircount,tcd->ace->users->user); sprintf(tmpbuf,pat_file,ldap_dircount,tcd->ace->users->user);
f=fopen(tmpbuf,"w+b"); f=fopen(tmpbuf,"w+b");
fseek(f,0,SEEK_SET); fseek(f,0,SEEK_SET);
fprintf(f,"%10lu %10lu %lu %lu\n",tcd->trafgb,tcd->traf, fprintf(f,"%"PRINTF_INT64_MODIFIER"u %lu %lu\n",tcd->traf64,
tcd->cleared,tcd->updated); (unsigned long)tcd->cleared,(unsigned long)tcd->updated);
fclose(f); fclose(f);
mypluginlink->myfree(tmpbuf); mypluginlink->myfree(tmpbuf);
@ -385,8 +375,7 @@ int h_trafgroup(int argc, unsigned char ** argv)
memset(newtrafcount, 0, sizeof(struct trafcount)); memset(newtrafcount, 0, sizeof(struct trafcount));
newtrafcount->ace = newace; newtrafcount->ace = newace;
newtrafcount->type=rtype; newtrafcount->type=rtype;
newtrafcount->traflimgb =(traflimit/(1024*4)); newtrafcount->traflim64 = traflimit;
newtrafcount->traflim = ((traflimit - (newtrafcount->traflimgb*(1024*4)))*(1024*1024));
newtrafcount->comment=(*mypluginlink->mystrdup)("ldapcounters"); newtrafcount->comment=(*mypluginlink->mystrdup)("ldapcounters");
newtrafcount->number=0; newtrafcount->number=0;
tmpbuf=(*mypluginlink->myalloc)(strlen(pat_file)+strlen(ldap_dircount)+strlen(vals[0])); tmpbuf=(*mypluginlink->myalloc)(strlen(pat_file)+strlen(ldap_dircount)+strlen(vals[0]));
@ -398,12 +387,11 @@ int h_trafgroup(int argc, unsigned char ** argv)
fseek(f,0,SEEK_SET); fseek(f,0,SEEK_SET);
fgets(buf, 256, f); fgets(buf, 256, f);
sscanf(buf,"%10lu %10lu %lu %lu\n",&rcounter.trafgb, &rcounter.traf, sscanf(buf,"%"PRINTF_INT64_MODIFIER"u %lu %lu\n",&rcounter.traf64,
&rcounter.cleared, &rcounter.updated); &rcounter.cleared, &rcounter.updated);
newtrafcount->trafgb=rcounter.trafgb; newtrafcount->traf64=rcounter.traf64;
newtrafcount->traf=rcounter.traf;
newtrafcount->cleared=rcounter.cleared; newtrafcount->cleared=rcounter.cleared;
newtrafcount->updated=rcounter.updated; newtrafcount->updated=rcounter.updated;
fclose(f); fclose(f);
@ -565,7 +553,7 @@ PLUGINAPI int PLUGINCALL start(struct pluginlink * pluginlink,
/*create job shedule for processing reload, save counters to file */ /*create job shedule for processing reload, save counters to file */
memset(&myschedule,0,sizeof(struct schedule)); memset(&myschedule,0,sizeof(struct schedule));
myschedule.type=MINUTELY; myschedule.type=MINUTELY;
myschedule.function=savecouters; myschedule.function=savecounters;
myschedule.next = *pluginlink->schedule; myschedule.next = *pluginlink->schedule;
*pluginlink->schedule=&myschedule; *pluginlink->schedule=&myschedule;

View File

@ -21,7 +21,6 @@
#include <ctype.h> #include <ctype.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/timeb.h>
#include <fcntl.h> #include <fcntl.h>
#include <time.h> #include <time.h>
@ -30,16 +29,6 @@
#define _PASSWORD_LEN 256 #define _PASSWORD_LEN 256
#define MAXNSERVERS 5 #define MAXNSERVERS 5
#define ALLOW 0
#define DENY 1
#define REDIRECT 2
#define BANDLIM 3
#define NOBANDLIM 4
#define COUNTIN 5
#define NOCOUNTIN 6
#define COUNTOUT 7
#define NOCOUNTOUT 8
#define UDPBUFSIZE 16384 #define UDPBUFSIZE 16384
#define TCPBUFSIZE 8192 #define TCPBUFSIZE 8192
#define SRVBUFSIZE (param->srv->bufsize?param->srv->bufsize:((param->service == S_UDPPM)?UDPBUFSIZE:TCPBUFSIZE)) #define SRVBUFSIZE (param->srv->bufsize?param->srv->bufsize:((param->service == S_UDPPM)?UDPBUFSIZE:TCPBUFSIZE))
@ -47,6 +36,7 @@
#ifdef _WIN32 #ifdef _WIN32
#include <winsock2.h> #include <winsock2.h>
#include <sys/timeb.h>
#ifndef _WINCE #ifndef _WINCE
#include <io.h> #include <io.h>
#else #else

View File

@ -376,7 +376,7 @@ fflush(stderr);
buf[i] = buf[i+1]; buf[i] = buf[i+1];
} }
buf[i++] = 0; buf[i++] = 0;
if(!getip46(param->srv->family, buf, (struct sockaddr *) &param->sinsr)) RETURN(100); if(!getip46(param->srv->family, buf+4, (struct sockaddr *) &param->sinsr)) RETURN(100);
break; break;
default: default:
RETURN(997); RETURN(997);

View File

@ -76,6 +76,18 @@ int
#endif #endif
#define ALLOW 0
#define DENY 1
#define REDIRECT 2
#define BANDLIM 3
#define NOBANDLIM 4
#define COUNTIN 5
#define NOCOUNTIN 6
#define COUNTOUT 7
#define NOCOUNTOUT 8
#define CONNLIM 9
#define NOCONNLIM 10
#define CONNECT 0x00000001 #define CONNECT 0x00000001
#define BIND 0x00000002 #define BIND 0x00000002
#define UDPASSOC 0x00000004 #define UDPASSOC 0x00000004

View File

@ -23,7 +23,7 @@ void * tcppmchild(struct clientparam* param) {
RETURN (sockmap(param, conf.timeouts[CONNECTION_L])); RETURN (sockmap(param, conf.timeouts[CONNECTION_L]));
CLEANRET: CLEANRET:
(*param->srv->logfunc)(param, NULL); (*param->srv->logfunc)(param, param->hostname);
freeparam(param); freeparam(param);
return (NULL); return (NULL);
} }

View File

@ -1,2 +1,2 @@
#define VERSION "3proxy-0.8.10" #define VERSION "3proxy-0.8.12"
#define BUILDDATE "170625190910" #define BUILDDATE "180418205022"