mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-26 23:59:41 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc9bd25c5a | ||
|
|
87fa9cca55 |
No files matched your search
+5
-23
@@ -5,12 +5,7 @@
|
|||||||
*.pydevproject
|
*.pydevproject
|
||||||
.project
|
.project
|
||||||
.metadata
|
.metadata
|
||||||
*.exe
|
bin/
|
||||||
*.dll
|
|
||||||
*.exp
|
|
||||||
*.lib
|
|
||||||
*.key
|
|
||||||
*.pem
|
|
||||||
bin64/
|
bin64/
|
||||||
dll/
|
dll/
|
||||||
tmp/
|
tmp/
|
||||||
@@ -20,27 +15,12 @@ tmp/
|
|||||||
*.swp
|
*.swp
|
||||||
*.o
|
*.o
|
||||||
*.idb
|
*.idb
|
||||||
*.err
|
src/res
|
||||||
res
|
|
||||||
version.c
|
version.c
|
||||||
version
|
|
||||||
3proxy.res
|
3proxy.res
|
||||||
|
|
||||||
src/3proxy
|
|
||||||
src/proxy
|
|
||||||
src/socks
|
|
||||||
src/tcppm
|
|
||||||
src/udppm
|
|
||||||
src/pop3p
|
|
||||||
src/smtpp
|
|
||||||
src/ftppr
|
|
||||||
src/icqpr
|
|
||||||
src/mycrypt
|
|
||||||
src/dighosts
|
|
||||||
*.ld.so
|
|
||||||
*.dSYM
|
|
||||||
doc/html/man3/
|
doc/html/man3/
|
||||||
doc/html/man8/
|
doc/html/man8/
|
||||||
|
doc/html/index.html
|
||||||
*.var
|
*.var
|
||||||
verfile.sh
|
verfile.sh
|
||||||
Makefile
|
Makefile
|
||||||
@@ -83,6 +63,7 @@ local.properties
|
|||||||
[Rr]elease/
|
[Rr]elease/
|
||||||
x64/
|
x64/
|
||||||
build/
|
build/
|
||||||
|
[Bb]in/
|
||||||
[Oo]bj/
|
[Oo]bj/
|
||||||
|
|
||||||
# MSTest test Results
|
# MSTest test Results
|
||||||
@@ -175,6 +156,7 @@ csx
|
|||||||
AppPackages/
|
AppPackages/
|
||||||
|
|
||||||
# Others
|
# Others
|
||||||
|
sql/
|
||||||
*.Cache
|
*.Cache
|
||||||
ClientBin/
|
ClientBin/
|
||||||
[Ss]tyle[Cc]op.*
|
[Ss]tyle[Cc]op.*
|
||||||
|
|||||||
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
@@ -1,25 +1,26 @@
|
|||||||
#include "src/version.h"
|
#include "src/version.h"
|
||||||
|
|
||||||
|
LANGUAGE 0x09, 0x01
|
||||||
|
|
||||||
1 VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 0,9,0,201022
|
FILEVERSION 0,7,0,0
|
||||||
PRODUCTVERSION 0,9,0,201022
|
PRODUCTVERSION 0,7,0,0
|
||||||
FILETYPE 1
|
FILETYPE 0x1L
|
||||||
FILESUBTYPE 0x0L
|
FILESUBTYPE 0x0L
|
||||||
BEGIN
|
BEGIN
|
||||||
BLOCK "StringFileInfo"
|
BLOCK "StringFileInfo"
|
||||||
BEGIN
|
BEGIN
|
||||||
BLOCK "040904E4"
|
BLOCK "000004b0"
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "Comments", "3proxy - tiny proxy server, http://3proxy.org/\0"
|
VALUE "Comments", "3proxy - tiny proxy server, http://3proxy.ru/"
|
||||||
VALUE "CompanyName", "Vladimir Dubrovin\0"
|
VALUE "CompanyName", "Vladimir Dubrovin"
|
||||||
VALUE "FileDescription", "3proxy - tiny proxy server\0"
|
VALUE "FileDescription", "3proxy - tiny proxy server"
|
||||||
VALUE "FileVersion", "0.9.0\0"
|
VALUE "FileVersion", VERSION "-" BUILDDATE
|
||||||
VALUE "InternalName", "3proxy\0"
|
VALUE "InternalName", "3proxy"
|
||||||
VALUE "LegalCopyright", "Copyright (C) 2002-2020 Vladimir Dubrovin\0"
|
VALUE "LegalCopyright", "Copyright (C) 2002-2014 Vladimir Dubrovin"
|
||||||
VALUE "OriginalFilename", "3proxy.exe\0"
|
VALUE "OriginalFilename", "3proxy.exe"
|
||||||
VALUE "ProductName", "3proxy\0"
|
VALUE "ProductName", "3proxy - tiny proxy server"
|
||||||
VALUE "ProductVersion", "0.9.0\0"
|
VALUE "ProductVersion", VERSION
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
#
|
|
||||||
# 3 proxy Makefile for GCC/Unix
|
|
||||||
#
|
|
||||||
# You can try to remove -DWITH_STD_MALLOC to CFLAGS to use optimized malloc
|
|
||||||
# libraries
|
|
||||||
#
|
|
||||||
# remove -DNOODBC from CFLAGS and add -lodbc to LDFLAGS to compile with ODBC
|
|
||||||
# library support. Add -DSAFESQL for poorely written ODBC library / drivers.
|
|
||||||
|
|
||||||
BUILDDIR = ../bin/
|
|
||||||
CC ?= gcc
|
|
||||||
|
|
||||||
CFLAGS = -c -O -fno-strict-aliasing -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL
|
|
||||||
COUT = -o
|
|
||||||
LN ?= ${CC}
|
|
||||||
LDFLAGS = -pthread -O -fno-strict-aliasing
|
|
||||||
# -lpthreads may be reuqired on some platforms instead of -pthreads
|
|
||||||
# -ldl or -lld may be required for some platforms
|
|
||||||
DCFLAGS = -fPIC
|
|
||||||
DLFLAGS = -shared
|
|
||||||
DLSUFFICS = .so
|
|
||||||
LIBS =
|
|
||||||
LIBSPREFIX = -l
|
|
||||||
LIBSSUFFIX =
|
|
||||||
LNOUT = -o
|
|
||||||
EXESUFFICS =
|
|
||||||
OBJSUFFICS = .o
|
|
||||||
DEFINEOPTION = -D
|
|
||||||
COMPFILES = *~
|
|
||||||
REMOVECOMMAND = rm -f
|
|
||||||
TYPECOMMAND = cat
|
|
||||||
COMPATLIBS =
|
|
||||||
MAKEFILE = Makefile.FreeBSD
|
|
||||||
PLUGINS = StringsPlugin TrafficPlugin PCREPlugin PamAuth TransparentPlugin
|
|
||||||
|
|
||||||
include Makefile.inc
|
|
||||||
|
|
||||||
install: all
|
|
||||||
if [ ! -d /usr/local/3proxy/bin ]; then mkdir -p /usr/local/3proxy/bin/; fi
|
|
||||||
install bin/3proxy /usr/local/3proxy/bin/3proxy
|
|
||||||
install bin/mycrypt /usr/local/3proxy/bin/mycrypt
|
|
||||||
install scripts/add3proxyuser.sh /usr/local/3proxy/bin/
|
|
||||||
if [ -s /usr/local/etc/3proxy/3proxy.cfg ]; then
|
|
||||||
echo /usr/local/3proxy/3proxy.cfg already exists
|
|
||||||
else
|
|
||||||
install scripts/3proxy.cfg /usr/local/etc/3proxy/
|
|
||||||
if [ ! -d /var/log/3proxy/ ]; then
|
|
||||||
mkdir /var/log/3proxy/
|
|
||||||
fi
|
|
||||||
touch /usr/local/3proxy/passwd
|
|
||||||
touch /usr/local/3proxy/counters
|
|
||||||
touch /usr/local/3proxy/bandlimiters
|
|
||||||
echo Run /usr/local/3proxy/bin/add3proxyuser.sh to add \'admin\' user
|
|
||||||
fi
|
|
||||||
|
|
||||||
allplugins:
|
|
||||||
@list='$(PLUGINS)'; for p in $$list; do cp Makefile Makefile.var plugins/$$p; cd plugins/$$p ; make ; cd ../.. ; done
|
|
||||||
+32
-92
@@ -1,25 +1,27 @@
|
|||||||
|
#$Id: Makefile.Linux,v 1.24 2014-04-07 20:34:57 vlad Exp $
|
||||||
#
|
#
|
||||||
# 3 proxy Makefile for GCC/Linux/Cygwin
|
# 3 proxy Makefile for GCC/Linux/Cygwin
|
||||||
#
|
#
|
||||||
# You can try to remove -DWITH_STD_MALLOC to CFLAGS to use optimized malloc
|
# You can try to remove -DWITH_STD_MALLOC to CFLAGS to use optimized malloc
|
||||||
# libraries
|
# libraries
|
||||||
#
|
#
|
||||||
# remove -DNOODBC from CFLAGS and add -lodbc to LIBS to compile with ODBC
|
# remove -DNOODBC from CFLAGS and add -lodbc to LDFLAGS to compile with ODBC
|
||||||
# library support. Add -DSAFESQL for poorely written ODBC library / drivers.
|
# library support. Add -DSAFESQL for poorely written ODBC library / drivers.
|
||||||
|
|
||||||
BUILDDIR = ../bin/
|
BUILDDIR =
|
||||||
CC = gcc
|
CC = gcc
|
||||||
|
|
||||||
CFLAGS = -g -fPIC -O2 -fno-strict-aliasing -c -pthread -DWITHSPLICE -D_GNU_SOURCE -DGETHOSTBYNAME_R -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL -DWITH_NETFILTER
|
CFLAGS = -Wall -g -O2 -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 =
|
DCFLAGS = -fpic
|
||||||
LDFLAGS = -fPIE -O2 -fno-strict-aliasing -pthread
|
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
|
||||||
LIBSPREFIX = -l
|
#LIBS = -lcrypto -lssl -ldl
|
||||||
LIBSSUFFIX =
|
# libcrypto and libssl are required for SSLPlugin
|
||||||
|
LIBS = -ldl
|
||||||
LNOUT = -o
|
LNOUT = -o
|
||||||
EXESUFFICS =
|
EXESUFFICS =
|
||||||
OBJSUFFICS = .o
|
OBJSUFFICS = .o
|
||||||
@@ -29,11 +31,8 @@ REMOVECOMMAND = rm -f
|
|||||||
TYPECOMMAND = cat
|
TYPECOMMAND = cat
|
||||||
COMPATLIBS =
|
COMPATLIBS =
|
||||||
MAKEFILE = Makefile.Linux
|
MAKEFILE = Makefile.Linux
|
||||||
# PamAuth requires libpam, you may require pam-devel package to be installed
|
#PLUGINS = SSLPlugin StringsPlugin TrafficPlugin PCREPlugin TransparentPlugin
|
||||||
# SSLPlugin requires -lcrypto -lssl
|
# SSLPlugin is not built by default because of external dependencies
|
||||||
#LIBS = -lcrypto -lssl -ldl
|
|
||||||
LIBS = -ldl
|
|
||||||
#PLUGINS = SSLPlugin StringsPlugin TrafficPlugin PCREPlugin TransparentPlugin PamAuth
|
|
||||||
PLUGINS = StringsPlugin TrafficPlugin PCREPlugin TransparentPlugin
|
PLUGINS = StringsPlugin TrafficPlugin PCREPlugin TransparentPlugin
|
||||||
|
|
||||||
include Makefile.inc
|
include Makefile.inc
|
||||||
@@ -42,72 +41,55 @@ allplugins:
|
|||||||
@list='$(PLUGINS)'; for p in $$list; do cp Makefile Makefile.var plugins/$$p; cd plugins/$$p ; make ; cd ../.. ; done
|
@list='$(PLUGINS)'; for p in $$list; do cp Makefile Makefile.var plugins/$$p; cd plugins/$$p ; make ; cd ../.. ; done
|
||||||
|
|
||||||
DESTDIR =
|
DESTDIR =
|
||||||
prefix =
|
prefix = /usr/local
|
||||||
exec_prefix = $(prefix)
|
exec_prefix = $(prefix)
|
||||||
man_prefix = /usr/share
|
man_prefix = $(prefix)/share
|
||||||
|
|
||||||
INSTALL = /usr/bin/install
|
INSTALL = /usr/bin/install
|
||||||
INSTALL_BIN = $(INSTALL) -m 755
|
INSTALL_BIN = $(INSTALL) -m 755
|
||||||
INSTALL_DATA = $(INSTALL) -m 644
|
INSTALL_DATA = $(INSTALL) -m 644
|
||||||
INSTALL_OBJS = bin/3proxy \
|
INSTALL_OBJS = src/3proxy \
|
||||||
bin/ftppr \
|
src/countersutil \
|
||||||
bin/mycrypt \
|
src/dighosts \
|
||||||
bin/pop3p \
|
src/ftppr \
|
||||||
bin/proxy \
|
src/mycrypt \
|
||||||
bin/socks \
|
src/pop3p \
|
||||||
bin/tcppm \
|
src/proxy \
|
||||||
bin/udppm
|
src/socks \
|
||||||
|
src/tcppm \
|
||||||
|
src/udppm
|
||||||
|
|
||||||
|
|
||||||
INSTALL_CFG = scripts/3proxy.cfg.chroot
|
|
||||||
INSTALL_CFG_OBJS = scripts/3proxy.cfg \
|
INSTALL_CFG_OBJS = scripts/3proxy.cfg \
|
||||||
scripts/add3proxyuser.sh
|
scripts/add3proxyuser.sh
|
||||||
|
INSTALL_CFG_DEST = config
|
||||||
|
|
||||||
INSTALL_CFG_OBJS2 = counters bandlimiters
|
INSTALL_CFG_OBJS2 = passwd counters bandlimiters
|
||||||
|
|
||||||
INSTALL_INITD_SCRIPT = scripts/init.d/3proxy.sh
|
|
||||||
|
|
||||||
CHROOTDIR = $(DESTDIR)/usr/local/3proxy
|
|
||||||
MANDIR1 = $(DESTDIR)$(man_prefix)/man/man1
|
MANDIR1 = $(DESTDIR)$(man_prefix)/man/man1
|
||||||
MANDIR3 = $(DESTDIR)$(man_prefix)/man/man3
|
MANDIR3 = $(DESTDIR)$(man_prefix)/man/man3
|
||||||
MANDIR8 = $(DESTDIR)$(man_prefix)/man/man8
|
MANDIR8 = $(DESTDIR)$(man_prefix)/man/man8
|
||||||
BINDIR = $(DESTDIR)$(exec_prefix)/bin
|
BINDIR = $(DESTDIR)$(exec_prefix)/bin
|
||||||
ETCDIR = $(DESTDIR)$(prefix)/etc/3proxy
|
ETCDIR = $(DESTDIR)$(prefix)/etc/3proxy
|
||||||
INITDDIR = $(DESTDIR)$(prefix)/etc/init.d
|
|
||||||
RUNBASE = $(DESTDIR)$(prefix)/var/run
|
|
||||||
RUNDIR = $(RUNBASE)/3proxy
|
|
||||||
LOGBASE = $(DESTDIR)$(prefix)/var/log
|
|
||||||
LOGDIR = $(LOGBASE)/3proxy
|
|
||||||
INSTALL_CFG_DEST = $(ETCDIR)/conf
|
|
||||||
|
|
||||||
install-bin:
|
install-bin:
|
||||||
$(INSTALL_BIN) -d $(BINDIR)
|
$(INSTALL_BIN) -d $(BINDIR)
|
||||||
$(INSTALL_BIN) -s $(INSTALL_OBJS) $(BINDIR)
|
$(INSTALL_BIN) -s $(INSTALL_OBJS) $(BINDIR)
|
||||||
$(INSTALL_BIN) -s bin/*.ld.so $(CHROOTDIR)/libexec
|
|
||||||
chmod -R a-w $(CHROOTDIR)/libexec
|
|
||||||
|
|
||||||
install-etc-dir:
|
install-etc-dir:
|
||||||
$(INSTALL_BIN) -d $(ETCDIR)
|
$(INSTALL_BIN) -d $(ETCDIR)
|
||||||
|
|
||||||
install-chroot-dir:
|
|
||||||
$(INSTALL_BIN) -d $(CHROOTDIR)
|
|
||||||
$(INSTALL_BIN) -d $(CHROOTDIR)/conf
|
|
||||||
$(INSTALL_BIN) -d $(CHROOTDIR)/logs
|
|
||||||
$(INSTALL_BIN) -d $(CHROOTDIR)/count
|
|
||||||
$(INSTALL_BIN) -d $(CHROOTDIR)/libexec
|
|
||||||
chmod -R o-rwx $(CHROOTDIR)
|
|
||||||
|
|
||||||
install-etc-default-config:
|
install-etc-default-config:
|
||||||
if [ ! -d $(INSTALL_CFG_DEST) ]; then \
|
if [ -f $(ETCDIR)/$(INSTALL_CFG_DEST) ]; then \
|
||||||
ln -s $(CHROOTDIR)/conf $(INSTALL_CFG_DEST); \
|
: ; \
|
||||||
$(INSTALL_BIN) $(INSTALL_CFG) $(ETCDIR)/3proxy.cfg; \
|
else \
|
||||||
$(INSTALL_BIN) $(INSTALL_CFG_OBJS) $(INSTALL_CFG_DEST); \
|
$(INSTALL_DATA) $(INSTALL_CFG_OBJS) $(ETCDIR)/$(INSTALL_CFG_DEST) \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
install-etc: install-etc-dir install-etc-default-config
|
install-etc: install-etc-dir
|
||||||
for file in $(INSTALL_CFG_OBJS2); \
|
for file in $(INSTALL_CFG_OBJS2); \
|
||||||
do \
|
do \
|
||||||
touch $(INSTALL_CFG_DEST)/$$file; chmod 0600 $(INSTALL_CFG_DEST)/$$file; \
|
touch $(ETCDIR)/$$file; chmod 0600 $(ETCDIR)/$$file; \
|
||||||
done;
|
done;
|
||||||
|
|
||||||
install-man:
|
install-man:
|
||||||
@@ -116,47 +98,5 @@ install-man:
|
|||||||
$(INSTALL_DATA) man/*.3 $(MANDIR3)
|
$(INSTALL_DATA) man/*.3 $(MANDIR3)
|
||||||
$(INSTALL_DATA) man/*.8 $(MANDIR8)
|
$(INSTALL_DATA) man/*.8 $(MANDIR8)
|
||||||
|
|
||||||
install-init:
|
install: install-bin install-etc install-man
|
||||||
if [ -d $(INITDIR) ]; then \
|
|
||||||
$(INSTALL_BIN) $(INSTALL_INITD_SCRIPT) $(INITDDIR)/3proxy; \
|
|
||||||
fi
|
|
||||||
if [ -f /usr/sbin/update-rc.d ]; then \
|
|
||||||
/usr/sbin/update-rc.d 3proxy defaults; \
|
|
||||||
/usr/sbin/update-rc.d 3proxy enable; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
install-run:
|
|
||||||
$(INSTALL_BIN) -d $(RUNDIR)
|
|
||||||
|
|
||||||
install-log:
|
|
||||||
@if [ -d $(LOGBASE) ] && [ ! -d $(LOGDIR) ]; then \
|
|
||||||
ln -s $(CHROOTDIR)/logs $(LOGDIR);\
|
|
||||||
fi
|
|
||||||
|
|
||||||
install: install-chroot-dir install-bin install-etc install-log install-man install-run install-init
|
|
||||||
@getent passwd proxy || useradd -UMr -s /bin/false -c 3proxy proxy
|
|
||||||
@if [ ! -f $(INSTALL_CFG_DEST)/passwd ]; then \
|
|
||||||
touch $(INSTALL_CFG_DEST)/passwd;\
|
|
||||||
fi
|
|
||||||
@chown -R proxy:proxy $(CHROOTDIR)
|
|
||||||
@chmod 550 $(CHROOTDIR)/
|
|
||||||
@chmod 550 $(CHROOTDIR)/conf/
|
|
||||||
@chmod 440 $(CHROOTDIR)/conf/*
|
|
||||||
@echo ""
|
|
||||||
@echo 3proxy installed.
|
|
||||||
@echo use
|
|
||||||
@echo " "service 3proxy start
|
|
||||||
@echo to start proxy
|
|
||||||
@echo " "service 3proxy stop
|
|
||||||
@echo to stop proxy
|
|
||||||
@echo " "$(INSTALL_CFG_DEST)/add3proxyuser.sh
|
|
||||||
@echo to add users
|
|
||||||
@echo ""
|
|
||||||
@echo Default config uses Google\'s DNS.
|
|
||||||
@echo It\'s recommended to use provider supplied DNS or install local recursor, e.g. pdns-recursor.
|
|
||||||
@echo Configure preferred DNS in $(INSTALL_CFG_DEST)/3proxy.cfg.
|
|
||||||
@echo run \'$(INSTALL_CFG_DEST)/add3proxyuser.sh admin password\' to configure \'admin\' user
|
|
||||||
@if [ -f /usr/sbin/service ]; then \
|
|
||||||
/usr/sbin/service 3proxy stop ;\
|
|
||||||
/usr/sbin/service 3proxy start ;\
|
|
||||||
fi
|
|
||||||
+4
-5
@@ -1,3 +1,4 @@
|
|||||||
|
#$Id: Makefile.Solaris,v 1.18 2008/09/30 13:58:44 vlad Exp $
|
||||||
#
|
#
|
||||||
# 3 proxy Makefile for Solaris/SunCC
|
# 3 proxy Makefile for Solaris/SunCC
|
||||||
#
|
#
|
||||||
@@ -7,18 +8,16 @@
|
|||||||
# remove -DNOODBC from CFLAGS and add -lodbc to LDFLAGS to compile with ODBC
|
# remove -DNOODBC from CFLAGS and add -lodbc to LDFLAGS to compile with ODBC
|
||||||
# library support. Add -DSAFESQL for poorely written ODBC library / drivers.
|
# library support. Add -DSAFESQL for poorely written ODBC library / drivers.
|
||||||
|
|
||||||
BUILDDIR = ../bin/
|
BUILDDIR =
|
||||||
CC = cc
|
CC = cc
|
||||||
CFLAGS = -xO3 -c -D_SOLARIS -D_THREAD_SAFE -DGETHOSTBYNAME_R -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL
|
CFLAGS = -xO3 -c -D_SOLARIS -D_THREAD_SAFE -DGETHOSTBYNAME_R -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL
|
||||||
COUT = -o ./
|
COUT = -o ./
|
||||||
LN = cc
|
LN = cc
|
||||||
LDFLAGS = -xO3
|
LDFLAGS = -xO3
|
||||||
DCFLAGS = -fPIC
|
DCFLAGS = -fpic
|
||||||
DLFLAGS = -shared
|
DLFLAGS = -shared
|
||||||
DLSUFFICS = .ld.so
|
DLSUFFICS = .ld.so
|
||||||
LIBS = -lpthread -lsocket -lnsl -lresolv -ldl
|
LIBS = -lpthread -lsocket -lnsl -lresolv -ldl
|
||||||
LIBSPREFIX = -l
|
|
||||||
LIBSSUFFIX =
|
|
||||||
LNOUT = -o ./
|
LNOUT = -o ./
|
||||||
EXESUFFICS =
|
EXESUFFICS =
|
||||||
OBJSUFFICS = .o
|
OBJSUFFICS = .o
|
||||||
@@ -28,7 +27,7 @@ REMOVECOMMAND = rm -f
|
|||||||
TYPECOMMAND = cat
|
TYPECOMMAND = cat
|
||||||
COMPATLIBS =
|
COMPATLIBS =
|
||||||
MAKEFILE = Makefile.Solaris
|
MAKEFILE = Makefile.Solaris
|
||||||
PLUGINS = StringsPlugin TrafficPlugin PCREPlugin TransparentPlugin
|
PLUGINS = StringsPlugin TrafficPlugin PCREPlugin
|
||||||
|
|
||||||
include Makefile.inc
|
include Makefile.inc
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#$Id: Makefile.Solaris-gcc,v 1.14 2008/09/30 13:58:44 vlad Exp $
|
||||||
#
|
#
|
||||||
# 3 proxy Makefile for Solaris/gcc
|
# 3 proxy Makefile for Solaris/gcc
|
||||||
#
|
#
|
||||||
@@ -8,18 +9,16 @@
|
|||||||
# library support. Add -DSAFESQL for poorely written ODBC library / drivers.
|
# library support. Add -DSAFESQL for poorely written ODBC library / drivers.
|
||||||
|
|
||||||
|
|
||||||
BUILDDIR = ../bin/
|
BUILDDIR =
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -O2 -fno-strict-aliasing -c -D_SOLARIS -D_THREAD_SAFE -DGETHOSTBYNAME_R -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL
|
CFLAGS = -O3 -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
|
||||||
DCFLAGS = -fPIC
|
DCFLAGS = -fpic
|
||||||
DLFLAGS = -shared
|
DLFLAGS = -shared
|
||||||
DLSUFFICS = .ld.so
|
DLSUFFICS = .ld.so
|
||||||
LIBS = -lpthread -lsocket -lnsl -lresolv -ldl
|
LIBS = -lpthread -lsocket -lnsl -lresolv -ldl
|
||||||
LIBSPREFIX = -l
|
|
||||||
LIBSSUFFIX =
|
|
||||||
LNOUT = -o ./
|
LNOUT = -o ./
|
||||||
EXESUFFICS =
|
EXESUFFICS =
|
||||||
OBJSUFFICS = .o
|
OBJSUFFICS = .o
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
#$Id: Makefile.ccc,v 1.12 2007/04/10 16:29:25 vlad Exp $
|
||||||
|
#
|
||||||
|
# 3 proxy Makefile for Compaq C Compiler
|
||||||
|
#
|
||||||
|
# You can try to remove -DWITH_STD_MALLOC to CFLAGS to use optimized malloc
|
||||||
|
# libraries
|
||||||
|
#
|
||||||
|
# remove -DNOODBC from CFLAGS and add -lodbc to LDFLAGS to compile with ODBC
|
||||||
|
# library support. Add -DSAFESQL for poorely written ODBC library / drivers.
|
||||||
|
|
||||||
|
BUILDDIR =
|
||||||
|
CC = ccc
|
||||||
|
CFLAGS = -Wall -O2 -c -pthread -D_THREAD_SAFE -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -WITH_POLL
|
||||||
|
COUT = -o
|
||||||
|
LN = ccc
|
||||||
|
LDFLAGS = -Wall -O2 -pthread
|
||||||
|
DCFLAGS = -fpic
|
||||||
|
DLFLAGS = -shared
|
||||||
|
DLSUFFICS = .ld.so
|
||||||
|
LIBS =
|
||||||
|
LNOUT = -o
|
||||||
|
EXESUFFICS =
|
||||||
|
OBJSUFFICS = .o
|
||||||
|
DEFINEOPTION = -D
|
||||||
|
COMPFILES = *~
|
||||||
|
REMOVECOMMAND = rm -f
|
||||||
|
TYPECOMMAND = cat
|
||||||
|
COMPATLIBS =
|
||||||
|
MAKEFILE = Makefile.ccc
|
||||||
|
PLUGINS = StringsPlugin TrafficPlugin PCREPlugin
|
||||||
|
|
||||||
|
include Makefile.inc
|
||||||
|
|
||||||
|
allplugins:
|
||||||
|
@list='$(PLUGINS)'; for p in $$list; do cp Makefile Makefile.var plugins/$$p; cd plugins/$$p ; make ; cd ../.. ; done
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#$Id: Makefile.debug,v 1.7 2007/04/18 05:33:19 vlad Exp $
|
||||||
#
|
#
|
||||||
# 3 proxy Makefile for Microsoft Visual C compiler (for both make and nmake)
|
# 3 proxy Makefile for Microsoft Visual C compiler (for both make and nmake)
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#$Id: Makefile.inc,v 1.3 2007/01/23 16:00:26 vlad Exp $
|
||||||
#
|
#
|
||||||
# 3 proxy common Makefile
|
# 3 proxy common Makefile
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#$Id: Makefile.intl,v 1.8 2007/07/21 18:47:00 vlad Exp $
|
||||||
#
|
#
|
||||||
# 3 proxy Makefile for Intel C compiler for Windows (for both make and nmake)
|
# 3 proxy Makefile for Intel C compiler for Windows (for both make and nmake)
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
#
|
|
||||||
# 3 proxy Makefile for GCC/windows
|
|
||||||
#
|
|
||||||
# You can try to remove -DWITH_STD_MALLOC to CFLAGS to use optimized malloc
|
|
||||||
# libraries
|
|
||||||
#
|
|
||||||
# remove -DNOODBC from CFLAGS and add -lodbc to LDFLAGS to compile with ODBC
|
|
||||||
# library support
|
|
||||||
|
|
||||||
|
|
||||||
BUILDDIR = ../bin/
|
|
||||||
CC = clang
|
|
||||||
CFLAGS = -O2 -fno-strict-aliasing -c -pthread -static -DWITH_STD_MALLOC -DNOIPV6
|
|
||||||
COUT = -o
|
|
||||||
LN = clang
|
|
||||||
LDFLAGS = -O2 -fno-strict-aliasing -static -s
|
|
||||||
DLFLAGS = -shared
|
|
||||||
DLSUFFICS = .dll
|
|
||||||
LIBS = -lws2_32 -lodbc32 -ladvapi32
|
|
||||||
LIBSPREFIX = -l
|
|
||||||
LIBSSUFFIX =
|
|
||||||
LNOUT = -o
|
|
||||||
EXESUFFICS = .exe
|
|
||||||
OBJSUFFICS = .o
|
|
||||||
DEFINEOPTION = -D
|
|
||||||
COMPFILES = *.tmp
|
|
||||||
REMOVECOMMAND = rm -f
|
|
||||||
TYPECOMMAND = cat
|
|
||||||
COMPATLIBS =
|
|
||||||
MAKEFILE = Makefile.win
|
|
||||||
PLUGINS = utf8tocp1251 WindowsAuthentication TrafficPlugin StringsPlugin PCREPlugin
|
|
||||||
|
|
||||||
include Makefile.inc
|
|
||||||
|
|
||||||
allplugins:
|
|
||||||
for /D %%i in ($(PLUGINS)) do (copy Makefile plugins\%%i && copy Makefile.var plugins\%%i && cd plugins\%%i && nmake && del *.o &&cd ..\..)
|
|
||||||
+8
-12
@@ -1,3 +1,4 @@
|
|||||||
|
#$Id: Makefile.msvc,v 1.17 2010-11-11 14:44:11 v.dubrovin Exp $
|
||||||
#
|
#
|
||||||
# 3 proxy Makefile for Microsoft Visual C compiler (for both make and nmake)
|
# 3 proxy Makefile for Microsoft Visual C compiler (for both make and nmake)
|
||||||
#
|
#
|
||||||
@@ -8,16 +9,14 @@
|
|||||||
|
|
||||||
BUILDDIR = ../bin/
|
BUILDDIR = ../bin/
|
||||||
CC = cl
|
CC = cl
|
||||||
CFLAGS = /nologo /MT /W3 /Ox /GS /EHs- /GA /GF /D "MSVC" /D "WITH_STD_MALLOC" /D "WITH_WSAPOLL" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "PRINTF_INT64_MODIFIER=\"I64\"" /Fp"proxy.pch" /FD /c $(VERSION) $(BUILDDATE)
|
CFLAGS = /nologo /MT /W3 /Ox /GS /EHs- /GA /GF /D "MSVC" /D "WITH_STD_MALLOC" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /Fp"proxy.pch" /FD /c
|
||||||
COUT = /Fo
|
COUT = /Fo
|
||||||
LN = link
|
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 libeay32.lib ssleay32.lib
|
LIBS = ws2_32.lib advapi32.lib odbc32.lib user32.lib kernel32.lib Gdi32.lib
|
||||||
LIBSOLD = libeay32MT.lib ssleay32MT.lib
|
LIBSOLD = libeay32MT.lib ssleay32MT.lib
|
||||||
LIBSPREFIX =
|
|
||||||
LIBSSUFFIX = .lib
|
|
||||||
LIBEXT = .lib
|
LIBEXT = .lib
|
||||||
LNOUT = /out:
|
LNOUT = /out:
|
||||||
EXESUFFICS = .exe
|
EXESUFFICS = .exe
|
||||||
@@ -28,19 +27,16 @@ REMOVECOMMAND = del 2>NUL >NUL
|
|||||||
TYPECOMMAND = type
|
TYPECOMMAND = type
|
||||||
COMPATLIBS =
|
COMPATLIBS =
|
||||||
MAKEFILE = Makefile.msvc
|
MAKEFILE = Makefile.msvc
|
||||||
PLUGINS = utf8tocp1251 WindowsAuthentication TrafficPlugin StringsPlugin PCREPlugin FilePlugin SSLPlugin
|
PLUGINS = utf8tocp1251 WindowsAuthentication TrafficPlugin StringsPlugin PCREPlugin lastFripper FilePlugin
|
||||||
VERFILE = $(VERFILE)
|
VERFILE = 3proxyres.obj $(VERFILE)
|
||||||
VERSION = $(VERSION)
|
|
||||||
BUILDDATE = $(BUILDDATE)
|
|
||||||
|
|
||||||
|
|
||||||
include Makefile.inc
|
include Makefile.inc
|
||||||
|
|
||||||
../3proxy.res:
|
../3proxy.res:
|
||||||
rc /fo../3proxy.res ../3proxy.rc $(VERSION) $(BUILDDATE)
|
rc /fo../3proxy.res ../3proxy.rc
|
||||||
|
|
||||||
3proxyres.obj: ../3proxy.res
|
3proxyres.obj: ../3proxy.res
|
||||||
cvtres /out:3proxyres.obj /MACHINE:I386 ../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 ..\..)
|
||||||
|
|||||||
+8
-16
@@ -1,3 +1,4 @@
|
|||||||
|
#$Id: Makefile.msvc64,v 1.14 2007/07/21 18:47:05 vlad Exp $
|
||||||
#
|
#
|
||||||
# 3 proxy Makefile for Microsoft Visual C compiler (for both make and nmake)
|
# 3 proxy Makefile for Microsoft Visual C compiler (for both make and nmake)
|
||||||
#
|
#
|
||||||
@@ -8,16 +9,14 @@
|
|||||||
|
|
||||||
BUILDDIR = ../bin64/
|
BUILDDIR = ../bin64/
|
||||||
CC = cl
|
CC = cl
|
||||||
CFLAGS = /nologo /MT /W3 /Ox /EHs- /GS /GA /GF /D "MSVC" /D "WITH_STD_MALLOC" /D "WITH_WSAPOLL" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "PRINTF_INT64_MODIFIER=\"I64\"" /Fp"proxy.pch" /FD /c $(VERSION) $(BUILDDATE)
|
CFLAGS = /nologo /MT /W3 /Ox /EHs- /GS /GA /GF /D "MSVC" /D "WITH_STD_MALLOC" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /Fp"proxy.pch" /FD /c
|
||||||
COUT = /Fo
|
COUT = /Fo
|
||||||
LN = link
|
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 libeay32.lib ssleay32.lib
|
LIBS = ws2_32.lib advapi32.lib odbc32.lib user32.lib kernel32.lib Gdi32.lib
|
||||||
LIBSOLD = libeay32.lib ssleay32.lib
|
LIBSOLD = libeay32MT.lib ssleay32MT.lib
|
||||||
LIBSPREFIX =
|
|
||||||
LIBSSUFFIX = .lib
|
|
||||||
LIBEXT = .lib
|
LIBEXT = .lib
|
||||||
LNOUT = /out:
|
LNOUT = /out:
|
||||||
EXESUFFICS = .exe
|
EXESUFFICS = .exe
|
||||||
@@ -28,23 +27,16 @@ REMOVECOMMAND = del 2>NUL >NUL
|
|||||||
TYPECOMMAND = type
|
TYPECOMMAND = type
|
||||||
COMPATLIBS =
|
COMPATLIBS =
|
||||||
MAKEFILE = Makefile.msvc64
|
MAKEFILE = Makefile.msvc64
|
||||||
PLUGINS = utf8tocp1251 WindowsAuthentication TrafficPlugin StringsPlugin PCREPlugin FilePlugin SSLPlugin
|
PLUGINS = utf8tocp1251 WindowsAuthentication TrafficPlugin StringsPlugin PCREPlugin
|
||||||
VERFILE = $(VERFILE)
|
VERFILE = 3proxyres.obj $(VERFILE)
|
||||||
|
|
||||||
#../3proxy.res:
|
|
||||||
# rc /fo../3proxy.res ../3proxy.rc
|
|
||||||
|
|
||||||
#3proxyres.obj: ../3proxy.res
|
|
||||||
# cvtres /out:3proxyres.obj /MACHINE:X64 ../3proxy.res
|
|
||||||
|
|
||||||
include Makefile.inc
|
include Makefile.inc
|
||||||
|
|
||||||
../3proxy.res:
|
../3proxy.res:
|
||||||
rc /fo../3proxy.res ../3proxy.rc $(VERSION) $(BUILDDATE)
|
rc /fo../3proxy.res ../3proxy.rc
|
||||||
|
|
||||||
3proxyres.obj: ../3proxy.res
|
3proxyres.obj: ../3proxy.res
|
||||||
cvtres /out:3proxyres.obj /machine:x64 ../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 ..\..)
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
#
|
|
||||||
# 3 proxy Makefile for Microsoft Visual C compiler (for both make and nmake)
|
|
||||||
#
|
|
||||||
# You can try to remove -DWITH_STD_MALLOC to CFLAGS to use optimized malloc
|
|
||||||
# libraries
|
|
||||||
#
|
|
||||||
# Add /DSAFESQL to CFLAGS if you are using poorely written/tested ODBC driver
|
|
||||||
|
|
||||||
BUILDDIR = ../bin64/
|
|
||||||
CC = cl
|
|
||||||
CFLAGS = /nologo /MT /W3 /Ox /EHs- /GS /GA /GF /D "MSVC" /D "WITH_STD_MALLOC" /D "WITH_WSAPOLL" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "PRINTF_INT64_MODIFIER=\"I64\"" /Fp"proxy.pch" /FD /c $(VERSION) $(BUILDDATE)
|
|
||||||
COUT = /Fo
|
|
||||||
LN = link
|
|
||||||
LDFLAGS = /nologo /subsystem:console /incremental:no /machine:arm64
|
|
||||||
DLFLAGS = /DLL
|
|
||||||
DLSUFFICS = .dll
|
|
||||||
LIBS = ws2_32.lib advapi32.lib odbc32.lib user32.lib kernel32.lib Gdi32.lib
|
|
||||||
LIBSOLD =
|
|
||||||
LIBSPREFIX =
|
|
||||||
LIBSSUFFIX = .lib
|
|
||||||
LIBEXT = .lib
|
|
||||||
LNOUT = /out:
|
|
||||||
EXESUFFICS = .exe
|
|
||||||
OBJSUFFICS = .obj
|
|
||||||
DEFINEOPTION = /D
|
|
||||||
COMPFILES = *.pch *.idb
|
|
||||||
REMOVECOMMAND = del 2>NUL >NUL
|
|
||||||
TYPECOMMAND = type
|
|
||||||
COMPATLIBS =
|
|
||||||
MAKEFILE = Makefile.msvcARM64
|
|
||||||
PLUGINS = utf8tocp1251 WindowsAuthentication TrafficPlugin StringsPlugin PCREPlugin FilePlugin
|
|
||||||
VERFILE = $(VERFILE)
|
|
||||||
|
|
||||||
#../3proxy.res:
|
|
||||||
# rc /fo../3proxy.res ../3proxy.rc
|
|
||||||
|
|
||||||
#3proxyres.obj: ../3proxy.res
|
|
||||||
# cvtres /out:3proxyres.obj /MACHINE:X64 ../3proxy.res
|
|
||||||
|
|
||||||
include Makefile.inc
|
|
||||||
|
|
||||||
../3proxy.res:
|
|
||||||
rc /fo../3proxy.res ../3proxy.rc $(VERSION) $(BUILDDATE)
|
|
||||||
|
|
||||||
3proxyres.obj: ../3proxy.res
|
|
||||||
cvtres /out:3proxyres.obj /machine:x64 ../3proxy.res
|
|
||||||
|
|
||||||
|
|
||||||
allplugins:
|
|
||||||
for /D %%i in ($(PLUGINS)) do (copy Makefile plugins\%%i && copy Makefile.var plugins\%%i && cd plugins\%%i && nmake && del *.obj *.idb &&cd ..\..)
|
|
||||||
|
|
||||||
+2
-1
@@ -1,3 +1,4 @@
|
|||||||
|
#$Id: Makefile.msvc,v 1.14 2007/07/21 18:47:02 vlad Exp $
|
||||||
#
|
#
|
||||||
# 3 proxy Makefile for Microsoft Visual C compiler (for both make and nmake)
|
# 3 proxy Makefile for Microsoft Visual C compiler (for both make and nmake)
|
||||||
#
|
#
|
||||||
@@ -8,7 +9,7 @@
|
|||||||
|
|
||||||
BUILDDIR = ../bin/
|
BUILDDIR = ../bin/
|
||||||
CC = cl
|
CC = cl
|
||||||
CFLAGS = /DARM /D "NOODBC" /nologo /MT /W3 /Wp64 /Ox /GS /EHs- /GA /GF /D "MSVC" /D "_WINCE" /D "WITH_STD_MALLOC" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "PRINTF_INT64_MODIFIER=\"I64\"" /Fp"proxy.pch" /FD /c
|
CFLAGS = /DARM /D "NOODBC" /nologo /MT /W3 /Wp64 /Ox /GS /EHs- /GA /GF /D "MSVC" /D "_WINCE" /D "WITH_STD_MALLOC" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /Fp"proxy.pch" /FD /c
|
||||||
COUT = /Fo
|
COUT = /Fo
|
||||||
LN = link
|
LN = link
|
||||||
LDFLAGS = /nologo /subsystem:console /incremental:no
|
LDFLAGS = /nologo /subsystem:console /incremental:no
|
||||||
|
|||||||
@@ -1,101 +0,0 @@
|
|||||||
#
|
|
||||||
# 3 proxy Makefile for GCC/Linux/Cygwin
|
|
||||||
#
|
|
||||||
# You can try to remove -DWITH_STD_MALLOC to CFLAGS to use optimized malloc
|
|
||||||
# libraries
|
|
||||||
#
|
|
||||||
# remove -DNOODBC from CFLAGS and add -lodbc to LIBS to compile with ODBC
|
|
||||||
# library support. Add -DSAFESQL for poorely written ODBC library / drivers.
|
|
||||||
|
|
||||||
BUILDDIR = ../bin/
|
|
||||||
CC = mips-openwrt-linux-gcc
|
|
||||||
|
|
||||||
CFLAGS = -g -O2 -fno-strict-aliasing -c -pthread -DGETHOSTBYNAME_R -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL -DWITH_NETFILTER
|
|
||||||
COUT = -o
|
|
||||||
LN = mips-openwrt-linux-gcc
|
|
||||||
DCFLAGS = -fPIC
|
|
||||||
LDFLAGS = -O2 -fno-strict-aliasing -pthread -s
|
|
||||||
DLFLAGS = -shared
|
|
||||||
DLSUFFICS = .ld.so
|
|
||||||
# -lpthreads may be reuqired on some platforms instead of -pthreads
|
|
||||||
LIBSPREFIX = -l
|
|
||||||
LIBSSUFFIX =
|
|
||||||
LNOUT = -o
|
|
||||||
EXESUFFICS =
|
|
||||||
OBJSUFFICS = .o
|
|
||||||
DEFINEOPTION = -D
|
|
||||||
COMPFILES = *~
|
|
||||||
REMOVECOMMAND = rm -f
|
|
||||||
TYPECOMMAND = cat
|
|
||||||
COMPATLIBS =
|
|
||||||
MAKEFILE = Makefile.openwrt-mips
|
|
||||||
# PamAuth requires libpam, you may require pam-devel package to be installed
|
|
||||||
# SSLPlugin requires -lcrypto -lssl
|
|
||||||
#LIBS = -lcrypto -lssl -ldl
|
|
||||||
LIBS = -ldl
|
|
||||||
#PLUGINS = SSLPlugin StringsPlugin TrafficPlugin PCREPlugin TransparentPlugin PamAuth
|
|
||||||
PLUGINS = StringsPlugin TrafficPlugin PCREPlugin TransparentPlugin
|
|
||||||
|
|
||||||
include Makefile.inc
|
|
||||||
|
|
||||||
allplugins:
|
|
||||||
@list='$(PLUGINS)'; for p in $$list; do cp Makefile Makefile.var plugins/$$p; cd plugins/$$p ; make ; cd ../.. ; done
|
|
||||||
|
|
||||||
DESTDIR =
|
|
||||||
prefix = /usr/local
|
|
||||||
exec_prefix = $(prefix)
|
|
||||||
man_prefix = $(prefix)/share
|
|
||||||
|
|
||||||
INSTALL = /usr/bin/install
|
|
||||||
INSTALL_BIN = $(INSTALL) -m 755
|
|
||||||
INSTALL_DATA = $(INSTALL) -m 644
|
|
||||||
INSTALL_OBJS = src/3proxy \
|
|
||||||
src/ftppr \
|
|
||||||
src/mycrypt \
|
|
||||||
src/pop3p \
|
|
||||||
src/proxy \
|
|
||||||
src/socks \
|
|
||||||
src/tcppm \
|
|
||||||
src/udppm
|
|
||||||
|
|
||||||
|
|
||||||
INSTALL_CFG_OBJS = scripts/3proxy.cfg \
|
|
||||||
scripts/add3proxyuser.sh
|
|
||||||
INSTALL_CFG_DEST = config
|
|
||||||
|
|
||||||
INSTALL_CFG_OBJS2 = passwd counters bandlimiters
|
|
||||||
|
|
||||||
MANDIR1 = $(DESTDIR)$(man_prefix)/man/man1
|
|
||||||
MANDIR3 = $(DESTDIR)$(man_prefix)/man/man3
|
|
||||||
MANDIR8 = $(DESTDIR)$(man_prefix)/man/man8
|
|
||||||
BINDIR = $(DESTDIR)$(exec_prefix)/bin
|
|
||||||
ETCDIR = $(DESTDIR)$(prefix)/etc/3proxy
|
|
||||||
|
|
||||||
install-bin:
|
|
||||||
$(INSTALL_BIN) -d $(BINDIR)
|
|
||||||
$(INSTALL_BIN) -s $(INSTALL_OBJS) $(BINDIR)
|
|
||||||
|
|
||||||
install-etc-dir:
|
|
||||||
$(INSTALL_BIN) -d $(ETCDIR)
|
|
||||||
|
|
||||||
install-etc-default-config:
|
|
||||||
if [ -f $(ETCDIR)/$(INSTALL_CFG_DEST) ]; then \
|
|
||||||
: ; \
|
|
||||||
else \
|
|
||||||
$(INSTALL_DATA) $(INSTALL_CFG_OBJS) $(ETCDIR)/$(INSTALL_CFG_DEST) \
|
|
||||||
fi
|
|
||||||
|
|
||||||
install-etc: install-etc-dir
|
|
||||||
for file in $(INSTALL_CFG_OBJS2); \
|
|
||||||
do \
|
|
||||||
touch $(ETCDIR)/$$file; chmod 0600 $(ETCDIR)/$$file; \
|
|
||||||
done;
|
|
||||||
|
|
||||||
install-man:
|
|
||||||
$(INSTALL_BIN) -d $(MANDIR3)
|
|
||||||
$(INSTALL_BIN) -d $(MANDIR8)
|
|
||||||
$(INSTALL_DATA) man/*.3 $(MANDIR3)
|
|
||||||
$(INSTALL_DATA) man/*.8 $(MANDIR8)
|
|
||||||
|
|
||||||
install: install-bin install-etc install-man
|
|
||||||
|
|
||||||
+8
-9
@@ -1,3 +1,4 @@
|
|||||||
|
#$Id: Makefile.unix,v 1.20 2007/04/10 16:29:25 vlad Exp $
|
||||||
#
|
#
|
||||||
# 3 proxy Makefile for GCC/Unix
|
# 3 proxy Makefile for GCC/Unix
|
||||||
#
|
#
|
||||||
@@ -7,22 +8,20 @@
|
|||||||
# remove -DNOODBC from CFLAGS and add -lodbc to LDFLAGS to compile with ODBC
|
# remove -DNOODBC from CFLAGS and add -lodbc to LDFLAGS to compile with ODBC
|
||||||
# library support. Add -DSAFESQL for poorely written ODBC library / drivers.
|
# library support. Add -DSAFESQL for poorely written ODBC library / drivers.
|
||||||
|
|
||||||
BUILDDIR = ../bin/
|
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 -fno-strict-aliasing -c -pthread -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL
|
CFLAGS = -Wall -g -O2 -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 -fno-strict-aliasing -pthread
|
LDFLAGS = -Wall -O2 -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
|
||||||
DLFLAGS = -shared
|
DLFLAGS = -shared
|
||||||
DLSUFFICS = .ld.so
|
DLSUFFICS = .ld.so
|
||||||
LIBS =
|
LIBS =
|
||||||
LIBSPREFIX = -l
|
|
||||||
LIBSSUFFIX =
|
|
||||||
LNOUT = -o
|
LNOUT = -o
|
||||||
EXESUFFICS =
|
EXESUFFICS =
|
||||||
OBJSUFFICS = .o
|
OBJSUFFICS = .o
|
||||||
@@ -32,14 +31,14 @@ REMOVECOMMAND = rm -f
|
|||||||
TYPECOMMAND = cat
|
TYPECOMMAND = cat
|
||||||
COMPATLIBS =
|
COMPATLIBS =
|
||||||
MAKEFILE = Makefile.unix
|
MAKEFILE = Makefile.unix
|
||||||
PLUGINS = StringsPlugin TrafficPlugin PCREPlugin PamAuth TransparentPlugin
|
PLUGINS = StringsPlugin TrafficPlugin PCREPlugin
|
||||||
|
|
||||||
include Makefile.inc
|
include Makefile.inc
|
||||||
|
|
||||||
install: all
|
install: all
|
||||||
if [ ! -d /usr/local/etc/3proxy/bin ]; then mkdir -p /usr/local/etc/3proxy/bin/; fi
|
if [ ! -d /usr/local/etc/3proxy/bin ]; then mkdir -p /usr/local/etc/3proxy/bin/; fi
|
||||||
install bin/3proxy /usr/local/etc/3proxy/bin/3proxy
|
install src/3proxy /usr/local/etc/3proxy/bin/3proxy
|
||||||
install bin/mycrypt /usr/local/etc/3proxy/bin/mycrypt
|
install src/mycrypt /usr/local/etc/3proxy/bin/mycrypt
|
||||||
install scripts/rc.d/proxy.sh /usr/local/etc/rc.d/proxy.sh
|
install scripts/rc.d/proxy.sh /usr/local/etc/rc.d/proxy.sh
|
||||||
install scripts/add3proxyuser.sh /usr/local/etc/3proxy/bin/
|
install scripts/add3proxyuser.sh /usr/local/etc/3proxy/bin/
|
||||||
if [ -s /usr/local/etc/3proxy/3proxy.cfg ]; then
|
if [ -s /usr/local/etc/3proxy/3proxy.cfg ]; then
|
||||||
|
|||||||
+10
-8
@@ -6,14 +6,16 @@ man_prefix = $(prefix)/share
|
|||||||
INSTALL = /usr/bin/install
|
INSTALL = /usr/bin/install
|
||||||
INSTALL_BIN = $(INSTALL) -m 755
|
INSTALL_BIN = $(INSTALL) -m 755
|
||||||
INSTALL_DATA = $(INSTALL) -m 644
|
INSTALL_DATA = $(INSTALL) -m 644
|
||||||
INSTALL_OBJS = bin/3proxy \
|
INSTALL_OBJS = src/3proxy \
|
||||||
bin/ftppr \
|
src/countersutil \
|
||||||
bin/mycrypt \
|
src/dighosts \
|
||||||
bin/pop3p \
|
src/ftppr \
|
||||||
bin/proxy \
|
src/mycrypt \
|
||||||
bin/socks \
|
src/pop3p \
|
||||||
bin/tcppm \
|
src/proxy \
|
||||||
bin/udppm \
|
src/socks \
|
||||||
|
src/tcppm \
|
||||||
|
src/udppm \
|
||||||
scripts/add3proxyuser.sh
|
scripts/add3proxyuser.sh
|
||||||
|
|
||||||
INSTALL_CFG_OBJS = scripts/3proxy.cfg
|
INSTALL_CFG_OBJS = scripts/3proxy.cfg
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
#
|
|
||||||
# 3 proxy Makefile for Open Watcom 2
|
|
||||||
#
|
|
||||||
# You can try to remove -DWITH_STD_MALLOC to CFLAGS to use optimized malloc
|
|
||||||
# libraries
|
|
||||||
#
|
|
||||||
# Add /DSAFESQL to CFLAGS if you are using poorely written/tested ODBC driver
|
|
||||||
|
|
||||||
BUILDDIR = ../bin/
|
|
||||||
CC = cl
|
|
||||||
CFLAGS = /nologo /Ox /MT /D "NOIPV6" /D "NODEBUG" /D "NOODBC" /D "NORADIUS" /D"WATCOM" /D "MSVC" /D "WITH_STD_MALLOC" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "PRINTF_INT64_MODIFIER=\"I64\"" /c $(VERSION) $(BUILDDATE)
|
|
||||||
COUT = /Fo
|
|
||||||
LN = link
|
|
||||||
LDFLAGS = /nologo /subsystem:console /incremental:no
|
|
||||||
DLFLAGS = /DLL
|
|
||||||
DLSUFFICS = .dll
|
|
||||||
LIBS = ws2_32.lib advapi32.lib user32.lib kernel32.lib
|
|
||||||
LIBSOLD = libeay32MT.lib ssleay32MT.lib
|
|
||||||
LIBSPREFIX =
|
|
||||||
LIBSSUFFIX = .lib
|
|
||||||
LIBEXT = .lib
|
|
||||||
LNOUT = /out:
|
|
||||||
EXESUFFICS = .exe
|
|
||||||
OBJSUFFICS = .obj
|
|
||||||
DEFINEOPTION = /D
|
|
||||||
COMPFILES = *.pch *.idb *.err
|
|
||||||
REMOVECOMMAND = del 2>NUL >NUL
|
|
||||||
TYPECOMMAND = type
|
|
||||||
COMPATLIBS =
|
|
||||||
MAKEFILE = Makefile.watcom
|
|
||||||
PLUGINS = utf8tocp1251 WindowsAuthentication TrafficPlugin StringsPlugin PCREPlugin
|
|
||||||
VERFILE = $(VERFILE)
|
|
||||||
|
|
||||||
include Makefile.inc
|
|
||||||
|
|
||||||
../3proxy.res:
|
|
||||||
rc /fo../3proxy.res ../3proxy.rc $(VERSION) $(BUILDDATE)
|
|
||||||
|
|
||||||
3proxyres.obj: ../3proxy.res
|
|
||||||
cvtres /out:3proxyres.obj ../3proxy.res
|
|
||||||
|
|
||||||
allplugins:
|
|
||||||
call ../makeplugins.bat
|
|
||||||
+3
-4
@@ -1,3 +1,4 @@
|
|||||||
|
#$Id: Makefile.win,v 1.9 2007/08/20 15:26:27 vlad Exp $
|
||||||
#
|
#
|
||||||
# 3 proxy Makefile for GCC/windows
|
# 3 proxy Makefile for GCC/windows
|
||||||
#
|
#
|
||||||
@@ -10,15 +11,13 @@
|
|||||||
|
|
||||||
BUILDDIR = ../bin/
|
BUILDDIR = ../bin/
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -O2 -s -c -mthreads -DWITH_STD_MALLOC -DNOIPV6 -DNORADIUS
|
CFLAGS = -O2 -s -c -mthreads -DWITH_STD_MALLOC
|
||||||
COUT = -o
|
COUT = -o
|
||||||
LN = gcc
|
LN = gcc
|
||||||
LDFLAGS = -O2 -s -mthreads
|
LDFLAGS = -O2 -s -mthreads
|
||||||
DLFLAGS = -shared
|
DLFLAGS = -shared
|
||||||
DLSUFFICS = .dll
|
DLSUFFICS = .dll
|
||||||
LIBS = -lws2_32 -lodbc32 -ladvapi32
|
LIBS = -lws2_32 -lodbc32 -ladvapi32
|
||||||
LIBSPREFIX = -l
|
|
||||||
LIBSSUFFIX =
|
|
||||||
LNOUT = -o
|
LNOUT = -o
|
||||||
EXESUFFICS = .exe
|
EXESUFFICS = .exe
|
||||||
OBJSUFFICS = .o
|
OBJSUFFICS = .o
|
||||||
|
|||||||
+3
-2
@@ -1,3 +1,4 @@
|
|||||||
|
#$Id: Makefile.win,v 1.9 2007/08/20 15:26:27 vlad Exp $
|
||||||
#
|
#
|
||||||
# 3 proxy Makefile for GCC/windows
|
# 3 proxy Makefile for GCC/windows
|
||||||
#
|
#
|
||||||
@@ -10,10 +11,10 @@
|
|||||||
|
|
||||||
BUILDDIR = ../bin/
|
BUILDDIR = ../bin/
|
||||||
CC = /opt/cegcc/arm-wince-cegcc/bin/gcc
|
CC = /opt/cegcc/arm-wince-cegcc/bin/gcc
|
||||||
CFLAGS = -O2 -s -c -mthreads -DWITH_STD_MALLOC -DNOODBC -D_WINCE -D_WIN32 -DNORADIUS -D__USE_W32_SOCKETS
|
CFLAGS = -Wall -O2 -s -c -mthreads -DWITH_STD_MALLOC -DNOODBC -D_WINCE -D_WIN32 -D__USE_W32_SOCKETS
|
||||||
COUT = -o
|
COUT = -o
|
||||||
LN = /opt/cegcc/arm-wince-cegcc/bin/gcc
|
LN = /opt/cegcc/arm-wince-cegcc/bin/gcc
|
||||||
LDFLAGS = -O2 -s -mthreads
|
LDFLAGS = -Wall -O2 -s -mthreads
|
||||||
DLFLAGS = -shared
|
DLFLAGS = -shared
|
||||||
DLSUFFICS = .dll
|
DLSUFFICS = .dll
|
||||||
LIBS = -lws2
|
LIBS = -lws2
|
||||||
|
|||||||
@@ -1,156 +1,24 @@
|
|||||||
# 3APA3A 3proxy tiny proxy server
|
/*
|
||||||
(c) 2002-2020 by Vladimir '3APA3A' Dubrovin <3proxy@3proxy.ru>
|
3APA3A 3proxy tiny proxy server
|
||||||
|
(c) 2002-2014 by Vladimir '3APA3A' Dubrovin <3proxy@3proxy.ru>
|
||||||
Download:
|
|
||||||
https://github.com/z3APA3A/3proxy/releases
|
|
||||||
or
|
|
||||||
https://3proxy.org/download/
|
|
||||||
Archive of old versions: https://github.com/z3APA3A/3proxy-archive
|
|
||||||
|
|
||||||
|
|
||||||
3proxy --install
|
|
||||||
|
|
||||||
installs and starts proxy as Windows service
|
|
||||||
(config file should be located in the same directory)
|
|
||||||
|
|
||||||
3proxy --remove
|
|
||||||
|
|
||||||
removes the service (should be stopped before via
|
|
||||||
'net stop 3proxy').
|
|
||||||
|
|
||||||
To build in Linux install git and build-essential packages, use
|
|
||||||
|
|
||||||
git clone https://github.com/z3apa3a/3proxy
|
|
||||||
cd 3proxy
|
|
||||||
ln -s Makefile.Linux Makefile
|
|
||||||
make
|
|
||||||
sudo make install
|
|
||||||
|
|
||||||
use /etc/3proxy/add3proxyuser.sh script to add users.
|
|
||||||
|
|
||||||
|
please read License Agreement
|
||||||
|
*/
|
||||||
|
|
||||||
Please read doc/html/index.html and man pages.
|
Please read doc/html/index.html and man pages.
|
||||||
|
|
||||||
Features:
|
|
||||||
1. General
|
|
||||||
+ IPv6 support for incoming and outgoing connection,
|
|
||||||
can be used as a proxy between IPv4 and IPv6 networks
|
|
||||||
in either direction.
|
|
||||||
+ HTTP/1.1 Proxy with keep-alive client and server support,
|
|
||||||
transparent proxy support.
|
|
||||||
+ HTTPS (CONNECT) proxy (compatible with HTTP/2 / SPDY)
|
|
||||||
+ Anonymous and random client IP emulation for HTTP proxy mode
|
|
||||||
+ FTP over HTTP support.
|
|
||||||
+ DNS caching with built-in resolver
|
|
||||||
+ DNS proxy
|
|
||||||
+ DNS over TCP support, redirecting DNS traffic via parent
|
|
||||||
proxy
|
|
||||||
+ SOCKSv4/4.5 Proxy
|
|
||||||
+ SOCKSv5 Proxy
|
|
||||||
+ SOCKSv5 UDP and BIND support (fully compatible with
|
|
||||||
SocksCAP/FreeCAP for UDP)
|
|
||||||
+ Transparent SOCKS redirection for HTTP, POP3, FTP, SMTP
|
|
||||||
+ POP3 Proxy
|
|
||||||
+ FTP proxy
|
|
||||||
+ TCP port mapper (port forwarding)
|
|
||||||
+ UDP port mapper (port forwarding)
|
|
||||||
+ SMTP proxy
|
|
||||||
+ Threaded application (no child process).
|
|
||||||
+ Web administration and statistics
|
|
||||||
+ Plugins for functionality extension
|
|
||||||
+ Native 32/64 bit application
|
|
||||||
2. Proxy chaining and network connections
|
|
||||||
+ Can be used as a bridge between client and different proxy type
|
|
||||||
(e.g. convert incoming HTTP proxy request from client to SOCKSv5
|
|
||||||
request to parent server).
|
|
||||||
+ Connect back proxy support to bypass firewalls
|
|
||||||
+ Parent proxy support for any type of incoming connection
|
|
||||||
+ Username/password authentication for parent proxy(s).
|
|
||||||
+ HTTPS/SOCKS4/SOCKS5 and ip/port redirection parent support
|
|
||||||
+ Random parent selection
|
|
||||||
+ Chain building (multihop proxing)
|
|
||||||
+ Load balancing between few network connections by choosing network
|
|
||||||
interface
|
|
||||||
3. Logging
|
|
||||||
+ tuneable log format compatible with any log parser
|
|
||||||
+ stdout logging
|
|
||||||
+ file logging
|
|
||||||
+ syslog logging (Unix)
|
|
||||||
+ ODBC logging
|
|
||||||
+ RADIUS accounting
|
|
||||||
+ log file rotation
|
|
||||||
+ automatic log file processing with external archiver (for files)
|
|
||||||
+ Character filtering for log files
|
|
||||||
+ different log files for different servces are supported
|
|
||||||
4. Access control
|
|
||||||
+ ACL-driven Access control by username, source IP,
|
|
||||||
destination IP/hostname, destination port and destination action
|
|
||||||
(POST, PUT, GET, etc), weekday and daytime.
|
|
||||||
+ ACL-driven (user/source/destination/protocol/weekday/daytime or
|
|
||||||
combined) bandwith limitation for incoming and (!)outgoing trafic.
|
|
||||||
+ ACL-driven traffic limitation per day, week or month for incoming and
|
|
||||||
outgoing traffic
|
|
||||||
+ Connection limitation and ratelimting
|
|
||||||
+ User authentication by username / password
|
|
||||||
+ RADIUS Authentication and Authorization
|
|
||||||
+ User authentication by DNS hostname
|
|
||||||
+ Authentication cache with possibility to limit user to single IP address
|
|
||||||
+ Access control by username/password for SOCKSv5 and HTTP/HTTPS/FTP
|
|
||||||
+ Cleartext or encrypted (crypt/MD5 or NT) passwords.
|
|
||||||
+ Connection redirection
|
|
||||||
+ Access control by requested action (CONNECT/BIND,
|
|
||||||
HTTP GET/POST/PUT/HEAD/OTHER).
|
|
||||||
+ All access control entries now support weekday and time limitations
|
|
||||||
+ Hostnames and * templates are supported instead of IP address
|
|
||||||
5. Extensions
|
|
||||||
+ Regular expression filtering (with PCRE) via PCREPlugin
|
|
||||||
+ Authentication with Windows username/password (cleartext only)
|
|
||||||
+ SSL/TLS decryptions with certificate spoofing
|
|
||||||
+ Transparent redirection support for Linux and *BSD
|
|
||||||
6. Configuration
|
|
||||||
+ support for configuration files
|
|
||||||
+ support for includes in configuration files
|
|
||||||
+ interface binding
|
|
||||||
+ socket options
|
|
||||||
+ running as daemon process
|
|
||||||
+ utility for automated networks list building
|
|
||||||
+ configuration reload on any file change
|
|
||||||
Unix
|
|
||||||
+ support for chroot
|
|
||||||
+ support for setgid
|
|
||||||
+ support for setuid
|
|
||||||
+ support for signals (SIGUSR1 to reload configuration)
|
|
||||||
Windows
|
|
||||||
+ support --install as service
|
|
||||||
+ support --remove as service
|
|
||||||
+ support for service START, STOP, PAUSE and CONTINUE commands (on
|
|
||||||
PAUSE no new connection accepted, but active connections still in
|
|
||||||
progress, on CONTINUE configuration is reloaded)
|
|
||||||
Windows 95/98/ME
|
|
||||||
+ support --install as service
|
|
||||||
+ support --remove as service
|
|
||||||
6. Compilation
|
|
||||||
+ MSVC (static)
|
|
||||||
+ OpenWatcom (static)
|
|
||||||
+ Intel Windows Compiler (msvcrt.dll)
|
|
||||||
+ Windows/gcc (msvcrt.dll)
|
|
||||||
+ Cygwin/gcc (cygwin.dll)
|
|
||||||
+ Unix/gcc
|
|
||||||
+ Unix/ccc
|
|
||||||
+ Solaris
|
|
||||||
+ Mac OS X, iPhone OS
|
|
||||||
+ Linux and derivered systems
|
|
||||||
+ Lite version for Windows 95/98/NT/2000/XP/2003
|
|
||||||
+ 32 bit and 64 bit versions for Windows Vista and above, Windows 2008 server and above
|
|
||||||
|
|
||||||
3proxy Combined proxy server may be used as
|
3proxy Combined proxy server may be used as
|
||||||
|
Windows 95/98/NT/2000/XP/2003/Vista
|
||||||
executable or service (supports installation and removal).
|
executable or service (supports installation and removal).
|
||||||
It uses config file to read it's configuration (see
|
It uses config file to read it's configuration (see
|
||||||
3proxy.cfg.sample for details).
|
3proxy.cfg.sample for details).
|
||||||
|
--install installs and starts proxy as NT/2000/XP service
|
||||||
|
(config file should be located in the same directory)
|
||||||
|
--remove removes the service (should be stopped before via
|
||||||
|
net stop 3proxy).
|
||||||
3proxy.exe is all-in-one, it doesn't require all others .exe
|
3proxy.exe is all-in-one, it doesn't require all others .exe
|
||||||
to work.
|
to work.
|
||||||
See 3proxy.cfg.sample for examples, see man 3proxy.cfg
|
See 3proxy.cfg.sample for examples, see man 3proxy.cfg
|
||||||
|
|
||||||
proxy HTTP proxy server, binds to port 3128
|
proxy HTTP proxy server, binds to port 3128
|
||||||
ftppr FTP proxy server, binds to port 21
|
ftppr FTP proxy server, binds to port 21
|
||||||
socks SOCKS 4/5 proxy server, binds to port 1080
|
socks SOCKS 4/5 proxy server, binds to port 1080
|
||||||
@@ -160,14 +28,18 @@ pop3p POP3 proxy server, binds to port 110. You must specify
|
|||||||
POP3 username as username@target.host.ip[:port]
|
POP3 username as username@target.host.ip[:port]
|
||||||
port is 110 by default.
|
port is 110 by default.
|
||||||
Exmple: in Username configuration for you e-mail reader
|
Exmple: in Username configuration for you e-mail reader
|
||||||
set someuser@pop.example.org, to obtains mail for someuser
|
set someuser@pop.somehost.ru, to obtains mail for someuser
|
||||||
from pop.somehost.ru via proxy.
|
from pop.somehost.ru via proxy.
|
||||||
smtpp SMTP proxy server, binds to port 25. You must specify
|
smtpp SMTP proxy server, binds to port 25. You must specify
|
||||||
SMTP username as username@target.host.ip[:port]
|
SMTP username as username@target.host.ip[:port]
|
||||||
port is 25 by default.
|
port is 25 by default.
|
||||||
Exmple: in Username configuration for you e-mail reader
|
Exmple: in Username configuration for you e-mail reader
|
||||||
set someuser@mail.example.org, to send mail as someuser
|
set someuser@mail.somehost.ru, to send mail as someuser
|
||||||
via mail.somehost.ru via proxy.
|
via mail.somehost.ru via proxy.
|
||||||
|
icqpr ICQ/AIM proxy. Maps some TCP port to TCP port of ICQ
|
||||||
|
server and performs packets translation. Example:
|
||||||
|
icqpr 5190 login.icq.com 5190
|
||||||
|
msnpr MSN proxy (beta)
|
||||||
tcppm TCP port mapping. Maps some TCP port on local machine to
|
tcppm TCP port mapping. Maps some TCP port on local machine to
|
||||||
TCP port on remote host.
|
TCP port on remote host.
|
||||||
udppm UDP port mapping. Maps some UDP port on local machine to
|
udppm UDP port mapping. Maps some UDP port on local machine to
|
||||||
@@ -184,10 +56,9 @@ mycrypt Program to obtain crypted password fro cleartext. Supports
|
|||||||
mycrypt salt password
|
mycrypt salt password
|
||||||
produces MD5/crypt password with salt "salt".
|
produces MD5/crypt password with salt "salt".
|
||||||
dighosts Utility for building networks list from web page.
|
dighosts Utility for building networks list from web page.
|
||||||
|
countersutil Utility to manage counters file
|
||||||
|
|
||||||
|
|
||||||
Run utility with --help option for command line reference.
|
Run utility with --help option for command line reference.
|
||||||
|
|
||||||
Latest version is available from https://3proxy.org/
|
Latest version is available from http://3proxy.ru/
|
||||||
|
|
||||||
Want to donate the project? https://3proxy.org/donations/
|
|
||||||
+107
@@ -0,0 +1,107 @@
|
|||||||
|
08/04/2014 3[APA3A]tiny proxy 0.7
|
||||||
|
|
||||||
|
Features:
|
||||||
|
1. General
|
||||||
|
+ HTTP/1.1 Proxy with keep-alive client and server support,
|
||||||
|
transparent proxy support.
|
||||||
|
+ Anonymous and random client emulation HTTP proxy mode
|
||||||
|
+ FTP over HTTP support.
|
||||||
|
+ DNS caching with built-in resolver
|
||||||
|
+ HTTPS (CONNECT) proxy
|
||||||
|
+ SOCKSv4/4.5 Proxy
|
||||||
|
+ SOCKSv5 Proxy
|
||||||
|
+ UDP and bind support for SOCKSv5 (fully compatible with
|
||||||
|
SocksCAP/FreeCAP for UDP)
|
||||||
|
+ Transparent SOCKS redirection for HTTP, POP3, FTP, SMTP, ICQ
|
||||||
|
+ POP3 Proxy
|
||||||
|
+ FTP proxy
|
||||||
|
+ DNS proxy
|
||||||
|
+ TCP port mapper
|
||||||
|
+ UDP port mapper
|
||||||
|
+ SMTP proxy
|
||||||
|
+ ICQ/AOL proxy
|
||||||
|
+ MSN proxy
|
||||||
|
+ Threaded application (no child process).
|
||||||
|
+ Web administration and statistics
|
||||||
|
+ Plugins for functionality extension
|
||||||
|
+ Native 64 bit application for 64 bit OS, including 64-bit editions of
|
||||||
|
Windows XP, Vista, 2003, 2008.
|
||||||
|
2. Proxy chaining and network connections
|
||||||
|
+ Parent proxy support for any type of incoming connection
|
||||||
|
+ Username/password authentication for parent proxy(s).
|
||||||
|
+ HTTPS/SOCKS4/SOCKS5 and redirection parent support
|
||||||
|
+ Random parent selection
|
||||||
|
+ Chain building (multihop proxing)
|
||||||
|
+ Load balancing between few network connections by choosing network
|
||||||
|
interface
|
||||||
|
3. Logging
|
||||||
|
+ turnable log format compatible with any log parser
|
||||||
|
+ stdout logging
|
||||||
|
+ file logging
|
||||||
|
+ syslog logging (Unix)
|
||||||
|
+ ODBC logging (Windows and Unix)
|
||||||
|
+ log file rotation (hourly, daily, weekly, monthly)
|
||||||
|
+ automatic log file comperssion with external archiver (for files)
|
||||||
|
+ automatic removal of older log files
|
||||||
|
+ Character filtering for log files
|
||||||
|
+ different log files for different servces are supported
|
||||||
|
4. Access control
|
||||||
|
+ ACL-driven (user/source/destination/protocol/weekday/daytime or
|
||||||
|
combined) bandwith limitation for incoming and (!)outgoing trafic.
|
||||||
|
+ ACL-driven (user/source/destination/protocol/weekday/daytime or
|
||||||
|
combined) traffic limitation per day, week or month for incoming and
|
||||||
|
(!) outgoing traffic
|
||||||
|
+ User authorization by NetBIOS messanger name
|
||||||
|
+ Access control by username, source IP, destination IP, destination
|
||||||
|
port and destination action (POST, PUT, GET, etc), weekday and daytime.
|
||||||
|
+ Access control by username/password for SOCKSv5 and HTTP/HTTPS/FTP
|
||||||
|
+ Cleartext or encrypted (crypt/MD5 or NT) passwords.
|
||||||
|
+ Connection redirection
|
||||||
|
+ Access control by requested action (CONNECT/BIND,
|
||||||
|
HTTP GET/POST/PUT/HEAD/OTHER).
|
||||||
|
+ NTLM (v1 only) authentication for HTTP proxy access
|
||||||
|
+ All access control entries now support weekday and time limitations
|
||||||
|
+ Hostnames and * templates are supported instead of IP address
|
||||||
|
5. Extensions
|
||||||
|
+ Regular expression filtering (with PCRE) via PCREPlugin
|
||||||
|
currently HTTP traffic only for URLs, HTTP headers and HTTP data.
|
||||||
|
+ Authentication with Windows username/password (cleartext only!)
|
||||||
|
6. Configuration
|
||||||
|
+ support for configuration files
|
||||||
|
+ support for includes in configuration files
|
||||||
|
+ interface binding
|
||||||
|
+ running as daemon process
|
||||||
|
+ utility for automated networks list building
|
||||||
|
+ configuration reload on any file change
|
||||||
|
Unix
|
||||||
|
+ support for chroot
|
||||||
|
+ support for setgid
|
||||||
|
+ support for setuid
|
||||||
|
+ support for signals
|
||||||
|
Windows NT/2K/XP/2K3
|
||||||
|
+ support --install as service
|
||||||
|
+ support --remove as service
|
||||||
|
+ support for service START, STOP, PAUSE and CONTINUE commands (on
|
||||||
|
PAUSE no new connection accepted, but active connections still in
|
||||||
|
progress, on CONTINUE configuration is reloaded)
|
||||||
|
Windows 95/98/ME
|
||||||
|
+ support --install as service
|
||||||
|
+ support --remove as service
|
||||||
|
6. Compilation
|
||||||
|
+ MSVC (static)
|
||||||
|
+ Intel Windows Compiler (msvcrt.dll)
|
||||||
|
+ Windows/gcc (msvcrt.dll)
|
||||||
|
+ Cygwin/gcc (cygwin.dll)
|
||||||
|
+ Unix/gcc
|
||||||
|
+ Unix/ccc
|
||||||
|
+ Solaris
|
||||||
|
+ Mac OS X, iPhone OS
|
||||||
|
|
||||||
|
|
||||||
|
Planned for future (0.8) release:
|
||||||
|
- SSL handling / SSL decryption by certificate spoofing
|
||||||
|
- NAT support under *nix
|
||||||
|
- Addon antiviral, HTTP cache filters modules, authentication
|
||||||
|
modules for different protocols (RADIUS, PAM etc).
|
||||||
|
|
||||||
|
$Id: Release.notes,v 1.9 2014-04-07 21:24:42 vlad Exp $
|
||||||
@@ -1 +1 @@
|
|||||||
(c) 2002-2019 by Vladimir '3APA3A' Dubrovin <vlad@3proxy.ru>
|
(c) 2002-2014 by Vladimir '3APA3A' Dubrovin <3proxy@3proxy.ru>
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
*.cfg
|
|
||||||
*.old
|
|
||||||
@@ -15,3 +15,4 @@ on the provider's Web server.
|
|||||||
Provider has proxy server 10.1.2.5. Traffic from proxy server is not free, but
|
Provider has proxy server 10.1.2.5. Traffic from proxy server is not free, but
|
||||||
is cheaper than traffic from non-free networks.
|
is cheaper than traffic from non-free networks.
|
||||||
|
|
||||||
|
$Id: 0.scenario.txt,v 1.2 2004/07/23 13:33:39 vlad Exp $
|
||||||
@@ -37,7 +37,7 @@ users 3APA3A:CL:3apa3a "test:CR:$1$qwer$CHFTUFGqkjue9HyhcMHEe1"
|
|||||||
service
|
service
|
||||||
# service is required under NT if you want 3proxy to start as service
|
# service is required under NT if you want 3proxy to start as service
|
||||||
|
|
||||||
#log /var/log/3proxy/log D
|
#log /usr/local/etc/3proxy/logs/3proxy.log D
|
||||||
log c:\3proxy\logs\3proxy.log D
|
log c:\3proxy\logs\3proxy.log D
|
||||||
# log allows to specify log file location and rotation, D means logfile
|
# log allows to specify log file location and rotation, D means logfile
|
||||||
# is created daily
|
# is created daily
|
||||||
@@ -199,3 +199,4 @@ admin
|
|||||||
# now we needn't any root rights. We can chroot and setgid/setuid.
|
# now we needn't any root rights. We can chroot and setgid/setuid.
|
||||||
|
|
||||||
|
|
||||||
|
###$Id: 3proxy.cfg.sample,v 1.7 2006/11/18 14:37:06 vlad Exp $#######
|
||||||
@@ -50,3 +50,4 @@ internal 127.0.0.1
|
|||||||
allow user1
|
allow user1
|
||||||
admin
|
admin
|
||||||
|
|
||||||
|
#$Id: counters.sample,v 1.2 2004/07/23 13:33:39 vlad Exp $
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
# By Mark Dreuband
|
|
||||||
nserver 10.1.2.1
|
|
||||||
nscache 65536
|
|
||||||
|
|
||||||
# we can grab wpad file from provider and feed it to dighosts
|
|
||||||
# to build list of free networks
|
|
||||||
# system "c:\3proxy\dighosts.exe -m http://wpad.security.nnov.ru/wpad.dat c:\3proxy\freenetworks.net"
|
|
||||||
|
|
||||||
service
|
|
||||||
|
|
||||||
internal 192.168.1.1
|
|
||||||
external 10.1.1.1
|
|
||||||
|
|
||||||
dnspr
|
|
||||||
|
|
||||||
log &3proxylog,root
|
|
||||||
#log c:\3proxy\logs\proxy.log D
|
|
||||||
#logformat "Linsert into log (timestamp, username, service, clientip, remoteip, remoteport, bytesin, bytesout,request,error) values (
|
|
||||||
#logformat "%t '%U' '%N' '%C' '%R' %r %I %O '%T' %E"
|
|
||||||
logformat "-\'+_Linsert into log (time, bytesin, bytesout, username, url, host, port, service) values ('%Y-%m-%d %H:%M:%S', %I, %O, '%U', '%T', '%n', %r, '%N');"
|
|
||||||
archiver zip c:\3proxy\zip.exe -m -qq %A %F
|
|
||||||
rotate 50
|
|
||||||
|
|
||||||
|
|
||||||
auth strong
|
|
||||||
users temp:CL:password root:CL:password
|
|
||||||
|
|
||||||
# access free networks directly
|
|
||||||
allow * * $c:\3proxy\freenetworks.net
|
|
||||||
# redirect web traffic for non-free networks to provider's proxy
|
|
||||||
allow * * * 80
|
|
||||||
parent 1000 http 10.1.2.5 3128
|
|
||||||
# allow rest of traffic
|
|
||||||
allow *
|
|
||||||
proxy
|
|
||||||
|
|
||||||
flush
|
|
||||||
|
|
||||||
auth iponly
|
|
||||||
allow *
|
|
||||||
pop3p
|
|
||||||
tcppm 25 mail.security.nnov.ru 25
|
|
||||||
|
|
||||||
flush
|
|
||||||
# redirect port 80 traffic via SOCKS server to local HTTP proxy to
|
|
||||||
# have URLs logged
|
|
||||||
allow * * * 80
|
|
||||||
parent 1000 http 0.0.0.0 0
|
|
||||||
allow *
|
|
||||||
socks
|
|
||||||
|
|
||||||
#daemon
|
|
||||||
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
# Connection: localhost
|
|
||||||
# Host: 127.0.0.1
|
|
||||||
# Saved: 2004-04-09 18:53:52
|
|
||||||
#
|
|
||||||
# Host: 127.0.0.1
|
|
||||||
# Database: 3proxy
|
|
||||||
# Table: 'log'
|
|
||||||
#
|
|
||||||
CREATE TABLE `log` (
|
|
||||||
`time` datetime NOT NULL default '0000-00-00 00:00:00',
|
|
||||||
`bytesin` int(11) NOT NULL default '0',
|
|
||||||
`bytesout` int(11) NOT NULL default '0',
|
|
||||||
`username` varchar(20) NOT NULL default '',
|
|
||||||
`service` varchar(7) NOT NULL default '',
|
|
||||||
`host` varchar(100) NOT NULL default '',
|
|
||||||
`port` int(11) NOT NULL default '0',
|
|
||||||
`url` varchar(255) NOT NULL default ''
|
|
||||||
) TYPE=MyISAM;
|
|
||||||
|
|
||||||
CREATE TABLE `services` (
|
|
||||||
`startport` int(11) NOT NULL default '0',
|
|
||||||
`endport` int(11) NOT NULL default '0',
|
|
||||||
`service` varchar(100) NOT NULL default '',
|
|
||||||
`description` varchar(100) NOT NULL default ''
|
|
||||||
) TYPE=MyISAM;
|
|
||||||
|
|
||||||
CREATE TABLE `timelimit` (
|
|
||||||
`datefrom` datetime NOT NULL default '0000-00-00 00:00:00',
|
|
||||||
`dateto` datetime NOT NULL default '0000-00-00 00:00:00'
|
|
||||||
) TYPE=MyISAM;
|
|
||||||
|
|
||||||
INSERT INTO services (80, 80, NULL, 'Access to Web Server');
|
|
||||||
|
|
||||||
INSERT INTO services (443, 443, NULL, 'Secure Access to Web Server');
|
|
||||||
|
|
||||||
INSERT INTO services (3128, 3128, NULL, 'Access to Web server via external Proxy');
|
|
||||||
INSERT INTO services (1080, 1080, NULL, 'Access to external SOCKS server');
|
|
||||||
INSERT INTO services (5190, 5190, NULL, 'Access to ICQ');
|
|
||||||
INSERT INTO services (6666, 6668, NULL, 'Access to IRC');
|
|
||||||
|
|
||||||
INSERT INTO services (119, 119, NULL, 'Access to news server');
|
|
||||||
INSERT INTO services (25, 25, NULL, 'Sent Mail');
|
|
||||||
|
|
||||||
INSERT INTO services (0, 0, 'POP3P', 'Received Mail');
|
|
||||||
INSERT INTO services (0, 0, 'SMTPP', 'Sent Mail');
|
|
||||||
INSERT INTO services (0, 0, 'TCPPM', 'Access to external server via TCP');
|
|
||||||
INSERT INTO services (0, 0, 'UDPPM', 'Access to external server via UDP');
|
|
||||||
INSERT INTO services (0, 0, 'PROXY', 'Access to external server via Proxy');
|
|
||||||
INSERT INTO services (0, 0, 'FTPPR', 'Access to external server via FTP Proxy');
|
|
||||||
INSERT INTO services (0, 0, 'ICQPR', 'Access to external server via ICQ Proxy');
|
|
||||||
INSERT INTO services (0, 0, 'SOCKS4', 'Access to external server via Socks v4');
|
|
||||||
INSERT INTO services (0, 0, 'SOCKS5', 'Access to external server via Socks v5');
|
|
||||||
INSERT INTO services (0, 0, 'DNSPR', 'Name resolution');
|
|
||||||
INSERT INTO services (0, 0, NULL, 'Unknown');
|
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
@@ -0,0 +1,6 @@
|
|||||||
|
all: isqlodbc$(EXESUFFICS)
|
||||||
|
clean:
|
||||||
|
@$(REMOVECOMMAND) *$(OBJSUFFICS) $(COMPFILES)
|
||||||
|
|
||||||
|
isqlodbc$(EXESUFFICS): isqlodbc$(OBJSUFFICS)
|
||||||
|
$(LN) $(LNOUT)isqlodbc$(EXESUFFICS) $(LDFLAGS) $(VERFILE) isqlodbc$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
CC = gcc
|
||||||
|
CFLAGS = -I /usr/local/include -DUNIX
|
||||||
|
COUT = -o
|
||||||
|
LN = gcc
|
||||||
|
LDFLAGS =
|
||||||
|
LIBS =-L /usr/local/lib -lodbc
|
||||||
|
LNOUT = -o
|
||||||
|
EXESUFFICS =
|
||||||
|
OBJSUFFICS = .o
|
||||||
|
DEFINEOPTION = -D
|
||||||
|
COMPFILES = *~
|
||||||
|
REMOVECOMMAND = rm -f
|
||||||
|
COMPATLIBS =
|
||||||
|
|
||||||
|
include Makefile.inc
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
CC = gcc
|
||||||
|
CFLAGS = -DWIN32
|
||||||
|
COUT = -o
|
||||||
|
LN = gcc
|
||||||
|
LDFLAGS =
|
||||||
|
LIBS = -lodbc32
|
||||||
|
LNOUT = -o
|
||||||
|
EXESUFFICS =
|
||||||
|
OBJSUFFICS = .o
|
||||||
|
DEFINEOPTION = -D
|
||||||
|
COMPFILES = *~
|
||||||
|
REMOVECOMMAND = rm -f
|
||||||
|
COMPATLIBS =
|
||||||
|
|
||||||
|
include Makefile.inc
|
||||||
@@ -0,0 +1,191 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#ifdef WIN32
|
||||||
|
#include <io.h>
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
#ifdef UNIX
|
||||||
|
#include <sqltypes.h>
|
||||||
|
#endif
|
||||||
|
#include <sql.h>
|
||||||
|
#include <sqlext.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define BUF_LENGTH 65000
|
||||||
|
|
||||||
|
/* environment variable */
|
||||||
|
SQLHENV env=NULL;
|
||||||
|
SQLHDBC dbc=NULL;
|
||||||
|
SQLHSTMT stmt=NULL;
|
||||||
|
SQLHSTMT cstmt=NULL;
|
||||||
|
unsigned char *dsn;
|
||||||
|
unsigned char *user;
|
||||||
|
unsigned char *pass;
|
||||||
|
|
||||||
|
RETCODE retcod;
|
||||||
|
|
||||||
|
/*description a columns of result of request */
|
||||||
|
SQLSMALLINT ColumnCount;
|
||||||
|
unsigned int ColNumber;
|
||||||
|
unsigned char ColName[SQL_MAX_COLUMN_NAME_LEN];
|
||||||
|
unsigned int Length;
|
||||||
|
unsigned int Type;
|
||||||
|
unsigned int Size;
|
||||||
|
unsigned int Digits;
|
||||||
|
unsigned int Nullable;
|
||||||
|
|
||||||
|
|
||||||
|
unsigned char data_buf[BUF_LENGTH];
|
||||||
|
unsigned long OutData;
|
||||||
|
|
||||||
|
/* function print error message*/
|
||||||
|
void PrintError(HENV env,HDBC dbc,HSTMT stmt,RETCODE retcod)
|
||||||
|
{
|
||||||
|
SQLINTEGER nError;
|
||||||
|
SQLSMALLINT TextLength;
|
||||||
|
unsigned char BufErrMsg[SQL_MAX_MESSAGE_LENGTH+1];
|
||||||
|
unsigned char SqlState[128];
|
||||||
|
|
||||||
|
SQLError(env,dbc,stmt,SqlState,&nError,BufErrMsg,512, &TextLength);
|
||||||
|
printf("%s\n" ,BufErrMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sqlquery(SQLHDBC dbc,SQLHSTMT stmt, unsigned char *strquery)
|
||||||
|
{
|
||||||
|
retcod=SQLAllocStmt(dbc, &stmt);
|
||||||
|
|
||||||
|
retcod=SQLExecDirect(stmt,strquery,SQL_NTS);
|
||||||
|
if(retcod!=SQL_SUCCESS)
|
||||||
|
{ PrintError(env,dbc,stmt,retcod);}
|
||||||
|
|
||||||
|
SQLNumResultCols(stmt,&ColumnCount);
|
||||||
|
|
||||||
|
while(SQLFetch(stmt)==SQL_SUCCESS)
|
||||||
|
{
|
||||||
|
for(ColNumber=1; ColNumber<=ColumnCount ; ColNumber++)
|
||||||
|
{
|
||||||
|
SQLGetData(stmt,ColNumber,SQL_CHAR,data_buf,BUF_LENGTH,&OutData);
|
||||||
|
printf("%s|",data_buf);
|
||||||
|
}
|
||||||
|
printf("\n",data_buf);
|
||||||
|
strcpy(data_buf,"");
|
||||||
|
}
|
||||||
|
SQLFreeStmt( stmt, SQL_DROP );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* isqlodbc dsn[[,user][,pass]] ["SQLCMD"] */
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
unsigned char qbuf[64000];
|
||||||
|
unsigned char *ptr=NULL;
|
||||||
|
|
||||||
|
/* Allocate environment and database connection handles */
|
||||||
|
retcod=SQLAllocEnv( &env );
|
||||||
|
if(retcod!=SQL_SUCCESS)
|
||||||
|
{
|
||||||
|
PrintError(env,dbc,stmt,retcod);
|
||||||
|
SQLFreeEnv(env);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
retcod = SQLAllocConnect( env, &dbc );
|
||||||
|
if(retcod!=SQL_SUCCESS)
|
||||||
|
{
|
||||||
|
PrintError(env,dbc,stmt,retcod);
|
||||||
|
SQLFreeConnect( dbc );
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(argc > 1 )
|
||||||
|
{
|
||||||
|
/* parsing command line and get parametrs */
|
||||||
|
dsn = strtok(argv[1],",");
|
||||||
|
user = strtok(NULL, ",");
|
||||||
|
pass = strtok(NULL, ",");
|
||||||
|
|
||||||
|
/* Connect from DSN */
|
||||||
|
retcod=SQLConnect(dbc,dsn,SQL_NTS,user,SQL_NTS,pass,SQL_NTS);
|
||||||
|
|
||||||
|
if(retcod!=SQL_SUCCESS)
|
||||||
|
{ PrintError(env,dbc,stmt,retcod); }
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (argc > 2)
|
||||||
|
{
|
||||||
|
/*sql cmd from command line*/
|
||||||
|
sqlquery(dbc,stmt,argv[2]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/*sql cmd from stdin */
|
||||||
|
if( isatty(0) ){ printf(".tables - list table\n.q - exit\nsql>"); }
|
||||||
|
while(fgets(qbuf,63000,stdin) != NULL )
|
||||||
|
{
|
||||||
|
ptr=strrchr(qbuf,';');
|
||||||
|
if (ptr!=NULL)
|
||||||
|
{
|
||||||
|
sqlquery(dbc,stmt,qbuf);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/*cmd exit*/
|
||||||
|
if (strstr(qbuf,".q")){ break; };
|
||||||
|
|
||||||
|
/*cmd table list*/
|
||||||
|
if (strstr(qbuf,".tables"))
|
||||||
|
{
|
||||||
|
retcod=SQLAllocStmt(dbc, &stmt);
|
||||||
|
if(retcod!=SQL_SUCCESS){ PrintError(env,dbc,stmt,retcod); }
|
||||||
|
else
|
||||||
|
{
|
||||||
|
retcod=SQLTables(stmt,NULL,0,NULL,0,NULL,0,NULL,0);
|
||||||
|
if(retcod !=SQL_SUCCESS) { PrintError(env,dbc,stmt,retcod);}
|
||||||
|
while(SQLFetch(stmt)==SQL_SUCCESS)
|
||||||
|
{
|
||||||
|
SQLGetData(stmt,3,SQL_CHAR,data_buf,BUF_LENGTH,&OutData);
|
||||||
|
printf("%s|",data_buf);
|
||||||
|
|
||||||
|
/*list columns */
|
||||||
|
retcod=SQLAllocStmt(dbc, &cstmt);
|
||||||
|
retcod=SQLColumns(cstmt,NULL,0,NULL,0,data_buf,strlen(data_buf),NULL,0);
|
||||||
|
|
||||||
|
if(retcod !=SQL_SUCCESS) { PrintError(env,dbc,stmt,retcod);}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("create table %s (",data_buf);
|
||||||
|
while(SQLFetch(cstmt)==SQL_SUCCESS)
|
||||||
|
{
|
||||||
|
SQLGetData(cstmt,4,SQL_CHAR,data_buf,BUF_LENGTH,&OutData);
|
||||||
|
printf("%s ",data_buf);
|
||||||
|
SQLGetData(cstmt,6,SQL_CHAR,data_buf,BUF_LENGTH,&OutData);
|
||||||
|
printf("%s, ",data_buf);
|
||||||
|
}
|
||||||
|
printf(");\n");
|
||||||
|
SQLFreeStmt( cstmt, SQL_DROP );
|
||||||
|
}/*end list columns*/
|
||||||
|
|
||||||
|
}/*end while SQLFetch */
|
||||||
|
SQLFreeStmt( stmt, SQL_DROP );
|
||||||
|
}
|
||||||
|
|
||||||
|
}/*end if (strstr(qbuf,".tables")) */
|
||||||
|
|
||||||
|
|
||||||
|
} /*end else cmd*/
|
||||||
|
if( isatty(0) ){ printf("sql>"); }
|
||||||
|
} /*end while*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SQLDisconnect(dbc);
|
||||||
|
} /* if (argc > 2) */
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("isqlodbc dsn[[,user][,pass]] [\"SQLCMD\"]\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
SQLFreeConnect( dbc );
|
||||||
|
SQLFreeEnv( env );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
create table log (ldate date,ltime time,username char (30),userip char (16),bytein integer (10),byteout integer (10),service char (8), host char(255), hostport integer (10), url char (255) );
|
||||||
|
|
||||||
|
create index idate on log (ldate);
|
||||||
|
create index iusername on log (username);
|
||||||
|
create index iuserip on log (userip);
|
||||||
|
create index ihost on log (host);
|
||||||
|
|
||||||
|
create table services (port integer(10),service char(100),description char (100));
|
||||||
|
|
||||||
|
INSERT INTO services values (80,'PROXY', 'Access to Web Server');
|
||||||
|
INSERT INTO services values (21,'PROXY', 'Access to Ftp Server via HTTP proxy');
|
||||||
|
INSERT INTO services values (5190,'PROXY', 'Access to ICQ via HTTP proxy');
|
||||||
|
INSERT INTO services values (0, 'POP3P', 'Received Mail via POP3');
|
||||||
|
INSERT INTO services values (0,'FTPPR', 'Access to Ftp server via FTP proxy');
|
||||||
|
INSERT INTO services values (0,'SOCKS4', 'Access to external server via Socks v4');
|
||||||
|
INSERT INTO services values (0,'SOCKS5', 'Access to external server via Socks v5');
|
||||||
|
INSERT INTO services values (0,'TCPPM', 'Access to external server via TCP mapping');
|
||||||
|
INSERT INTO services values (0,'UDPPM', 'Access to external server via UDP mapping');
|
||||||
|
INSERT INTO services values (0, 0, NULL, 'Unknown');
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
------------------------------ KOI8-R ------------------------------------
|
||||||
|
Этот архив содержит набор CGI cкриптов и программ для получения
|
||||||
|
статистики работы пользователей прокси сервера "3proxy", посредством анализа
|
||||||
|
лога расположенного в ODBC источнике(базе), через Web интерфейс.
|
||||||
|
|
||||||
|
stat.awk - основной CGI скрипт (Для его испольнения под Win9X/2000 необходима
|
||||||
|
программа awk.exe ,в linux/freebsd она как правило входит в сиситему
|
||||||
|
по умолчанию).
|
||||||
|
isqlodbc - программа для выполнения SQL запросов к базам ODBC
|
||||||
|
(вызывается из stat.awk). компилируется gcc и работает как в
|
||||||
|
win9X/2000 так и в linux/freebsd. (Так же может
|
||||||
|
использоваться независимо от stat.awk как отдельная
|
||||||
|
программа..)
|
||||||
|
log.sql - SQL скрипт создания базы для лога сервера.
|
||||||
|
awk.exe - awk интерпретатор под Win9X/2000.
|
||||||
|
|
||||||
|
Настройка скриптов статистики .
|
||||||
|
|
||||||
|
Для работы вам потребуется:
|
||||||
|
1) любой http сервер подерживающий CGI
|
||||||
|
2) odbc менеджер (под win32 ) или iodbc менеджер (под unix)
|
||||||
|
любая база данных например : sqlite, mysql, postgress или любые другие
|
||||||
|
имеющие ODBC драйвера.(Как настраивать iODBC под linux/freebsd смотрите в
|
||||||
|
файле iodbc.txt в каталоге /doc/ru архива 3proxy.)
|
||||||
|
|
||||||
|
Шаг настройки N1:
|
||||||
|
Создаем базу данных и DSN для хранения лога. ( в нашем случае DSN будет
|
||||||
|
называться "sqlite".) далее выполняя скрипт log.sql создаем необходимые
|
||||||
|
таблицы и индексы:
|
||||||
|
|
||||||
|
isqlodbc sqlite < log.sql
|
||||||
|
|
||||||
|
Шаг настройки N2:
|
||||||
|
Устанавливаем DSN и формат таблицы с логом в файле 3proxy.cfg следующего вида:
|
||||||
|
-----------
|
||||||
|
# create table log (
|
||||||
|
# ldate date,
|
||||||
|
# ltime time,
|
||||||
|
# username char (30),
|
||||||
|
# userip char (16),
|
||||||
|
# bytein integer (10),
|
||||||
|
# byteout integer (10),
|
||||||
|
# service char (8),
|
||||||
|
# host char(255),
|
||||||
|
# hostport integer (10),
|
||||||
|
# url char (255)
|
||||||
|
# );
|
||||||
|
|
||||||
|
log &sqlite
|
||||||
|
logformat "Linsert into log values ('%Y-%m-%d','%H:%M:%S','%U','%C','%I','%O','%N','%n','%r','%T');"
|
||||||
|
-----------
|
||||||
|
|
||||||
|
Шаг настройки N3:
|
||||||
|
Копируем файлы isqlodbc и stat.awk в каталог с CGI скриптами http сервера
|
||||||
|
и меняем в stat.awk путь вызова и DSN на свои значения , например:
|
||||||
|
isql="./isqlodbc.exe sqlite "
|
||||||
|
|
||||||
|
Шаг настройки N4:
|
||||||
|
Пробуем вызвать скрипт из web браузера , например
|
||||||
|
|
||||||
|
http://localhost/cgi/stat.awk?
|
||||||
|
|
||||||
|
------------------------------ KOI8-R ------------------------------------
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
#!/usr/bin/awk -f
|
||||||
|
BEGIN {
|
||||||
|
scriptname = ENVIRON["SCRIPT_NAME"]
|
||||||
|
#for win32
|
||||||
|
isql=".\\isqlodbc.exe sqlite "
|
||||||
|
|
||||||
|
#for unix
|
||||||
|
#isql="./isqlodbc sqlite "
|
||||||
|
|
||||||
|
|
||||||
|
print "Content-Type: text/html; charset=koi8-r \n\n"
|
||||||
|
print "<HTML>\n<BODY>\n";
|
||||||
|
|
||||||
|
# query parse
|
||||||
|
query_str = ENVIRON["QUERY_STRING"]
|
||||||
|
n = split(query_str, querys, "&")
|
||||||
|
for (i=1; i<=n; i++)
|
||||||
|
{
|
||||||
|
split(querys[i], data, "=")
|
||||||
|
qr[data[1]] = data[2]
|
||||||
|
}
|
||||||
|
|
||||||
|
printf "<FORM METHOD=PUT action=\"" scriptname "?rep=1\">"
|
||||||
|
printf "datefrom:<INPUT name=\"datefrom\" value=\"2004-06-01\"> "
|
||||||
|
printf "dateto:<INPUT name=\"dateto\" value=\"2004-07-30\"> <br>"
|
||||||
|
printf "<INPUT type=\"radio\" name=\"userid\" value=\"username\" checked> LOGIN user <br>"
|
||||||
|
printf "<INPUT type=\"radio\" name=\"userid\" value=\"userip\"> IP user <br>"
|
||||||
|
printf "<INPUT type=\"hidden\" name=\"rep\" value=\"user\">"
|
||||||
|
printf "<INPUT type=\"submit\" value=\"Report\">"
|
||||||
|
printf "</FORM>"
|
||||||
|
|
||||||
|
|
||||||
|
#printf "query_str=%s\n<br>",query_str
|
||||||
|
#print qr["rep"]
|
||||||
|
|
||||||
|
if(qr["rep"]=="user")
|
||||||
|
{
|
||||||
|
cmd = isql " \"select " qr["userid"] ",sum(bytein),sum(byteout),sum(bytein+byteout) from log \
|
||||||
|
where ldate > '" qr["datefrom"] "' AND ldate < '" qr["dateto"] \
|
||||||
|
"' group by " qr["userid"] " order by sum(bytein+byteout) desc;\""
|
||||||
|
printf " <table WIDTH=100%% BORDER=1><tr><td><b>user</b></td> <td><b>bytein</b></td> <td><b>byteout</b> </td> <td> <b>bytesum</b></td></tr>"
|
||||||
|
while( (cmd|getline result)>0)
|
||||||
|
{
|
||||||
|
split(result, rt, "|")
|
||||||
|
printf "<tr> <td><a href=\"%s?rep=host&datefrom=%s&dateto=%s&userid=%s&selectid=%s\"> %s <\/a></td><td>%d</td><td>%d</td><td>%d</td></tr>",
|
||||||
|
scriptname,qr["datefrom"],qr["dateto"],qr["userid"],rt[1],rt[1],rt[2],rt[3],rt[4]
|
||||||
|
totalbytein=totalbytein+rt[2];
|
||||||
|
totalbyteout=totalbyteout+rt[3];
|
||||||
|
totalbytesum=totalbytesum+rt[4];
|
||||||
|
}
|
||||||
|
printf "<tr> <td><br>Total users</td> <td><br>%d</td> <td><br>%d</td> \
|
||||||
|
<td><br>%d</td></tr> </table> ",totalbytein,totalbyteout, totalbytesum
|
||||||
|
close(cmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(qr["rep"]=="host")
|
||||||
|
{
|
||||||
|
cmd = isql "\"select sum(bytein+byteout), sum(bytein), sum(byteout),host from log \
|
||||||
|
where ldate > '" qr["datefrom"] "' AND ldate < '"qr["dateto"] \
|
||||||
|
"' AND " qr["userid"] " = '" qr["selectid"] \
|
||||||
|
"' group by host order by sum(bytein+byteout) desc;\""
|
||||||
|
|
||||||
|
printf "<center><b>Detail statistic for user: %s</b></center>",qr["selectid"]
|
||||||
|
printf " <table WIDTH=100%% BORDER=1> <tr><td><b>sum byte</b></td> <td><b>bytein</b></td> <td><b>byteout</b></td><td><b>host</b></td></tr>"
|
||||||
|
while( (cmd|getline result)>0)
|
||||||
|
{
|
||||||
|
split(result, rt, "|")
|
||||||
|
printf "<tr><td>%d</td><td>%d</td><td>%d</td><td>%s</td></tr>",rt[1],rt[2],rt[3],rt[4]
|
||||||
|
totalbytein=totalbytein+rt[1];
|
||||||
|
totalbyteout=totalbyteout+rt[2];
|
||||||
|
totalbytesum=totalbytesum+rt[3];
|
||||||
|
|
||||||
|
}
|
||||||
|
printf "<tr> <td><br>%d</td> <td><br>%d</td> \
|
||||||
|
<td><br>%d</td><td><br>Total host</td></tr> </table> ",totalbytein,totalbyteout, totalbytesum
|
||||||
|
printf " </table> "
|
||||||
|
close(cmd)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
printf " </BODY> </HTML>";
|
||||||
|
} # end BEGIN
|
||||||
|
|
||||||
|
|
||||||
|
# decode urlencoded string
|
||||||
|
function decode(text, hex, i, hextab, decoded, len, c, c1, c2, code) {
|
||||||
|
|
||||||
|
split("0 1 2 3 4 5 6 7 8 9 a b c d e f", hex, " ")
|
||||||
|
for (i=0; i<16; i++) hextab[hex[i+1]] = i
|
||||||
|
|
||||||
|
# urldecode function from Heiner Steven
|
||||||
|
# http://www.shelldorado.com/scripts/cmds/urldecode
|
||||||
|
|
||||||
|
# decode %xx to ASCII char
|
||||||
|
decoded = ""
|
||||||
|
i = 1
|
||||||
|
len = length(text)
|
||||||
|
|
||||||
|
while ( i <= len ) {
|
||||||
|
c = substr (text, i, 1)
|
||||||
|
if ( c == "%" )
|
||||||
|
{
|
||||||
|
if ( i+2 <= len )
|
||||||
|
{
|
||||||
|
c1 = tolower(substr(text, i+1, 1))
|
||||||
|
c2 = tolower(substr(text, i+2, 1))
|
||||||
|
if ( hextab [c1] != "" || hextab [c2] != "" ) {
|
||||||
|
if ( (c1 >= 2 && (c1 != 7 && c2 != "F")) || (c1 == 0 && c2 ~ "[9acd]") )
|
||||||
|
{
|
||||||
|
code = 0 + hextab [c1] * 16 + hextab [c2] + 0
|
||||||
|
c = sprintf ("%c", code)
|
||||||
|
}
|
||||||
|
else { c = " " }
|
||||||
|
i = i + 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if ( c == "+" ) { # special handling: "+" means " "
|
||||||
|
c = " "
|
||||||
|
}
|
||||||
|
decoded = decoded c
|
||||||
|
++i
|
||||||
|
}
|
||||||
|
# change linebreaks to \n
|
||||||
|
gsub(/\r\n/, "\n", decoded)
|
||||||
|
# remove last linebreak
|
||||||
|
sub(/[\n\r]*$/,"",decoded)
|
||||||
|
return decoded
|
||||||
|
}
|
||||||
@@ -0,0 +1,185 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
|
||||||
|
if $running_under_some_shell;
|
||||||
|
# this emulates #! processing on NIH machines.
|
||||||
|
# (remove #! line above if indigestible)
|
||||||
|
|
||||||
|
eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_0-9]+=)(.*)/ && shift;
|
||||||
|
# process any FOO=bar switches
|
||||||
|
|
||||||
|
$[ = 1; # set array base to 1
|
||||||
|
$, = ' '; # set output field separator
|
||||||
|
$\ = "\n"; # set output record separator
|
||||||
|
|
||||||
|
$scriptname = $ENVIRON{'SCRIPT_NAME'};
|
||||||
|
#for win32
|
||||||
|
$isql = ".\\isqlodbc.exe sqlite ";
|
||||||
|
|
||||||
|
#for unix
|
||||||
|
#isql="./isqlodbc sqlite "
|
||||||
|
|
||||||
|
print "Content-Type: text/html; charset=koi8-r \n\n";
|
||||||
|
print "<HTML>\n<BODY>\n";
|
||||||
|
|
||||||
|
# query parse
|
||||||
|
$query_str = $ENVIRON{'QUERY_STRING'};
|
||||||
|
$n = (@querys = split(/&/, $query_str, 9999));
|
||||||
|
for ($i = 1; $i <= $n; $i++) {
|
||||||
|
@data = split(/=/, $querys[$i], 9999);
|
||||||
|
$qr{$data[1]} = $data[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
printf "<FORM METHOD=PUT action=\"" . $scriptname . "?rep=1\">";
|
||||||
|
printf "datefrom:<INPUT name=\"datefrom\" value=\"2004-06-01\"> ";
|
||||||
|
printf "dateto:<INPUT name=\"dateto\" value=\"2004-07-30\"> <br>";
|
||||||
|
printf
|
||||||
|
|
||||||
|
"<INPUT type=\"radio\" name=\"userid\" value=\"username\" checked> LOGIN user <br>";
|
||||||
|
printf
|
||||||
|
|
||||||
|
"<INPUT type=\"radio\" name=\"userid\" value=\"userip\"> IP user <br>";
|
||||||
|
printf "<INPUT type=\"hidden\" name=\"rep\" value=\"user\">";
|
||||||
|
printf "<INPUT type=\"submit\" value=\"Report\">";
|
||||||
|
printf '</FORM>';
|
||||||
|
|
||||||
|
#printf "query_str=%s\n<br>",query_str
|
||||||
|
#print qr["rep"]
|
||||||
|
|
||||||
|
if ($qr{'rep'} eq 'user') {
|
||||||
|
$cmd = $isql . " \"select " . $qr{'userid'} .
|
||||||
|
|
||||||
|
",sum(bytein),sum(byteout),sum(bytein+byteout) from log where ldate > '"
|
||||||
|
|
||||||
|
. $qr{'datefrom'} . "' AND ldate < '" . $qr{'dateto'} . "' group by " .
|
||||||
|
|
||||||
|
$qr{'userid'} . " order by sum(bytein+byteout) desc;\"";
|
||||||
|
printf
|
||||||
|
|
||||||
|
' <table WIDTH=100%% BORDER=1><tr><td><b>user</b></td> <td><b>bytein</b></td> <td><b>byteout</b> </td> <td> <b>bytesum</b></td></tr>';
|
||||||
|
while ((($result = &Getline3($cmd, '|'),$getline_ok)) > 0) {
|
||||||
|
@rt = split(/\|/, $result, 9999);
|
||||||
|
printf
|
||||||
|
|
||||||
|
"<tr> <td><a href=\"%s?rep=host&datefrom=%s&dateto=%s&userid=%s&selectid=%s\"> %s <\\/a></td><td>%d</td><td>%d</td><td>%d</td></tr>",
|
||||||
|
|
||||||
|
|
||||||
|
$scriptname, $qr{'datefrom'}, $qr{'dateto'}, $qr{'userid'}, $rt[1],
|
||||||
|
|
||||||
|
$rt[1], $rt[2], $rt[3], $rt[4];
|
||||||
|
$totalbytein = $totalbytein + $rt[2];
|
||||||
|
$totalbyteout = $totalbyteout + $rt[3];
|
||||||
|
$totalbytesum = $totalbytesum + $rt[4];
|
||||||
|
}
|
||||||
|
printf
|
||||||
|
|
||||||
|
'<tr> <td><br>Total users</td> <td><br>%d</td> <td><br>%d</td> <td><br>%d</td></tr> </table> ',
|
||||||
|
|
||||||
|
$totalbytein, $totalbyteout, $totalbytesum;
|
||||||
|
delete $opened{$cmd} && close($cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($qr{'rep'} eq 'host') {
|
||||||
|
$cmd = $isql .
|
||||||
|
|
||||||
|
"\"select sum(bytein+byteout), sum(bytein), sum(byteout),host from log where ldate > '"
|
||||||
|
|
||||||
|
. $qr{'datefrom'} . "' AND ldate < '" . $qr{'dateto'} . "' AND " .
|
||||||
|
|
||||||
|
$qr{'userid'} . " = '" . $qr{'selectid'} .
|
||||||
|
|
||||||
|
"' group by host order by sum(bytein+byteout) desc;\"";
|
||||||
|
|
||||||
|
printf '<center><b>Detail statistic for user: %s</b></center>',
|
||||||
|
|
||||||
|
$qr{'selectid'};
|
||||||
|
printf
|
||||||
|
|
||||||
|
' <table WIDTH=100%% BORDER=1> <tr><td><b>sum byte</b></td> <td><b>bytein</b></td> <td><b>byteout</b></td><td><b>host</b></td></tr>';
|
||||||
|
while ((($result = &Getline3($cmd, '|'),$getline_ok)) > 0) {
|
||||||
|
@rt = split(/\|/, $result, 9999);
|
||||||
|
printf '<tr><td>%d</td><td>%d</td><td>%d</td><td>%s</td></tr>',
|
||||||
|
|
||||||
|
$rt[1], $rt[2], $rt[3], $rt[4];
|
||||||
|
$totalbytein = $totalbytein + $rt[1];
|
||||||
|
$totalbyteout = $totalbyteout + $rt[2];
|
||||||
|
$totalbytesum = $totalbytesum + $rt[3];
|
||||||
|
}
|
||||||
|
printf
|
||||||
|
|
||||||
|
'<tr> <td><br>%d</td> <td><br>%d</td> <td><br>%d</td><td><br>Total host</td></tr> </table> ',
|
||||||
|
|
||||||
|
$totalbytein, $totalbyteout, $totalbytesum;
|
||||||
|
printf ' </table> ';
|
||||||
|
delete $opened{$cmd} && close($cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf ' </BODY> </HTML>';
|
||||||
|
|
||||||
|
# end BEGIN
|
||||||
|
|
||||||
|
# decode urlencoded string
|
||||||
|
|
||||||
|
sub decode {
|
||||||
|
local($text, *Hex, $i, *hextab, $decoded, $len, $c, $c1, $c2, $code) = @_;
|
||||||
|
@Hex = split(' ', '0 1 2 3 4 5 6 7 8 9 a b c d e f', 9999);
|
||||||
|
for ($i = 0; $i < 16; $i++) {
|
||||||
|
$hextab{$Hex[$i + 1]} = $i;
|
||||||
|
|
||||||
|
# urldecode function from Heiner Steven
|
||||||
|
# http://www.shelldorado.com/scripts/cmds/urldecode
|
||||||
|
|
||||||
|
# decode %xx to ASCII char
|
||||||
|
;
|
||||||
|
}
|
||||||
|
$decoded = '';
|
||||||
|
$i = 1;
|
||||||
|
$len = length($text);
|
||||||
|
|
||||||
|
while ($i <= $len) { #???
|
||||||
|
$c = substr($text, $i, 1);
|
||||||
|
if ($c eq '%') {
|
||||||
|
if ($i + 2 <= $len) {
|
||||||
|
$c1 = &tolower(substr($text, $i + 1, 1));
|
||||||
|
$c2 = &tolower(substr($text, $i + 2, 1));
|
||||||
|
if ($hextab{$c1} ne '' || $hextab{$c2} ne '') {
|
||||||
|
if (($c1 >= 2 && ($c1 != 7 && $c2 ne 'F')) ||
|
||||||
|
|
||||||
|
($c1 == 0 && $c2 =~ '[9acd]')) {
|
||||||
|
$code = 0 + $hextab{$c1} * 16 + $hextab{$c2} + 0;
|
||||||
|
$c = sprintf('%c', $code);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$c = ' ';
|
||||||
|
}
|
||||||
|
$i = $i + 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elsif ($c eq '+') {
|
||||||
|
# special handling: "+" means " "
|
||||||
|
$c = ' ';
|
||||||
|
}
|
||||||
|
$decoded = $decoded . $c;
|
||||||
|
++$i;
|
||||||
|
}
|
||||||
|
# change linebreaks to \n
|
||||||
|
$decoded =~ s/\r\n/\n/g;
|
||||||
|
# remove last linebreak
|
||||||
|
$decoded =~ s/[\n\r]*$//;
|
||||||
|
$decoded;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub Getline3 {
|
||||||
|
&Pick('',@_);
|
||||||
|
local($_);
|
||||||
|
if ($getline_ok = (($_ = <$fh>) ne '')) {
|
||||||
|
;
|
||||||
|
}
|
||||||
|
$_;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub Pick {
|
||||||
|
local($mode,$name,$pipe) = @_;
|
||||||
|
$fh = $name;
|
||||||
|
open($name,$mode.$name.$pipe) unless $opened{$name}++;
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
3proxy 0.9 Public License Agreement
|
3proxy 0.7 Public License Agreement
|
||||||
|
|
||||||
(c) 2000-2019 by 3APA3A (3APA3A@3proxy.ru)
|
(c) 2000-2014 by 3APA3A (3APA3A@security.nnov.ru)
|
||||||
(c) 2000-2019 by 3proxy.org (http://3proxy.org/)
|
(c) 2000-2014 by SecurityVulns.com (http://3proxy.ru/)
|
||||||
(c) 2000-2019 by Vladimir Dubrovin (vlad@3proxy.ru)
|
(c) 2000-2014 by Vladimir Dubrovin (vlad@sandy.ru)
|
||||||
|
|
||||||
This software uses:
|
This software uses:
|
||||||
RSA Data Security, Inc. MD4 Message-Digest Algorithm
|
RSA Data Security, Inc. MD4 Message-Digest Algorithm
|
||||||
@@ -39,7 +39,7 @@ are met (BSD style license):
|
|||||||
Instead of this license, you can also use and redistribute this software under
|
Instead of this license, you can also use and redistribute this software under
|
||||||
terms of compatible license, including:
|
terms of compatible license, including:
|
||||||
|
|
||||||
1. Apache License, Version 2.0 or (at your option) any later version
|
1. Apache License, Version 2.0
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
@@ -59,3 +59,4 @@ terms of compatible license, including:
|
|||||||
http://www.gnu.org/licenses/lgpl.txt
|
http://www.gnu.org/licenses/lgpl.txt
|
||||||
|
|
||||||
|
|
||||||
|
$Id: License,v 1.3 2007/04/05 11:59:47 vlad Exp $
|
||||||
+6
-13
@@ -9,6 +9,8 @@ A: Most probable reasons: 'auth none' or no auth is used. For any ACL based feat
|
|||||||
<p><i>Q: Why doesn't 3proxy work as service under Windows?</i></p>
|
<p><i>Q: Why doesn't 3proxy work as service under Windows?</i></p>
|
||||||
Possible reasons:
|
Possible reasons:
|
||||||
<ul>
|
<ul>
|
||||||
|
<li>'service' command absents in configuration file. Command is required for
|
||||||
|
3proxy.exe to behave as system service in 3proxy 0.5.2 and prior.
|
||||||
<li>there are relative paths in configuration file for included files,
|
<li>there are relative paths in configuration file for included files,
|
||||||
log files, etc. Always use absolute paths. For example
|
log files, etc. Always use absolute paths. For example
|
||||||
$"c:\3proxy\networks.local" instead of $networks.local. For debugging remove
|
$"c:\3proxy\networks.local" instead of $networks.local. For debugging remove
|
||||||
@@ -62,18 +64,6 @@ to automatically reload configuration on address change.
|
|||||||
A: Check you use system DSN.
|
A: Check you use system DSN.
|
||||||
Check SQL request is valid.
|
Check SQL request is valid.
|
||||||
The best way to check is to make file or stdout logging, get SQL request from log file or console and execute this request manually.
|
The best way to check is to make file or stdout logging, get SQL request from log file or console and execute this request manually.
|
||||||
Under Unix, you may also want to adjust 'stacksize' parameter.
|
|
||||||
|
|
||||||
<p><i>Q: Why doesn't IPv6 work?</i></p>
|
|
||||||
A: Proxy can not access destination directly over IPv6 if client requests IPv4 address.
|
|
||||||
To access IPv6 destination, either IPv6 address or hostname must be used in request.
|
|
||||||
Best solution is to enable option to resolve hostnames via proxy on client side.
|
|
||||||
<p><i>Q: Why proxy crash on request processing?</a></i></p>
|
|
||||||
<i>A:</i> default stacksize may be insufficient, if some non-default plugins
|
|
||||||
are used (e.g. PAM and ODBC on Linux) or if compiled on some platforms with
|
|
||||||
invalid system defined values (few versionds of FreeBSD on amd64).
|
|
||||||
Problem can be resolved with 'stacksize' command or '-S' option starting 3proxy 0.8.4.
|
|
||||||
|
|
||||||
|
|
||||||
<p><i>Q: Why doesn't APOP/CRAM-MD5 authentication work with POP3 proxy?</i></p>
|
<p><i>Q: Why doesn't APOP/CRAM-MD5 authentication work with POP3 proxy?</i></p>
|
||||||
A: Any Challenge-response authentication require challenge to be transmitted from server. Pop3p doesn't know which server to use before authentication, it makes it impossible to obtain challenge. You can encrypt your POP3 communications with TLS (i.e. stunnel) or IPSec.
|
A: Any Challenge-response authentication require challenge to be transmitted from server. Pop3p doesn't know which server to use before authentication, it makes it impossible to obtain challenge. You can encrypt your POP3 communications with TLS (i.e. stunnel) or IPSec.
|
||||||
@@ -124,7 +114,7 @@ parent 1000 http 0.0.0.0 0
|
|||||||
allow * * $c:\3proxy\local.nets 80,8080-8088
|
allow * * $c:\3proxy\local.nets 80,8080-8088
|
||||||
#allow direct access to local.nets networks
|
#allow direct access to local.nets networks
|
||||||
allow * * * 80,8080-8088
|
allow * * * 80,8080-8088
|
||||||
parent 1000 http proxy.3proxy.org 3128
|
parent 1000 http proxy.sandy.ru 3128
|
||||||
#use parent caching proxy for rest of the networks
|
#use parent caching proxy for rest of the networks
|
||||||
|
|
||||||
allow *
|
allow *
|
||||||
@@ -163,3 +153,6 @@ A: First, I'm not programmer. Second, 3proxy was 'proof of concept' in reply for
|
|||||||
|
|
||||||
<p><i>Q: Why do you use insecure strcpy, sprintf, etc?</i></p>
|
<p><i>Q: Why do you use insecure strcpy, sprintf, etc?</i></p>
|
||||||
A: Why not? I try to use insecure function in secure manner. You're welcome to look for vulnerabilities.
|
A: Why not? I try to use insecure function in secure manner. You're welcome to look for vulnerabilities.
|
||||||
|
<pre>
|
||||||
|
$Id: faqe.html,v 1.10 2007/07/31 08:42:38 vlad Exp $
|
||||||
|
</pre>
|
||||||
+187
-199
@@ -1,295 +1,283 @@
|
|||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
|
||||||
3APA3A 3proxy tiny proxy server Frequently Asked Questions (FAQ)
|
3APA3A 3proxy tiny proxy server Frequently Asked Questions (FAQ)
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#TROUBLE">Почему не работает...</a></li>
|
<li><a href="#TROUBLE">Почему не работает...</a></li>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#NOTHING">Q: Почему ничего не работает?</a></li>
|
<li><a href="#NOTHING">Q: Почему ничего не работает?</a></li>
|
||||||
<li><a href="#LIMITS">Q: Почему не работают ограничения доступа (перенаправления, ограничения по скорости, трафику и т.д.)?</a></li>
|
<li><a href="#LIMITS">Q: Почему не работают ограничения доступа (перенаправления, ограничения по скорости, трафику и т.д.)?</a></li>
|
||||||
<li><a href="#SERVICE">Q: Почему 3proxy не запускается как служба?</a></li>
|
<li><a href="#SERVICE">Q: Почему 3proxy не запускается как служба?</a></li>
|
||||||
<li><a href="#INTEXT">Q: Почему не получается указать internal и external?</a></li>
|
<li><a href="#INTEXT">Q: Почему не получается указать internal и external?</a></li>
|
||||||
<li><a href="#ODBC">Q: Почему не работает ведение журналов в ODBC?</a></li>
|
<li><a href="#ODBC">Q: Почему не работает ведение журналов в ODBC?</a></li>
|
||||||
<li><a href="#IPV6">Q: Почему не работает IPv6?</a></li>
|
<li><a href="#CHAP">Q: Почему не поддерживаются APOP и CRAM-MD5 в POP3 прокси?</a></li>
|
||||||
<li><a href="#CHAP">Q: Почему не поддерживаются APOP и CRAM-MD5 в POP3 прокси?</a></li>
|
|
||||||
<li><a href="#CRASH">Q: Почему прокси крэшится при обработке запроса?</a></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="#SOCKSREDIR">Перенаправление socks соединений в локальный прокси</a></li>
|
<li><a href="#SOCKSREDIR">Перенаправление socks соединений в локальный прокси</a></li>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#REDIR">Q: Для чего это надо?</a></li>
|
<li><a href="#REDIR">Q: Для чего это надо?</a></li>
|
||||||
<li><a href="#REDIRLIMIT">Q: Какие недостатки?</a></li>
|
<li><a href="#REDIRLIMIT">Q: Какие недостатки?</a></li>
|
||||||
<li><a href="#REDIRADV">Q: Какие преимущества?</a></li>
|
<li><a href="#REDIRADV">Q: Какие преимущества?</a></li>
|
||||||
<li><a href="#REDIRHOW">Q: Как настраивается?</a></li>
|
<li><a href="#REDIRHOW">Q: Как настраивается?</a></li>
|
||||||
<li><a href="#REDIINTER">Q: Как взаимодействует с другими правилами в ACL?</a></li>
|
<li><a href="#REDIINTER">Q: Как взаимодействует с другими правилами в ACL?</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="#ISIT">А есть ли...</a></li>
|
<li><a href="#ISIT">А есть ли...</a></li>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#NAMES">Можно ли разрешать имена на родительском прокси?</a></li>
|
<li><a href="#NAMES">Можно ли разрешать имена на родительском прокси?</a></li>
|
||||||
<li><a href="#ISFTP">Существует ли сейчас поддержка FTP прокси в продукте?</a></li>
|
<li><a href="#ISFTP">Существует ли сейчас поддержка FTP прокси в продукте?</a></li>
|
||||||
<li><a href="#PORT">Каким образом можно прибиндить сервисы на свой порт, к примеру, HTTP прокси к 8080, а не 3128 как по-умолчанию?</a></li>
|
<li><a href="#PORT">Каким образом можно прибиндить сервисы на свой порт, к примеру, HTTP прокси к 8080, а не 3128 как по-умолчанию?</a></li>
|
||||||
<li><a href="#BANDLIM">Как ограничить ширину канала?</a></li>
|
<li><a href="#BANDLIM">Как ограничить ширину канала?</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="#BRRR">Почему так криво...</a></li>
|
<li><a href="#BRRR">Почему так криво...</a></li>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#TRAF">Почему так криво считается трафик? Не совпадает с ...</a></li>
|
<li><a href="#TRAF">Почему так криво считается трафик? Не совпадает с ...</a></li>
|
||||||
<li><a href="#CONFIG">Почему такая кривая конфигурация и ничерта не понятно?</a></li>
|
<li><a href="#CONFIG">Почему такая кривая конфигурация и ничерта не понятно?</a></li>
|
||||||
<li><a href="#CODE">Почему так криво написан код?</a>
|
<li><a href="#CODE">Почему так криво написан код?</a>
|
||||||
<li><a href="#UNSAFE">Почему так много strcpy, sprintf и т.д., это ж дыры!</a>
|
<li><a href="#UNSAFE">Почему так много strcpy, sprintf и т.д., это ж дыры!</a>
|
||||||
</ul>
|
</ul>
|
||||||
</ul>
|
</ul>
|
||||||
<hr>
|
<hr>
|
||||||
<li><b><a name="TROUBLE">Почему не работает...<a></b></li>
|
<li><b><a name="TROUBLE">Почему не работает...<a></b></li>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a name="NOTHING"><i>Q: Почему ничего не работает?</i></a></li>
|
<li><a name="NOTHING"><i>Q: Почему ничего не работает?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Потому что для работы нужен правильный файл конфигурации.
|
<i>A:</i> Потому что для работы нужен правильный файл конфигурации.
|
||||||
</p>
|
</p>
|
||||||
<li><a name="LIMITS"><i>Q: Почему не работают ограничения доступа (перенаправления, ограничения по скорости,
|
<li><a name="LIMITS"><i>Q: Почему не работают ограничения доступа (перенаправления, ограничения по скорости,
|
||||||
трафику и т.д.)?</i></a></li>
|
трафику и т.д.)?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Обычные ошибки - использование auth none (для работы любых
|
<i>A:</i> Обычные ошибки - использование auth none (для работы любых
|
||||||
функций, основанных на ACL, требуется auth iponly, nbname или strong),
|
функций, основанных на ACL, требуется auth iponly, nbname или strong),
|
||||||
нарушение порядка ввода команд (команды выполняются последовательно,
|
нарушение порядка ввода команд (команды выполняются последовательно,
|
||||||
запуск сервиса proxy, socks, tcppm и т.д. должен осуществляться после
|
запуск сервиса proxy, socks, tcppm и т.д. должен осуществляться после
|
||||||
того, как указана его конфигурация), неправильный порядок записей в ACL
|
того, как указана его конфигурация), неправильный порядок записей в ACL
|
||||||
(записи просматриваются последовательно до первой, удовлетворяющей
|
(записи просматриваются последовательно до первой, удовлетворяющей
|
||||||
критериям). Если в ACL имеется хотя бы одна запись, то считается, что
|
критериям). Если в ACL имеется хотя бы одна запись, то считается, что
|
||||||
последняя запись в ACL - это неявная deny *.
|
последняя запись в ACL - это неявная deny *.
|
||||||
</p>
|
</p>
|
||||||
<li><a name="SERVICE"><i>Q: Почему 3proxy не запускается как служба?</i></a></li>
|
<li><a name="SERVICE"><i>Q: Почему 3proxy не запускается как служба?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Наиболее вероятные причины:
|
<i>A:</i> Наиболее вероятные причины:
|
||||||
<ul>
|
<ul>
|
||||||
<li>Использование относительных (неполных) путей файлов в файле конфигурации
|
<li>Отсутствие команды service в файле конфигурации - команда необходима в 3proxy 0.5.2 и более ранних, чтобы 3proxy вел себя как системная служба Windows
|
||||||
При использовании файлов журналов, файлов вставок ($filename) используйте
|
<li>Использование относительных (неполных) путей файлов в файле конфигурации
|
||||||
полные пути, например, $"c:\3proxy\include files\networks.local". Тоже самое
|
При использовании файлов журналов, файлов вставок ($filename) используйте
|
||||||
относится к файлам журналов и любым другим.
|
полные пути, например, $"c:\3proxy\include files\networks.local". Тоже самое
|
||||||
Для отладки лучше запускать 3proxy с ведением журнала на стандартный вывод.
|
относится к файлам журналов и любым другим.
|
||||||
Не забудьте в таком случае отключить daemon и service в файле конфигурации.
|
Для отладки лучше запускать 3proxy с ведением журнала на стандартный вывод.
|
||||||
Для чистоты эксперимента запускать 3proxy из коммандной строки в таком случае
|
Не забудьте в таком случае отключить daemon и service в файле конфигурации.
|
||||||
следует, находясь в другой папке.
|
Для чистоты эксперимента запускать 3proxy из коммандной строки в таком случае
|
||||||
<li>Отсутствие у системной записи прав на доступ к исполняемому файлу, каким-либо файлам конфигурации, журнала и т.п.
|
следует, находясь в другой папке.
|
||||||
<li>Отсутствие файла конфигурации по стандартному расположению -
|
<li>Отсутствие у системной записи прав на доступ к исполняемому файлу, каким-либо файлам конфигурации, журнала и т.п.
|
||||||
3proxy.cfg в одном каталоге с исполняемым файлом. Если файл расположен по
|
<li>Отсутствие файла конфигурации по стандартному расположению -
|
||||||
другому пути, необходимо использовать команду
|
3proxy.cfg в одном каталоге с исполняемым файлом. Если файл расположен по
|
||||||
|
другому пути, необходимо использовать команду
|
||||||
<pre>
|
<pre>
|
||||||
3proxy --install path_to_configuration_file</pre>
|
3proxy --install path_to_configuration_file</pre>
|
||||||
<li>Отсутствие у пользователя прав на установку или запуск службы
|
<li>Отсутствие у пользователя прав на установку или запуск службы
|
||||||
<li>Служба уже установлена или запущена
|
<li>Служба уже установлена или запущена
|
||||||
</ul>
|
</ul>
|
||||||
</p>
|
</p>
|
||||||
<li><a name="INTEXT"><i>Q: Почему не получается указать internal и external?</i></a></li></li>
|
<li><a name="INTEXT"><i>Q: Почему не получается указать internal и external?</i></a></li></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Убедитесь, что выправильно понимаете что такое internal и external адреса.
|
<i>A:</i> Убедитесь, что выправильно понимаете что такое internal и external адреса.
|
||||||
Оба адреса - это адреса, принадлежищие хосту, на котором установлен 3proxy.
|
Оба адреса - это адреса, принадлежищие хосту, на котором установлен 3proxy.
|
||||||
Эта опция конфигурации необходима в классической ситуации, когда 3proxy
|
Эта опция конфигурации необходима в классической ситуации, когда 3proxy
|
||||||
установлен на граничном компьютере с двумя (или более) подключениями:
|
установлен на граничном компьютере с двумя (или более) подключениями:
|
||||||
<pre>
|
<pre>
|
||||||
LAN connection +-------------+ Internet connection
|
LAN connection +-------------+ Internet connection
|
||||||
LAN <-------------->| 3proxy host |<-------------------> INTERNET
|
LAN <-------------->| 3proxy host |<-------------------> INTERNET
|
||||||
^+-------------+^
|
^+-------------+^
|
||||||
| |
|
| |
|
||||||
Internal IP External IP</pre>
|
Internal IP External IP</pre>
|
||||||
Если 3proxy работает на хосте с одним интерфейсом, то его адрес будет и
|
Если 3proxy работает на хосте с одним интерфейсом, то его адрес будет и
|
||||||
internal и external.
|
internal и external.
|
||||||
<br>Интерфейс с адресом internal должен существовать и быть рабочим на момент
|
<br>Интерфейс с адресом internal должен существовать и быть рабочим на момент
|
||||||
запуска 3proxy, и не должен отключаться. Если internal интерфейс
|
запуска 3proxy, и не должен отключаться. Если internal интерфейс
|
||||||
периодически отключается, то не следует его указывать, или можно указать адрес
|
периодически отключается, то не следует его указывать, или можно указать адрес
|
||||||
0.0.0.0. При этом прокси будет принимать запросы на всех интерфейсах, поэтому
|
0.0.0.0. При этом прокси будет принимать запросы на всех интерфейсах, поэтому
|
||||||
при наличии нескольких интерфейсов для ограничения доступа следует использовать
|
при наличии нескольких интерфейсов для ограничения доступа следует использовать
|
||||||
фаервол или хотя бы ACL.
|
фаервол или хотя бы ACL.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Интерфейс с адресом external, если он указан, должен быть рабочим на момент
|
Интерфейс с адресом external, если он указан, должен быть рабочим на момент
|
||||||
получения запроса клиента. При отсутствии external или адресе 0.0.0.0 внешний
|
получения запроса клиента. При отсутствии external или адресе 0.0.0.0 внешний
|
||||||
адрес будет выбираться системой при установке соединения. При этом, может быть
|
адрес будет выбираться системой при установке соединения. При этом, может быть
|
||||||
возможность доступа через прокси к ресурсам локальной сети, поэтому для
|
возможность доступа через прокси к ресурсам локальной сети, поэтому для
|
||||||
предотвращения несанкционированного доступа следует использовать ACL. Кроме
|
предотвращения несанкционированного доступа следует использовать ACL. Кроме
|
||||||
того, могут быть проблемы с приемом входящих соединений через SOCKSv5
|
того, могут быть проблемы с приемом входящих соединений через SOCKSv5
|
||||||
(SOCKSv5 используется в клиентах исключительно редко).
|
(SOCKSv5 используется в клиентах исключительно редко).
|
||||||
В случае, если адрес динамический, можно либо не
|
В случае, если адрес динамический, можно либо не
|
||||||
указывать external, либо использовать адрес 0.0.0.0, либо, если необходима
|
указывать external, либо использовать адрес 0.0.0.0, либо, если необходима
|
||||||
поддержка входящих соединений в SOCKSv5, использовать скрипт,
|
поддержка входящих соединений в SOCKSv5, использовать скрипт,
|
||||||
который будет получать текущий адрес и сохранять его в файл, который будет
|
который будет получать текущий адрес и сохранять его в файл, который будет
|
||||||
отслуживаться через команду monitor.
|
отслуживаться через команду monitor.
|
||||||
</p>
|
</p>
|
||||||
<li><a name="ODBC"><i>Q: Почему не работает ведение журналов в ODBC?</i></a></li>
|
<li><a name="ODBC"><i>Q: Почему не работает ведение журналов в ODBC?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Убедитесь, что используется системный, а не
|
<i>A:</i> Убедитесь, что используется системный, а не
|
||||||
пользовательский DSN. Убедитесь, что выполняется правильный SQL запрос. Наиболее
|
пользовательский DSN. Убедитесь, что выполняется правильный SQL запрос. Наиболее
|
||||||
распространенная проблема связана с отсутствием кавычек или неправильным
|
распространенная проблема связана с отсутствием кавычек или неправильным
|
||||||
форматом данных. Самый простой способ - сделать ведение журнала в файл или
|
форматом данных. Самый простой способ - сделать ведение журнала в файл или
|
||||||
на стандартный вывод, просмотреть выдаваемые SQL запросы и попробовать
|
на стандартный вывод, просмотреть выдаваемые SQL запросы и попробовать
|
||||||
дать такой запрос вручную.
|
дать такой запрос вручную.
|
||||||
</p>
|
</p>
|
||||||
<li><a name="IPv6"><i>Q: Почему не работает IPv6?</i></a></li>
|
<li><a name="CHAP"><i>Q: Почему не поддерживаются APOP и CRAM-MD5 в POP3 прокси?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Прокси не может обращаться напрямую к IPv6 сети если в запросе от клиента
|
<i>A:</i> Любая challenge-response аутентификация, к которым относятся APOP
|
||||||
указан IPv4. В запросе от клиента должен быть IPv6 адрес или имя хоста, чаще
|
и CRAM-MD5, требует, чтобы со стороны сервера был передан уникальный challenge.
|
||||||
всего это решается включением опции разрешения имен через прокси-сервер на стороне
|
До начала аутентификации POP3 прокси не знает, к какому серверу следует
|
||||||
клиента.
|
подключаться для получения Challenge, поэтому challenge-response в принципе
|
||||||
</p>
|
невозможен. Защитить соединение можно с помощью TLS (например, stunnel) или
|
||||||
<li><a name="CHAP"><i>Q: Почему не поддерживаются APOP и CRAM-MD5 в POP3 прокси?</i></a></li>
|
|
||||||
<p>
|
|
||||||
<i>A:</i> Любая challenge-response аутентификация, к которым относятся APOP
|
|
||||||
и CRAM-MD5, требует, чтобы со стороны сервера был передан уникальный challenge.
|
|
||||||
До начала аутентификации POP3 прокси не знает, к какому серверу следует
|
|
||||||
подключаться для получения Challenge, поэтому challenge-response в принципе
|
|
||||||
невозможен. Защитить соединение можно с помощью TLS (например, stunnel) или
|
|
||||||
IPSec.
|
IPSec.
|
||||||
</p>
|
</p>
|
||||||
<li><a name="CRASH"><i>Q: Почему прокси крэшится при обработке запроса?</a></i></li>
|
|
||||||
<p>
|
|
||||||
<i>A:</i> Возможно, недостаточен размер стека потока по-умолчанию, это может
|
|
||||||
быть при использовани каких-либо сторонних плагинов (PAM, ODBC) или на
|
|
||||||
некоторых платформах (некоторые версии FreeBSD на amd64). Можно решить
|
|
||||||
проблему с помощью опции 'stacksize' или '-S', поддерживаемых в 0.8.4 и выше.
|
|
||||||
</p>
|
|
||||||
</ul>
|
</ul>
|
||||||
<hr>
|
<hr>
|
||||||
<li><b><a name="SOCKSREDIR">Перенаправление socks соединений в локальный прокси</a></b></li>
|
<li><b><a name="SOCKSREDIR">Перенаправление socks соединений в локальный прокси</a></b></li>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a name="REDIR"><i>Q: Для чего это надо?</i></a></li>
|
<li><a name="REDIR"><i>Q: Для чего это надо?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Чтобы иметь в логах URL запросов, если пользователь SOCKS пользуется
|
<i>A:</i> Чтобы иметь в логах URL запросов, если пользователь SOCKS пользуется
|
||||||
Web, FTP или POP3.
|
Web, FTP или POP3.
|
||||||
</p>
|
</p>
|
||||||
<li><a name="REDIRLIMIT"><i>Q: Какие недостатки?</i></a></li>
|
<li><a name="REDIRLIMIT"><i>Q: Какие недостатки?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Перенапраление невозможно для web-серверов или FTP, висящих на
|
<i>A:</i> Перенапраление невозможно для web-серверов или FTP, висящих на
|
||||||
нестандартных портах, для SOCKSv4 не поддрживается авторизация с
|
нестандартных портах, для SOCKSv4 не поддрживается авторизация с
|
||||||
паролем (IE поддерживает только SOCKSv4), но при этом IE передает
|
паролем (IE поддерживает только SOCKSv4), но при этом IE передает
|
||||||
имя пользователя по SOCKSv4 (имя, с которым пользователь вошел в систему).
|
имя пользователя по SOCKSv4 (имя, с которым пользователь вошел в систему).
|
||||||
Для SOCKSv5 не поддерживается NTLM авторизация, пароли передаются в открытом
|
Для SOCKSv5 не поддерживается NTLM авторизация, пароли передаются в открытом
|
||||||
тексте.
|
тексте.
|
||||||
</p>
|
</p>
|
||||||
<li><a name="REDIRADV"><i>Q: Какие преимущества?</i></a></li>
|
<li><a name="REDIRADV"><i>Q: Какие преимущества?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Достаточно в настройках IE только указать адрес SOCKS прокси. В
|
<i>A:</i> Достаточно в настройках IE только указать адрес SOCKS прокси. В
|
||||||
больших сетях можно для этого использовать WPAD (автоматическое
|
больших сетях можно для этого использовать WPAD (автоматическое
|
||||||
обнаружение прокси). В 3proxy достаточно запускать только одну службу
|
обнаружение прокси). В 3proxy достаточно запускать только одну службу
|
||||||
(socks). Если используется только Internet Explorer, то можно
|
(socks). Если используется только Internet Explorer, то можно
|
||||||
автоматически получать имя пользователя в логах, не запрашивая
|
автоматически получать имя пользователя в логах, не запрашивая
|
||||||
логин/пароль.
|
логин/пароль.
|
||||||
</p>
|
</p>
|
||||||
<li><a name="REDIRHOW"><i>Q: Как настраивается?</i></a></li>
|
<li><a name="REDIRHOW"><i>Q: Как настраивается?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Указывается parent http proxy со специальным адресом 0.0.0.0 и портом
|
<i>A:</i> Указывается parent http proxy со специальным адресом 0.0.0.0 и портом
|
||||||
0. Пример:
|
0. Пример:
|
||||||
<pre>
|
<pre>
|
||||||
allow * * * 80,8080-8088
|
allow * * * 80,8080-8088
|
||||||
parent 1000 http 0.0.0.0 0
|
parent 1000 http 0.0.0.0 0
|
||||||
allow * * * 80,8080-8088
|
allow * * * 80,8080-8088
|
||||||
#перенаправить соединения по портам 80 и 8080-8088 в локальный
|
#перенаправить соединения по портам 80 и 8080-8088 в локальный
|
||||||
#http прокси. Вторая команда allow необходима, т.к. контроль доступа
|
#http прокси. Вторая команда allow необходима, т.к. контроль доступа
|
||||||
#осуществляется 2 раза - на уровне socks и на уровне HTTP прокси
|
#осуществляется 2 раза - на уровне socks и на уровне HTTP прокси
|
||||||
allow * * * 21,2121
|
allow * * * 21,2121
|
||||||
parent 1000 ftp 0.0.0.0 0
|
parent 1000 ftp 0.0.0.0 0
|
||||||
allow * * * 21,2121
|
allow * * * 21,2121
|
||||||
#перенаправить соединения по портам 21 и 2121 в локальный
|
#перенаправить соединения по портам 21 и 2121 в локальный
|
||||||
#ftp прокси
|
#ftp прокси
|
||||||
allow *
|
allow *
|
||||||
#пустить все соединения напрямую
|
#пустить все соединения напрямую
|
||||||
socks</pre>
|
socks</pre>
|
||||||
</p>
|
</p>
|
||||||
<li><a name="REDIINTER"><i>Q: Как взаимодействует с другими правилами в ACL?</i></a></li>
|
<li><a name="REDIINTER"><i>Q: Как взаимодействует с другими правилами в ACL?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> После внутреннего перенаправления правила рассматриваются еще раз за
|
<i>A:</i> После внутреннего перенаправления правила рассматриваются еще раз за
|
||||||
исключением самого правила с перенаправлением (т.е. обработка правил не
|
исключением самого правила с перенаправлением (т.е. обработка правил не
|
||||||
прекращается). Это позволяет сделать дальнейшие перенаправления на
|
прекращается). Это позволяет сделать дальнейшие перенаправления на
|
||||||
внешний прокси. По этой же причине локальное перенаправление не должно
|
внешний прокси. По этой же причине локальное перенаправление не должно
|
||||||
быть последним правилом (т.е. должно быть еще хотя бы правило allow,
|
быть последним правилом (т.е. должно быть еще хотя бы правило allow,
|
||||||
чтобы разрешить внешние соединения через HTTP прокси).
|
чтобы разрешить внешние соединения через HTTP прокси).
|
||||||
Например,
|
Например,
|
||||||
<pre>
|
<pre>
|
||||||
allow * * * 80,8080-8088
|
allow * * * 80,8080-8088
|
||||||
parent 1000 http 0.0.0.0 0
|
parent 1000 http 0.0.0.0 0
|
||||||
#перенаправить во внутренний прокси
|
#перенаправить во внутренний прокси
|
||||||
allow * * $c:\3proxy\local.nets 80,8080-8088
|
allow * * $c:\3proxy\local.nets 80,8080-8088
|
||||||
#разрешить прямой web-доступ к сетям из local.nets
|
#разрешить прямой web-доступ к сетям из local.nets
|
||||||
allow * * * 80,8080-8088
|
allow * * * 80,8080-8088
|
||||||
parent 1000 http proxy.3proxy.ru 3128
|
parent 1000 http proxy.sandy.ru 3128
|
||||||
#все остальные веб-запросы перенаправить на внешний прокси-сервер
|
#все остальные веб-запросы перенаправить на внешний прокси-сервер
|
||||||
allow *
|
allow *
|
||||||
#разрешить socks-запросы по другим портам</pre>
|
#разрешить socks-запросы по другим портам</pre>
|
||||||
</p>
|
</p>
|
||||||
</ul>
|
</ul>
|
||||||
<hr>
|
<hr>
|
||||||
<li><b><a name="ISIT">А есть ли...</a></b></li>
|
<li><b><a name="ISIT">А есть ли...</a></b></li>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a name="NAMES"><i>Q: Можно ли разрешать имена на родительском прокси?</i></a></li>
|
<li><a name="NAMES"><i>Q: Можно ли разрешать имена на родительском прокси?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Можно. Для этого надо использовать тип родительского прокси http,
|
<i>A:</i> Можно. Для этого надо использовать тип родительского прокси http,
|
||||||
connect+, socks4+ и socks5+. Однако, при это надо помнить, что самому 3proxy
|
connect+, socks4+ и socks5+. Однако, при это надо помнить, что самому 3proxy
|
||||||
требуется разрешение имени для управления ACL. Поэтому, если с прокси-хоста
|
требуется разрешение имени для управления ACL. Поэтому, если с прокси-хоста
|
||||||
не работают разрешения имени, необходимо в конфигурации дать команду
|
не работают разрешения имени, необходимо в конфигурации дать команду
|
||||||
<pre>
|
<pre>
|
||||||
fakeresolve</pre>
|
fakeresolve</pre>
|
||||||
которая разрешает любое имя в адрес 127.0.0.2.
|
которая разрешает любое имя в адрес 127.0.0.2.
|
||||||
</p>
|
</p>
|
||||||
<li><a name="ISFTP"><i>Q: Существует ли сейчас поддержка FTP прокси в продукте?</i></a></li>
|
<li><a name="ISFTP"><i>Q: Существует ли сейчас поддержка FTP прокси в продукте?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
Есть поддержка как FTP через HTTP (то, что называется FTP прокси в Internet
|
Есть поддержка как FTP через HTTP (то, что называется FTP прокси в Internet
|
||||||
Explorer, Netscape, Opera) так и настоящего FTP прокси (то, что называется
|
Explorer, Netscape, Opera) так и настоящего FTP прокси (то, что называется
|
||||||
FTP proxy в FAR и FTP клиентах).
|
FTP proxy в FAR и FTP клиентах).
|
||||||
</p>
|
</p>
|
||||||
<li><a name="PORT"><i>Q: Каким образом можно прибиндить сервисы на свой порт, к примеру, HTTP прокси к 8080, а не 3128 как по-умолчанию?</i></a></li>
|
<li><a name="PORT"><i>Q: Каким образом можно прибиндить сервисы на свой порт, к примеру, HTTP прокси к 8080, а не 3128 как по-умолчанию?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
А:
|
А:
|
||||||
<pre>
|
<pre>
|
||||||
proxy -p8080</pre>
|
proxy -p8080</pre>
|
||||||
</p>
|
</p>
|
||||||
<li><a name="BANDLIM"><i>Q: Как ограничить ширину канала?</i></a></li>
|
<li><a name="BANDLIM"><i>Q: Как ограничить ширину канала?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Читайте HowTo <a href="https://3proxy.ru/howtor.asp#BANDLIM">https://3proxy.ru/howtor.asp#BANDLIM</a>
|
<i>A:</i> Читайте HowTo <a href="http://3proxy.ru/howtor.asp#BANDLIM">http://3proxy.ru/howtor.asp#BANDLIM</a>
|
||||||
</p>
|
</p>
|
||||||
</ul>
|
</ul>
|
||||||
<hr>
|
<hr>
|
||||||
<li><b><a name="BRRR">Почему так криво...</a></b></li>
|
<li><b><a name="BRRR">Почему так криво...</a></b></li>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a name="TRAF"><i>Q: Почему так криво считается трафик? Не совпадает с ...</i></a></li>
|
<li><a name="TRAF"><i>Q: Почему так криво считается трафик? Не совпадает с ...</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Следует учитывать, что 3proxy считает трафик только на прикладном уровне и
|
<i>A:</i> Следует учитывать, что 3proxy считает трафик только на прикладном уровне и
|
||||||
только проходящий через прокси-сервер. Провайдеры и другие средства учета
|
только проходящий через прокси-сервер. Провайдеры и другие средства учета
|
||||||
трафика считают трафик на сетевом уровне, что уже дает расхождение порядка 10%
|
трафика считают трафик на сетевом уровне, что уже дает расхождение порядка 10%
|
||||||
за счет информации из заголовков пакетов. Кроме того, часть трафика, как
|
за счет информации из заголовков пакетов. Кроме того, часть трафика, как
|
||||||
минимум DNS-разрешения, различный флудовый трафик и т.д. идут мимо прокси.
|
минимум DNS-разрешения, различный флудовый трафик и т.д. идут мимо прокси.
|
||||||
Уровень "шумового" трафика в Internet сейчас составляет порядка 50KB/день на
|
Уровень "шумового" трафика в Internet сейчас составляет порядка 50KB/день на
|
||||||
каждый реальный IP адрес, но может сильно варьироваться в зависимости от сети,
|
каждый реальный IP адрес, но может сильно варьироваться в зависимости от сети,
|
||||||
наличия открытых портов, реакции на ping-запросы и текущего уровня вирусной
|
наличия открытых портов, реакции на ping-запросы и текущего уровня вирусной
|
||||||
активности. По этим причинам, если 3proxy используется чтобы не "выжрать"
|
активности. По этим причинам, если 3proxy используется чтобы не "выжрать"
|
||||||
трафик, выделенный провайдером, всегда следует делать некий запас порядка
|
трафик, выделенный провайдером, всегда следует делать некий запас порядка
|
||||||
15%.
|
15%.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Если на одной с 3proxy машине имеются какие-либо сервисы или
|
Если на одной с 3proxy машине имеются какие-либо сервисы или
|
||||||
работает пользователь, то их трафик не проходит через proxy-сервер и так же
|
работает пользователь, то их трафик не проходит через proxy-сервер и так же
|
||||||
не будет учтен. Если где-то есть NAT, то клиенты, выходящие через NAT мимо
|
не будет учтен. Если где-то есть NAT, то клиенты, выходящие через NAT мимо
|
||||||
прокси, так же останутся неучтенными. Если расхождение с провайдером превышает
|
прокси, так же останутся неучтенными. Если расхождение с провайдером превышает
|
||||||
10% - нужно искать причину именно в этом.
|
10% - нужно искать причину именно в этом.
|
||||||
</p>
|
</p>
|
||||||
<li><a name="CONFIG"><i>Q: Почему такая кривая конфигурация и ничерта не понятно?</i></a></li>
|
<li><a name="CONFIG"><i>Q: Почему такая кривая конфигурация и ничерта не понятно?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Есть несколько причин. Во-первых, до выхода релиза (т.е. версии 1.0) я буду изо
|
<i>A:</i> Есть несколько причин. Во-первых, до выхода релиза (т.е. версии 1.0) я буду изо
|
||||||
всех сил добиваться совместимости конфигурации между версиями. Во-вторых,
|
всех сил добиваться совместимости конфигурации между версиями. Во-вторых,
|
||||||
конфигурация сделана так, чтобы ее можно было легко разбирать программно.
|
конфигурация сделана так, чтобы ее можно было легко разбирать программно.
|
||||||
В-третьих, все там понятно. При желании. Если знать как все работает.
|
В-третьих, все там понятно. При желании. Если знать как все работает.
|
||||||
</p>
|
</p>
|
||||||
<li><a name="CODE"><i>Q: Почему так криво написан код?</i></a></li>
|
<li><a name="CODE"><i>Q: Почему так криво написан код?</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Есть несколько причин. Во-первых, я не программист. Во-вторых, 3proxy изначально
|
<i>A:</i> Есть несколько причин. Во-первых, я не программист. Во-вторых, 3proxy изначально
|
||||||
писался на коленке (в отет на "слабо" в одной из конференций). Никто
|
писался на коленке (в отет на "слабо" в одной из конференций). Никто
|
||||||
не мог предположить, что им кто-то реально будет пользоваться. В-третьих, у многих
|
не мог предположить, что им кто-то реально будет пользоваться. В-третьих, у многих
|
||||||
возникает желание разобраться в коде 3proxy чтобы внедрить его в какой-нибудь
|
возникает желание разобраться в коде 3proxy чтобы внедрить его в какой-нибудь
|
||||||
троян. Очень не хочется облегчать эту задачу. В-четвертых, мне надо добиться
|
троян. Очень не хочется облегчать эту задачу. В-четвертых, мне надо добиться
|
||||||
компиляции кода в как можно большем числе систем. Замечено, что чем кривее код в
|
компиляции кода в как можно большем числе систем. Замечено, что чем кривее код в
|
||||||
C, тем он лучше переносится.
|
C, тем он лучше переносится.
|
||||||
</p>
|
</p>
|
||||||
<li><a name="UNSAFE"><i>Q: Почему так много strcpy, sprintf и т.д., это ж дыры!</i></a><li>
|
<li><a name="UNSAFE"><i>Q: Почему так много strcpy, sprintf и т.д., это ж дыры!</i></a><li>
|
||||||
<p>
|
<p>
|
||||||
<i>A:</i> Есть несколько причин. Во-первых, несмотря на дурной тон использования этих
|
<i>A:</i> Есть несколько причин. Во-первых, несмотря на дурной тон использования этих
|
||||||
функций, они наиболее совместимы между разными системами и компиляторами.
|
функций, они наиболее совместимы между разными системами и компиляторами.
|
||||||
Во-вторых, само по себе их использование не означает присутствие дыры, если их
|
Во-вторых, само по себе их использование не означает присутствие дыры, если их
|
||||||
параметры должным образом контролируются. Найдете дыру - обязательно сообщите.
|
параметры должным образом контролируются. Найдете дыру - обязательно сообщите.
|
||||||
В третьих, может быть я уберу их перед конечным релизом, чтобы никого не
|
В третьих, может быть я уберу их перед конечным релизом, чтобы никого не
|
||||||
пугать.
|
пугать.
|
||||||
</p>
|
</p>
|
||||||
</ul>
|
</ul>
|
||||||
|
<pre>
|
||||||
|
$Id: faqr.html,v 1.28 2007/09/25 09:47:13 vlad Exp $
|
||||||
|
</pre>
|
||||||
@@ -1,287 +0,0 @@
|
|||||||
<h3>Optimizing 3proxy for high load</h3>
|
|
||||||
<p>Precaution 1: 3proxy was not initially developed for high load and is positioned as a SOHO product, the main reason is "one connection - one thread" model 3proxy uses. 3proxy is known to work with above 200,000 connections under proper configuration, but use it in production environment under high loads at your own risk and do not expect too much.
|
|
||||||
<p>Precaution 2: This documentation is incomplete and is not sufficient. High loads may require very specific system tuning including, but not limited to specific or cusomized kernels, builds, settings, sysctls, options, etc. All this is not covered by this documentation.
|
|
||||||
|
|
||||||
<h4>Configuring 'maxconn'</h4>
|
|
||||||
|
|
||||||
A number of simulatineous connections per service is limited by 'maxconn' option.
|
|
||||||
Default maxconn value since 3proxy 0.8 is 500. You may want to set 'maxconn'
|
|
||||||
to higher value. Under this configuration:
|
|
||||||
<pre>
|
|
||||||
maxconn 1000
|
|
||||||
proxy -p3129
|
|
||||||
proxy -p3128
|
|
||||||
socks
|
|
||||||
</pre>
|
|
||||||
maxconn for every service is 1000, and there are 3 services running
|
|
||||||
(2 proxy and 1 socks), so, for all services there can be up to 3000
|
|
||||||
simulatineous connections to 3proxy.
|
|
||||||
<p>Avoid setting 'maxconn' to arbitrary high value, it should be carefully
|
|
||||||
choosen to protect system and proxy from resources exhaution. Setting maxconn
|
|
||||||
above resources available can lead to denial of service conditions.
|
|
||||||
<h4>Understanding resources requirements</h4>
|
|
||||||
Each running service require:
|
|
||||||
<ul>
|
|
||||||
<li>1*thread (process)
|
|
||||||
<li>1*socket (file descriptor)
|
|
||||||
<li>1 stack memory segment + some heap memory, ~64K-128K depending on the system
|
|
||||||
</ul>
|
|
||||||
Each connected client require:
|
|
||||||
<ul>
|
|
||||||
<li>1*thread (process)
|
|
||||||
<li>2*socket (file descriptor). For FTP 4 sockets are required.
|
|
||||||
<br>Under linux since 0.9 splice() is used. It's much more effective, but requires
|
|
||||||
<br>2*socket (file descriptor) + 2*pipe (file descriptors) = 4 file descriptors.
|
|
||||||
<br>For FTP 4 sockets and 2 pipes are required with splice().
|
|
||||||
<br>Up to 128K (up to 256K in the case of splice()) of kernel buffers memory. This is theoretical maximum, actual numbers depend on connection quality and traffic amount.
|
|
||||||
<br>1 additional socket (file descriptor) during name resolution for non-cached names
|
|
||||||
<br>1 additional socket during authentication or logging for RADIUS authentication or logging.
|
|
||||||
<li>1*ephemeral port (3*ephemeral ports for FTP connection).
|
|
||||||
<li>1 stack memory segment of ~32K-128K depending on the system + at least 16K and up to few MB (for 'proxy' and 'ftppr') of heap memory. If you are short of memory, prefer 'socks' to 'proxy' and 'ftppr'.
|
|
||||||
<li>a lot of system buffers, specially in the case of slow network connections.
|
|
||||||
</ul>
|
|
||||||
Also, additional resources like system buffers are required for network activity.
|
|
||||||
|
|
||||||
<h4>Setting ulimits</h4>
|
|
||||||
|
|
||||||
Hard and soft ulimits must be set above calculated requirements. Under Linux, you can
|
|
||||||
check limits of running process with
|
|
||||||
<pre>
|
|
||||||
cat /proc/PID/limits
|
|
||||||
</pre>
|
|
||||||
where PID is a pid of the process.
|
|
||||||
Validate ulimits match your expectation, especially if you run 3proxy under dedicated account
|
|
||||||
by adding e.g.
|
|
||||||
<pre>
|
|
||||||
system "ulimit -Ha >>/tmp/3proxy.ulim.hard"
|
|
||||||
system "ulimit -Sa >>/tmp/3proxy.ulim.soft"
|
|
||||||
</pre>
|
|
||||||
in the beginning (before first service started) and the end of config file.
|
|
||||||
Make both hard restart (that is kill and start 3proxy process) and soft restart
|
|
||||||
by sending SIGUSR1 to 3proxy process, check ulimits recorded to files match your
|
|
||||||
expecation. In systemd based distros (e.g. latest Debian / Ubuntu) changing limits.conf
|
|
||||||
is not enough, limits must be ajusted in systemd configuration, e.g. by setting
|
|
||||||
<pre>
|
|
||||||
DefaultLimitDATA=infinity
|
|
||||||
DefaultLimitSTACK=infinity
|
|
||||||
DefaultLimitCORE=infinity
|
|
||||||
DefaultLimitRSS=infinity
|
|
||||||
DefaultLimitNOFILE=102400
|
|
||||||
DefaultLimitAS=infinity
|
|
||||||
DefaultLimitNPROC=10240
|
|
||||||
DefaultLimitMEMLOCK=infinity
|
|
||||||
</pre>
|
|
||||||
in user.conf / system.conf
|
|
||||||
|
|
||||||
<h4>Extending system limitation</h4>
|
|
||||||
|
|
||||||
Check manuals / documentation for your system limitations e.g. system-wide limit for number of open files
|
|
||||||
(fs.file-max in Linux). You may need to change sysctls or even rebuild the kernel from source.
|
|
||||||
<p>
|
|
||||||
To help with socket-based system-dependant settings, since 0.9-devel 3proxy supports different
|
|
||||||
socket options which can be set via -ol option for listening socket, -oc for proxy-to-client
|
|
||||||
socket and -os for proxy-to-server socket. Example:
|
|
||||||
<pre>
|
|
||||||
proxy -olSO_REUSEADDR,SO_REUSEPORT -ocTCP_TIMESTAMPS,TCP_NODELAY -osTCP_NODELAY
|
|
||||||
</pre>
|
|
||||||
available options are system dependant.
|
|
||||||
|
|
||||||
<h4>Using 3proxy in virtual environment</h4>
|
|
||||||
|
|
||||||
If 3proxy is used in VPS environment, there can be additional limitations.
|
|
||||||
For example, kernel resources / system CPU usage / IOCTLs can be limited in a different way, and this can become a bottleneck.
|
|
||||||
Since 0.9 devel, 3proxy uses splice() by default on Linux, splice() prevents network traffic from being copied from
|
|
||||||
kernel space to 3proxy process and generally increases throughput, epecially in the case of high volume traffic. It especially
|
|
||||||
true for virtual environment (it can improve thoughput up to 10 times) unless there are additional kernel limitations.
|
|
||||||
Since some work is moved to kernel, it requires up to 2 times more kernel resources in terms of CPU, memory and IOCTLs.
|
|
||||||
If your hosting additionally limits kernel resources (you can see it as nearly 100% CPU usage without any real CPU activity for
|
|
||||||
any application which performs IOCTLS), use -s0 option to disable splice() usage for given service e.g.
|
|
||||||
<pre>
|
|
||||||
socks -s0
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h4>Extending ephemeral port range</h4>
|
|
||||||
|
|
||||||
Check ephemeral port range for your system and extend it to the number of the
|
|
||||||
ports required.
|
|
||||||
Ephimeral range is always limited to maximum number of ports (64K). To extend the
|
|
||||||
number of outgoing connections above this limit, extending ephemeral port range
|
|
||||||
is not enough, you need additional actions:
|
|
||||||
<ol>
|
|
||||||
<li> Configure multiple outgoing IPs
|
|
||||||
<li> Make sure 3proxy is configured to use different outgoing IP by either setting
|
|
||||||
external IP via RADIUS
|
|
||||||
<pre>
|
|
||||||
radius secret 1.2.3.4
|
|
||||||
auth radius
|
|
||||||
proxy
|
|
||||||
</pre>
|
|
||||||
or by using multiple services with different external
|
|
||||||
interfaces, example:
|
|
||||||
<pre>
|
|
||||||
allow user1,user11,user111
|
|
||||||
proxy -p1111 -e1.1.1.1
|
|
||||||
flush
|
|
||||||
allow user2,user22,user222
|
|
||||||
proxy -p2222 -e2.2.2.2
|
|
||||||
flush
|
|
||||||
allow user3,user33,user333
|
|
||||||
proxy -p3333 -e3.3.3.3
|
|
||||||
flush
|
|
||||||
allow user4,user44,user444
|
|
||||||
proxy -p4444 -e4.4.4.4
|
|
||||||
flush
|
|
||||||
</pre>
|
|
||||||
or via "parent extip" rotation,
|
|
||||||
e.g.
|
|
||||||
<pre>
|
|
||||||
allow user1,user11,user111
|
|
||||||
parent 1000 extip 1.1.1.1 0
|
|
||||||
allow user2,user22,user222
|
|
||||||
parent 1000 extip 2.2.2.2 0
|
|
||||||
allow user3,user33,user333
|
|
||||||
parent 1000 extip 3.3.3.3 0
|
|
||||||
allow user4,user44,user444
|
|
||||||
parent 1000 extip 4.4.4.4 0
|
|
||||||
proxy
|
|
||||||
</pre>
|
|
||||||
or
|
|
||||||
<pre>
|
|
||||||
allow *
|
|
||||||
parent 250 extip 1.1.1.1 0
|
|
||||||
parent 250 extip 2.2.2.2 0
|
|
||||||
parent 250 extip 3.3.3.3 0
|
|
||||||
parent 250 extip 4.4.4.4 0
|
|
||||||
socks
|
|
||||||
</pre>
|
|
||||||
<pre>
|
|
||||||
</pre>
|
|
||||||
Under latest Linux version you can also start multiple services with different
|
|
||||||
external addresses on the single port with SO_REUSEPORT on listening socket to
|
|
||||||
evenly distribute incoming connections between outgoing interfaces:
|
|
||||||
<pre>
|
|
||||||
socks -olSO_REUSEPORT -p3128 -e 1.1.1.1
|
|
||||||
socks -olSO_REUSEPORT -p3128 -e 2.2.2.2
|
|
||||||
socks -olSO_REUSEPORT -p3128 -e 3.3.3.3
|
|
||||||
socks -olSO_REUSEPORT -p3128 -e 4.4.4.4
|
|
||||||
</pre>
|
|
||||||
for Web browsing last two examples are not recommended, because same client can get
|
|
||||||
different external address for different requests, you should choose external
|
|
||||||
interface with user-based rules instead.
|
|
||||||
<li> You may need additional system dependant actions to use same port on different IPs,
|
|
||||||
usually by adding SO_REUSEADDR (SO_PORT_SCALABILITY for Windows) socket option to
|
|
||||||
external socket. This option can be set (since 0.9 devel) with -os option:
|
|
||||||
<pre>
|
|
||||||
proxy -p3128 -e1.2.3.4 -osSO_REUSEADDR
|
|
||||||
</pre>
|
|
||||||
Behavior for SO_REUSEADDR and SO_REUSEPORT is different between different system,
|
|
||||||
even between different kernel versions and can lead to unexpected results.
|
|
||||||
Specifics is described <a href="https://stackoverflow.com/questions/14388706/socket-options-so-reuseaddr-and-so-reuseport-how-do-they-differ-do-they-mean-t">here</a>.
|
|
||||||
Use this options only if actually required and if you fully understand possible
|
|
||||||
consiquences. E.g. SO_REUSEPORT can help to establish more connections than the
|
|
||||||
number of the client port available, but it can also lead to situation connections
|
|
||||||
are randomely fail due to ip+port pairs collision if remote or local system
|
|
||||||
doesn't support this trick.
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
<h4>Setting stacksize</h4>
|
|
||||||
|
|
||||||
'stacksize' is a size added to all stack allocations and can be both positive and
|
|
||||||
negative. Stack is required in functions call. 3proxy itself doesn't require large
|
|
||||||
stack, but it can be required if some
|
|
||||||
purely-written libc, 3rd party libraries or system functions called. There is known\
|
|
||||||
dirty code in Unix ODBC
|
|
||||||
implementations, build-in DNS resolvers, especially in the case of IPv6 and large
|
|
||||||
number of interfaces. Under most 64-bit system extending stacksize will lead
|
|
||||||
to additional memory space usage, but do not require actual commited memory,
|
|
||||||
so you can inrease stacksize to relatively large value (e.g. 1024000) without
|
|
||||||
the need to add additional phisical memory,
|
|
||||||
but it's system/libc dependant and requires additional testing under your
|
|
||||||
installation. Don't forget about memory related ulimts.
|
|
||||||
<p>For 32-bit systems address space can be a bottlneck you should consider. If
|
|
||||||
you're short of address space you can try to use negative stack size.
|
|
||||||
|
|
||||||
<h4>Known system issues</h4>
|
|
||||||
|
|
||||||
There are known race condition issues in Linux / glibc resolver. The probability
|
|
||||||
of race condition arises under configuration with IPv6, large number of interfaces
|
|
||||||
or IP addresses or resolvers configured. In this case, install local recursor and
|
|
||||||
use 3proxy built-in resolver (nserver / nscache / nscache6).
|
|
||||||
<h4>Do not use public resolvers</h4>
|
|
||||||
Public resolvers like ones from Google have ratelimits. For large number of
|
|
||||||
requests install local caching recursor (ISC bind named, PowerDNS recursor, etc).
|
|
||||||
|
|
||||||
<h4>Avoid large lists</h4>
|
|
||||||
|
|
||||||
Currently, 3proxy is not optimized to use large ACLs, user lists, etc. All lists
|
|
||||||
are processed lineary. In devel version you can use RADIUS authentication to avoid
|
|
||||||
user lists and ACLs in 3proxy itself. Also, RADIUS allows to easily set outgoing IP
|
|
||||||
on per-user basis or more sophisicated logics.
|
|
||||||
RADIUS is a new beta feature, test it before using in production.
|
|
||||||
|
|
||||||
<h4>Avoid changing configuration too often</h4>
|
|
||||||
|
|
||||||
Every configuration reload requires additional resources. Do not do frequent
|
|
||||||
changes, like users addition/deletaion via connfiguration, use alternative
|
|
||||||
authentication methods instead, like RADIUS.
|
|
||||||
|
|
||||||
<h4>Consider using 'noforce'</h4>
|
|
||||||
|
|
||||||
'force' behaviour (default) re-authenticates all connections after
|
|
||||||
configuration reload, it may be resource consuming on large number of
|
|
||||||
connections. Consider adding 'noforce' command before services started
|
|
||||||
to prevent connections reauthentication.
|
|
||||||
|
|
||||||
<h4>Do not monitor configuration files directly</h4>
|
|
||||||
|
|
||||||
Using configuration file directly in 'monitor' can lead to race condition where
|
|
||||||
configuration is reloaded while file is being written.
|
|
||||||
To avoid race conditions:
|
|
||||||
<ol>
|
|
||||||
<li> Update config files only if there is no lock file
|
|
||||||
<li> Create lock file then 3proxy configuration is updated, e.g. with
|
|
||||||
"touch /some/path/3proxy/3proxy.lck". If you generate config files
|
|
||||||
asynchronously, e.g. by user's request via web, you should consider
|
|
||||||
implementing existance checking and file creation as atomic operation.
|
|
||||||
<li>add
|
|
||||||
<pre>
|
|
||||||
system "rm /some/path/3proxy/3proxy.lck"
|
|
||||||
</pre>
|
|
||||||
at the end of config file to remove it after configuration is successfully loaded
|
|
||||||
<li> Use a dedicated version file to monitor, e.g.
|
|
||||||
<pre>
|
|
||||||
monitor "/some/path/3proxy/3proxy.ver"
|
|
||||||
</pre>
|
|
||||||
<li> After config is updated, change version file for 3proxy to reload configuration,
|
|
||||||
e.g. with "touch /some/path/3proxy/3proxy.ver".
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
<h4>Use TCP_NODELAY to speed-up connections with small amount of data</h4>
|
|
||||||
|
|
||||||
If most requests require exchange with a small amount of data in a both ways
|
|
||||||
without the need for bandwidth, e.g. messengers or small web request,
|
|
||||||
you can eliminate Nagle's algorithm delay with TCP_NODELAY flag. Usage example:
|
|
||||||
<pre>
|
|
||||||
proxy -osTCP_NODELAY -ocTCP_NODELAY
|
|
||||||
</pre>
|
|
||||||
sets TCP_NODELAY for client (oc) and server (os) connections.
|
|
||||||
<p>Do not use TCP_NODELAY on slow connections with high delays and then
|
|
||||||
connection bandwidth is a bottleneck.
|
|
||||||
|
|
||||||
<h4>Use splice to speedup large data amount transfers</h4>
|
|
||||||
|
|
||||||
splice() allows to copy data between connections without copying to process
|
|
||||||
addres space. It can speedup proxy on high bandwidth connections, if most
|
|
||||||
connections require large data transfers. Splice is enabled by default on Linux
|
|
||||||
since 0.9, "-s0" disables splice usage. Example:
|
|
||||||
<pre>
|
|
||||||
proxy -s0
|
|
||||||
</pre>
|
|
||||||
Splice is only available on Linux. Splice requires more system buffers and file descriptors,
|
|
||||||
and produces more IOCTLs but reduces process memory and overall CPU usage.
|
|
||||||
Disable splice if there is a lot of short-living connections with no bandwidth
|
|
||||||
requirements.
|
|
||||||
<p>Use splice only on high-speed connections (e.g. 10GBE), if processor, memory speed or
|
|
||||||
system bus are bottlenecks.
|
|
||||||
<p>TCP_NODELAY and splice are not contrary to each over and should be combined on
|
|
||||||
high-speed connections.
|
|
||||||
+9
-85
@@ -33,9 +33,6 @@
|
|||||||
<li><A HREF="#BANDLIM">How to limit bandwidth</A>
|
<li><A HREF="#BANDLIM">How to limit bandwidth</A>
|
||||||
<li><A HREF="#TRAFLIM">How to limit traffic amount</A>
|
<li><A HREF="#TRAFLIM">How to limit traffic amount</A>
|
||||||
<li><A HREF="#NETLIST">How to build network lists</A>
|
<li><A HREF="#NETLIST">How to build network lists</A>
|
||||||
<li><a href="#NSCACHING">How to configure name resolution and DNS caching</a>
|
|
||||||
<li><a href="#IPV6">How to use IPv6</a>
|
|
||||||
<li><a href="#CONNBACK">How to use connect back</a>
|
|
||||||
</ul>
|
</ul>
|
||||||
<li><A HREF="#CLIENT">Client configuration</A>
|
<li><A HREF="#CLIENT">Client configuration</A>
|
||||||
<li><A HREF="#ADMIN">Administering and information analisys</A>
|
<li><A HREF="#ADMIN">Administering and information analisys</A>
|
||||||
@@ -219,7 +216,7 @@ sets rotation type. LOGTYPE may be:
|
|||||||
<li>W, weekly
|
<li>W, weekly
|
||||||
<li>D, daily
|
<li>D, daily
|
||||||
<li>H, hourly
|
<li>H, hourly
|
||||||
<li>C, minutely
|
<li>‘, minutely
|
||||||
</ul>
|
</ul>
|
||||||
<pre>
|
<pre>
|
||||||
rotate NUMBER
|
rotate NUMBER
|
||||||
@@ -280,17 +277,17 @@ logformat "L%t.%. %N.%p %E %U %C:%c %R:%r %O %I %h %T"
|
|||||||
</pre>
|
</pre>
|
||||||
generates something like
|
generates something like
|
||||||
<p><font face="courier">
|
<p><font face="courier">
|
||||||
1042454727.0296 SOCK4.1080 000 3APA3A 127.0.0.1:4739 195.122.226.28:4739 505 18735 1 GET http://3proxy.org/ HTTP/1.1
|
1042454727.0296 SOCK4.1080 000 3APA3A 127.0.0.1:4739 195.122.226.28:4739 505 18735 1 GET http://3proxy.ru/ HTTP/1.1
|
||||||
</font>
|
</font>
|
||||||
<br>(no line breaks)
|
<br>(no line breaks)
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
If ODBC used, logformat should specify SQL command,
|
If ODBC used, logformat should specify SQL command,
|
||||||
to insert record into log, for example
|
to insert record into log, for example
|
||||||
<p><pre>
|
<p><font face="courier">
|
||||||
logformat "-\'+_GINSERT INTO proxystat VALUES (%t, '%c', '%U', %I)"</pre>
|
logformat "GINSERT INTO proxystat VALUES (%t, '%c', '%U', %I)"
|
||||||
|
</font>
|
||||||
<br>(no line breaks)
|
<br>(no line breaks)
|
||||||
<br>-\'+_ instructs to replace characters \ and ' with _
|
|
||||||
</p>
|
</p>
|
||||||
<li><A NAME="LOGANALIZERS">How to use log analizers with 3proxy</A>
|
<li><A NAME="LOGANALIZERS">How to use log analizers with 3proxy</A>
|
||||||
<p>
|
<p>
|
||||||
@@ -461,12 +458,7 @@ proxy -n
|
|||||||
</p>
|
</p>
|
||||||
Please note, that caching affects security. Never use caching for access to
|
Please note, that caching affects security. Never use caching for access to
|
||||||
critical resources, such as web administration.
|
critical resources, such as web administration.
|
||||||
<p>authcache can be used to bind user's sessions to ip with 'limit' option, with
|
|
||||||
<pre>
|
|
||||||
autchcache ip,user,pass,limit 120
|
|
||||||
auth cache strong</pre>
|
|
||||||
user will not be able to use more than a single IP during cache time (120 sec).
|
|
||||||
</p>
|
|
||||||
<li><A NAME="USERS">How to create user list</A>
|
<li><A NAME="USERS">How to create user list</A>
|
||||||
<p>
|
<p>
|
||||||
Userslist is created with 'users' command.
|
Userslist is created with 'users' command.
|
||||||
@@ -746,65 +738,6 @@ In this example we obtain list of local networks from provider's page to
|
|||||||
local.networks file, allow direct access to these networks and redirect all
|
local.networks file, allow direct access to these networks and redirect all
|
||||||
connection to external networks to provider's proxy.
|
connection to external networks to provider's proxy.
|
||||||
</p>
|
</p>
|
||||||
<li><a name="NSCACHING"><i>How to configure name resolution and DNS caching</i></a>
|
|
||||||
<p>
|
|
||||||
For name resolution and caching use commands nserver, nscache / nscache6 and nsrecord.
|
|
||||||
<pre>
|
|
||||||
nserver 192.168.1.2
|
|
||||||
nserver 192.168.1.3:5353/tcp</pre>
|
|
||||||
sets DNS resolvers. 192.168.1.3 will be used via TCP/5353 (instead of default UDP/53)
|
|
||||||
only if 192.168.1.2 fails. Up to 5 nservers may be specified.
|
|
||||||
If no nserver is configured, default system name resolution functions are used.
|
|
||||||
<pre>
|
|
||||||
nscache 65535
|
|
||||||
nscache6 65535</pre>
|
|
||||||
sets name cache size for IPv4 and IPv6. Name cache must be large enouth, if presents.
|
|
||||||
name cache is only used if nserver is configured.
|
|
||||||
<pre>
|
|
||||||
nsrecord server.mycompany.example.com 192.168.1.1
|
|
||||||
nsrecord www.porno.com 127.0.0.2
|
|
||||||
...
|
|
||||||
deny * * 127.0.0.2</pre>
|
|
||||||
adds static nsrecords. Also, static nsrecords are used for dnspr, unless -s option is specified.
|
|
||||||
Since 0.8 version, parent proxy may be configured for dnspr.
|
|
||||||
</p>
|
|
||||||
<li><a name="IPV6"><i>How to use IPv6</i></a>
|
|
||||||
<p>
|
|
||||||
IPv6 is supported since 0.8. Please note, some proxy protolos, e.g. SOCKSv4,
|
|
||||||
do not support IPv6. SOCKSv5 supports IPv6 with special request type (must be
|
|
||||||
implemented by client).
|
|
||||||
<br>
|
|
||||||
3proxy supports proxying from IPv4 and IPv6 networks to IPv4,
|
|
||||||
IPv6 and mixed networks. IPv6 address may be used in
|
|
||||||
internal, external, parent commands, ACLs, -i and -e options,etc.
|
|
||||||
external command and -e options may be given twice for each service - once with IPv4
|
|
||||||
and once with IPv6 address. internal can be given only once, to bind to all IPv4 and
|
|
||||||
IPv6 addresses use [0:0:0:0:0:0:0:0] or [::].
|
|
||||||
<br>
|
|
||||||
Any service may be configured with -4, -46, -64, -6 options to specify decied
|
|
||||||
priority for name to IPv4/IPv6 address resolution (IPv4 only, IPv4 priority,
|
|
||||||
IPv6 priority, IPv6 only).
|
|
||||||
</p>
|
|
||||||
<li><a name="CONNBACK"><i>How to use connect back</i></a>
|
|
||||||
<p>
|
|
||||||
In example, users needs access from external network to proxy server located
|
|
||||||
on the host 192.168.1.2. This host can not be accessed from external network,
|
|
||||||
but it has access to external network with with external address 1.1.1.1.
|
|
||||||
Also, user has access to the host 2.2.2.2 (IP address may be dynamic) with
|
|
||||||
hostname host.dyndns.example.org via external network. User needs 2 instances
|
|
||||||
of 3proxy, first one on the host 192.168.1.2 with config
|
|
||||||
<pre>
|
|
||||||
users user:CL:password
|
|
||||||
auth strong
|
|
||||||
allow user
|
|
||||||
proxy -rhost.dyndns.example.org:1234</pre>
|
|
||||||
second one on the host.dyndns.example.org (2.2.2.2) with config
|
|
||||||
<pre>
|
|
||||||
auth iponly
|
|
||||||
allow * * 1.1.1.1
|
|
||||||
tcppm -R0.0.0.0:1234 3128 1.1.1.1 3128</pre>
|
|
||||||
For browser settings proxy is host.dyndns.example.org:3128.
|
|
||||||
</p>
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
@@ -817,7 +750,7 @@ connection to external networks to provider's proxy.
|
|||||||
<li><A NAME="NEWVERSION">How to obtain latest 3proxy version</A>
|
<li><A NAME="NEWVERSION">How to obtain latest 3proxy version</A>
|
||||||
<p>
|
<p>
|
||||||
Latest version of 3proxy may be obtained
|
Latest version of 3proxy may be obtained
|
||||||
<A HREF="http://3proxy.org/">here</A>.
|
<A HREF="http://3proxy.ru/">here</A>.
|
||||||
New version may have changes and incompatibilities with previous one in files
|
New version may have changes and incompatibilities with previous one in files
|
||||||
format or commands. Please, read CHANGELOG file and another documentation
|
format or commands. Please, read CHANGELOG file and another documentation
|
||||||
before installing new version.
|
before installing new version.
|
||||||
@@ -870,16 +803,6 @@ You can control 3proxy service via "Services" administration ot via "net" comman
|
|||||||
<li>50-69 - SOCKS5 PROXY REDIRECTION ERRORS
|
<li>50-69 - SOCKS5 PROXY REDIRECTION ERRORS
|
||||||
<li>70-79 PARENT PROXY CONNECTION ERRORS (identical to 1x)
|
<li>70-79 PARENT PROXY CONNECTION ERRORS (identical to 1x)
|
||||||
<li>90-99 - established connection errors
|
<li>90-99 - established connection errors
|
||||||
<li>since 0.9
|
|
||||||
<li>90 - unexpected system error (should not happen)
|
|
||||||
<li>91 - unexpected poll error (should not happen)
|
|
||||||
<li>92 - connection terminated by timeout (see timeouts)
|
|
||||||
<li>93 - connection terminated by ratelimit-related timeout or due to errors limit
|
|
||||||
<li>94 - connection termination by server or client with unsent data
|
|
||||||
<li>95 - dirty connection termination by client (or networking issue)
|
|
||||||
<li>96 - dirty connection termination by server (or networking issue)
|
|
||||||
<li>97 - dirty connection termination by both client and server (probably networking issue)
|
|
||||||
<li>prior to 0.9:
|
|
||||||
<li>90 - socket error or connection broken
|
<li>90 - socket error or connection broken
|
||||||
<li>91 - TCP/IP common failure
|
<li>91 - TCP/IP common failure
|
||||||
<li>92 - connection timed out
|
<li>92 - connection timed out
|
||||||
@@ -903,9 +826,10 @@ You can control 3proxy service via "Services" administration ot via "net" comman
|
|||||||
<hr>
|
<hr>
|
||||||
<li><A NAME="QUEST">How To ask quiestion not in How To?</A>
|
<li><A NAME="QUEST">How To ask quiestion not in How To?</A>
|
||||||
<p>
|
<p>
|
||||||
Ask it in <A HREF="https://github.com/z3APA3A/3proxy/issues">Github</A>.
|
Ask it in <A HREF="http://3proxy.ru/board4.html">3proxy forum</A>.
|
||||||
Don't try to ask something before reading this document.
|
Don't try to ask something before reading this document.
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<pre>$Id: howtoe.html,v 1.41 2009/02/02 10:04:49 vlad Exp $</pre>
|
||||||
+682
-738
File diff suppressed because it is too large.
Load diff
@@ -1,19 +0,0 @@
|
|||||||
<html><title>3proxy documentation</title><body><h2>3proxy documentation</h2>
|
|
||||||
<a href="securityen.html">Security recommendations</a><br>
|
|
||||||
<a href="highload.html">Optimizing 3proxy for high loads</a><br>
|
|
||||||
<a href="howtoe.html">How To (English, very incomplete)</a><br>
|
|
||||||
<a href="howtor.html">How To (Russian)</a><br>
|
|
||||||
<a href="faqe.html">FAQ (English)</a><br>
|
|
||||||
<a href="faqr.html">FAQ (Russian)</a>
|
|
||||||
<h3>Man pages:</h>
|
|
||||||
<br><A HREF="man8/3proxy.8.html">3proxy.8</A>
|
|
||||||
<br><A HREF="man8/ftppr.8.html">ftppr.8</A>
|
|
||||||
<br><A HREF="man8/icqpr.8.html">icqpr.8</A>
|
|
||||||
<br><A HREF="man8/pop3p.8.html">pop3p.8</A>
|
|
||||||
<br><A HREF="man8/proxy.8.html">proxy.8</A>
|
|
||||||
<br><A HREF="man8/smtpp.8.html">smtpp.8</A>
|
|
||||||
<br><A HREF="man8/socks.8.html">socks.8</A>
|
|
||||||
<br><A HREF="man8/tcppm.8.html">tcppm.8</A>
|
|
||||||
<br><A HREF="man8/udppm.8.html">udppm.8</A>
|
|
||||||
<br><A HREF="man3/3proxy.cfg.3.html">3proxy.cfg.3</A>
|
|
||||||
</body></html>
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
|
|
||||||
<h3>3proxy Perl Compatible Regular Expressions (PCRE) plugin</h3>
|
|
||||||
|
|
||||||
This filtering plugin can be used to create matching and replace
|
|
||||||
rules with regular expressions for client's request, client and
|
|
||||||
servers header and client and server data. It adds 3 additional
|
|
||||||
configuration commands:
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
pcre TYPE FILTER_ACTION REGEXP [ACE]
|
|
||||||
pcre_rewrite TYPE FILTER_ACTION REGEXP REWRITE_EXPRESSION [ACE]
|
|
||||||
pcre_extend FILTER_ACTION [ACE]
|
|
||||||
pcre_options OPTION1 [...]
|
|
||||||
</pre>
|
|
||||||
pcre - allows to apply some rule for matching
|
|
||||||
<br>pcre_rewrite - in addition to 'pcre' allows to substitute substrings
|
|
||||||
<br>pcre_extend - extends ACL of the last pcre or pcre_rewrite comand by
|
|
||||||
adding additional ACE (like with allow/deny configuration commands).
|
|
||||||
<br>pcre_options - allows to set matching options. Awailable options are:
|
|
||||||
PCRE_CASELESS,
|
|
||||||
PCRE_MULTILINE,
|
|
||||||
PCRE_DOTALL,
|
|
||||||
PCRE_EXTENDED,
|
|
||||||
PCRE_ANCHORED,
|
|
||||||
PCRE_DOLLAR_ENDONLY,
|
|
||||||
PCRE_EXTRA,
|
|
||||||
PCRE_NOTBOL,
|
|
||||||
PCRE_NOTEOL,
|
|
||||||
PCRE_UNGREEDY,
|
|
||||||
PCRE_NOTEMPTY,
|
|
||||||
PCRE_UTF8,
|
|
||||||
PCRE_NO_AUTO_CAPTURE,
|
|
||||||
PCRE_NO_UTF8_CHECK,
|
|
||||||
PCRE_AUTO_CALLOUT,
|
|
||||||
PCRE_PARTIAL,
|
|
||||||
PCRE_DFA_SHORTEST,
|
|
||||||
PCRE_DFA_RESTART,
|
|
||||||
PCRE_FIRSTLINE,
|
|
||||||
PCRE_DUPNAMES,
|
|
||||||
PCRE_NEWLINE_CR,
|
|
||||||
PCRE_NEWLINE_LF,
|
|
||||||
PCRE_NEWLINE_CRLF,
|
|
||||||
PCRE_NEWLINE_ANY,
|
|
||||||
PCRE_NEWLINE_ANYCRLF,
|
|
||||||
PCRE_BSR_ANYCRLF,
|
|
||||||
PCRE_BSR_UNICODE
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>TYPE - type of filtered data. May contain one or more
|
|
||||||
(comma delimited list) values:
|
|
||||||
<ul>
|
|
||||||
<li>request - content of client's request e.g. HTTP GET request string.
|
|
||||||
(known problem: changing request string doesn't change IP of the host to connect)
|
|
||||||
<li>cliheader - content of client request headers, e.g. HTTP request header.
|
|
||||||
<li>srvheader - content of server's reply headers, e.g. HTTP status and headers.
|
|
||||||
<li>clidata - data received from client, e.g. HTTP POST request data
|
|
||||||
<li>srvdata - data received from server, e.g. HTML page
|
|
||||||
</ul>
|
|
||||||
<li>FILTER_ACTION - action on match
|
|
||||||
<ul>allow - allow this request without checking rest of the given type
|
|
||||||
of the rules
|
|
||||||
<li>deny - deny this request without checking rest of the rules
|
|
||||||
<li>dunno - continue with the rest of rules (useful with pcre_rewrite)
|
|
||||||
</ul>
|
|
||||||
<li>REGEXP - PCRE (perl) regular expression. Use * if no regexp matching
|
|
||||||
required.
|
|
||||||
<li>REWRITE_EXPRESSION - substitution string. May contain perl-style
|
|
||||||
substrings
|
|
||||||
(not tested) $1, $2. $0 - means whole matched string. \r and \n may be used
|
|
||||||
to insert new strings, string may be empty ("").
|
|
||||||
<li>ACE - access control entry (user names, source IPs, destination IPs,
|
|
||||||
ports, etc), absolutely identical to allow/deny/bandlimin commands.
|
|
||||||
Regular expression is only matched if ACL matches connection data.
|
|
||||||
Warning:
|
|
||||||
reqular expression doesn't require authentication and can not replace
|
|
||||||
authentication and/or allow/deny ACLs.
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h4>Example:</h4>
|
|
||||||
<pre>
|
|
||||||
plugin PCREPlugin.dll pcre_plugin
|
|
||||||
pcre request deny "porn|sex" user1,user2,user3 192.168.0.0/16
|
|
||||||
pcre srvheader deny "Content-type: application"
|
|
||||||
pcre_rewrite clidata,srvdata dunno "porn|sex|pussy" "***" baduser
|
|
||||||
pcre_extend deny * 192.168.0.1/16
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h4>Download:</h4>
|
|
||||||
<ul>
|
|
||||||
<li>Plugin is included into 3proxy 0.6 binary and source distribution
|
|
||||||
<li>Example configuration (by Dennis Garber): <A HREF="NoPornLitest.cfg.txt">NoPornLitest.cfg</A>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
<h3>Плагин регулярных выражений совместимых с Perl (PCRE) для 3proxy</h3>
|
|
||||||
|
|
||||||
Фильтрующий плагин используется для создания правил поиска и замены
|
|
||||||
регулярных выражений в запросе, заголовков запроса и ответа и данных.
|
|
||||||
Добавляет поддержку 3х новых команд в файле конфигурации:
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
pcre TYPE FILTER_ACTION REGEXP [ACE]
|
|
||||||
pcre_rewrite TYPE FILTER_ACTION REGEXP REWRITE_EXPRESSION [ACE]
|
|
||||||
pcre_extend FILTER_ACTION [ACE]
|
|
||||||
pcre_options OPTION1 [...]
|
|
||||||
</pre>
|
|
||||||
pcre - позволяет искать совпадения
|
|
||||||
<br>pcre_rewrite - дополнительно позволяет производить замену подстрок
|
|
||||||
<br>pcre_extend - расширяет ACL последней команды pcre или pcre_rewrite путем
|
|
||||||
добавления еще одной ACE (аналогично списку правил allow/deny).
|
|
||||||
<br>pcre_options - позволяет устанавливать опции поиска, доступны следующие опции:
|
|
||||||
PCRE_CASELESS,
|
|
||||||
PCRE_MULTILINE,
|
|
||||||
PCRE_DOTALL,
|
|
||||||
PCRE_EXTENDED,
|
|
||||||
PCRE_ANCHORED,
|
|
||||||
PCRE_DOLLAR_ENDONLY,
|
|
||||||
PCRE_EXTRA,
|
|
||||||
PCRE_NOTBOL,
|
|
||||||
PCRE_NOTEOL,
|
|
||||||
PCRE_UNGREEDY,
|
|
||||||
PCRE_NOTEMPTY,
|
|
||||||
PCRE_UTF8,
|
|
||||||
PCRE_NO_AUTO_CAPTURE,
|
|
||||||
PCRE_NO_UTF8_CHECK,
|
|
||||||
PCRE_AUTO_CALLOUT,
|
|
||||||
PCRE_PARTIAL,
|
|
||||||
PCRE_DFA_SHORTEST,
|
|
||||||
PCRE_DFA_RESTART,
|
|
||||||
PCRE_FIRSTLINE,
|
|
||||||
PCRE_DUPNAMES,
|
|
||||||
PCRE_NEWLINE_CR,
|
|
||||||
PCRE_NEWLINE_LF,
|
|
||||||
PCRE_NEWLINE_CRLF,
|
|
||||||
PCRE_NEWLINE_ANY,
|
|
||||||
PCRE_NEWLINE_ANYCRLF,
|
|
||||||
PCRE_BSR_ANYCRLF,
|
|
||||||
PCRE_BSR_UNICODE
|
|
||||||
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>TYPE - тип фильтруемых данных. Может содержать одно или
|
|
||||||
несколько (список через запятую) значений:
|
|
||||||
<ul>
|
|
||||||
<li>request - содержимое запроса клиента (например строка HTTP GET-запроса).
|
|
||||||
(в настоящий момент изменение запроса не приводит к изменению адреса запрашиваемого хоста)
|
|
||||||
<li>cliheader - содержимое заголовков запроса клиента, например заголовки HTTP
|
|
||||||
<li>srvheader - содержимое заголовков ответа сервера, например заголовки HTTP
|
|
||||||
<li>clidata - данные полученные от клиента, например данные POST-запроса
|
|
||||||
<li>srvdata - данные полученные от сервера, например содержимое HTML-страницы
|
|
||||||
</ul>
|
|
||||||
<li>FILTER_ACTION - действие при совпадении. Может принимать значение
|
|
||||||
<ul>allow - разрешить данный запрос без просмотра дальнейших правил
|
|
||||||
<li>deny - запретить данный запрос без просмотра дальнейших правил
|
|
||||||
<li>dunno - продолжить анализ правил (полезно для pcre_rewrite)
|
|
||||||
</ul>
|
|
||||||
<li>REGEXP - регулярное выражение в формате PCRE (perl). Используйте * если не
|
|
||||||
требуется проерка регулярного выражения.
|
|
||||||
<li>REWRITE_EXPRESSION - строка замены. Может содержать макроподстановки
|
|
||||||
(не тестировалось) $1, $2 и т.д. аналогично perl. $0 - полная найденная
|
|
||||||
подстрока. В строке замены можно использовать сочетания \r, \n для вставки
|
|
||||||
новых строк. Строка может быть пустой ("").
|
|
||||||
<li>ACE - Список контроля доступа (имя пользователя, IP источника, IP назначения, порт и т.д.),
|
|
||||||
полностью аналогичный ACE в командах allow, deny, bandlimin и т.п. Регулярное
|
|
||||||
выражение проверяется только при совпадении ACE с запросом. ВНИМАНИЕ:
|
|
||||||
использование регулярных выражений не требует авторизации и не заменяет ее.
|
|
||||||
Авторизацию необходимо конфигурировать отдельно.
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h4>Пример:</h4>
|
|
||||||
<pre>
|
|
||||||
plugin PCREPlugin.dll pcre_plugin
|
|
||||||
pcre request deny "porn|sex" user1,user2,user3 192.168.0.0/16
|
|
||||||
pcre srvheader deny "Content-type: application"
|
|
||||||
pcre_rewrite clidata,srvdata dunno "porn|sex|pussy" "***" baduser
|
|
||||||
pcre_extend deny * 192.168.0.1/16
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h4>Загрузить:</h4>
|
|
||||||
<ul>
|
|
||||||
<li>Плагин включен в дистрибутив 3proxy 0.6
|
|
||||||
<li>Пример конфигурации (by Dennis Garber): <A HREF="NoPornLitest.cfg.txt">NoPornLitest.cfg</A>
|
|
||||||
</ul>
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
<h3>3proxy SSL/TLS plugin</h3>
|
|
||||||
|
|
||||||
Plugin can be used to transparently decypher SSL/TLS data. Plugin should never be used in production environment due to
|
|
||||||
potential securiy reasons.
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
ssl_certcache PATH_TO_CACHE
|
|
||||||
ssl_mitm
|
|
||||||
ssl_nomitm
|
|
||||||
</pre>
|
|
||||||
ssl_certcache - path to certificates cache. For transparent spoofing cache must contain 3 files: 3proxy.pem - public
|
|
||||||
self-signed certificates, 3proxy.key - key for public certificates, server.key - this key will be used to generates
|
|
||||||
spoofed certificates.
|
|
||||||
Generated certificates will be placed to the same path.
|
|
||||||
<br>ssl_mitm - spoof certificates for services started below
|
|
||||||
<br>ssl_nomitm - do not spoof certificates for services started below
|
|
||||||
|
|
||||||
|
|
||||||
<h4>Example:</h4>
|
|
||||||
<pre>
|
|
||||||
plugin /path/to/SslPlugin.dll ssl_plugin
|
|
||||||
ssl_certcache /path/to/cache/
|
|
||||||
ssl_mitm
|
|
||||||
proxy -p3128
|
|
||||||
ssl_nomitm
|
|
||||||
proxy -p3129
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h4>Download:</h4>
|
|
||||||
<ul>
|
|
||||||
<li>Plugin included into 3proxy 0.8
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
© Vladimir Dubrovin, License: BSD style
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
<h3>Плагин SSL/TLS для 3proxy</h3>
|
|
||||||
|
|
||||||
Плагин используется для транспарентной дешифровки SSL-трафика с подменой сертификата.
|
|
||||||
Плагин не должен использоваться в рабочем окружении, т.к. его использование дает возможность обхода проверок SSL.
|
|
||||||
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
ssl_certcache PATH_TO_CACHE
|
|
||||||
ssl_mitm
|
|
||||||
ssl_nomitm
|
|
||||||
</pre>
|
|
||||||
ssl_certcache - путь к кэшу сертификатов. Для транспорентной подмены сертификатов в кэше должно находиться 3 файла: 3proxy.pem - публичный
|
|
||||||
самоподписанный сертификат, 3proxy.key - ключ от этого сертификата, server.key - ключ с которым будут генерироваться подменные сертификаты.
|
|
||||||
Сгенерированные сертификаты будут помещаться в этот же каталог.
|
|
||||||
<br>ssl_mitm - подменять сертитфикаты для запущенных ниже сервисов
|
|
||||||
<br>ssl_nomitm - не подменять сертитфикаты для запущенных ниже сервисов
|
|
||||||
|
|
||||||
|
|
||||||
<h4>Пример:</h4>
|
|
||||||
<pre>
|
|
||||||
plugin /path/to/SslPlugin.dll ssl_plugin
|
|
||||||
ssl_certcache /path/to/cache/
|
|
||||||
ssl_mitm
|
|
||||||
proxy -p3128
|
|
||||||
ssl_nomitm
|
|
||||||
proxy -p3129
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h4>Загрузить:</h4>
|
|
||||||
<ul>
|
|
||||||
<li>Плагин включен в дистрибутив 3proxy 0.8
|
|
||||||
</ul>
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
|
|
||||||
<h3>3proxy strings substitution plugin</h3>
|
|
||||||
May be used to make interface more pretty or to translate proxy server
|
|
||||||
messages to different language. All messages are taken from proxy.c and
|
|
||||||
moved to external text file (e.g. rus.3ps). On the moment of
|
|
||||||
writing there are 15 sections. Sections are delimited with "[end]".
|
|
||||||
<h4>Example:</h4>
|
|
||||||
<pre>plugin "StringsPlugin.dll" start c:\3proxy\bin\rus.3ps
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h4>Download:</h4>
|
|
||||||
<ul>
|
|
||||||
<li>Plugin is included into 3proxy 0.6 binary and source distribution
|
|
||||||
</li></ul>
|
|
||||||
|
|
||||||
©Kirill Lopuchov
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
<h3>Плагин подмены строк 3proxy</h3>
|
|
||||||
|
|
||||||
Используется, в частности, для руссификации сообщений выдаваемых 3proxy.
|
|
||||||
Для корректной работы требуется 0.6 версия 3proxy.
|
|
||||||
Все сообщения были взяты из proxy.c
|
|
||||||
и вынесенны в отдельный файл. Пример файла rus-win1251.3ps.
|
|
||||||
Всего 15 секций на момент написания плагина в файле rus-win1251.3ps каждая секция отделяется строкой "[end]"
|
|
||||||
новая строка определяется строкой "\n"
|
|
||||||
|
|
||||||
<h4>Пример:</h4>
|
|
||||||
<pre>
|
|
||||||
plugin "StringsPlugin.dll" start c:\3proxy\bin\rus-win1251.3ps
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h4>Загрузить:</h4>
|
|
||||||
<ul>
|
|
||||||
<li>Плагин включен в дистрибутив 3proxy 0.6
|
|
||||||
</ul>
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
<h3>3proxy traffic correction plugin</h3>
|
|
||||||
3proxy logs and counts traffic on application level, while provider usually does
|
|
||||||
it on network or link level. It's significant if you use 3proxy for billing,
|
|
||||||
especially in case where network packets are small, e.g. network games.
|
|
||||||
<p>
|
|
||||||
This plugin attempts to correct 3proxy computations to approximate network or
|
|
||||||
link level traffic by using either fixed coefficients by port number or
|
|
||||||
attempting to predict number and sizes of network packets.
|
|
||||||
</p><h4>Usage:</h4>
|
|
||||||
<ol>
|
|
||||||
<li>Extract TrafficPlugin.dll to the same folder with 3proxy executable.
|
|
||||||
</li><li>Start plugin in 3proxy.cfg with
|
|
||||||
<pre>plugin TrafficPlugin.dll start
|
|
||||||
</pre>
|
|
||||||
</li><li>Add correction rules:
|
|
||||||
<br>
|
|
||||||
FOR FIXED COEFFICIENTS MODE:
|
|
||||||
<pre>trafcorrect m <service> <target port> <coefficient>
|
|
||||||
</pre>
|
|
||||||
where <service> - one of proxy, socks4, socks45, socks5, tcppm, udppm, pop3p, * matches "any".
|
|
||||||
<br> <target port> - target port, * matches any
|
|
||||||
<br> <coefficient> - coefficient to multiply traffic for this port.
|
|
||||||
<br>
|
|
||||||
FOR PACKET HEADER PREDICTION MODE
|
|
||||||
<pre>trafcorrect p <service> <tcp/udp> <target port> [empty packet size]
|
|
||||||
</pre>
|
|
||||||
tcp ot udp - transport level protocol to apply rule
|
|
||||||
<br>
|
|
||||||
empty packet size - average size of "empty" packet, that is sum of average network/transport headers.
|
|
||||||
You can use network sniffer, such is Ethereal to discover it. Usually packet size
|
|
||||||
is 42 for UDP and
|
|
||||||
<br>Modes can be mixed.
|
|
||||||
<br>Plugin creates a list of rules, first matching rule will be applied.
|
|
||||||
</li></ol>
|
|
||||||
For any mode plugin approximates traffic, logged or counted amount is not exact.
|
|
||||||
<h4>Example:</h4>
|
|
||||||
<pre>plugin "TrafficPlugin.dll" start
|
|
||||||
trafcorrect m socks5 6112 4.5
|
|
||||||
trafcorrect m socks5 * 1.1
|
|
||||||
</pre>
|
|
||||||
wrong usage:
|
|
||||||
<pre>trafcorrect m socks5 * 1.1
|
|
||||||
trafcorrect m socks5 6112 4.5
|
|
||||||
</pre>
|
|
||||||
second rule will never be applied.
|
|
||||||
<h4>Download:</h4>
|
|
||||||
<ul>
|
|
||||||
<li>Plugin is included into 3proxy 0.6 binary and source distribution
|
|
||||||
</li></ul>
|
|
||||||
|
|
||||||
©Maslov Michael aka Flexx(rus)
|
|
||||||
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
<h3>Плагин коррекции траффика 3proxy</h3>
|
|
||||||
Как известно, 3proxy считает траффик не сетевой, а прикладной.
|
|
||||||
Обычно прикладной траффик немного меньше (примерно на 10%) чем сетевой,
|
|
||||||
однако в некоторых случаях, например когда пользователи сети играют в
|
|
||||||
игры, сетевой траффик может превысить прикладной в 4-5 раз. Это довольно неприятно,
|
|
||||||
так как получается, что они за это не платят.
|
|
||||||
<p>
|
|
||||||
Происходит это потому, что в каждом посланом пакете есть заголовок+данные. Заголовок
|
|
||||||
весит порядка 50-60 байт а количество данных может меняться от 15-20 байт (что характерно для игр)
|
|
||||||
до 800-900 байт (у IE). Также количество данных в пакете зависит от загрузки сети,
|
|
||||||
удалённости сервера и прочих причин.
|
|
||||||
<p>
|
|
||||||
Данный плагин может исправить такую ситуацию. Он может умножать счётчик траффика
|
|
||||||
при окончании соединения на некоторый коэффициент либо добавлять к данным размеры заголовков пакетов,
|
|
||||||
которые прошли по сети.
|
|
||||||
<h4>Использование</h4>
|
|
||||||
<ol>
|
|
||||||
<li>Извлечь TrafficPlugin.dll в каталог с 3proxy.exe
|
|
||||||
<li>Стартовать плагин в 3proxy.cfg
|
|
||||||
<pre>
|
|
||||||
plugin TrafficPlugin.dll start
|
|
||||||
</pre>
|
|
||||||
<li>Добавить правила:
|
|
||||||
<br>
|
|
||||||
ДЛЯ РЕЖИМА ДОМНОЖЕНИЯ ТРАФФИКА НА ЧИСЛО:
|
|
||||||
<pre>
|
|
||||||
trafcorrect m <сервис> <исходящий порт> <коэффициент>
|
|
||||||
</pre>
|
|
||||||
где: <сервис> может быть proxy, socks4, socks45, socks5, tcppm, udppm, pop3p
|
|
||||||
если сервис указан неверно то считается, что это может быть любой сервис.
|
|
||||||
можно использовать *, тогда правило будет считаться для любого сервиса.
|
|
||||||
<br> <исходящий порт> - порт, к которому подключается прокси сервер. * - любой
|
|
||||||
<коэффициент> - число на каоторое домнажается траффик. Обязательный параметр.
|
|
||||||
Должен быть от больше 0 и меньше 100
|
|
||||||
<br>
|
|
||||||
ДЛЯ РЕЖИМА С УЧЁТОМ РАЗМЕРА ЗАГОЛОВКОВ ПАКЕТОВ:
|
|
||||||
<pre>
|
|
||||||
trafcorrect p <сервис> <tcp/udp> <исходящий порт> [размер пустого пакета]
|
|
||||||
</pre>
|
|
||||||
<tcp/udp> - протокол, по которому осуществляется соединение.
|
|
||||||
[размер пакета] - средний размер пустого пакета. Можно определить захватив
|
|
||||||
данные при помощи такой утилиты как Ethereal. Параметр необязателен. Если отсутствует,
|
|
||||||
то размер пакета будет считаться равным 66 байт.
|
|
||||||
<br>Режимы можно смешивать.
|
|
||||||
Следует учитывать, что плугин создаёт список всех правил изменения траффика.
|
|
||||||
Когда происходит окончание соединения выполняется первое подходящее правило.
|
|
||||||
</ol>
|
|
||||||
Подсчет трафика в любом режиме не является точным, это некоторая аппроксимация
|
|
||||||
позволяющаяподсчитать трафик с точностью до нескольких процентов.
|
|
||||||
|
|
||||||
<h4>Пример:</h4>
|
|
||||||
<pre>
|
|
||||||
plugin "TrafficPlugin.dll" start
|
|
||||||
trafcorrect m socks5 6112 4.5
|
|
||||||
trafcorrect m socks5 * 1.1
|
|
||||||
</pre>
|
|
||||||
следующее неверно:
|
|
||||||
<pre>
|
|
||||||
plugin "TrafficPlugin.dll" start
|
|
||||||
trafcorrect m socks5 * 1.1
|
|
||||||
trafcorrect m socks5 6112 4.5
|
|
||||||
</pre>
|
|
||||||
Вторая строчка выполнена никогда не будет, т.к. правило 1 содержит *.
|
|
||||||
|
|
||||||
|
|
||||||
<h4>Загрузить:</h4>
|
|
||||||
<ul>
|
|
||||||
<li>Плагин включен в дистрибутив 3proxy 0.6
|
|
||||||
</ul>
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
<h3>3proxy TransparentPlugin plugin (Linux/BSD only)</h3>
|
|
||||||
|
|
||||||
Plugin can turn 3proxy into transparent proxy for virtually any TCP-based protocol
|
|
||||||
and use all 3proxy features - redirections, parent proxies, ACLs, traffic limitations,
|
|
||||||
etc. TransparentPlugin plugin takes destination IP:port from Linux and uses this
|
|
||||||
information as a target IP in proxy. An example of usage:
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
plugin /path/to/TransparentPlugin.ld.so transparent_plugin
|
|
||||||
log /path/to/log
|
|
||||||
auth iponly
|
|
||||||
allow * * * 80
|
|
||||||
parent 1000 http 0.0.0.0 0
|
|
||||||
allow *
|
|
||||||
parent 1000 socks5 SOCKS5_IP SOCKS5_PORT USER PASSWORD
|
|
||||||
transparent
|
|
||||||
tcppm -iLOCAL_IP 12345 127.0.0.1 11111
|
|
||||||
notransparent
|
|
||||||
proxy
|
|
||||||
</pre>
|
|
||||||
Now, any TCP traffic transparently redirected to port 12345 will be routed via
|
|
||||||
parent SOCKSv5 proxy and logged, all URLs for web requests are visible in logs.
|
|
||||||
Paremeters '127.0.0.1 11111' in this case are not used and are overwritten by
|
|
||||||
destination IP:port for each transparent connection.
|
|
||||||
|
|
||||||
<h4>Download:</h4>
|
|
||||||
<ul>
|
|
||||||
<li>Plugin included into 3proxy 0.8
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
© Vladimir Dubrovin, License: BSD style
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<h3>Плагин TransparentPlugin 3proxy (только для Linux/BSD)</h3>
|
|
||||||
|
|
||||||
Плагин превращает 3proxy в транспарентный прокси для практически любых TCP-соединений
|
|
||||||
и позволяет прозрачно для клиентов использовать весь фунционал прокси - редиректоры,
|
|
||||||
родительские прокси, ACLи, ограничения трафика. TransparentPlugin получает IP:port
|
|
||||||
назначения от Linux и использует эту информацию в качестве конечного адреса назначения.
|
|
||||||
<br>
|
|
||||||
Пример использования:
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
plugin /path/to/TransparentPlugin.ld.so transparent_plugin
|
|
||||||
log /path/to/log
|
|
||||||
auth iponly
|
|
||||||
allow * * * 80
|
|
||||||
parent 1000 http 0.0.0.0 0
|
|
||||||
allow *
|
|
||||||
parent 1000 socks5 SOCKS5_IP SOCKS5_PORT USER PASSWORD
|
|
||||||
transparent
|
|
||||||
tcppm -iLOCAL_IP 12345 127.0.0.1 11111
|
|
||||||
notransparent
|
|
||||||
proxy
|
|
||||||
</pre>
|
|
||||||
Теперь любые TCP-соединения транспарентно перенаправленные в локальный порт 12345
|
|
||||||
будут прологгированы и перенаправлены в родительский SOCKSv5 proxy, при этом для
|
|
||||||
HTTP-запросов по порту TCP/80 будут видны параметры HTTP-запроса.
|
|
||||||
Параметры '127.0.0.1 11111' в данном случае не оказывают влияния, т.к.
|
|
||||||
будут перезаписываться IP и портом назначения для каждого TCP-соединения соответственно.
|
|
||||||
<h4>Загрузить:</h4>
|
|
||||||
<ul>
|
|
||||||
<li>Плагин включен в дистрибутив 3proxy 0.8
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
© Vladimir Dubrovin, License: BSD style
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
|
|
||||||
<h3>3proxy Windows Authentication plugin</h3>
|
|
||||||
Support for cleartext authentication against Windows domain or local Windows account.
|
|
||||||
<h4>Usage:</h4>
|
|
||||||
<ol>
|
|
||||||
<li>Extract WindowsAuthentication.dll to the same folder with 3proxy executable.
|
|
||||||
<li>Create 3ProxyAllowedGroup - Windows system group allowed to use proxy.
|
|
||||||
You can choose different group name. Group can be either local or
|
|
||||||
Active Directory. Every account allowed to use 3proxy must be included in this
|
|
||||||
group either directly or through group nesting.
|
|
||||||
<li>Configure plugin with 'plugin' command in 3proxy.cfg, e.g.:
|
|
||||||
<pre><code>
|
|
||||||
plugin "WindowsAuthentication.dll" WindowsAuthentication "3ProxyAllowedGroup"
|
|
||||||
</code></pre>
|
|
||||||
<br>WindowsAuthentication.dll - location of DLL, if DLL is located in different folder
|
|
||||||
from 3proxy.exe you must specify complete path to DLL here. 3ProxyAllowedGroup - Windows
|
|
||||||
system group allowed to use 3proxy.
|
|
||||||
After plugin is loaded, 'windows' authentication type is supported.
|
|
||||||
|
|
||||||
<li>Configure 'auth windows' for services that require Windows authentication.
|
|
||||||
<li>It's recommended you also configure authentication caching (see 'authcache'),
|
|
||||||
to prevent excessive workload for domain controller. Example:
|
|
||||||
<pre>
|
|
||||||
authcache user,pass 900
|
|
||||||
auth cache windows
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<li>NTLM authentication is not currently supported for plugins, you should use proxy -n key to disable it.
|
|
||||||
</ol>
|
|
||||||
<h4>Download:</h4>
|
|
||||||
<ul>
|
|
||||||
<li>Plugin is included into 3proxy 0.6 binary and source distribution
|
|
||||||
</ul>
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
<h3>Плагин аутентификации Windows для 3proxy</h3>
|
|
||||||
Поддерживается только аутентификация открытым текстом в домене или на локальной машине Windows.
|
|
||||||
<h4>Использование</h4>
|
|
||||||
<ol>
|
|
||||||
<li>Извлечь WindowsAuthentication.dll в каталог с 3proxy.exe
|
|
||||||
<li>Создать 3ProxyAllowedGroup - системная группа Windows, которой разрешено использование прокси. Ее необходимо создать (можно
|
|
||||||
использовать группу с другим именем, см. ниже). Учетные записи пользователей, которым разрешен доступ к прокси
|
|
||||||
должны быть включены в группу непосредственно или посредством включения их групп. Группа может быть как локальной, так и в
|
|
||||||
ActiveDirectory.
|
|
||||||
<li>В файле конфигурации загрузить dll с помощью команды plugin:
|
|
||||||
<br>plugin "WindowsAuthentication.dll" WindowsAuthentication "3ProxyAllowedGroup"
|
|
||||||
<br>Если DLL находится в другом каталоге, то вместо "WindowsAuthentication.dll"
|
|
||||||
необходимо указать полный путь к DLL. 3ProxyAllowedGroup - название системной группы,
|
|
||||||
которой разрешен доступ к прокси.
|
|
||||||
<li>Плагин добавляет новый тип аутентификации - windows. Т.е. для использования
|
|
||||||
Windows-аутентификации надо дать команду
|
|
||||||
<pre>
|
|
||||||
auth windows
|
|
||||||
</pre>
|
|
||||||
<li>Не рекомендуется использовать данный плагин без кэширования
|
|
||||||
аутентификации (authcache), т.к. это приведет к увеличению нагрузки на
|
|
||||||
сервер/контроллер домена. Пример:
|
|
||||||
<pre>
|
|
||||||
authcache user,pass 900
|
|
||||||
auth cache windows
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<li>В настоящее время не поддерживается NTLM-аутентификация для плагинов,
|
|
||||||
поэтому необходимо запускать proxy с ключиком -n.
|
|
||||||
</ol>
|
|
||||||
<h4>Загрузить:</h4>
|
|
||||||
<ul>
|
|
||||||
<li>Плагин включен в дистрибутив 3proxy 0.6
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
<h3>3proxy security considirations</h3>
|
<h3>3proxy security considirations</h3>
|
||||||
</ul>
|
</ul>
|
||||||
<ul>
|
<ol>
|
||||||
<li>Never install 3proxy suid. If you need it to run suid write some
|
<li>Never install 3proxy suid. If you need it to run suid write some
|
||||||
wrapper with fixed configuration file.
|
wrapper with fixed configuration file.
|
||||||
<li>Make configuration file only available to account 3proxy starts with.
|
<li>Make configuration file only available to account 3proxy starts with.
|
||||||
<li>Under Windows if 3proxy is used as service create new
|
<li>Under Windows NT/2000/XP/2003 if 3proxy is used as service create new
|
||||||
unprivileged local account without "logon locally" right. Assign this account
|
unprivileged local account without "logon locally" right. Assign this account
|
||||||
to 3proxy service.
|
to 3proxy service.
|
||||||
<li>Under unix use chroot to jail 3proxy (make sure files included in
|
<li>Under unix use chroot to jail 3proxy (make sure files included in
|
||||||
@@ -20,8 +20,9 @@ authentication method is currently available.
|
|||||||
<li>Always limit connections to internal network and localhost (to 127.0.0.1 and
|
<li>Always limit connections to internal network and localhost (to 127.0.0.1 and
|
||||||
all interfaces) with ACLs. Be carefull, because BIND command in SOCKS requies
|
all interfaces) with ACLs. Be carefull, because BIND command in SOCKS requies
|
||||||
BIND method with external interface IP address to be allowed.
|
BIND method with external interface IP address to be allowed.
|
||||||
<li> Before 3proxy 0.8 always use nserver and nscache under Unix, overwise DoS attack is possible
|
<li> Always use nserver and nscache under Unix, overwise DoS attack is possible
|
||||||
with unreachable DNS server (because gethostbyname will block over threads).
|
with unreachable DNS server (because gethostbyname will block over threads).
|
||||||
|
<li>Remember, that 'nbname' authentication is not reliable and can be spoofed.
|
||||||
<li>Keep logs in secure location, because some confidential information from
|
<li>Keep logs in secure location, because some confidential information from
|
||||||
user's request can be logged.
|
user's request can be logged.
|
||||||
<li>Use -xyz+A character filtering sequences for 'logformat', especially with
|
<li>Use -xyz+A character filtering sequences for 'logformat', especially with
|
||||||
@@ -30,6 +31,7 @@ ODBC logging to prevent SQL and log record injections.
|
|||||||
<li>Participate in code audit :)
|
<li>Participate in code audit :)
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
</ul>
|
</ol>
|
||||||
<p>
|
<p>
|
||||||
|
|
||||||
|
<pre>$Id: securityen.html,v 1.4 2007/05/07 09:16:51 vlad Exp $</pre>
|
||||||
+1690
-6372
File diff suppressed because it is too large.
Load diff
@@ -96,3 +96,4 @@ setuid 65534
|
|||||||
После того как мы создали конфигурационный файл сервера, запускаем 3proxy командой:
|
После того как мы создали конфигурационный файл сервера, запускаем 3proxy командой:
|
||||||
/usr/local/3proxy/3proxy /usr/local/3proxy/3proxy.cfg
|
/usr/local/3proxy/3proxy /usr/local/3proxy/3proxy.cfg
|
||||||
|
|
||||||
|
$Id: example1.txt,v 1.7 2007/04/20 19:58:42 vlad Exp $
|
||||||
@@ -98,3 +98,4 @@ LIBS = -L /usr/local/lib -lodbc
|
|||||||
make clean
|
make clean
|
||||||
make -f Makefile.unix
|
make -f Makefile.unix
|
||||||
|
|
||||||
|
$Id: iodbc.txt,v 1.3 2006/02/08 17:59:07 vlad Exp $
|
||||||
+7
-5
@@ -1,4 +1,4 @@
|
|||||||
.TH 3proxy "8" "January 2019" "3proxy 0.9" "Universal proxy server"
|
.TH 3proxy "8" "July 2009" "3proxy 0.7" "Universal proxy server"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.B 3proxy
|
.B 3proxy
|
||||||
\- 3[APA3A] tiny proxy server, or trivial proxy server, or free proxy
|
\- 3[APA3A] tiny proxy server, or trivial proxy server, or free proxy
|
||||||
@@ -138,14 +138,16 @@ wget to automate this task.
|
|||||||
configuration file
|
configuration file
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
Report all bugs to
|
Report all bugs to
|
||||||
.BR 3proxy@3proxy.ru
|
.BR 3proxy@security.nnov.ru
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
3proxy.cfg(3), proxy(8), ftppr(8), socks(8), pop3p(8), tcppm(8), udppm(8),
|
3proxy.cfg(3), proxy(8), ftppr(8), socks(8), pop3p(8), tcppm(8), udppm(8),
|
||||||
kill(1), syslogd(8),
|
kill(1), syslogd(8),
|
||||||
.br
|
.br
|
||||||
https://3proxy.org/
|
http://3proxy.ru/
|
||||||
.SH TRIVIA
|
.SH TRIVIA
|
||||||
3APA3A is pronounced as \`\`zaraza\'\'.
|
3APA3A is pronounced as \`\`zaraza\'\'.
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
3proxy is designed by Vladimir 3APA3A Dubrovin
|
3proxy is designed by 3APA3A
|
||||||
.RI ( 3proxy@3proxy.ru )
|
.RI ( 3APA3A@security.nnov.ru ),
|
||||||
|
Vladimir Dubrovin
|
||||||
|
.RI ( vlad@sandy.ru )
|
||||||
+245
-414
File diff suppressed because it is too large.
Load diff
+7
-9
@@ -1,4 +1,4 @@
|
|||||||
.TH ftppr "8" "January 2019" "3proxy 0.9" "Universal proxy server"
|
.TH ftppr "8" "July 2009" "3proxy 0.7" "Universal proxy server"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.B ftppr
|
.B ftppr
|
||||||
\- FTP proxy gateway service
|
\- FTP proxy gateway service
|
||||||
@@ -51,10 +51,6 @@ is specified logging is to file. Under Unix, if
|
|||||||
preceeds
|
preceeds
|
||||||
.IR logfile ,
|
.IR logfile ,
|
||||||
syslog is used for logging.
|
syslog is used for logging.
|
||||||
.TP
|
|
||||||
.B -S
|
|
||||||
Increase or decrease stack size. You may want to try something like -S8192 if you experience 3proxy
|
|
||||||
crashes.
|
|
||||||
.SH CLIENTS
|
.SH CLIENTS
|
||||||
You can use any FTP client, regardless of FTP proxy support. For client with
|
You can use any FTP client, regardless of FTP proxy support. For client with
|
||||||
FTP proxy support configure
|
FTP proxy support configure
|
||||||
@@ -77,11 +73,13 @@ is user\'s login on this FTP server. Login itself may contain \'@\' sign.
|
|||||||
Only cleartext authentication is currently supported.
|
Only cleartext authentication is currently supported.
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
Report all bugs to
|
Report all bugs to
|
||||||
.BR 3proxy@3proxy.ru
|
.BR 3proxy@security.nnov.ru
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
3proxy(8), proxy(8), pop3p(8), socks(8), tcppm(8), udppm(8), syslogd(8),
|
3proxy(8), proxy(8), pop3p(8), socks(8), tcppm(8), udppm(8), syslogd(8),
|
||||||
.br
|
.br
|
||||||
https://3proxy.org/
|
http://3proxy.ru/
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
3proxy is designed by Vladimir 3APA3A Dubrovin
|
3proxy is designed by 3APA3A
|
||||||
.RI ( 3proxy@3proxy.ru )
|
.RI ( 3APA3A@security.nnov.ru ),
|
||||||
|
Vladimir Dubrovin
|
||||||
|
.RI ( vlad@sandy.ru )
|
||||||
+7
-9
@@ -1,4 +1,4 @@
|
|||||||
.TH icqpr "8" "January 2019" "3proxy 0.9" "Universal proxy server"
|
.TH icqpr "8" "July 2009" "3proxy 0.7" "Universal proxy server"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.B icqpr
|
.B icqpr
|
||||||
\- ICQ (AOL OSCAR) proxy
|
\- ICQ (AOL OSCAR) proxy
|
||||||
@@ -45,10 +45,6 @@ is specified logging is to file. Under Unix, if
|
|||||||
preceeds
|
preceeds
|
||||||
.IR logfile ,
|
.IR logfile ,
|
||||||
syslog is used for logging.
|
syslog is used for logging.
|
||||||
.TP
|
|
||||||
.B -S
|
|
||||||
Increase or decrease stack size. You may want to try something like -S8192 if you experience 3proxy
|
|
||||||
crashes.
|
|
||||||
.SH ARGUMENTS
|
.SH ARGUMENTS
|
||||||
.TP
|
.TP
|
||||||
.I local_port
|
.I local_port
|
||||||
@@ -70,11 +66,13 @@ as a destination in client application. Connection is forwarded to
|
|||||||
.IR remote_host : remote_port
|
.IR remote_host : remote_port
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
Report all bugs to
|
Report all bugs to
|
||||||
.BR 3proxy@3proxy.ru
|
.BR 3proxy@security.nnov.ru
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
3proxy(8), proxy(8), ftppr(8), socks(8), pop3p(8), udppm(8), syslogd(8),
|
3proxy(8), proxy(8), ftppr(8), socks(8), pop3p(8), udppm(8), syslogd(8),
|
||||||
.br
|
.br
|
||||||
https://3proxy.org/
|
http://3proxy.ru/
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
3proxy is designed by Vladimir 3APA3A Dubrovin
|
3proxy is designed by 3APA3A
|
||||||
.RI ( 3proxy@3proxy.ru )
|
.RI ( 3APA3A@security.nnov.ru ),
|
||||||
|
Vladimir Dubrovin
|
||||||
|
.RI ( vlad@sandy.ru )
|
||||||
+7
-9
@@ -1,4 +1,4 @@
|
|||||||
.TH pop3p "8" "January 2019" "3proxy 0.9" "Universal proxy server"
|
.TH pop3p "8" "July 2009" "3proxy 0.7" "Universal proxy server"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.B pop3p
|
.B pop3p
|
||||||
\- POP3 proxy gateway service
|
\- POP3 proxy gateway service
|
||||||
@@ -51,10 +51,6 @@ is specified logging is to file. Under Unix, if
|
|||||||
preceeds
|
preceeds
|
||||||
.IR logfile ,
|
.IR logfile ,
|
||||||
syslog is used for logging.
|
syslog is used for logging.
|
||||||
.TP
|
|
||||||
.B -S
|
|
||||||
Increase or decrease stack size. You may want to try something like -S8192 if you experience 3proxy
|
|
||||||
crashes.
|
|
||||||
.SH CLIENTS
|
.SH CLIENTS
|
||||||
You can use any MUA (Mail User Agent) with POP3 support. Set client to use
|
You can use any MUA (Mail User Agent) with POP3 support. Set client to use
|
||||||
.I internal_ip
|
.I internal_ip
|
||||||
@@ -73,11 +69,13 @@ authentication (APOP, CRAM-MD5, etc) requires challenge from server before
|
|||||||
we know which server to connect.
|
we know which server to connect.
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
Report all bugs to
|
Report all bugs to
|
||||||
.BR 3proxy@3proxy.ru
|
.BR 3proxy@security.nnov.ru
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
3proxy(8), ftppr(8), proxy(8), socks(8), tcppm(8), udppm(8), syslogd(8),
|
3proxy(8), ftppr(8), proxy(8), socks(8), tcppm(8), udppm(8), syslogd(8),
|
||||||
.br
|
.br
|
||||||
https://3proxy.org/
|
http://3proxy.ru/
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
3proxy is designed by Vladimir 3APA3A Dubrovin
|
3proxy is designed by 3APA3A
|
||||||
.RI ( 3proxy@3proxy.ru )
|
.RI ( 3APA3A@security.nnov.ru ),
|
||||||
|
Vladimir Dubrovin
|
||||||
|
.RI ( vlad@sandy.ru )
|
||||||
+7
-9
@@ -1,4 +1,4 @@
|
|||||||
.TH proxy "8" "January 2019" "3proxy 0.9" "Universal proxy server"
|
.TH proxy "8" "July 2009" "3proxy 0.7" "Universal proxy server"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.B proxy
|
.B proxy
|
||||||
\- HTTP proxy gateway service
|
\- HTTP proxy gateway service
|
||||||
@@ -52,10 +52,6 @@ is specified logging is to file. Under Unix, if
|
|||||||
preceeds
|
preceeds
|
||||||
.IR logfile ,
|
.IR logfile ,
|
||||||
syslog is used for logging.
|
syslog is used for logging.
|
||||||
.TP
|
|
||||||
.B -S
|
|
||||||
Increase or decrease stack size. You may want to try something like -S8192 if you experience 3proxy
|
|
||||||
crashes.
|
|
||||||
.SH CLIENTS
|
.SH CLIENTS
|
||||||
You should use client with HTTP proxy support or configure router to redirect
|
You should use client with HTTP proxy support or configure router to redirect
|
||||||
HTTP traffic to proxy (transparent proxy). Configure client to connect to
|
HTTP traffic to proxy (transparent proxy). Configure client to connect to
|
||||||
@@ -68,11 +64,13 @@ limit clients, use
|
|||||||
instead.
|
instead.
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
Report all bugs to
|
Report all bugs to
|
||||||
.BR 3proxy@3proxy.ru
|
.BR 3proxy@security.nnov.ru
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
3proxy(8), ftppr(8), socks(8), pop3p(8), tcppm(8), udppm(8), syslogd(8),
|
3proxy(8), ftppr(8), socks(8), pop3p(8), tcppm(8), udppm(8), syslogd(8),
|
||||||
.br
|
.br
|
||||||
https://3proxy.org/
|
http://3proxy.ru/
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
3proxy is designed by Vladimir 3APA3A Dubrovin
|
3proxy is designed by 3APA3A
|
||||||
.RI ( 3proxy@3proxy.ru )
|
.RI ( 3APA3A@security.nnov.ru ),
|
||||||
|
Vladimir Dubrovin
|
||||||
|
.RI ( vlad@sandy.ru )
|
||||||
+7
-9
@@ -1,4 +1,4 @@
|
|||||||
.TH smtpp "8" "January 2019" "3proxy 0.9" "Universal proxy server"
|
.TH smtpp "8" "July 2009" "3proxy 0.7" "Universal proxy server"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.B smtpp
|
.B smtpp
|
||||||
\- SMTP proxy gateway service
|
\- SMTP proxy gateway service
|
||||||
@@ -51,10 +51,6 @@ is specified logging is to file. Under Unix, if
|
|||||||
preceeds
|
preceeds
|
||||||
.IR logfile ,
|
.IR logfile ,
|
||||||
syslog is used for logging.
|
syslog is used for logging.
|
||||||
.TP
|
|
||||||
.B -S
|
|
||||||
Increase or decrease stack size. You may want to try something like -S8192 if you experience 3proxy
|
|
||||||
crashes.
|
|
||||||
.SH CLIENTS
|
.SH CLIENTS
|
||||||
You can use any MUA (Mail User Agent) with SMTP authentication support.
|
You can use any MUA (Mail User Agent) with SMTP authentication support.
|
||||||
Set client to use
|
Set client to use
|
||||||
@@ -74,11 +70,13 @@ authentication (CRAM-MD5, SPA, etc) requires challenge from server before
|
|||||||
we know which server to connect.
|
we know which server to connect.
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
Report all bugs to
|
Report all bugs to
|
||||||
.BR 3proxy@3proxy.ru
|
.BR 3proxy@security.nnov.ru
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
3proxy(8), ftppr(8), proxy(8), socks(8), tcppm(8), udppm(8), syslogd(8),
|
3proxy(8), ftppr(8), proxy(8), socks(8), tcppm(8), udppm(8), syslogd(8),
|
||||||
.br
|
.br
|
||||||
https://3proxy.org/
|
http://3proxy.ru/
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
3proxy is designed by Vladimir 3APA3A Dubrovin
|
3proxy is designed by 3APA3A
|
||||||
.RI ( 3proxy@3proxy.ru )
|
.RI ( 3APA3A@security.nnov.ru ),
|
||||||
|
Vladimir Dubrovin
|
||||||
|
.RI ( vlad@sandy.ru )
|
||||||
+7
-14
@@ -1,4 +1,4 @@
|
|||||||
.TH socks "8" "January 2019" "3proxy 0.9" "Universal proxy server"
|
.TH socks "8" "July 2009" "3proxy 0.7" "Universal proxy server"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.B socks
|
.B socks
|
||||||
\- SOCKS 4/4.5/5 gateway service
|
\- SOCKS 4/4.5/5 gateway service
|
||||||
@@ -33,11 +33,6 @@ from. External IP must be specified if you need incoming connections.
|
|||||||
By default system will deside which address to use in accordance
|
By default system will deside which address to use in accordance
|
||||||
with routing table.
|
with routing table.
|
||||||
.TP
|
.TP
|
||||||
.B -N
|
|
||||||
External NAT address 3proxy reports to client for BIND and UDPASSOC
|
|
||||||
By default external address is reported. It's only useful in the case
|
|
||||||
of IP-IP NAT (will not work for PAT)
|
|
||||||
.TP
|
|
||||||
.B -i
|
.B -i
|
||||||
Internal address. IP address proxy accepts connections to.
|
Internal address. IP address proxy accepts connections to.
|
||||||
By default connection to any interface is accepted. It\'s usually unsafe.
|
By default connection to any interface is accepted. It\'s usually unsafe.
|
||||||
@@ -53,10 +48,6 @@ is specified logging is to file. Under Unix, if
|
|||||||
preceeds
|
preceeds
|
||||||
.IR logfile ,
|
.IR logfile ,
|
||||||
syslog is used for logging.
|
syslog is used for logging.
|
||||||
.TP
|
|
||||||
.B -S
|
|
||||||
Increase or decrease stack size. You may want to try something like -S8192 if you experience 3proxy
|
|
||||||
crashes.
|
|
||||||
.SH CLIENTS
|
.SH CLIENTS
|
||||||
You should use client with SOCKS support or use some socksification support
|
You should use client with SOCKS support or use some socksification support
|
||||||
(for example
|
(for example
|
||||||
@@ -74,11 +65,13 @@ sufficient privileges). If you need to control access use
|
|||||||
instead.
|
instead.
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
Report all bugs to
|
Report all bugs to
|
||||||
.BR 3proxy@3proxy.ru
|
.BR 3proxy@security.nnov.ru
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
3proxy(8), proxy(8), ftppr(8), pop3p(8), tcppm(8), udppm(8), syslogd(8),
|
3proxy(8), proxy(8), ftppr(8), pop3p(8), tcppm(8), udppm(8), syslogd(8),
|
||||||
.br
|
.br
|
||||||
https://3proxy.org/
|
http://3proxy.ru/
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
3proxy is designed by Vladimir 3APA3A Dubrovin
|
3proxy is designed by 3APA3A
|
||||||
.RI ( 3proxy@3proxy.ru )
|
.RI ( 3APA3A@security.nnov.ru ),
|
||||||
|
Vladimir Dubrovin
|
||||||
|
.RI ( vlad@sandy.ru )
|
||||||
+7
-9
@@ -1,4 +1,4 @@
|
|||||||
.TH tcppm "8" "January 2019" "3proxy 0.9" "Universal proxy server"
|
.TH tcppm "8" "July 2009" "3proxy 0.7" "Universal proxy server"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.B tcppm
|
.B tcppm
|
||||||
\- TCP port mapper
|
\- TCP port mapper
|
||||||
@@ -40,10 +40,6 @@ is specified logging is to file. Under Unix, if
|
|||||||
preceeds
|
preceeds
|
||||||
.IR logfile ,
|
.IR logfile ,
|
||||||
syslog is used for logging.
|
syslog is used for logging.
|
||||||
.TP
|
|
||||||
.B -S
|
|
||||||
Increase or decrease stack size. You may want to try something like -S8192 if you experience 3proxy
|
|
||||||
crashes.
|
|
||||||
.SH ARGUMENTS
|
.SH ARGUMENTS
|
||||||
.TP
|
.TP
|
||||||
.I local_port
|
.I local_port
|
||||||
@@ -63,11 +59,13 @@ as a destination in client application. Connection is forwarded to
|
|||||||
.IR remote_host : remote_port
|
.IR remote_host : remote_port
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
Report all bugs to
|
Report all bugs to
|
||||||
.BR 3proxy@3proxy.ru
|
.BR 3proxy@security.nnov.ru
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
3proxy(8), proxy(8), ftppr(8), socks(8), pop3p(8), udppm(8), syslogd(8),
|
3proxy(8), proxy(8), ftppr(8), socks(8), pop3p(8), udppm(8), syslogd(8),
|
||||||
.br
|
.br
|
||||||
https://3proxy.org/
|
http://3proxy.ru/
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
3proxy is designed by Vladimir 3APA3A Dubrovin
|
3proxy is designed by 3APA3A
|
||||||
.RI ( 3proxy@3proxy.ru )
|
.RI ( 3APA3A@security.nnov.ru ),
|
||||||
|
Vladimir Dubrovin
|
||||||
|
.RI ( vlad@sandy.ru )
|
||||||
+7
-9
@@ -1,4 +1,4 @@
|
|||||||
.TH udppm "8" "January 2019" "3proxy 0.9" "Universal proxy server"
|
.TH udppm "8" "July 2009" "3proxy 0.7" "Universal proxy server"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.B udppm
|
.B udppm
|
||||||
\- UDP port mapper
|
\- UDP port mapper
|
||||||
@@ -46,10 +46,6 @@ Single packet. By default only one client can use udppm service, but
|
|||||||
if -s is specified only one packet will be forwarded between client and server.
|
if -s is specified only one packet will be forwarded between client and server.
|
||||||
It allows to share service between multiple clients for single packet services
|
It allows to share service between multiple clients for single packet services
|
||||||
(for example name lookups).
|
(for example name lookups).
|
||||||
.TP
|
|
||||||
.B -S
|
|
||||||
Increase or decrease stack size. You may want to try something like -S8192 if you experience 3proxy
|
|
||||||
crashes.
|
|
||||||
.SH ARGUMENTS
|
.SH ARGUMENTS
|
||||||
.TP
|
.TP
|
||||||
.I local_port
|
.I local_port
|
||||||
@@ -69,11 +65,13 @@ as a destination in client application. All datagrams are forwarded to
|
|||||||
.IR remote_host : remote_port
|
.IR remote_host : remote_port
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
Report all bugs to
|
Report all bugs to
|
||||||
.BR 3proxy@3proxy.ru
|
.BR 3proxy@security.nnov.ru
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
3proxy(8), proxy(8), ftppr(8), socks(8), pop3p(8), udppm(8), syslogd(8),
|
3proxy(8), proxy(8), ftppr(8), socks(8), pop3p(8), udppm(8), syslogd(8),
|
||||||
.br
|
.br
|
||||||
https://3proxy.org/
|
http://3proxy.ru/
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
3proxy is designed by Vladimir 3APA3A Dubrovin
|
3proxy is designed by 3APA3A
|
||||||
.RI ( 3proxy@3proxy.ru )
|
.RI ( 3APA3A@security.nnov.ru ),
|
||||||
|
Vladimir Dubrovin
|
||||||
|
.RI ( vlad@sandy.ru )
|
||||||
@@ -1,256 +0,0 @@
|
|||||||
[--admin--]
|
|
||||||
HTTP/1.0 401 Authentication Required\n
|
|
||||||
WWW-Authenticate: Basic realm="proxy", encoding="utf-8"\n
|
|
||||||
Connection: close\n
|
|
||||||
Content-type: text/html; charset=utf-8\n
|
|
||||||
\n
|
|
||||||
<html><head><title>401 Authentication Required</title></head>\n
|
|
||||||
<body><h2>401 Authentication Required</h2>
|
|
||||||
<h3>Access to requested resource disallowed by administrator or you need valid username/password to use this resource<br><hr>
|
|
||||||
Доступ запрещен администратором или Вы ввели неправильное имя/пароль.
|
|
||||||
</h3></body></html>\n
|
|
||||||
[end]
|
|
||||||
HTTP/1.0 200 OK\n
|
|
||||||
Connection: close\n
|
|
||||||
Expires: Thu, 01 Dec 1994 16:00:00 GMT\n
|
|
||||||
Cache-Control: no-cache\n
|
|
||||||
Content-type: text/html; charset=utf-8\n
|
|
||||||
\n
|
|
||||||
<http><head><title>%s Страница конфигурации</title></head>\n
|
|
||||||
<table width='100%%' border='0'>\n
|
|
||||||
<tr><td width='150' valign='top'>\n
|
|
||||||
<h2>
|
|
||||||
</h2>\n
|
|
||||||
<A HREF='/C'>Счетчики</A><br><br>\n
|
|
||||||
<A HREF='/R'>Перезагрузка конфигурации сервера</A><br><br>\n
|
|
||||||
<A HREF='/S'>Запущенные сервисы</A><br><br>\n
|
|
||||||
<A HREF='/F'>Настройка сервера</A>\n
|
|
||||||
</td><td>
|
|
||||||
<h2>%s %s Конфигурация</h2>
|
|
||||||
[end]
|
|
||||||
HTTP/1.0 200 OK\n
|
|
||||||
Connection: close\n
|
|
||||||
Cache-Control: no-cache\n
|
|
||||||
Content-type: text/xml; charset=utf-8 \n
|
|
||||||
\n
|
|
||||||
<?xml version="1.0"?>\n
|
|
||||||
<?xml-stylesheet href="/SX" type="text/css"?>\n
|
|
||||||
<services>\n
|
|
||||||
<description>Текущие запущенные сервисы и подключившиеся клиенты</description>\n
|
|
||||||
[end]
|
|
||||||
</services>\n
|
|
||||||
[end]
|
|
||||||
HTTP/1.0 200 OK\n
|
|
||||||
Connection: close\n
|
|
||||||
Cache-Control: no-cache\n
|
|
||||||
Content-type: text/css\n
|
|
||||||
\n
|
|
||||||
services {\n
|
|
||||||
display: block;\n
|
|
||||||
margin: 10px auto 10px auto;\n
|
|
||||||
width: 80%;\n
|
|
||||||
background: black;\n"
|
|
||||||
font-family: sans-serif;\n
|
|
||||||
font-size: small;\n
|
|
||||||
color: silver;\n
|
|
||||||
}\n
|
|
||||||
item {\n
|
|
||||||
display: block;\n
|
|
||||||
margin-bottom: 10px;\n
|
|
||||||
border: 2px solid #CCC;\n
|
|
||||||
padding: 10px;\n
|
|
||||||
spacing: 2px;\n
|
|
||||||
}\n
|
|
||||||
parameter {\n
|
|
||||||
display: block;\n
|
|
||||||
padding: 2px;\n
|
|
||||||
margin-top: 10px;\n
|
|
||||||
border: 1px solid grey;\n
|
|
||||||
background: #EEE;\n
|
|
||||||
color: black;\n
|
|
||||||
}\n
|
|
||||||
name {\n
|
|
||||||
display: inline;\n
|
|
||||||
float: left;\n
|
|
||||||
margin-right: 5px;\n
|
|
||||||
font-weight: bold;\n
|
|
||||||
}\n
|
|
||||||
type {\n
|
|
||||||
display: inline;\n
|
|
||||||
font-size: x-small;\n
|
|
||||||
margin-right: 5px;\n
|
|
||||||
color: #666;\n
|
|
||||||
white-space: nowrap;\n
|
|
||||||
font-style: italic;\n
|
|
||||||
}\n
|
|
||||||
description {\n
|
|
||||||
display: inline;\n
|
|
||||||
margin-right: 5px;\n
|
|
||||||
white-space: nowrap;\n
|
|
||||||
}\n
|
|
||||||
value {\n
|
|
||||||
display: block;\n
|
|
||||||
margin-right: 5px;\n
|
|
||||||
}\n
|
|
||||||
[end]
|
|
||||||
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />\n
|
|
||||||
<pre><font size='-2'><b>
|
|
||||||
(c)3APA3A, Владимир Дубровин и <A href='http://3proxy.ru/'>3proxy.ru</A>\n
|
|
||||||
</b></font>\n
|
|
||||||
</td></tr></table></body></html>
|
|
||||||
[end]
|
|
||||||
<h3>Счетчики</h3>\n
|
|
||||||
<table border = '1'>\n
|
|
||||||
<tr align='center'><td>Описание</td><td>Активный</td>
|
|
||||||
<td>Пользователи</td><td>Адрес источника</td><td>Адрес назначения</td>
|
|
||||||
<td>Порты</td>
|
|
||||||
<td>Лимит</td><td>Ед.</td><td>Значение</td>
|
|
||||||
<td>Дата сброса</td><td>Дата обновения</td><td>Номер</td></tr>\n
|
|
||||||
[end]
|
|
||||||
</table>\n
|
|
||||||
[end]
|
|
||||||
[/--admin--]
|
|
||||||
[--proxy--]
|
|
||||||
HTTP/1.0 400 Bad Request\n
|
|
||||||
Connection: close\n
|
|
||||||
Content-type: text/html; charset=utf-8\n
|
|
||||||
\n
|
|
||||||
<html><head><title>400 Bad Request</title></head>\n
|
|
||||||
<body><h2>400 Bad Request</h2>
|
|
||||||
<h2>400 Ошибка: Неправильный запрос.</h2>
|
|
||||||
</body>
|
|
||||||
</html>\n
|
|
||||||
[end]
|
|
||||||
HTTP/1.0 502 Bad Gateway\n
|
|
||||||
Connection: close\n
|
|
||||||
Content-type: text/html; charset=utf-8\n
|
|
||||||
\n
|
|
||||||
<html><head><title>502 Bad Gateway</title></head>\n
|
|
||||||
<body><h2>502 Bad Gateway</h2><h3>Host Not Found or connection failed <br><hr>
|
|
||||||
Ошибка: Удалённый сервер не найден или не удалось связаться с ним.</h3>
|
|
||||||
</body></html>\n
|
|
||||||
[end]
|
|
||||||
HTTP/1.0 503 Service Unavailable\n
|
|
||||||
Connection: close\n
|
|
||||||
Content-type: text/html; charset=utf-8\n
|
|
||||||
\n
|
|
||||||
<html><head><title>503 Service Unavailable</title></head>\n
|
|
||||||
<body><h2>503 Service Unavailable</h2><h3>You have exceeded your traffic limit <br><hr>
|
|
||||||
Вы превысили свой лимит трафика.
|
|
||||||
</h3></body></html>\n
|
|
||||||
[end]
|
|
||||||
HTTP/1.0 503 Service Unavailable\n
|
|
||||||
Connection: close\n
|
|
||||||
Content-type: text/html; charset=utf-8\n
|
|
||||||
\n
|
|
||||||
<html><head><title>503 Service Unavailable</title></head>\n
|
|
||||||
<body><h2>503 Service Unavailable</h2><h3>Recursion detected<br><hr>
|
|
||||||
Ошибка: Сервис не доступен, обнаружена рекурсия
|
|
||||||
</h3></body></html>\n
|
|
||||||
[end]
|
|
||||||
HTTP/1.0 501 Not Implemented\n
|
|
||||||
Connection: close\n
|
|
||||||
Content-type: text/html; charset=utf-8\n
|
|
||||||
\n
|
|
||||||
<html><head><title>501 Not Implemented</title></head>\n
|
|
||||||
<body><h2>501 Not Implemented</h2><h3>Required action is not supported by proxy server <br><hr>
|
|
||||||
Ошибка: Действие не поддерживается в данном proxy сервере
|
|
||||||
</h3></body></html>\n
|
|
||||||
[end]
|
|
||||||
HTTP/1.0 502 Bad Gateway\n
|
|
||||||
Connection: close\n
|
|
||||||
Content-type: text/html; charset=utf-8\n
|
|
||||||
\n
|
|
||||||
<html><head><title>502 Bad Gateway</title></head>\n
|
|
||||||
<body><h2>502 Bad Gateway</h2><h3>Failed to connect parent proxy <br><hr>
|
|
||||||
Ошибка: Невозможно соединиться c вышестоящим proxy сервером
|
|
||||||
</h3></body></html>\n",
|
|
||||||
[end]
|
|
||||||
HTTP/1.0 500 Internal Error\n
|
|
||||||
Connection: close\n
|
|
||||||
Content-type: text/html; charset=utf-8\n
|
|
||||||
\n
|
|
||||||
<html><head><title>500 Internal Error</title></head>\n
|
|
||||||
<body><h2>500 Internal Error</h2><h3>Internal proxy error during processing your request <br><hr>
|
|
||||||
Ошибка: Возникла внутренняя ошибка proxy сервера при обработке вашего запроса
|
|
||||||
</h3></body></html>\n
|
|
||||||
[end]
|
|
||||||
HTTP/1.0 407 Proxy Authentication Required\n
|
|
||||||
Proxy-Authenticate: Basic realm="proxy", encoding="utf-8"\n
|
|
||||||
Connection: close\n
|
|
||||||
Content-type: text/html; charset=utf-8\n
|
|
||||||
\n
|
|
||||||
<html><head><title>407 Proxy Authentication Required</title></head>\n
|
|
||||||
<body><h2>407 Proxy Authentication Required</h2><h3>Access to requested resource disallowed by administrator or you need valid username/password to use this resource.<br><hr>
|
|
||||||
Доступ запрещен администратором или Вы ввели неправильное имя/пароль.
|
|
||||||
</h3></body></html>\n
|
|
||||||
[end]
|
|
||||||
HTTP/1.0 200 Connection established\n\n
|
|
||||||
[end]
|
|
||||||
HTTP/1.0 200 Connection established\n
|
|
||||||
Content-Type: text/html\n\n
|
|
||||||
[end]
|
|
||||||
HTTP/1.0 404 Not Found\n
|
|
||||||
Connection: close\n
|
|
||||||
Content-type: text/html; charset=utf-8\n
|
|
||||||
\n
|
|
||||||
<html><head><title>404 Not Found</title></head>\n
|
|
||||||
<body><h2>404 Not Found</h2><h3>File not found <br><hr>
|
|
||||||
Файл не найден
|
|
||||||
</h3></body></html>\n
|
|
||||||
[end]
|
|
||||||
HTTP/1.0 403 Forbidden\n
|
|
||||||
Connection: close\n
|
|
||||||
Content-type: text/html; charset=utf-8\n
|
|
||||||
\n
|
|
||||||
<html><head><title>403 Access Denied</title></head>\n
|
|
||||||
<body><h2>403 Access Denied</h2><h3>Access control list denies you to access this resource.<br><hr>
|
|
||||||
Доступ к данному ресурсу запрещен списком доступа на proxy сервер.
|
|
||||||
Если Вы считаете, что это ошибка обратитесь к администратору
|
|
||||||
</h3></body></html>\n
|
|
||||||
[end]
|
|
||||||
HTTP/1.0 407 Proxy Authentication Required\n
|
|
||||||
Proxy-Authenticate: NTLM\n
|
|
||||||
Proxy-Authenticate: basic realm="proxy", encoding="utf-8"\n
|
|
||||||
Connection: close\n
|
|
||||||
Content-type: text/html; charset=utf-8\n
|
|
||||||
\n
|
|
||||||
<html><head><title>407 Proxy Authentication Required</title></head>\n
|
|
||||||
<body><h2>407 Proxy Authentication Required</h2><h3>Access to requested resource disallowed by administrator or you need valid username/password to use this resource.<br><hr>
|
|
||||||
Доступ запрещен администратором или Вы ввели неправильное имя/пароль.
|
|
||||||
</h3></body></html>\n
|
|
||||||
[end]
|
|
||||||
HTTP/1.0 407 Proxy Authentication Required\n
|
|
||||||
Connection: keep-alive\n
|
|
||||||
Content-Length: 0\n
|
|
||||||
Proxy-Authenticate: NTLM
|
|
||||||
[end]
|
|
||||||
HTTP/1.0 403 Forbidden\n
|
|
||||||
Connection: close\n
|
|
||||||
Content-type: text/html; charset=us-ascii\n
|
|
||||||
\n
|
|
||||||
<pre>
|
|
||||||
[end]
|
|
||||||
HTTP/1.0 503 Service Unavailable\n
|
|
||||||
Connection: close\n
|
|
||||||
Content-type: text/html; charset=utf-8\n
|
|
||||||
\n
|
|
||||||
<html><head><title>503 Service Unavailable</title></head>\n
|
|
||||||
<body><h2>503 Service Unavailable</h2><h3>Your request violates configured policy<br><hr>
|
|
||||||
Запрос не сответствует сконфигурированной политике.
|
|
||||||
</h3></body></html>\n
|
|
||||||
[end]
|
|
||||||
HTTP/1.0 401 Authentication Required\n
|
|
||||||
WWW-Authenticate: basic realm="FTP Server", encoding="utf-8"\n
|
|
||||||
Connection: close\n
|
|
||||||
Content-type: text/html; charset=utf-8\n
|
|
||||||
\n
|
|
||||||
<html><head><title>401 FTP Server requires authentication</title></head>\n
|
|
||||||
<body><h2>401 FTP Server requires authentication</h2><h3>This FTP server rejects anonymous access<br><hr>
|
|
||||||
Этот FTP сервер отвергает анонимный доступ.
|
|
||||||
</h3></body></html>\n
|
|
||||||
[end]
|
|
||||||
HTTP/1.1 100 Continue\n
|
|
||||||
\n
|
|
||||||
[end]
|
|
||||||
[/--proxy--]
|
|
||||||
@@ -1,985 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# 3proxy build and install script for Debian Linux
|
|
||||||
# Release 2.0 at 29.12.2016
|
|
||||||
# (с) Evgeniy Solovyev
|
|
||||||
# mail-to: eugen-soloviov@yandex.ru
|
|
||||||
|
|
||||||
ScriptPath=""
|
|
||||||
Src3proxyDirPath=""
|
|
||||||
ScriptName=""
|
|
||||||
ScriptFullName=""
|
|
||||||
SourceRoot=""
|
|
||||||
|
|
||||||
ResourcesData=""
|
|
||||||
|
|
||||||
|
|
||||||
ProxyVersion=""
|
|
||||||
LasestProxyVersion=""
|
|
||||||
LasestProxyVersionLink=""
|
|
||||||
UseSudo=0
|
|
||||||
PacketFiles=""
|
|
||||||
NeedSourceUpdate=0
|
|
||||||
|
|
||||||
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
local msgNewVersion
|
|
||||||
local msgInsertYorN
|
|
||||||
|
|
||||||
VarsInit
|
|
||||||
LoadResources
|
|
||||||
CheckRunConditions
|
|
||||||
|
|
||||||
if [ $UseSudo == 1 ]
|
|
||||||
then
|
|
||||||
sudo bash "${0}"
|
|
||||||
exit $?
|
|
||||||
fi
|
|
||||||
|
|
||||||
CheckLocation
|
|
||||||
GetLasestVersionInfo
|
|
||||||
|
|
||||||
SourceDownloadOrUpdate
|
|
||||||
|
|
||||||
cd "${SourceRoot}"
|
|
||||||
|
|
||||||
Build3Proxy
|
|
||||||
BinInstall
|
|
||||||
ManInstall
|
|
||||||
CreateLogDir
|
|
||||||
CopyConfig
|
|
||||||
SetInit
|
|
||||||
Pack3proxyFiles
|
|
||||||
}
|
|
||||||
|
|
||||||
VarsInit()
|
|
||||||
{
|
|
||||||
cd `dirname $0`
|
|
||||||
ScriptPath="${PWD}"
|
|
||||||
ScriptName=`basename $0`
|
|
||||||
ScriptFullName="${ScriptPath}/${ScriptName}"
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckLocation()
|
|
||||||
{
|
|
||||||
Src3proxyDirPath="${ScriptPath}"
|
|
||||||
|
|
||||||
if echo ${ScriptPath} | grep -e "/scripts$"
|
|
||||||
then
|
|
||||||
if [ -e "../src/version.h" ]
|
|
||||||
then
|
|
||||||
ProxyVersion=`cat "../src/version.h" | awk '/VERSION/ { gsub("\"", "\n"); print; exit }' | grep "3proxy"`
|
|
||||||
cd ../
|
|
||||||
SourceRoot="${PWD}"
|
|
||||||
cd ../
|
|
||||||
Src3proxyDirPath="${PWD}"
|
|
||||||
cd "${ScriptPath}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
GetLasestVersionInfo()
|
|
||||||
{
|
|
||||||
local Githublink
|
|
||||||
local msg
|
|
||||||
|
|
||||||
Githublink=`wget https://github.com/z3APA3A/3proxy/releases/latest -O /dev/stdout |
|
|
||||||
awk '/<a.+href=.+\.tar\.gz/ { gsub("\"", "\n"); print; exit }' |
|
|
||||||
grep -e ".tar.gz"`
|
|
||||||
if [ $? != 0 ]
|
|
||||||
then
|
|
||||||
msg=`GetResource "msgInternetConnectionError"`
|
|
||||||
echo -e "${msg}"
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
|
|
||||||
LasestProxyVersionLink="https://github.com${Githublink}"
|
|
||||||
|
|
||||||
LasestProxyVersion=`basename "${Githublink}" | awk 'gsub(".tar.gz", "") { print "3proxy-" $0 }'`
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckRunConditions()
|
|
||||||
{
|
|
||||||
local UserName
|
|
||||||
local answer
|
|
||||||
local msg
|
|
||||||
local msgContinueWork
|
|
||||||
local msgInsertYorN
|
|
||||||
|
|
||||||
UserName=`whoami`
|
|
||||||
|
|
||||||
if [ $UID != 0 ]
|
|
||||||
then
|
|
||||||
if [ `CheckPacketInstall "sudo"` == 0 ]
|
|
||||||
then
|
|
||||||
msg=`GetResource "msgSudoNotInstalled"`
|
|
||||||
echo -e "${msg}"
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
|
|
||||||
UseSudo=1
|
|
||||||
|
|
||||||
if [ -z `cat /etc/group | grep -e "^sudo" | grep "${UserName}"` ]
|
|
||||||
then
|
|
||||||
msg=`GetResource "msgUserNotMemberOfSudoGroup"`
|
|
||||||
echo -e "${msg}"
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ `env | grep -e ^http_proxy` != "" ]
|
|
||||||
then
|
|
||||||
msg=`GetResource "msgSystemUseProxy"`
|
|
||||||
echo -e "${msg}"
|
|
||||||
|
|
||||||
msgContinueWork=`GetResource "msgDoYouWishContinue"`
|
|
||||||
msgInsertYorN=`GetResource "msgPleaseInsertYorN"`
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
read -s -n1 -p "${msgContinueWork}" answer
|
|
||||||
case $answer in
|
|
||||||
[Yy]* ) echo -ne "\n";break;;
|
|
||||||
[Nn]* ) echo -ne "\n"; sleep 0; exit 0;;
|
|
||||||
* ) echo -e "${msgInsertYorN}";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
DonwnloadSource()
|
|
||||||
{
|
|
||||||
if [ ! -e "${Src3proxyDirPath}/${LasestProxyVersion}.tar.gz" ]
|
|
||||||
then
|
|
||||||
wget "${LasestProxyVersionLink}" -O "${Src3proxyDirPath}/${LasestProxyVersion}.tar.gz"
|
|
||||||
fi
|
|
||||||
|
|
||||||
ProxyVersion="${LasestProxyVersion}"
|
|
||||||
}
|
|
||||||
|
|
||||||
UnpackSource()
|
|
||||||
{
|
|
||||||
if [ ! -d "${Src3proxyDirPath}/${LasestProxyVersion}" ]
|
|
||||||
then
|
|
||||||
tar -xvf "${Src3proxyDirPath}/${LasestProxyVersion}.tar.gz" -C "${Src3proxyDirPath}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
SourceRoot="${Src3proxyDirPath}/${LasestProxyVersion}"
|
|
||||||
}
|
|
||||||
|
|
||||||
SourceDownloadOrUpdate()
|
|
||||||
{
|
|
||||||
if [ -z "${ProxyVersion}" ]
|
|
||||||
then
|
|
||||||
NeedSourceUpdate=1
|
|
||||||
else
|
|
||||||
if [ "${ProxyVersion}" != "${LasestProxyVersion}" ]
|
|
||||||
then
|
|
||||||
msgNewVersion=`GetResource "msgNewVersion"`
|
|
||||||
msgInsertYorN=`GetResource "msgPleaseInsertYorN"`
|
|
||||||
|
|
||||||
echo -ne "\a"
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
read -s -n1 -p "${msgNewVersion}" answer
|
|
||||||
case $answer in
|
|
||||||
[Yy]* ) echo -ne "\n"; NeedSourceUpdate=1; sleep 0; break;;
|
|
||||||
[Nn]* ) echo -ne "\n"; NeedSourceUpdate=0; sleep 0; break;;
|
|
||||||
* ) echo -e "${msgInsertYorN}";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $NeedSourceUpdate == 1 ]
|
|
||||||
then
|
|
||||||
DonwnloadSource
|
|
||||||
UnpackSource
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
Build3Proxy()
|
|
||||||
{
|
|
||||||
local msg
|
|
||||||
|
|
||||||
if [ `CheckPacketInstall "build-essential"` == 0 ]
|
|
||||||
then
|
|
||||||
apt-get -y install build-essential
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ `CheckPacketInstall "build-essential"` == 0 ]
|
|
||||||
then
|
|
||||||
msg=`GetResource "msgBuildEssentialNotInstalled"`
|
|
||||||
echo -e "${msg}"
|
|
||||||
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
|
|
||||||
make -f Makefile.Linux
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BinInstall()
|
|
||||||
{
|
|
||||||
local binlist
|
|
||||||
local liblist
|
|
||||||
|
|
||||||
if [! -d bin]
|
|
||||||
then
|
|
||||||
mkdir bin
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd bin
|
|
||||||
|
|
||||||
binlist=`ls -l --time-style="+%d.%m.%Y %H:%m" | awk '$1 ~ /x$/ && $1 ~ /^[^d]/ && $8 !~ /\.so$/ { print $8 }'`
|
|
||||||
|
|
||||||
for file in $binlist
|
|
||||||
do
|
|
||||||
cp -vf "${file}" /usr/bin
|
|
||||||
PacketFiles=`echo -e "${PacketFiles}\n/usr/bin/${file}"`
|
|
||||||
done
|
|
||||||
|
|
||||||
liblist=`ls -l --time-style="+%d.%m.%Y %H:%m" | awk '$1 ~ /x$/ && $1 ~ /^[^d]/ && $8 ~ /\.so$/ { print $8 }'`
|
|
||||||
|
|
||||||
for file in $liblist
|
|
||||||
do
|
|
||||||
cp -vf "${file}" /usr/lib
|
|
||||||
PacketFiles=`echo -e "${PacketFiles}\n/usr/lib/${file}"`
|
|
||||||
done
|
|
||||||
|
|
||||||
cd ..
|
|
||||||
}
|
|
||||||
|
|
||||||
ManInstall()
|
|
||||||
{
|
|
||||||
local man3list
|
|
||||||
local man8list
|
|
||||||
|
|
||||||
cd man
|
|
||||||
|
|
||||||
man3list=`ls -l --time-style="+%d.%m.%Y %H:%m" | awk '$8 ~ /\.3$/ { print $8 }'`
|
|
||||||
gzip -vfk $man3list
|
|
||||||
|
|
||||||
man3list=`echo "${man3list}" | awk '{ print $1 ".gz" }'`
|
|
||||||
|
|
||||||
for file in $man3list
|
|
||||||
do
|
|
||||||
mv -vf "${file}" /usr/share/man/man3
|
|
||||||
PacketFiles="${PacketFiles}\n/usr/share/man/man3/${file}"
|
|
||||||
done
|
|
||||||
|
|
||||||
man8list=`ls -l --time-style="+%d.%m.%Y %H:%m" | awk '$8 ~ /\.8$/ { print $8 }'`
|
|
||||||
|
|
||||||
gzip -vfk $man8list
|
|
||||||
|
|
||||||
man8list=`echo "${man8list}" | awk '{ print $1 ".gz" }'`
|
|
||||||
|
|
||||||
for file in $man8list
|
|
||||||
do
|
|
||||||
mv -vf "${file}" /usr/share/man/man8
|
|
||||||
PacketFiles=`echo -e "${PacketFiles}\n/usr/share/man/man8/${file}"`
|
|
||||||
done
|
|
||||||
|
|
||||||
cd ..
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CreateLogDir()
|
|
||||||
{
|
|
||||||
local LogDir
|
|
||||||
LogDir="/var/log/3proxy"
|
|
||||||
|
|
||||||
if [ ! -d "${LogDir}" ]
|
|
||||||
then
|
|
||||||
mkdir "${LogDir}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
chown nobody:nogroup "${LogDir}"
|
|
||||||
chmod 775 "${LogDir}"
|
|
||||||
PacketFiles="${PacketFiles}\n${LogDir}"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CopyConfig()
|
|
||||||
{
|
|
||||||
local ConfigDir
|
|
||||||
ConfigDir="/etc/3proxy"
|
|
||||||
|
|
||||||
if [ ! -d "${ConfigDir}" ]
|
|
||||||
then
|
|
||||||
mkdir "${ConfigDir}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
LoadGlobalResource "ConfigFile" > "${ConfigDir}/3proxy.cfg"
|
|
||||||
|
|
||||||
PacketFiles=`echo -e "${PacketFiles}\n${ConfigDir}/3proxy.cfg"`
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SetInit()
|
|
||||||
{
|
|
||||||
LoadGlobalResource "InitScript" > "/etc/init.d/3proxy"
|
|
||||||
chown root:root "/etc/init.d/3proxy"
|
|
||||||
chmod 755 "/etc/init.d/3proxy"
|
|
||||||
|
|
||||||
PacketFiles=`echo -e "${PacketFiles}\n/etc/init.d/3proxy"`
|
|
||||||
update-rc.d 3proxy defaults
|
|
||||||
}
|
|
||||||
|
|
||||||
Pack3proxyFiles()
|
|
||||||
{
|
|
||||||
local CPU_Arc
|
|
||||||
CPU_Arc=`uname -m`
|
|
||||||
cd ../
|
|
||||||
tar -czPpvf "${ProxyVersion}-${CPU_Arc}.tar.gz" $PacketFiles
|
|
||||||
}
|
|
||||||
|
|
||||||
LoadResources()
|
|
||||||
{
|
|
||||||
local StartRow
|
|
||||||
local EndRow
|
|
||||||
local LngLabel
|
|
||||||
local msgResourceErr="\aError! Script could not find resources!"
|
|
||||||
|
|
||||||
if env | grep -q 'LANG=ru_RU.UTF-8'
|
|
||||||
then
|
|
||||||
LngLabel="RU"
|
|
||||||
#LngLabel="EN"
|
|
||||||
else
|
|
||||||
LngLabel="EN"
|
|
||||||
fi
|
|
||||||
|
|
||||||
StartRow=`cat "${ScriptFullName}" | awk "/^#Resources_${LngLabel}/ { print NR; exit}"`
|
|
||||||
|
|
||||||
if [ -z "${StartRow}" ]
|
|
||||||
then
|
|
||||||
echo -e "${msgResourceErr}"
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
|
|
||||||
EndRow=`cat "${ScriptFullName}" | awk "NR > ${StartRow} && /^#Resources_${LngLabel}_end/ { print NR; exit}"`
|
|
||||||
|
|
||||||
if [ -z "${EndRow}" ]
|
|
||||||
then
|
|
||||||
echo -e "${msgResourceErr}"
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
|
|
||||||
ResourcesData=`cat "${ScriptFullName}" | awk -v StartRow="${StartRow}" -v EndRow="${EndRow}" 'NR > StartRow && NR < EndRow { print $0 }'`
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# $1 - Name of Resource
|
|
||||||
GetResource()
|
|
||||||
{
|
|
||||||
local StartRow
|
|
||||||
local EndRow
|
|
||||||
local msgResourceErr="\aError! Script could not find resource \"${1}\"!"
|
|
||||||
|
|
||||||
StartRow=`echo "${ResourcesData}" | awk "/^#Resource=${1}/ { print NR; exit}"`
|
|
||||||
|
|
||||||
if [ -z "${StartRow}" ]
|
|
||||||
then
|
|
||||||
echo -e "${msgResourceErr}" > /dev/stderr
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
|
|
||||||
EndRow=`echo "${ResourcesData}" | awk "NR > ${StartRow} && /^#endResource=${1}/ { print NR; exit}"`
|
|
||||||
|
|
||||||
if [ -z "${EndRow}" ]
|
|
||||||
then
|
|
||||||
echo -e "${msgResourceErr}" > /dev/stderr
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "${ResourcesData}" | awk -v StartRow="${StartRow}" -v EndRow="${EndRow}" 'NR > StartRow && NR < EndRow { print $0 }'
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# $1 - Name of Resource
|
|
||||||
LoadGlobalResource()
|
|
||||||
{
|
|
||||||
local StartRow
|
|
||||||
local EndRow
|
|
||||||
local LngLabel
|
|
||||||
local msgResourceErr="\aError! Script could not find resource \"${1}\"!"
|
|
||||||
|
|
||||||
|
|
||||||
StartRow=`cat "${ScriptFullName}" | awk "/^#Resource=${1}/ { print NR; exit}"`
|
|
||||||
|
|
||||||
if [ -z "${StartRow}" ]
|
|
||||||
then
|
|
||||||
echo -e "${msgResourceErr}" > /dev/stderr
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
|
|
||||||
EndRow=`cat "${ScriptFullName}" | awk "NR > ${StartRow} && /^#endResource=${1}/ { print NR; exit}"`
|
|
||||||
|
|
||||||
if [ -z "${EndRow}" ]
|
|
||||||
then
|
|
||||||
echo -e "${msgResourceErr}" > /dev/stderr
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
|
|
||||||
cat "${ScriptFullName}" | awk -v StartRow="${StartRow}" -v EndRow="${EndRow}" 'NR > StartRow && NR < EndRow { print $0 }'
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CheckPacketInstall()
|
|
||||||
{
|
|
||||||
if [ `dpkg -l ${1} 2>&1 | wc -l` -le 1 ]
|
|
||||||
then
|
|
||||||
echo 0
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
if [ `dpkg -l ${1} | grep -e ^un | wc -l` == 1 ]
|
|
||||||
then
|
|
||||||
echo 0
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo 1
|
|
||||||
}
|
|
||||||
|
|
||||||
main
|
|
||||||
exit 0
|
|
||||||
|
|
||||||
#Resources_EN
|
|
||||||
|
|
||||||
#Resource=msgSudoNotInstalled
|
|
||||||
\aThe script is running under the account a non-privileged user.
|
|
||||||
"Sudo" package is not installed in the system.
|
|
||||||
The script can not continue, as the execution of operations,
|
|
||||||
requiring rights "root" - is not possible!
|
|
||||||
Please run the script under the account "root",
|
|
||||||
or install and configure "sudo" package!
|
|
||||||
#endResource=msgSudoNotInstalled
|
|
||||||
|
|
||||||
#Resource=msgUserNotMemberOfSudoGroup
|
|
||||||
\aThe script is running under account a non-privileged user.
|
|
||||||
The account of the current user is not included in the "sudo" group!
|
|
||||||
The script can not continue, as the execution of operations,
|
|
||||||
requiring rights "root" - is not possible!
|
|
||||||
Please run the script under the account "root",
|
|
||||||
or configure "sudo" package!
|
|
||||||
#endResource=msgUserNotMemberOfSudoGroup
|
|
||||||
|
|
||||||
#Resource=msgSystemUseProxy
|
|
||||||
\aAttention! The operating system uses proxy-server.
|
|
||||||
For correctly work of package manager "apt"
|
|
||||||
in the file "/etc/sudoers" should be present line:
|
|
||||||
Defaults env_keep = "http_proxy https_proxy"
|
|
||||||
#endResource=msgSystemUseProxy
|
|
||||||
|
|
||||||
#Resource=msgDoYouWishContinue
|
|
||||||
Do you wish to the script continued executing? (y/n):
|
|
||||||
#endResource=msgDoYouWishContinue
|
|
||||||
|
|
||||||
#Resource=msgPleaseInsertYorN
|
|
||||||
\a\nPlease insert "y" or "n"!
|
|
||||||
#endResource=msgPleaseInsertYorN
|
|
||||||
|
|
||||||
#Resource=msgInternetConnectionError
|
|
||||||
\aError downloading "https://github.com/z3APA3A/3proxy/releases/latest"!
|
|
||||||
Please check the settings of the Internet connection.
|
|
||||||
#endResource=msgInternetConnectionError
|
|
||||||
|
|
||||||
#Resource=msgNewVersion
|
|
||||||
The new version of "3proxy" detected, do you want download it?
|
|
||||||
#endResource=msgNewVersion
|
|
||||||
|
|
||||||
#Resource=msgBuildEssentialNotInstalled
|
|
||||||
\aPackage "build-essential" was not installed.
|
|
||||||
The installation can not be continued!
|
|
||||||
#endResource=msgBuildEssentialNotInstalled
|
|
||||||
|
|
||||||
#Resources_EN_end
|
|
||||||
|
|
||||||
#Resources_RU
|
|
||||||
|
|
||||||
#Resource=msgSudoNotInstalled
|
|
||||||
\aСкрипт запущен под учётной записью обычного пользователя.
|
|
||||||
В системе не установлен пакет "sudo".
|
|
||||||
Скрипт не может продолжить работу, так как выполнение операций,
|
|
||||||
требующих прав "root" - не представляется возможным!
|
|
||||||
Пожалуйста, запустите скрипт под учётной записью "root",
|
|
||||||
либо установите и настройте пакет "sudo"!
|
|
||||||
#endResource=msgSudoNotInstalled
|
|
||||||
|
|
||||||
#Resource=msgUserNotMemberOfSudoGroup
|
|
||||||
\aСкрипт запущен под учётной записью обычного пользователя.
|
|
||||||
Учётная запись текущего пользователя не включена в группу "sudo"!
|
|
||||||
Скрипт не может продолжить работу, так как выполнение операций,
|
|
||||||
требующих прав "root" - не представляется возможным!
|
|
||||||
Пожалуйста, запустите скрипт под учётной записью "root",
|
|
||||||
либо настройте пакет "sudo"!
|
|
||||||
#endResource=msgUserNotMemberOfSudoGroup
|
|
||||||
|
|
||||||
#Resource=msgSystemUseProxy
|
|
||||||
\aВнимание! В системе используется прокси-сервер.
|
|
||||||
Чтобы менеджер пакетов "apt" работал корректно,
|
|
||||||
в файле "/etc/sudoers" должна присутствовать строка:
|
|
||||||
Defaults env_keep = "http_proxy https_proxy"
|
|
||||||
#endResource=msgSystemUseProxy
|
|
||||||
|
|
||||||
#Resource=msgDoYouWishContinue
|
|
||||||
Хотите чтобы скрипт дальше продолжил работу? (y/n):
|
|
||||||
#endResource=msgDoYouWishContinue
|
|
||||||
|
|
||||||
#Resource=msgPleaseInsertYorN
|
|
||||||
\a\nПожалуйста введите "y" или "n"!
|
|
||||||
#endResource=msgPleaseInsertYorN
|
|
||||||
|
|
||||||
#Resource=msgInternetConnectionError
|
|
||||||
\aОшибка закачки "https://github.com/z3APA3A/3proxy/releases/latest"!
|
|
||||||
Пожалуйста, проверьте настройки интернет соединения.
|
|
||||||
#endResource=msgInternetConnectionError
|
|
||||||
|
|
||||||
#Resource=msgNewVersion
|
|
||||||
Обнаружена новая версия "3proxy", скачать её (y/n)?
|
|
||||||
#endResource=msgNewVersion
|
|
||||||
|
|
||||||
#Resource=msgBuildEssentialNotInstalled
|
|
||||||
\aПакет "build-essential" не был установлен.
|
|
||||||
Дальнейшая установка не может быть продолжена!
|
|
||||||
#endResource=msgBuildEssentialNotInstalled
|
|
||||||
|
|
||||||
#Resources_RU_end
|
|
||||||
|
|
||||||
|
|
||||||
#Resource=ConfigFile
|
|
||||||
noconfig
|
|
||||||
# If in this file have line "noconfig", then 3proxy not to be runned!
|
|
||||||
# For usung this configuration file 3proxy you must to delete
|
|
||||||
# or comment out the line with "noconfig".
|
|
||||||
|
|
||||||
daemon
|
|
||||||
# Parameter "daemon" - means run 3proxy as daemon
|
|
||||||
|
|
||||||
|
|
||||||
pidfile /tmp/3proxy.pid
|
|
||||||
# PID file location
|
|
||||||
# This parameter must have the same value as
|
|
||||||
# the variable "PidFile" in the script "/etc/init.d/3proxy"
|
|
||||||
|
|
||||||
|
|
||||||
# Configuration file location
|
|
||||||
config /etc/3proxy/3proxy.cfg
|
|
||||||
|
|
||||||
|
|
||||||
internal 127.0.0.1
|
|
||||||
# Internal is address of interface proxy will listen for incoming requests
|
|
||||||
# 127.0.0.1 means only localhost will be able to use this proxy. This is
|
|
||||||
# address you should specify for clients as proxy IP.
|
|
||||||
# You MAY use 0.0.0.0 but you shouldn't, because it's a chance for you to
|
|
||||||
# have open proxy in your network in this case.
|
|
||||||
|
|
||||||
external 192.168.0.1
|
|
||||||
# External is address 3proxy uses for outgoing connections. 0.0.0.0 means any
|
|
||||||
# interface. Using 0.0.0.0 is not good because it allows to connect to 127.0.0.1
|
|
||||||
|
|
||||||
|
|
||||||
# DNS IP addresses
|
|
||||||
nserver 8.8.8.8
|
|
||||||
nserver 8.8.4.4
|
|
||||||
|
|
||||||
|
|
||||||
# DNS cache size
|
|
||||||
nscache 65536
|
|
||||||
|
|
||||||
# Timeouts settings
|
|
||||||
timeouts 1 5 30 60 180 1800 15 60
|
|
||||||
|
|
||||||
|
|
||||||
# log file location
|
|
||||||
log /var/log/3proxy/3proxy.log D
|
|
||||||
|
|
||||||
# log file format
|
|
||||||
logformat "L%C - %U [%d-%o-%Y %H:%M:%S %z] ""%T"" %E %I %O %N/%R:%r"
|
|
||||||
|
|
||||||
archiver gz /usr/bin/gzip %F
|
|
||||||
# If archiver specified log file will be compressed after closing.
|
|
||||||
# you should specify extension, path to archiver and command line, %A will be
|
|
||||||
# substituted with archive file name, %f - with original file name.
|
|
||||||
# Original file will not be removed, so archiver should care about it.
|
|
||||||
|
|
||||||
rotate 30
|
|
||||||
# We will keep last 30 log files
|
|
||||||
|
|
||||||
proxy -p3128
|
|
||||||
# Run http/https proxy on port 3128
|
|
||||||
|
|
||||||
auth none
|
|
||||||
# No authentication is requires
|
|
||||||
|
|
||||||
setgid 65534
|
|
||||||
setuid 65534
|
|
||||||
# Run 3proxy under account "nobody" with group "nobody"
|
|
||||||
#endResource=ConfigFile
|
|
||||||
|
|
||||||
|
|
||||||
#Resource=InitScript
|
|
||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
# 3proxy daemon control script
|
|
||||||
#
|
|
||||||
### BEGIN INIT INFO
|
|
||||||
# Provides: 3proxy
|
|
||||||
# Required-Start: $network $remote_fs $syslog
|
|
||||||
# Required-Stop: $network $remote_fs $syslog
|
|
||||||
# Should-Start: $named
|
|
||||||
# Should-Stop: $named
|
|
||||||
# Default-Start: 2 3 4 5
|
|
||||||
# Default-Stop: 0 1 6
|
|
||||||
# Short-Description: 3proxy HTTP Proxy
|
|
||||||
### END INIT INFO
|
|
||||||
|
|
||||||
|
|
||||||
ScriptName="3proxy"
|
|
||||||
ScriptFullName="/etc/init.d/3proxy"
|
|
||||||
|
|
||||||
ConfigFile="/etc/3proxy/3proxy.cfg"
|
|
||||||
LogDir="/var/log/3proxy"
|
|
||||||
PidFile="/tmp/3proxy.pid"
|
|
||||||
|
|
||||||
ResourcesData=""
|
|
||||||
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
LoadResources
|
|
||||||
|
|
||||||
if [ ! -d "${LogDir}" ]
|
|
||||||
then
|
|
||||||
mkdir -p "${LogDir}";
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
start) Start ;;
|
|
||||||
stop) Stop ;;
|
|
||||||
restart) Stop; Start ;;
|
|
||||||
status) Status ;;
|
|
||||||
*) ShowHelp;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
Start()
|
|
||||||
{
|
|
||||||
local msg
|
|
||||||
local ProxyPID
|
|
||||||
|
|
||||||
if [ ! -f "${ConfigFile}" ]
|
|
||||||
then
|
|
||||||
msg=`GetResource "msgConfigFileNotFound"`
|
|
||||||
printf "${msg}" "${ConfigFile}"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
if cat "${ConfigFile}" | grep -qe "^noconfig"
|
|
||||||
then
|
|
||||||
msg=`GetResource "msgNoconfigDetected"`
|
|
||||||
printf "${msg}" "${ConfigFile}"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
ProxyPID=`Get3proxyPID`
|
|
||||||
|
|
||||||
if [ ! -z "${ProxyPID}" ]
|
|
||||||
then
|
|
||||||
msg=`GetResource "msg3proxyAlreadyRunning"`
|
|
||||||
printf "${msg}" "${ProxyPID}"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
3proxy "${ConfigFile}"
|
|
||||||
sleep 1
|
|
||||||
|
|
||||||
ProxyPID=`Get3proxyPID`
|
|
||||||
|
|
||||||
if [ ! -f "${PidFile}" ]
|
|
||||||
then
|
|
||||||
msg=`GetResource "msg3proxyStartProblems"`
|
|
||||||
printf "${msg}"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ `cat "${PidFile}"` != "${ProxyPID}" ]
|
|
||||||
then
|
|
||||||
msg=`GetResource "msg3proxyStartProblems"`
|
|
||||||
printf "${msg}"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
msg=`GetResource "msg3proxyStartedSuccessfully"`
|
|
||||||
printf "${msg}" `date +%d-%m-%Y" "%H:%M:%S` "${ProxyPID}"
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Stop()
|
|
||||||
{
|
|
||||||
local msg
|
|
||||||
local ProxyPID
|
|
||||||
|
|
||||||
ProxyPID=`Get3proxyPID`
|
|
||||||
|
|
||||||
if [ -f "${PidFile}" ]
|
|
||||||
then
|
|
||||||
if [ `cat "${PidFile}"` = "${ProxyPID}" ]
|
|
||||||
then
|
|
||||||
kill -9 "${ProxyPID}"
|
|
||||||
rm -f "${PidFile}"
|
|
||||||
|
|
||||||
msg=`GetResource "msg3proxyStoppedSuccessfully"`
|
|
||||||
printf "${msg}" `date +%d-%m-%Y" "%H:%M:%S`
|
|
||||||
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "${ProxyPID}" ]
|
|
||||||
then
|
|
||||||
msg=`GetResource "msg3proxyProxyNotDetected"`
|
|
||||||
printf "${msg}"
|
|
||||||
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
pkill -o 3proxy
|
|
||||||
|
|
||||||
msg=`GetResource "msg3proxyStoppedByKillall"`
|
|
||||||
printf "${msg}" `date +%d-%m-%Y" "%H:%M:%S` "${PidFile}"
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Status()
|
|
||||||
{
|
|
||||||
local msg
|
|
||||||
local ProxyPID
|
|
||||||
|
|
||||||
if [ -f "${PidFile}" ]
|
|
||||||
then
|
|
||||||
msg=`GetResource "msgPidFileExists"`
|
|
||||||
printf "${msg}" "${PidFile}" `cat "${PidFile}"`
|
|
||||||
else
|
|
||||||
msg=`GetResource "msgPidFileNotExists"`
|
|
||||||
printf "${msg}" "${PidFile}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
ProxyPID=`Get3proxyPID`
|
|
||||||
|
|
||||||
if [ ! -z "${ProxyPID}" ]
|
|
||||||
then
|
|
||||||
msg=`GetResource "msg3proxyProcessDetected"`
|
|
||||||
printf "${msg}"
|
|
||||||
ps -ef | awk '$8 ~ /^3proxy/ { print "User: " $1 "\tPID: " $2 }'
|
|
||||||
else
|
|
||||||
msg=`GetResource "msg3proxyProcessNotDetected"`
|
|
||||||
printf "${msg}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
ShowHelp()
|
|
||||||
{
|
|
||||||
local msg
|
|
||||||
|
|
||||||
msg=`GetResource "msg3proxyHelp"`
|
|
||||||
printf "${msg}" "${ScriptFullName}" "${ScriptName}"
|
|
||||||
}
|
|
||||||
|
|
||||||
Get3proxyPID()
|
|
||||||
{
|
|
||||||
ps -ef | awk '$8 ~ /^3proxy/ { print $2; exit }'
|
|
||||||
}
|
|
||||||
|
|
||||||
LoadResources()
|
|
||||||
{
|
|
||||||
local StartRow
|
|
||||||
local EndRow
|
|
||||||
local LngLabel
|
|
||||||
local msgResourceErr="\aError! Script could not find resources!"
|
|
||||||
|
|
||||||
if env | grep -q 'LANG=ru_RU.UTF-8'
|
|
||||||
then
|
|
||||||
LngLabel="RU"
|
|
||||||
else
|
|
||||||
LngLabel="EN"
|
|
||||||
fi
|
|
||||||
|
|
||||||
StartRow=`cat "${ScriptFullName}" | awk "/^#Resources_${LngLabel}/ { print NR; exit}"`
|
|
||||||
|
|
||||||
if [ -z "${StartRow}" ]
|
|
||||||
then
|
|
||||||
echo -e "${msgResourceErr}"
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
|
|
||||||
EndRow=`cat "${ScriptFullName}" | awk "NR > ${StartRow} && /^#Resources_${LngLabel}_end/ { print NR; exit}"`
|
|
||||||
|
|
||||||
if [ -z "${EndRow}" ]
|
|
||||||
then
|
|
||||||
echo -e "${msgResourceErr}"
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
|
|
||||||
ResourcesData=`cat "${ScriptFullName}" | awk -v StartRow="${StartRow}" -v EndRow="${EndRow}" 'NR > StartRow && NR < EndRow { print $0 }'`
|
|
||||||
}
|
|
||||||
|
|
||||||
# $1 - Name of Resource
|
|
||||||
GetResource()
|
|
||||||
{
|
|
||||||
local StartRow
|
|
||||||
local EndRow
|
|
||||||
local msgResourceErr="\aError! Script could not find resource \"${1}\"!"
|
|
||||||
|
|
||||||
StartRow=`echo "${ResourcesData}" | awk "/^#Resource=${1}/ { print NR; exit}"`
|
|
||||||
|
|
||||||
if [ -z "${StartRow}" ]
|
|
||||||
then
|
|
||||||
echo -e "${msgResourceErr}" > /dev/stderr
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
|
|
||||||
EndRow=`echo "${ResourcesData}" | awk "NR > ${StartRow} && /^#endResource=${1}/ { print NR; exit}"`
|
|
||||||
|
|
||||||
if [ -z "${EndRow}" ]
|
|
||||||
then
|
|
||||||
echo -e "${msgResourceErr}" > /dev/stderr
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "${ResourcesData}" | awk -v StartRow="${StartRow}" -v EndRow="${EndRow}" 'NR > StartRow && NR < EndRow { print $0 }'
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
main $@
|
|
||||||
exit 0;
|
|
||||||
|
|
||||||
#Resources_EN
|
|
||||||
|
|
||||||
#Resource=msg3proxyHelp
|
|
||||||
Usage:
|
|
||||||
\t%s {start|stop|restart}
|
|
||||||
or
|
|
||||||
\tservice %s {start|stop|restart|status}\\n
|
|
||||||
#endResource=msg3proxyHelp
|
|
||||||
|
|
||||||
#Resource=msgConfigFileNotFound
|
|
||||||
\a3proxy configuration file - "%s" is not found!\\n
|
|
||||||
#endResource=msgConfigFileNotFound
|
|
||||||
|
|
||||||
#Resource=msgNoconfigDetected
|
|
||||||
Parameter "noconfig" found in 3proxy configuration file -
|
|
||||||
"% s" !
|
|
||||||
To run 3proxy this parameter should be disabled.\\n
|
|
||||||
#endResource=msgNoconfigDetected
|
|
||||||
|
|
||||||
#Resource=msg3proxyAlreadyRunning
|
|
||||||
\a3proxy already running PID: %s\\n
|
|
||||||
#endResource=msg3proxyAlreadyRunning
|
|
||||||
|
|
||||||
#Resource=msg3proxyStartProblems
|
|
||||||
With the start of 3proxy, something is wrong!
|
|
||||||
Use: service 3proxy status\\n
|
|
||||||
#endResource=msg3proxyStartProblems
|
|
||||||
|
|
||||||
#Resource=msg3proxyStartedSuccessfully
|
|
||||||
[ %s %s ] 3proxy started successfully! PID: %s\\n
|
|
||||||
#endResource=msg3proxyStartedSuccessfully
|
|
||||||
|
|
||||||
#Resource=msg3proxyStoppedSuccessfully
|
|
||||||
[ %s %s ] 3proxy stopped successfully!\\n
|
|
||||||
#endResource=msg3proxyStoppedSuccessfully
|
|
||||||
|
|
||||||
#Resource=msg3proxyProxyNotDetected
|
|
||||||
Process "3proxy" is not detected!\\n
|
|
||||||
#endResource=msg3proxyProxyNotDetected
|
|
||||||
|
|
||||||
#Resource=msg3proxyStoppedByKillall
|
|
||||||
[ %s %s ] Command "pkill -o 3proxy" was executed,
|
|
||||||
because process number was not stored in "%s",
|
|
||||||
but in fact 3proxy was runned!\\n
|
|
||||||
#endResource=msg3proxyStoppedByKillall
|
|
||||||
|
|
||||||
#Resource=msgPidFileExists
|
|
||||||
File "%s" exists. It contains the PID: %s\\n
|
|
||||||
#endResource=msgPidFileExists
|
|
||||||
|
|
||||||
#Resource=msgPidFileNotExists
|
|
||||||
File "%s" not found, that is, PID 3proxy was not stored!\\n
|
|
||||||
#endResource=msgPidFileNotExists
|
|
||||||
|
|
||||||
#Resource=msg3proxyProcessDetected
|
|
||||||
Process 3proxy detected:\\n
|
|
||||||
#endResource=msg3proxyProcessDetected
|
|
||||||
|
|
||||||
#Resource=msg3proxyProcessNotDetected
|
|
||||||
Processes of 3proxy is not found!\\n
|
|
||||||
#endResource=msg3proxyProcessNotDetected
|
|
||||||
|
|
||||||
#Resources_EN_end
|
|
||||||
|
|
||||||
|
|
||||||
#Resources_RU
|
|
||||||
|
|
||||||
#Resource=msg3proxyHelp
|
|
||||||
Используйте:
|
|
||||||
\t%s {start|stop|restart}
|
|
||||||
или
|
|
||||||
\tservice %s {start|stop|restart|status}\\n
|
|
||||||
#endResource=msg3proxyHelp
|
|
||||||
|
|
||||||
#Resource=msgConfigFileNotFound
|
|
||||||
\aФайл конфигурации 3proxy - "%s", не найден!\\n
|
|
||||||
#endResource=msgConfigFileNotFound
|
|
||||||
|
|
||||||
#Resource=msgNoconfigDetected
|
|
||||||
\aОбнаружен параметр "noconfig" в файле конфигурации 3proxy -
|
|
||||||
"%s" !
|
|
||||||
Для запуска 3proxy этот параметр нужно отключить.\\n
|
|
||||||
#endResource=msgNoconfigDetected
|
|
||||||
|
|
||||||
#Resource=msg3proxyAlreadyRunning
|
|
||||||
\a3proxy уже запущен PID: %s\\n
|
|
||||||
#endResource=msg3proxyAlreadyRunning
|
|
||||||
|
|
||||||
#Resource=msg3proxyStartProblems
|
|
||||||
\aСо стартом 3proxy, что-то не так!
|
|
||||||
Используйте: service 3proxy status\\n
|
|
||||||
#endResource=msg3proxyStartProblems
|
|
||||||
|
|
||||||
#Resource=msg3proxyStartedSuccessfully
|
|
||||||
[ %s %s ] 3proxy успешно стартовал! PID: %s\\n
|
|
||||||
#endResource=msg3proxyStartedSuccessfully
|
|
||||||
|
|
||||||
#Resource=msg3proxyStoppedSuccessfully
|
|
||||||
[ %s %s ] 3proxy успешно остановлен!\\n
|
|
||||||
#endResource=msg3proxyStoppedSuccessfully
|
|
||||||
|
|
||||||
#Resource=msg3proxyProxyNotDetected
|
|
||||||
Процесс "3proxy" не обнаружен!\\n
|
|
||||||
#endResource=msg3proxyProxyNotDetected
|
|
||||||
|
|
||||||
#Resource=msg3proxyStoppedByKillall
|
|
||||||
[ %s %s ] Выполнена команда "pkill -o 3proxy",
|
|
||||||
т.к. номер процесса не записан в "%s",
|
|
||||||
но по факту 3proxy рабатал!\\n
|
|
||||||
#endResource=msg3proxyStoppedByKillall
|
|
||||||
|
|
||||||
#Resource=msgPidFileExists
|
|
||||||
Файл "%s" есть. Он содержит PID: %s\\n
|
|
||||||
#endResource=msgPidFileExists
|
|
||||||
|
|
||||||
#Resource=msgPidFileNotExists
|
|
||||||
Файл "%s" не найден, т.е. PID 3proxy не был сохранён!\\n
|
|
||||||
#endResource=msgPidFileNotExists
|
|
||||||
|
|
||||||
#Resource=msg3proxyProcessDetected
|
|
||||||
Обнаружен процесс 3proxy:\\n
|
|
||||||
#endResource=msg3proxyProcessDetected
|
|
||||||
|
|
||||||
#Resource=msg3proxyProcessNotDetected
|
|
||||||
Процессов 3proxy не обнаружено!\\n
|
|
||||||
#endResource=msg3proxyProcessNotDetected
|
|
||||||
|
|
||||||
#Resources_RU_end
|
|
||||||
#endResource=InitScript
|
|
||||||
+16
-9
@@ -1,18 +1,23 @@
|
|||||||
|
#!/usr/local/etc/3proxy/bin/3proxy
|
||||||
|
daemon
|
||||||
|
pidfile /usr/local/etc/3proxy/3proxy.pid
|
||||||
nscache 65536
|
nscache 65536
|
||||||
nserver 8.8.8.8
|
nserver 127.0.0.1
|
||||||
nserver 8.8.4.4
|
|
||||||
|
|
||||||
config /conf/3proxy.cfg
|
config /usr/local/etc/3proxy/3proxy.cfg
|
||||||
monitor /conf/3proxy.cfg
|
monitor /usr/local/etc/3proxy/3proxy.cfg
|
||||||
|
monitor /usr/local/etc/3proxy/counters
|
||||||
|
monitor /usr/local/etc/3proxy/passwd
|
||||||
|
monitor /usr/local/etc/3proxy/bandlimiters
|
||||||
|
|
||||||
log /logs/3proxy-%y%m%d.log D
|
log /usr/local/etc/3proxy/log/log D
|
||||||
rotate 60
|
rotate 60
|
||||||
counter /count/3proxy.3cf
|
counter /usr/local/etc/3proxy/3proxy.3cf
|
||||||
|
|
||||||
users $/conf/passwd
|
users $/usr/local/etc/3proxy/passwd
|
||||||
|
|
||||||
include /conf/counters
|
include /usr/local/etc/3proxy/counters
|
||||||
include /conf/bandlimiters
|
include /usr/local/etc/3proxy/bandlimiters
|
||||||
|
|
||||||
auth strong
|
auth strong
|
||||||
deny * * 127.0.0.1
|
deny * * 127.0.0.1
|
||||||
@@ -23,3 +28,5 @@ flush
|
|||||||
allow admin
|
allow admin
|
||||||
|
|
||||||
admin -p8080
|
admin -p8080
|
||||||
|
|
||||||
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
#!/bin/3proxy
|
|
||||||
daemon
|
|
||||||
pidfile /var/run/3proxy/3proxy.pid
|
|
||||||
chroot /usr/local/3proxy proxy proxy
|
|
||||||
include /conf/3proxy.cfg
|
|
||||||
@@ -1,15 +1,10 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
if [ $4 ]; then
|
if [ $4 ]; then
|
||||||
echo bandlimin $4 $1 >> /etc/3proxy/conf/bandlimiters
|
echo $1:`/usr/local/etc/3proxy/bin/mycrypt $$ $2` >> /usr/local/etc/3proxy/passwd
|
||||||
fi
|
echo countin \"`wc -l /usr/local/etc/3proxy/counters|awk '{print $1}'`/$1\" D $3 $1 >> /usr/local/etc/3proxy/counters
|
||||||
if [ $3 ]; then
|
echo bandlimin $4 $1 >> /usr/local/etc/3proxy/bandlimiters
|
||||||
echo countin \"`wc -l /etc/3proxy/conf/counters|awk '{print $1}'`/$1\" D $3 $1 >> /etc/3proxy/conf/counters
|
|
||||||
fi
|
|
||||||
if [ $2 ]; then
|
|
||||||
echo $1:`/bin/mycrypt $$ $2` >> /etc/3proxy/conf/passwd
|
|
||||||
else
|
else
|
||||||
echo usage: $0 username password [day_limit] [bandwidth]
|
echo usage: $0 username password day_limit bandwidth
|
||||||
echo " "day_limit - traffic limit in MB per day
|
echo " "day_limit - traffic limit in MB per day
|
||||||
echo " "bandwidth - bandwith in bits per second 1048576 = 1Mbps
|
echo " "bandwidth - bandwith in bits per second 1048576 = 1Mbps
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
### BEGIN INIT INFO
|
|
||||||
# Provides: 3proxy
|
|
||||||
# Required-Start:
|
|
||||||
# Required-Stop:
|
|
||||||
# Should-Start:
|
|
||||||
# Should-Stop:
|
|
||||||
# Default-Start: 2 3 4 5
|
|
||||||
# Default-Stop: 0 1 6
|
|
||||||
# Short-Description: Start/stop 3proxy
|
|
||||||
# Description: Start/stop 3proxy, tiny proxy server
|
|
||||||
### END INIT INFO
|
|
||||||
# chkconfig: 2345 20 80
|
|
||||||
# description: 3proxy tiny proxy server
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
start)
|
|
||||||
echo Starting 3Proxy
|
|
||||||
|
|
||||||
/bin/mkdir -p /var/run/3proxy
|
|
||||||
/bin/3proxy /etc/3proxy/3proxy.cfg
|
|
||||||
|
|
||||||
RETVAL=$?
|
|
||||||
echo
|
|
||||||
[ $RETVAL ]
|
|
||||||
;;
|
|
||||||
|
|
||||||
stop)
|
|
||||||
echo Stopping 3Proxy
|
|
||||||
if [ -f /var/run/3proxy/3proxy.pid ]; then
|
|
||||||
/bin/kill `cat /var/run/3proxy/3proxy.pid`
|
|
||||||
else
|
|
||||||
/usr/bin/killall 3proxy
|
|
||||||
fi
|
|
||||||
|
|
||||||
RETVAL=$?
|
|
||||||
echo
|
|
||||||
[ $RETVAL ]
|
|
||||||
;;
|
|
||||||
|
|
||||||
restart|reload)
|
|
||||||
echo Reloading 3Proxy
|
|
||||||
if [ -f /var/run/3proxy/3proxy.pid ]; then
|
|
||||||
/bin/kill -s USR1 `cat /var/run/3proxy/3proxy.pid`
|
|
||||||
else
|
|
||||||
/usr/bin/killall -s USR1 3proxy
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
|
|
||||||
|
|
||||||
*)
|
|
||||||
echo Usage: $0 "{start|stop|restart}"
|
|
||||||
exit 1
|
|
||||||
esac
|
|
||||||
exit 0
|
|
||||||
|
|
||||||
@@ -3,8 +3,8 @@ cd ..
|
|||||||
cp Makefile.unix Makefile
|
cp Makefile.unix Makefile
|
||||||
make
|
make
|
||||||
if [ ! -d /usr/local/etc/3proxy/bin ]; then mkdir -p /usr/local/etc/3proxy/bin/; fi
|
if [ ! -d /usr/local/etc/3proxy/bin ]; then mkdir -p /usr/local/etc/3proxy/bin/; fi
|
||||||
install bin/3proxy /usr/local/bin/3proxy
|
install src/3proxy /usr/local/etc/3proxy/bin/3proxy
|
||||||
install bin/mycrypt /usr/local/bin/mycrypt
|
install src/mycrypt /usr/local/etc/3proxy/bin/mycrypt
|
||||||
install scripts/rc.d/proxy.sh /usr/local/etc/rc.d/proxy.sh
|
install scripts/rc.d/proxy.sh /usr/local/etc/rc.d/proxy.sh
|
||||||
install scripts/add3proxyuser.sh /usr/local/etc/3proxy/bin/
|
install scripts/add3proxyuser.sh /usr/local/etc/3proxy/bin/
|
||||||
if [ -s /usr/local/etc/3proxy/3proxy.cfg ]; then
|
if [ -s /usr/local/etc/3proxy/3proxy.cfg ]; then
|
||||||
@@ -19,4 +19,3 @@ else
|
|||||||
touch /usr/local/etc/3proxy/bandlimiters
|
touch /usr/local/etc/3proxy/bandlimiters
|
||||||
echo Run /usr/local/etc/3proxy/bin/add3proxyuser.sh to add \'admin\' user
|
echo Run /usr/local/etc/3proxy/bin/add3proxyuser.sh to add \'admin\' user
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# chkconfig: 2345 20 80
|
||||||
|
# description: 3proxy tiny proxy server
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
echo Starting 3Proxy
|
||||||
|
|
||||||
|
/usr/local/etc/3proxy/bin/3proxy /usr/local/etc/3proxy/3proxy.cfg
|
||||||
|
|
||||||
|
RETVAL=$?
|
||||||
|
echo
|
||||||
|
[ $RETVAL ]
|
||||||
|
;;
|
||||||
|
|
||||||
|
stop)
|
||||||
|
echo Stopping 3Proxy
|
||||||
|
if [ /usr/local/etc/3proxy/3proxy.pid ]; then
|
||||||
|
/bin/kill `cat /usr/local/etc/3proxy/3proxy.pid`
|
||||||
|
else
|
||||||
|
/usr/bin/killall 3proxy
|
||||||
|
fi
|
||||||
|
|
||||||
|
RETVAL=$?
|
||||||
|
echo
|
||||||
|
[ $RETVAL ]
|
||||||
|
;;
|
||||||
|
|
||||||
|
restart|reload)
|
||||||
|
echo Reloading 3Proxy
|
||||||
|
if [ /usr/local/etc/3proxy/3proxy.pid ]; then
|
||||||
|
/bin/kill -s USR1 `cat /usr/local/etc/3proxy/3proxy.pid`
|
||||||
|
else
|
||||||
|
/usr/bin/killall -s USR1 3proxy
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo Usage: $0 "{start|stop|restart}"
|
||||||
|
exit 1
|
||||||
|
esac
|
||||||
|
exit 0
|
||||||
+1527
-37
File diff suppressed because it is too large.
Load diff
+58
-27
@@ -1,8 +1,14 @@
|
|||||||
|
#$Id: Makefile.inc,v 1.19 2008/12/10 13:12:10 vlad Exp $
|
||||||
#
|
#
|
||||||
# 3 proxy common Makefile
|
# 3 proxy common Makefile
|
||||||
#
|
#
|
||||||
|
|
||||||
all: $(BUILDDIR)3proxy$(EXESUFFICS) $(BUILDDIR)mycrypt$(EXESUFFICS) $(BUILDDIR)pop3p$(EXESUFFICS) $(BUILDDIR)smtpp$(EXESUFFICS) $(BUILDDIR)ftppr$(EXESUFFICS) $(BUILDDIR)tcppm$(EXESUFFICS) $(BUILDDIR)udppm$(EXESUFFICS) $(BUILDDIR)socks$(EXESUFFICS) $(BUILDDIR)proxy$(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:
|
||||||
|
-cd .. && $(TYPECOMMAND) copying
|
||||||
|
$(PREMAKE)
|
||||||
|
|
||||||
|
|
||||||
sockmap$(OBJSUFFICS): sockmap.c proxy.h structures.h
|
sockmap$(OBJSUFFICS): sockmap.c proxy.h structures.h
|
||||||
@@ -11,6 +17,9 @@ sockmap$(OBJSUFFICS): sockmap.c proxy.h structures.h
|
|||||||
common$(OBJSUFFICS): common.c proxy.h structures.h
|
common$(OBJSUFFICS): common.c proxy.h structures.h
|
||||||
$(CC) $(CFLAGS) common.c
|
$(CC) $(CFLAGS) common.c
|
||||||
|
|
||||||
|
myalloc$(OBJSUFFICS): myalloc.c proxy.h structures.h
|
||||||
|
$(CC) $(CFLAGS) myalloc.c
|
||||||
|
|
||||||
plugins$(OBJSUFFICS): plugins.c proxy.h structures.h
|
plugins$(OBJSUFFICS): plugins.c proxy.h structures.h
|
||||||
$(CC) $(CFLAGS) plugins.c
|
$(CC) $(CFLAGS) plugins.c
|
||||||
|
|
||||||
@@ -41,6 +50,12 @@ ftppr$(OBJSUFFICS): ftppr.c proxy.h structures.h proxymain.c
|
|||||||
tcppm$(OBJSUFFICS): tcppm.c proxy.h structures.h proxymain.c
|
tcppm$(OBJSUFFICS): tcppm.c proxy.h structures.h proxymain.c
|
||||||
$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)PORTMAP tcppm.c
|
$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)PORTMAP tcppm.c
|
||||||
|
|
||||||
|
icqpr$(OBJSUFFICS): icqpr.c proxy.h structures.h proxymain.c
|
||||||
|
$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)PORTMAP icqpr.c
|
||||||
|
|
||||||
|
msnpr$(OBJSUFFICS): msnpr.c proxy.h structures.h proxymain.c
|
||||||
|
$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)PORTMAP msnpr.c
|
||||||
|
|
||||||
socks$(OBJSUFFICS): socks.c proxy.h structures.h proxymain.c
|
socks$(OBJSUFFICS): socks.c proxy.h structures.h proxymain.c
|
||||||
$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)NOPORTMAP socks.c
|
$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)NOPORTMAP socks.c
|
||||||
|
|
||||||
@@ -50,26 +65,32 @@ udppm$(OBJSUFFICS): udppm.c proxy.h structures.h proxymain.c
|
|||||||
3proxy$(OBJSUFFICS): 3proxy.c proxy.h structures.h
|
3proxy$(OBJSUFFICS): 3proxy.c proxy.h structures.h
|
||||||
$(CC) $(CFLAGS) 3proxy.c
|
$(CC) $(CFLAGS) 3proxy.c
|
||||||
|
|
||||||
$(BUILDDIR)proxy$(EXESUFFICS): sockmap$(OBJSUFFICS) proxy$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) $(COMPATLIBS)
|
$(BUILDDIR)proxy$(EXESUFFICS): sockmap$(OBJSUFFICS) proxy$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) $(COMPATLIBS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)proxy$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) proxy$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) log$(OBJSUFFICS) common$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)proxy$(EXESUFFICS) $(LDFLAGS) $(VERFILE) sockmap$(OBJSUFFICS) proxy$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
||||||
|
|
||||||
$(BUILDDIR)pop3p$(EXESUFFICS): sockmap$(OBJSUFFICS) pop3p$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS) $(COMPATLIBS)
|
$(BUILDDIR)pop3p$(EXESUFFICS): sockmap$(OBJSUFFICS) pop3p$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)pop3p$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) pop3p$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) log$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)pop3p$(EXESUFFICS) $(LDFLAGS) $(VERFILE) sockmap$(OBJSUFFICS) pop3p$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
||||||
|
|
||||||
$(BUILDDIR)smtpp$(EXESUFFICS): sockmap$(OBJSUFFICS) smtpp$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS) base64$(OBJSUFFICS) $(COMPATLIBS)
|
$(BUILDDIR)smtpp$(EXESUFFICS): sockmap$(OBJSUFFICS) smtpp$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) base64$(OBJSUFFICS) $(COMPATLIBS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)smtpp$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) smtpp$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) base64$(OBJSUFFICS) log$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)smtpp$(EXESUFFICS) $(LDFLAGS) $(VERFILE) sockmap$(OBJSUFFICS) smtpp$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) base64$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
||||||
|
|
||||||
$(BUILDDIR)ftppr$(EXESUFFICS): sockmap$(OBJSUFFICS) ftppr$(OBJSUFFICS) ftp$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS) $(COMPATLIBS)
|
$(BUILDDIR)ftppr$(EXESUFFICS): sockmap$(OBJSUFFICS) ftppr$(OBJSUFFICS) ftp$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)ftppr$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) ftppr$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS) ftp$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)ftppr$(EXESUFFICS) $(LDFLAGS) $(VERFILE) sockmap$(OBJSUFFICS) ftppr$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) ftp$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
||||||
|
|
||||||
$(BUILDDIR)socks$(EXESUFFICS): sockmap$(OBJSUFFICS) socks$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS)
|
$(BUILDDIR)socks$(EXESUFFICS): sockmap$(OBJSUFFICS) socks$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)socks$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) socks$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) log$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)socks$(EXESUFFICS) $(LDFLAGS) $(VERFILE) sockmap$(OBJSUFFICS) socks$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
|
||||||
|
|
||||||
$(BUILDDIR)tcppm$(EXESUFFICS): sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) tcppm$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS)
|
$(BUILDDIR)tcppm$(EXESUFFICS): sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) tcppm$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)tcppm$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) tcppm$(OBJSUFFICS) log$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)tcppm$(EXESUFFICS) $(LDFLAGS) $(VERFILE) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) tcppm$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
|
||||||
|
|
||||||
$(BUILDDIR)udppm$(EXESUFFICS): sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) udppm$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS)
|
$(BUILDDIR)icqpr$(EXESUFFICS): sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) icqpr$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)udppm$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) udppm$(OBJSUFFICS) log$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)icqpr$(EXESUFFICS) $(LDFLAGS) $(VERFILE) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) icqpr$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
|
||||||
|
|
||||||
|
$(BUILDDIR)msnpr$(EXESUFFICS): sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) msnpr$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS)
|
||||||
|
$(LN) $(LNOUT)$(BUILDDIR)msnpr$(EXESUFFICS) $(LDFLAGS) $(VERFILE) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) msnpr$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
|
||||||
|
|
||||||
|
$(BUILDDIR)udppm$(EXESUFFICS): sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) udppm$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS)
|
||||||
|
$(LN) $(LNOUT)$(BUILDDIR)udppm$(EXESUFFICS) $(LDFLAGS) $(VERFILE) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) udppm$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
|
||||||
|
|
||||||
mainfunc$(OBJSUFFICS): proxy.h structures.h proxymain.c
|
mainfunc$(OBJSUFFICS): proxy.h structures.h proxymain.c
|
||||||
$(CC) $(COUT)mainfunc$(OBJSUFFICS) $(CFLAGS) $(DEFINEOPTION)MODULEMAINFUNC=mainfunc proxymain.c
|
$(CC) $(COUT)mainfunc$(OBJSUFFICS) $(CFLAGS) $(DEFINEOPTION)MODULEMAINFUNC=mainfunc proxymain.c
|
||||||
@@ -91,6 +112,12 @@ srvftppr$(OBJSUFFICS): ftppr.c proxy.h structures.h
|
|||||||
srvtcppm$(OBJSUFFICS): tcppm.c proxy.h structures.h
|
srvtcppm$(OBJSUFFICS): tcppm.c proxy.h structures.h
|
||||||
$(CC) $(COUT)srvtcppm$(OBJSUFFICS) $(CFLAGS) tcppm.c
|
$(CC) $(COUT)srvtcppm$(OBJSUFFICS) $(CFLAGS) tcppm.c
|
||||||
|
|
||||||
|
srvicqpr$(OBJSUFFICS): icqpr.c proxy.h structures.h
|
||||||
|
$(CC) $(COUT)srvicqpr$(OBJSUFFICS) $(CFLAGS) icqpr.c
|
||||||
|
|
||||||
|
srvmsnpr$(OBJSUFFICS): msnpr.c proxy.h structures.h
|
||||||
|
$(CC) $(COUT)srvmsnpr$(OBJSUFFICS) $(CFLAGS) msnpr.c
|
||||||
|
|
||||||
srvsocks$(OBJSUFFICS): socks.c proxy.h structures.h
|
srvsocks$(OBJSUFFICS): socks.c proxy.h structures.h
|
||||||
$(CC) $(COUT)srvsocks$(OBJSUFFICS) $(CFLAGS) socks.c
|
$(CC) $(COUT)srvsocks$(OBJSUFFICS) $(CFLAGS) socks.c
|
||||||
|
|
||||||
@@ -106,26 +133,30 @@ srvdnspr$(OBJSUFFICS): dnspr.c proxy.h structures.h
|
|||||||
auth$(OBJSUFFICS): auth.c proxy.h structures.h
|
auth$(OBJSUFFICS): auth.c proxy.h structures.h
|
||||||
$(CC) $(COUT)auth$(OBJSUFFICS) $(CFLAGS) auth.c
|
$(CC) $(COUT)auth$(OBJSUFFICS) $(CFLAGS) auth.c
|
||||||
|
|
||||||
authradius$(OBJSUFFICS): authradius.c proxy.h structures.h
|
|
||||||
$(CC) $(COUT)authradius$(OBJSUFFICS) $(CFLAGS) authradius.c
|
|
||||||
|
|
||||||
conf$(OBJSUFFICS): conf.c proxy.h structures.h
|
|
||||||
$(CC) $(COUT)conf$(OBJSUFFICS) $(CFLAGS) conf.c
|
|
||||||
|
|
||||||
log$(OBJSUFFICS): log.c proxy.h structures.h
|
|
||||||
$(CC) $(COUT)log$(OBJSUFFICS) $(CFLAGS) log.c
|
|
||||||
|
|
||||||
datatypes$(OBJSUFFICS): datatypes.c proxy.h structures.h
|
datatypes$(OBJSUFFICS): datatypes.c proxy.h structures.h
|
||||||
$(CC) $(COUT)datatypes$(OBJSUFFICS) $(CFLAGS) datatypes.c
|
$(CC) $(COUT)datatypes$(OBJSUFFICS) $(CFLAGS) datatypes.c
|
||||||
|
|
||||||
mycrypt$(OBJSUFFICS): mycrypt.c
|
mycrypt$(OBJSUFFICS): mycrypt.c
|
||||||
$(CC) $(COUT)mycrypt$(OBJSUFFICS) $(CFLAGS) mycrypt.c
|
$(CC) $(COUT)mycrypt$(OBJSUFFICS) $(CFLAGS) mycrypt.c
|
||||||
|
|
||||||
|
dighosts$(OBJSUFFICS): dighosts.c
|
||||||
|
$(CC) $(COUT)dighosts$(OBJSUFFICS) $(CFLAGS) dighosts.c
|
||||||
|
|
||||||
|
$(BUILDDIR)dighosts$(EXESUFFICS): dighosts$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS)
|
||||||
|
$(LN) $(LNOUT)$(BUILDDIR)dighosts$(EXESUFFICS) $(LDFLAGS) $(VERFILE) dighosts$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
||||||
|
|
||||||
|
countersutil$(OBJSUFFICS): countersutil.c
|
||||||
|
$(CC) $(COUT)countersutil$(OBJSUFFICS) $(CFLAGS) countersutil.c
|
||||||
|
|
||||||
|
$(BUILDDIR)countersutil$(EXESUFFICS): countersutil$(OBJSUFFICS) $(COMPATLIBS)
|
||||||
|
$(LN) $(LNOUT)$(BUILDDIR)countersutil$(EXESUFFICS) $(LDFLAGS) $(VERFILE) countersutil$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
||||||
|
|
||||||
|
|
||||||
mycryptmain$(OBJSUFFICS): mycrypt.c
|
mycryptmain$(OBJSUFFICS): mycrypt.c
|
||||||
$(CC) $(COUT)mycryptmain$(OBJSUFFICS) $(CFLAGS) $(DEFINEOPTION)WITHMAIN mycrypt.c
|
$(CC) $(COUT)mycryptmain$(OBJSUFFICS) $(CFLAGS) $(DEFINEOPTION)WITHMAIN mycrypt.c
|
||||||
|
|
||||||
$(BUILDDIR)mycrypt$(EXESUFFICS): md4$(OBJSUFFICS) md5$(OBJSUFFICS) mycryptmain$(OBJSUFFICS) base64$(OBJSUFFICS)
|
$(BUILDDIR)mycrypt$(EXESUFFICS): md4$(OBJSUFFICS) md5$(OBJSUFFICS) mycryptmain$(OBJSUFFICS) base64$(OBJSUFFICS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)mycrypt$(EXESUFFICS) $(LDFLAGS) md4$(OBJSUFFICS) md5$(OBJSUFFICS) base64$(OBJSUFFICS) mycryptmain$(OBJSUFFICS)
|
$(LN) $(LNOUT)$(BUILDDIR)mycrypt$(EXESUFFICS) $(VERFILE) $(LDFLAGS) md4$(OBJSUFFICS) md5$(OBJSUFFICS) base64$(OBJSUFFICS) mycryptmain$(OBJSUFFICS)
|
||||||
|
|
||||||
|
|
||||||
md4$(OBJSUFFICS): libs/md4.h libs/md4.c
|
md4$(OBJSUFFICS): libs/md4.h libs/md4.c
|
||||||
@@ -143,8 +174,8 @@ ntlm$(OBJSUFFICS): ntlm.c
|
|||||||
stringtable$(OBJSUFFICS): stringtable.c
|
stringtable$(OBJSUFFICS): stringtable.c
|
||||||
$(CC) $(COUT)stringtable$(OBJSUFFICS) $(CFLAGS) stringtable.c
|
$(CC) $(COUT)stringtable$(OBJSUFFICS) $(CFLAGS) stringtable.c
|
||||||
|
|
||||||
$(BUILDDIR)3proxy$(EXESUFFICS): 3proxy$(OBJSUFFICS) mainfunc$(OBJSUFFICS) srvproxy$(OBJSUFFICS) srvpop3p$(OBJSUFFICS) srvsmtpp$(OBJSUFFICS) srvftppr$(OBJSUFFICS) srvsocks$(OBJSUFFICS) srvtcppm$(OBJSUFFICS) srvudppm$(OBJSUFFICS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) auth$(OBJSUFFICS) authradius$(OBJSUFFICS) conf$(OBJSUFFICS) log$(OBJSUFFICS) datatypes$(OBJSUFFICS) md4$(OBJSUFFICS) md5$(OBJSUFFICS) mycrypt$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) smbdes$(OBJSUFFICS) ntlm$(OBJSUFFICS) stringtable$(OBJSUFFICS) srvwebadmin$(OBJSUFFICS) srvdnspr$(OBJSUFFICS) plugins$(OBJSUFFICS) $(COMPATLIBS)
|
$(BUILDDIR)3proxy$(EXESUFFICS): 3proxy$(OBJSUFFICS) mainfunc$(OBJSUFFICS) srvproxy$(OBJSUFFICS) srvpop3p$(OBJSUFFICS) srvsmtpp$(OBJSUFFICS) srvftppr$(OBJSUFFICS) srvsocks$(OBJSUFFICS) srvtcppm$(OBJSUFFICS) srvicqpr$(OBJSUFFICS) srvmsnpr$(OBJSUFFICS) srvudppm$(OBJSUFFICS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) auth$(OBJSUFFICS) datatypes$(OBJSUFFICS) md4$(OBJSUFFICS) md5$(OBJSUFFICS) mycrypt$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) smbdes$(OBJSUFFICS) ntlm$(OBJSUFFICS) stringtable$(OBJSUFFICS) srvwebadmin$(OBJSUFFICS) srvdnspr$(OBJSUFFICS) plugins$(OBJSUFFICS) $(COMPATLIBS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)3proxy$(EXESUFFICS) $(LDFLAGS) $(VERFILE) 3proxy$(OBJSUFFICS) mainfunc$(OBJSUFFICS) auth$(OBJSUFFICS) authradius$(OBJSUFFICS) conf$(OBJSUFFICS) datatypes$(OBJSUFFICS) srvproxy$(OBJSUFFICS) srvpop3p$(OBJSUFFICS) srvsmtpp$(OBJSUFFICS) srvftppr$(OBJSUFFICS) srvsocks$(OBJSUFFICS) srvtcppm$(OBJSUFFICS) srvudppm$(OBJSUFFICS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS) mycrypt$(OBJSUFFICS) md5$(OBJSUFFICS) md4$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) smbdes$(OBJSUFFICS) ntlm$(OBJSUFFICS) stringtable$(OBJSUFFICS) srvwebadmin$(OBJSUFFICS) srvdnspr$(OBJSUFFICS) plugins$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)3proxy$(EXESUFFICS) $(LDFLAGS) $(VERFILE) 3proxy$(OBJSUFFICS) mainfunc$(OBJSUFFICS) auth$(OBJSUFFICS) datatypes$(OBJSUFFICS) srvproxy$(OBJSUFFICS) srvpop3p$(OBJSUFFICS) srvsmtpp$(OBJSUFFICS) srvftppr$(OBJSUFFICS) srvsocks$(OBJSUFFICS) srvtcppm$(OBJSUFFICS) srvicqpr$(OBJSUFFICS) srvmsnpr$(OBJSUFFICS) srvudppm$(OBJSUFFICS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) mycrypt$(OBJSUFFICS) md5$(OBJSUFFICS) md4$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) smbdes$(OBJSUFFICS) ntlm$(OBJSUFFICS) stringtable$(OBJSUFFICS) srvwebadmin$(OBJSUFFICS) srvdnspr$(OBJSUFFICS) plugins$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@$(REMOVECOMMAND) *$(OBJSUFFICS) $(COMPFILES)
|
@$(REMOVECOMMAND) *$(OBJSUFFICS) $(COMPFILES)
|
||||||
+320
-493
File diff suppressed because it is too large.
Load diff
@@ -1,672 +0,0 @@
|
|||||||
/*
|
|
||||||
3APA3A simpliest proxy server
|
|
||||||
(c) 2000-2016 by Vladimir Dubrovin <3proxy@3proxy.ru>
|
|
||||||
|
|
||||||
please read License Agreement
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef NORADIUS
|
|
||||||
#include "proxy.h"
|
|
||||||
#include "libs/md5.h"
|
|
||||||
|
|
||||||
#define AUTH_VECTOR_LEN 16
|
|
||||||
#define MAX_STRING_LEN 254
|
|
||||||
#define PW_AUTH_UDP_PORT 1645
|
|
||||||
|
|
||||||
#define PW_TYPE_STRING 0
|
|
||||||
#define PW_TYPE_INTEGER 1
|
|
||||||
#define PW_TYPE_IPADDR 2
|
|
||||||
#define PW_TYPE_DATE 3
|
|
||||||
#define PW_TYPE_ABINARY 4
|
|
||||||
#define PW_TYPE_OCTETS 5
|
|
||||||
|
|
||||||
#define PW_AUTHENTICATION_REQUEST 1
|
|
||||||
#define PW_AUTHENTICATION_ACK 2
|
|
||||||
#define PW_AUTHENTICATION_REJECT 3
|
|
||||||
#define PW_ACCOUNTING_REQUEST 4
|
|
||||||
#define PW_ACCOUNTING_RESPONSE 5
|
|
||||||
#define PW_ACCOUNTING_STATUS 6
|
|
||||||
#define PW_PASSWORD_REQUEST 7
|
|
||||||
|
|
||||||
|
|
||||||
#define PW_USER_NAME 1
|
|
||||||
#define PW_PASSWORD 2
|
|
||||||
#define PW_CHAP_PASSWORD 3
|
|
||||||
#define PW_NAS_IP_ADDRESS 4
|
|
||||||
#define PW_NAS_PORT_ID 5
|
|
||||||
#define PW_SERVICE_TYPE 6
|
|
||||||
#define PW_FRAMED_PROTOCOL 7
|
|
||||||
#define PW_FRAMED_IP_ADDRESS 8
|
|
||||||
#define PW_FRAMED_IP_NETMASK 9
|
|
||||||
#define PW_FRAMED_ROUTING 10
|
|
||||||
#define PW_FILTER_ID 11
|
|
||||||
#define PW_FRAMED_MTU 12
|
|
||||||
#define PW_FRAMED_COMPRESSION 13
|
|
||||||
#define PW_LOGIN_IP_HOST 14
|
|
||||||
#define PW_LOGIN_SERVICE 15
|
|
||||||
#define PW_LOGIN_TCP_PORT 16
|
|
||||||
#define PW_OLD_PASSWORD 17
|
|
||||||
#define PW_REPLY_MESSAGE 18
|
|
||||||
#define PW_CALLBACK_NUMBER 19
|
|
||||||
#define PW_CALLBACK_ID 20
|
|
||||||
#define PW_FRAMED_ROUTE 22
|
|
||||||
#define PW_FRAMED_IPXNET 23
|
|
||||||
#define PW_STATE 24
|
|
||||||
#define PW_CLASS 25
|
|
||||||
#define PW_VENDOR_SPECIFIC 26
|
|
||||||
#define PW_SESSION_TIMEOUT 27
|
|
||||||
#define PW_IDLE_TIMEOUT 28
|
|
||||||
#define PW_CALLED_STATION_ID 30
|
|
||||||
#define PW_CALLING_STATION_ID 31
|
|
||||||
#define PW_NAS_IDENTIFIER 32
|
|
||||||
#define PW_PROXY_STATE 33
|
|
||||||
|
|
||||||
#define PW_ACCT_STATUS_TYPE 40
|
|
||||||
#define PW_ACCT_DELAY_TIME 41
|
|
||||||
#define PW_ACCT_INPUT_OCTETS 42
|
|
||||||
#define PW_ACCT_OUTPUT_OCTETS 43
|
|
||||||
#define PW_ACCT_SESSION_ID 44
|
|
||||||
#define PW_ACCT_AUTHENTIC 45
|
|
||||||
#define PW_ACCT_SESSION_TIME 46
|
|
||||||
#define PW_ACCT_INPUT_PACKETS 47
|
|
||||||
#define PW_ACCT_OUTPUT_PACKETS 48
|
|
||||||
#define PW_ACCT_TERMINATE_CAUSE 49
|
|
||||||
|
|
||||||
#define PW_EVENT_TIMESTAMP 55
|
|
||||||
|
|
||||||
#define PW_CHAP_CHALLENGE 60
|
|
||||||
#define PW_NAS_PORT_TYPE 61
|
|
||||||
#define PW_PORT_LIMIT 62
|
|
||||||
|
|
||||||
#define PW_ARAP_PASSWORD 70
|
|
||||||
#define PW_ARAP_FEATURES 71
|
|
||||||
#define PW_ARAP_ZONE_ACCESS 72
|
|
||||||
#define PW_ARAP_SECURITY 73
|
|
||||||
#define PW_ARAP_SECURITY_DATA 74
|
|
||||||
#define PW_PASSWORD_RETRY 75
|
|
||||||
#define PW_PROMPT 76
|
|
||||||
#define PW_CONNECT_INFO 77
|
|
||||||
#define PW_CONFIGURATION_TOKEN 78
|
|
||||||
#define PW_EAP_MESSAGE 79
|
|
||||||
#define PW_MESSAGE_AUTHENTICATOR 80
|
|
||||||
|
|
||||||
#define PW_ARAP_CHALLENGE_RESPONSE 84
|
|
||||||
#define PW_NAS_PORT_ID_STRING 87
|
|
||||||
#define PW_FRAMED_POOL 89
|
|
||||||
|
|
||||||
#define PW_NAS_IPV6_ADDRESS 95
|
|
||||||
#define PW_LOGIN_IPV6_HOST 98
|
|
||||||
#define PW_FRAMED_IPV6_ADDRESS 168
|
|
||||||
|
|
||||||
#define PW_FALL_THROUGH 500
|
|
||||||
#define PW_ADD_PORT_TO_IP_ADDRESS 501
|
|
||||||
#define PW_EXEC_PROGRAM 502
|
|
||||||
#define PW_EXEC_PROGRAM_WAIT 503
|
|
||||||
|
|
||||||
#define PW_AUTHTYPE 1000
|
|
||||||
#define PW_PREFIX 1003
|
|
||||||
#define PW_SUFFIX 1004
|
|
||||||
#define PW_GROUP 1005
|
|
||||||
#define PW_CRYPT_PASSWORD 1006
|
|
||||||
#define PW_CONNECT_RATE 1007
|
|
||||||
#define PW_ADD_PREFIX 1008
|
|
||||||
#define PW_ADD_SUFFIX 1009
|
|
||||||
#define PW_EXPIRATION 1010
|
|
||||||
#define PW_USER_CATEGORY 1029
|
|
||||||
#define PW_GROUP_NAME 1030
|
|
||||||
#define PW_HUNTGROUP_NAME 1031
|
|
||||||
#define PW_SIMULTANEOUS_USE 1034
|
|
||||||
#define PW_STRIP_USER_NAME 1035
|
|
||||||
#define PW_HINT 1040
|
|
||||||
#define PAM_AUTH_ATTR 1041
|
|
||||||
#define PW_LOGIN_TIME 1042
|
|
||||||
#define PW_STRIPPED_USER_NAME 1043
|
|
||||||
#define PW_CURRENT_TIME 1044
|
|
||||||
#define PW_REALM 1045
|
|
||||||
#define PW_NO_SUCH_ATTRIBUTE 1046
|
|
||||||
#define PW_PACKET_TYPE 1047
|
|
||||||
#define PW_PROXY_TO_REALM 1048
|
|
||||||
#define PW_REPLICATE_TO_REALM 1049
|
|
||||||
#define PW_ACCT_SESSION_START_TIME 1050
|
|
||||||
#define PW_ACCT_UNIQUE_SESSION_ID 1051
|
|
||||||
#define PW_CLIENT_IP_ADDRESS 1052
|
|
||||||
#define LDAP_USERDN 1053
|
|
||||||
#define PW_NS_MTA_MD5_PASSWORD 1054
|
|
||||||
#define PW_SQL_USER_NAME 1055
|
|
||||||
|
|
||||||
#define PW_LOGIN_USER 1
|
|
||||||
#define PW_FRAMED_USER 2
|
|
||||||
#define PW_CALLBACK_LOGIN_USER 3
|
|
||||||
#define PW_CALLBACK_FRAMED_USER 4
|
|
||||||
#define PW_OUTBOUND_USER 5
|
|
||||||
#define PW_ADMINISTRATIVE_USER 6
|
|
||||||
#define PW_NAS_PROMPT_USER 7
|
|
||||||
#define PW_AUTHENTICATE_ONLY 8
|
|
||||||
#define PW_CALLBACK_NAS_PROMPT 9
|
|
||||||
|
|
||||||
#define PW_NAS_PORT_ASYNC 0
|
|
||||||
#define PW_NAS_PORT_SYNC 1
|
|
||||||
#define PW_NAS_PORT_ISDN 2
|
|
||||||
#define PW_NAS_PORT_ISDN_V120 3
|
|
||||||
#define PW_NAS_PORT_ISDN_V110 4
|
|
||||||
#define PW_NAS_PORT_VIRTUAL 5
|
|
||||||
|
|
||||||
#define PW_STATUS_START 1
|
|
||||||
#define PW_STATUS_STOP 2
|
|
||||||
#define PW_STATUS_ALIVE 3
|
|
||||||
#define PW_STATUS_ACCOUNTING_ON 7
|
|
||||||
#define PW_STATUS_ACCOUNTING_OFF 8
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct radserver radiuslist[MAXRADIUS];
|
|
||||||
|
|
||||||
static int ntry = 0;
|
|
||||||
int nradservers = 0;
|
|
||||||
char radiussecret[64]="";
|
|
||||||
|
|
||||||
pthread_mutex_t rad_mutex;
|
|
||||||
|
|
||||||
void md5_calc(unsigned char *output, unsigned char *input,
|
|
||||||
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,
|
|
||||||
unsigned int inlen)
|
|
||||||
{
|
|
||||||
MD5_CTX context;
|
|
||||||
|
|
||||||
MD5Init(&context);
|
|
||||||
MD5Update(&context, input, inlen);
|
|
||||||
MD5Final(output, &context);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static uint8_t random_vector_pool[AUTH_VECTOR_LEN*2];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int calc_replydigest(char *packet, char *original, const char *secret, int len)
|
|
||||||
{
|
|
||||||
int secretlen;
|
|
||||||
uint8_t calc_digest[AUTH_VECTOR_LEN];
|
|
||||||
uint8_t calc_vector[AUTH_VECTOR_LEN];
|
|
||||||
|
|
||||||
memcpy(calc_vector, packet + 4, AUTH_VECTOR_LEN);
|
|
||||||
memcpy(packet + 4, original, AUTH_VECTOR_LEN);
|
|
||||||
secretlen = strlen(secret);
|
|
||||||
memcpy(packet + len, secret, secretlen);
|
|
||||||
md5_calc(calc_digest, (u_char *)packet, len + secretlen);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Return 0 if OK, 2 if not OK.
|
|
||||||
*/
|
|
||||||
return memcmp(calc_vector, calc_digest, AUTH_VECTOR_LEN) ? 2 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define AUTH_PASS_LEN (16)
|
|
||||||
int rad_pwencode(char *passwd, int *pwlen, const char *secret, const char *vector)
|
|
||||||
{
|
|
||||||
uint8_t buffer[AUTH_VECTOR_LEN + MAX_STRING_LEN + 1];
|
|
||||||
char digest[AUTH_VECTOR_LEN];
|
|
||||||
int i, n, secretlen;
|
|
||||||
int len;
|
|
||||||
|
|
||||||
len = strlen(passwd);
|
|
||||||
if (len > 128) len = 128;
|
|
||||||
*pwlen = len;
|
|
||||||
if (len % AUTH_PASS_LEN != 0) {
|
|
||||||
n = AUTH_PASS_LEN - (len % AUTH_PASS_LEN);
|
|
||||||
for (i = len; n > 0; n--, i++)
|
|
||||||
passwd[i] = 0;
|
|
||||||
len = *pwlen = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
secretlen = strlen(secret);
|
|
||||||
memcpy(buffer, secret, secretlen);
|
|
||||||
memcpy(buffer + secretlen, vector, AUTH_VECTOR_LEN);
|
|
||||||
md5_calc((u_char *)digest, buffer, secretlen + AUTH_VECTOR_LEN);
|
|
||||||
|
|
||||||
for (i = 0; i < AUTH_PASS_LEN; i++)
|
|
||||||
passwd[i] ^= digest[i];
|
|
||||||
|
|
||||||
if (len <= AUTH_PASS_LEN) return 0;
|
|
||||||
|
|
||||||
for (n = 0; n < 128 && n <= (len - AUTH_PASS_LEN); n += AUTH_PASS_LEN) {
|
|
||||||
memcpy(buffer + secretlen, passwd + n, AUTH_PASS_LEN);
|
|
||||||
md5_calc((u_char *)digest, buffer, secretlen + AUTH_PASS_LEN);
|
|
||||||
for (i = 0; i < AUTH_PASS_LEN; i++)
|
|
||||||
passwd[i + n + AUTH_PASS_LEN] ^= digest[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void random_vector(uint8_t *vector, struct clientparam *param)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
static int did_random = 0;
|
|
||||||
static int counter = 0;
|
|
||||||
|
|
||||||
if (!did_random) {
|
|
||||||
|
|
||||||
ntry = (int)basetime;
|
|
||||||
for (i = 0; i < (int)sizeof(random_vector_pool); i++) {
|
|
||||||
random_vector_pool[i] += myrand((void *) ¶m->msec_start, sizeof(param->msec_start)) & 0xff;
|
|
||||||
}
|
|
||||||
did_random = 1;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
counter++;
|
|
||||||
random_vector_pool[AUTH_VECTOR_LEN] += (counter & 0xff);
|
|
||||||
md5_calc((u_char *) random_vector_pool,
|
|
||||||
(u_char *) random_vector_pool,
|
|
||||||
sizeof(random_vector_pool));
|
|
||||||
|
|
||||||
md5_calc((u_char *) vector,
|
|
||||||
(u_char *) random_vector_pool,
|
|
||||||
sizeof(random_vector_pool));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static float timeout = 5;
|
|
||||||
|
|
||||||
typedef struct radius_packet_t {
|
|
||||||
uint8_t code;
|
|
||||||
uint8_t id;
|
|
||||||
uint16_t length;
|
|
||||||
uint8_t vector[AUTH_VECTOR_LEN];
|
|
||||||
uint8_t data[4096];
|
|
||||||
} radius_packet_t;
|
|
||||||
|
|
||||||
#define RETURN(xxx) { res = xxx; goto CLEANRET; }
|
|
||||||
|
|
||||||
int radsend(struct clientparam * param, int auth, int stop){
|
|
||||||
|
|
||||||
int loop;
|
|
||||||
int id;
|
|
||||||
int res = 4;
|
|
||||||
SOCKET sockfd = -1;
|
|
||||||
unsigned char *ptr;
|
|
||||||
int total_length;
|
|
||||||
int len;
|
|
||||||
int op;
|
|
||||||
#ifdef NOIPV6
|
|
||||||
struct sockaddr_in saremote;
|
|
||||||
#else
|
|
||||||
struct sockaddr_in6 saremote;
|
|
||||||
#endif
|
|
||||||
struct pollfd fds[1];
|
|
||||||
char vector[AUTH_VECTOR_LEN];
|
|
||||||
radius_packet_t packet, rpacket;
|
|
||||||
SASIZETYPE salen;
|
|
||||||
int data_len;
|
|
||||||
uint8_t *vendor_len;
|
|
||||||
int count=0;
|
|
||||||
uint8_t *attr;
|
|
||||||
long vendor=0;
|
|
||||||
int vendorlen=0;
|
|
||||||
char buf[64];
|
|
||||||
|
|
||||||
|
|
||||||
if(!radiussecret || !nradservers) {
|
|
||||||
return 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(&packet, 0, sizeof(packet));
|
|
||||||
|
|
||||||
|
|
||||||
pthread_mutex_lock(&rad_mutex);
|
|
||||||
if(auth)random_vector(packet.vector, param);
|
|
||||||
|
|
||||||
id = ((ntry++) & 0xff);
|
|
||||||
pthread_mutex_unlock(&rad_mutex);
|
|
||||||
|
|
||||||
packet.code = auth?PW_AUTHENTICATION_REQUEST:PW_ACCOUNTING_REQUEST;
|
|
||||||
packet.id=id;
|
|
||||||
ptr = packet.data;
|
|
||||||
total_length = 0;
|
|
||||||
|
|
||||||
/* Service Type */
|
|
||||||
*ptr++ = auth?PW_SERVICE_TYPE:PW_ACCT_STATUS_TYPE;
|
|
||||||
*ptr++ = 6;
|
|
||||||
(*(uint32_t *)ptr)=htonl(auth?PW_AUTHENTICATE_ONLY:stop?PW_STATUS_STOP:PW_STATUS_START);
|
|
||||||
ptr+=4;
|
|
||||||
total_length+=6;
|
|
||||||
|
|
||||||
/* Acct-Session-Id */
|
|
||||||
sprintf(buf, "%u.%u.%u", (unsigned)param->time_start, (unsigned)param->msec_start, (unsigned)param->threadid);
|
|
||||||
len = strlen(buf);
|
|
||||||
*ptr++ = PW_ACCT_SESSION_ID;
|
|
||||||
*ptr++ = 2+len;
|
|
||||||
memcpy(ptr, buf, len);
|
|
||||||
ptr+=len;
|
|
||||||
total_length+=len+2;
|
|
||||||
|
|
||||||
/* NAS-Port-Type */
|
|
||||||
*ptr++ = PW_NAS_PORT_TYPE;
|
|
||||||
*ptr++ = 6;
|
|
||||||
(*(uint32_t *)ptr)=htonl(PW_NAS_PORT_VIRTUAL);
|
|
||||||
ptr+=4;
|
|
||||||
total_length+=6;
|
|
||||||
|
|
||||||
/* NAS-Port */
|
|
||||||
*ptr++ = PW_NAS_PORT_ID;
|
|
||||||
*ptr++ = 6;
|
|
||||||
(*(uint32_t *)ptr)=htonl((uint32_t)ntohs((*SAPORT(¶m->srv->intsa))));
|
|
||||||
ptr+=4;
|
|
||||||
total_length+=6;
|
|
||||||
|
|
||||||
|
|
||||||
if(*SAFAMILY(¶m->sincl) == AF_INET6){
|
|
||||||
/* NAS-IPv6-Address */
|
|
||||||
*ptr++ = PW_NAS_IPV6_ADDRESS;
|
|
||||||
*ptr++ = 18;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* NAS-IP-Address */
|
|
||||||
*ptr++ = PW_NAS_IP_ADDRESS;
|
|
||||||
*ptr++ = 6;
|
|
||||||
}
|
|
||||||
len = SAADDRLEN(¶m->sincl);
|
|
||||||
memcpy(ptr, SAADDR(¶m->sincl), len);
|
|
||||||
ptr += len;
|
|
||||||
total_length += (2+len);
|
|
||||||
|
|
||||||
/* NAS-Identifier */
|
|
||||||
if(conf.stringtable){
|
|
||||||
*ptr++ = PW_NAS_IDENTIFIER;
|
|
||||||
len = strlen(conf.stringtable[SERVICES+param->service]);
|
|
||||||
*ptr++ = (2 + len);
|
|
||||||
memcpy(ptr, conf.stringtable[SERVICES+param->service], len);
|
|
||||||
ptr += len;
|
|
||||||
total_length+=(len+2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(*SAFAMILY(¶m->sincr) == AF_INET6){
|
|
||||||
/* Framed-IPv6-Address */
|
|
||||||
*ptr++ = PW_FRAMED_IPV6_ADDRESS;
|
|
||||||
*ptr++ = 18;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* Framed-IP-Address */
|
|
||||||
*ptr++ = PW_FRAMED_IP_ADDRESS;
|
|
||||||
*ptr++ = 6;
|
|
||||||
}
|
|
||||||
len = SAADDRLEN(¶m->sincr);
|
|
||||||
memcpy(ptr, SAADDR(¶m->sincr), len);
|
|
||||||
ptr += len;
|
|
||||||
total_length += (2+len);
|
|
||||||
|
|
||||||
/* Called-Station-ID */
|
|
||||||
if(param->hostname){
|
|
||||||
*ptr++ = PW_CALLED_STATION_ID;
|
|
||||||
len = strlen(param->hostname);
|
|
||||||
*ptr++ = (2 + len);
|
|
||||||
memcpy(ptr, param->hostname, len);
|
|
||||||
ptr += len;
|
|
||||||
total_length+=(len+2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Login-Service */
|
|
||||||
op = param->operation;
|
|
||||||
for(len=0; op; len++)op>>=1;
|
|
||||||
*ptr++ = PW_LOGIN_SERVICE;
|
|
||||||
*ptr++ = 4;
|
|
||||||
(*(uint16_t *)ptr)=htons((uint16_t)(len + 1000));
|
|
||||||
ptr+=2;
|
|
||||||
total_length+=4;
|
|
||||||
|
|
||||||
/* Login-TCP-Port */
|
|
||||||
*ptr++ = PW_LOGIN_TCP_PORT;
|
|
||||||
*ptr++ = 4;
|
|
||||||
(*(uint16_t *)ptr)=*SAPORT(¶m->req);
|
|
||||||
ptr+=2;
|
|
||||||
total_length+=4;
|
|
||||||
|
|
||||||
|
|
||||||
if(*SAFAMILY(¶m->req) == AF_INET6){
|
|
||||||
/* Login-IPv6-Host */
|
|
||||||
*ptr++ = PW_LOGIN_IPV6_HOST;
|
|
||||||
*ptr++ = 18;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* Login-IP-Host */
|
|
||||||
*ptr++ = PW_LOGIN_IP_HOST;
|
|
||||||
*ptr++ = 6;
|
|
||||||
}
|
|
||||||
len = SAADDRLEN(¶m->req);
|
|
||||||
memcpy(ptr, SAADDR(¶m->req), len);
|
|
||||||
ptr += len;
|
|
||||||
total_length += (2+len);
|
|
||||||
|
|
||||||
|
|
||||||
/* Username */
|
|
||||||
if(param->username){
|
|
||||||
len = strlen(param->username);
|
|
||||||
if(len>128)len=128;
|
|
||||||
*ptr++ = PW_USER_NAME;
|
|
||||||
*ptr++ = len + 2;
|
|
||||||
memcpy(ptr, param->username, len);
|
|
||||||
ptr+=len;
|
|
||||||
total_length += (len+2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(stop){
|
|
||||||
/* Acct-Input-Octets */
|
|
||||||
*ptr++ = PW_ACCT_INPUT_OCTETS;
|
|
||||||
*ptr++ = 6;
|
|
||||||
(*(uint32_t *)ptr)=htonl((uint32_t)param->statssrv64);
|
|
||||||
ptr+=4;
|
|
||||||
total_length+=6;
|
|
||||||
/* Acct-Output-Octets */
|
|
||||||
*ptr++ = PW_ACCT_OUTPUT_OCTETS;
|
|
||||||
*ptr++ = 6;
|
|
||||||
(*(uint32_t *)ptr)=htonl((uint32_t)param->statscli64);
|
|
||||||
ptr+=4;
|
|
||||||
total_length+=6;
|
|
||||||
/* Acct-Input-Packets */
|
|
||||||
*ptr++ = PW_ACCT_INPUT_PACKETS;
|
|
||||||
*ptr++ = 6;
|
|
||||||
(*(uint32_t *)ptr)=htonl((uint32_t)param->nreads);
|
|
||||||
ptr+=4;
|
|
||||||
total_length+=6;
|
|
||||||
/* Acct-Output-Packets */
|
|
||||||
*ptr++ = PW_ACCT_OUTPUT_PACKETS;
|
|
||||||
*ptr++ = 6;
|
|
||||||
(*(uint32_t *)ptr)=htonl((uint32_t)param->nwrites);
|
|
||||||
ptr+=4;
|
|
||||||
total_length+=6;
|
|
||||||
/* Acct-Session-Time */
|
|
||||||
*ptr++ = PW_ACCT_SESSION_TIME;
|
|
||||||
*ptr++ = 6;
|
|
||||||
(*(uint32_t *)ptr)=htonl((uint32_t)(time(0) - param->time_start));
|
|
||||||
ptr+=4;
|
|
||||||
total_length+=6;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(auth && param->password){
|
|
||||||
len = strlen(param->password);
|
|
||||||
if(len > 128) len = 128;
|
|
||||||
*ptr++ = PW_PASSWORD;
|
|
||||||
ptr++;
|
|
||||||
memcpy(ptr, param->password, len);
|
|
||||||
rad_pwencode(ptr,
|
|
||||||
&len,
|
|
||||||
radiussecret,
|
|
||||||
(char *)packet.vector);
|
|
||||||
*(ptr-1) = len + 2;
|
|
||||||
ptr+=len;
|
|
||||||
total_length+= (len+2);
|
|
||||||
}
|
|
||||||
|
|
||||||
total_length+=(4+AUTH_VECTOR_LEN);
|
|
||||||
packet.length = htons(total_length);
|
|
||||||
|
|
||||||
if(!auth){
|
|
||||||
len = strlen(radiussecret);
|
|
||||||
memcpy(ptr,radiussecret,len);
|
|
||||||
md5_calc(packet.vector, (u_char *)&packet, total_length + len);
|
|
||||||
}
|
|
||||||
memcpy(vector, packet.vector, AUTH_VECTOR_LEN);
|
|
||||||
|
|
||||||
for (loop = 0; loop < nradservers && loop < MAXRADIUS; loop++) {
|
|
||||||
SOCKET remsock;
|
|
||||||
|
|
||||||
|
|
||||||
saremote = auth?radiuslist[loop].authaddr : radiuslist[loop].logaddr;
|
|
||||||
#ifdef NOIPV6
|
|
||||||
if(*SAFAMILY(&saremote)!= AF_INET) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if(*SAFAMILY(&saremote)!= AF_INET && *SAFAMILY(&saremote)!= AF_INET6){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
if(auth) {
|
|
||||||
*/
|
|
||||||
if(sockfd >= 0) so._closesocket(sockfd);
|
|
||||||
if ((sockfd = so._socket(SASOCK(&saremote), SOCK_DGRAM, 0)) < 0) {
|
|
||||||
return 4;
|
|
||||||
}
|
|
||||||
remsock = sockfd;
|
|
||||||
/*
|
|
||||||
}
|
|
||||||
else remsock = radiuslist[loop].logsock;
|
|
||||||
*/
|
|
||||||
so._bind(param->remsock,(struct sockaddr *)&radiuslist[loop].localaddr,SASIZE(&radiuslist[loop].localaddr));
|
|
||||||
len = so._sendto(remsock, (char *)&packet, total_length, 0,
|
|
||||||
(struct sockaddr *)&saremote, sizeof(saremote));
|
|
||||||
if(len != ntohs(packet.length)){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(fds, 0, sizeof(fds));
|
|
||||||
fds[0].fd = remsock;
|
|
||||||
fds[0].events = POLLIN;
|
|
||||||
if(so._poll(fds, 1, conf.timeouts[SINGLEBYTE_L]*1000) <= 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
salen = sizeof(saremote);
|
|
||||||
|
|
||||||
data_len = so._recvfrom(remsock, (char *)&rpacket, sizeof(packet)-16,
|
|
||||||
0, (struct sockaddr *)&saremote, &salen);
|
|
||||||
|
|
||||||
|
|
||||||
if (data_len < 20) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( auth && rpacket.code != PW_AUTHENTICATION_ACK &&
|
|
||||||
rpacket.code != PW_AUTHENTICATION_REJECT ){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if( !auth && rpacket.code != PW_ACCOUNTING_RESPONSE){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (calc_replydigest((char *)&rpacket, packet.vector, radiussecret,
|
|
||||||
data_len) ){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
total_length = ntohs(rpacket.length);
|
|
||||||
if (data_len != total_length) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!auth) RETURN(0);
|
|
||||||
|
|
||||||
attr = rpacket.data;
|
|
||||||
count = total_length - 20;
|
|
||||||
vendor_len = 0;
|
|
||||||
|
|
||||||
while (count >= 2) {
|
|
||||||
if (!vendor && attr[0] == 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (attr[1] < 2) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!vendor && attr[0] == PW_VENDOR_SPECIFIC) {
|
|
||||||
if (attr[1] < 6 || count < 6) RETURN(4);
|
|
||||||
vendorlen = attr[1]-6;
|
|
||||||
vendor = htonl(*((int*)(attr +2)));
|
|
||||||
count -= 6;
|
|
||||||
attr += 6;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!vendor && attr[0] == PW_FRAMED_IP_ADDRESS && attr[1] == 6) {
|
|
||||||
*SAFAMILY(¶m->sinsl) = AF_INET;
|
|
||||||
memcpy(SAADDR(¶m->sinsl), attr+2, 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (!vendor && attr[0] == PW_FRAMED_IPV6_ADDRESS && attr[1] == 18) {
|
|
||||||
*SAFAMILY(¶m->sinsl) = AF_INET6;
|
|
||||||
memcpy(SAADDR(¶m->sinsl), attr+2, 16);
|
|
||||||
}
|
|
||||||
else if (!vendor && attr[0] == PW_REPLY_MESSAGE && attr[1] >= 3 && isdigit(attr[2])) {
|
|
||||||
res = 0;
|
|
||||||
for(len = 2; len < attr[1] && isdigit(attr[len]); len++) res = (res * 10) + (attr[len] - '0');
|
|
||||||
}
|
|
||||||
|
|
||||||
count -= attr[1];
|
|
||||||
if(vendorlen) {
|
|
||||||
vendorlen -= attr[1];
|
|
||||||
if (!vendorlen) vendor = 0;
|
|
||||||
else if (vendorlen < 0) RETURN(4);
|
|
||||||
}
|
|
||||||
attr += attr[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count !=0 || vendorlen!=0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(rpacket.code == PW_AUTHENTICATION_REJECT) RETURN (res);
|
|
||||||
if(rpacket.code == PW_AUTHENTICATION_ACK) RETURN(0);
|
|
||||||
res = 4;
|
|
||||||
}
|
|
||||||
CLEANRET:
|
|
||||||
if(sockfd >= 0) so._closesocket(sockfd);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
int radauth(struct clientparam * param){
|
|
||||||
/*radsend(param, 0, 0);*/
|
|
||||||
return radsend(param, 1, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void logradius(struct clientparam * param, const unsigned char *s) {
|
|
||||||
radsend(param, 0, 1);
|
|
||||||
if(param->trafcountfunc)(*param->trafcountfunc)(param);
|
|
||||||
clearstat(param);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
+6
-5
@@ -1,9 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
(c) 2002-2016 by Vladimir Dubrovin <3proxy@3proxy.ru>
|
* Copyright (c) 2000-2008 3APA3A
|
||||||
|
*
|
||||||
please read License Agreement
|
* please read License Agreement
|
||||||
|
*
|
||||||
*/
|
* $Id: base64.c,v 1.6 2008/01/08 21:46:36 vlad Exp $
|
||||||
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|||||||
+383
-296
@@ -1,9 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
3APA3A simpliest proxy server
|
3APA3A simpliest proxy server
|
||||||
(c) 2002-2016 by Vladimir Dubrovin <3proxy@3proxy.ru>
|
(c) 2002-2008 by ZARAZA <3APA3A@security.nnov.ru>
|
||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
|
$Id: common.c,v 1.94 2014-04-07 21:24:45 vlad Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -15,69 +16,19 @@ char * copyright = COPYRIGHT;
|
|||||||
|
|
||||||
int randomizer = 1;
|
int randomizer = 1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
pthread_attr_t pa;
|
pthread_attr_t pa;
|
||||||
|
|
||||||
|
|
||||||
void daemonize(void){
|
|
||||||
if(fork() > 0) {
|
|
||||||
usleep(SLEEPTIME);
|
|
||||||
_exit(0);
|
|
||||||
}
|
|
||||||
setsid();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
unsigned char **stringtable = NULL;
|
unsigned char **stringtable = NULL;
|
||||||
|
|
||||||
#ifdef WITH_LINUX_FUTEX
|
int myinet_ntoa(struct in_addr in, char * buf){
|
||||||
int sys_futex(void *addr1, int op, int val1, struct timespec *timeout, void *addr2, int val3)
|
unsigned u = ntohl(in.s_addr);
|
||||||
{
|
return sprintf(buf, "%u.%u.%u.%u",
|
||||||
return syscall(SYS_futex, addr1, op, val1, timeout, addr2, val3);
|
((u&0xFF000000)>>24),
|
||||||
}
|
((u&0x00FF0000)>>16),
|
||||||
int mutex_lock(int *val)
|
((u&0x0000FF00)>>8),
|
||||||
{
|
((u&0x000000FF)));
|
||||||
int c;
|
|
||||||
if ((c = __sync_val_compare_and_swap(val, 0, 1)) != 0)
|
|
||||||
do {
|
|
||||||
if(c == 2 || __sync_val_compare_and_swap(val, 1, 2) != 0)
|
|
||||||
sys_futex(val, FUTEX_WAIT_PRIVATE, 2, NULL, NULL, 0);
|
|
||||||
} while ((c = __sync_val_compare_and_swap(val, 0, 2)) != 0);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int mutex_unlock(int *val)
|
|
||||||
{
|
|
||||||
if(__sync_fetch_and_sub (val, 1) != 1){
|
|
||||||
*val = 0;
|
|
||||||
sys_futex(val, FUTEX_WAKE_PRIVATE, 1, NULL, NULL, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int myinet_ntop(int af, void *src, char *dst, socklen_t size){
|
|
||||||
#ifndef NOIPV6
|
|
||||||
if(af != AF_INET6){
|
|
||||||
#endif
|
|
||||||
unsigned u = ntohl(((struct in_addr *)src)->s_addr);
|
|
||||||
return sprintf(dst, "%u.%u.%u.%u",
|
|
||||||
((u&0xFF000000)>>24),
|
|
||||||
((u&0x00FF0000)>>16),
|
|
||||||
((u&0x0000FF00)>>8),
|
|
||||||
((u&0x000000FF)));
|
|
||||||
#ifndef NOIPV6
|
|
||||||
}
|
|
||||||
*dst = 0;
|
|
||||||
inet_ntop(af, src, dst, size);
|
|
||||||
return (int)strlen(dst);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *rotations[] = {
|
char *rotations[] = {
|
||||||
@@ -93,26 +44,20 @@ char *rotations[] = {
|
|||||||
|
|
||||||
|
|
||||||
struct extparam conf = {
|
struct extparam conf = {
|
||||||
{1, 5, 30, 60, 180, 1800, 15, 60, 15, 5, 0, 0},
|
{1, 5, 30, 60, 180, 1800, 15, 60, 0, 0},
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
0, -1, 0, 0, 0, 0, 0, 500, 0, 0, 0,
|
||||||
0,
|
|
||||||
0, -1, 0, 0, 0, 0,
|
|
||||||
0, 500, 0, 0, 0, 0,
|
|
||||||
6, 600,
|
6, 600,
|
||||||
1048576,
|
1048576,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
NONE, NONE,
|
NONE, NONE,
|
||||||
NULL,
|
NULL,
|
||||||
#ifndef NOIPV6
|
INADDR_ANY, INADDR_ANY,
|
||||||
{AF_INET},{AF_INET6},{AF_INET},
|
0, 0,
|
||||||
#else
|
|
||||||
{AF_INET},{AF_INET},
|
|
||||||
#endif
|
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
doconnect,
|
doconnect,
|
||||||
@@ -128,13 +73,9 @@ struct extparam conf = {
|
|||||||
NULL,
|
NULL,
|
||||||
(time_t)0, (time_t)0,
|
(time_t)0, (time_t)0,
|
||||||
0,0,
|
0,0,
|
||||||
'@',
|
'@'
|
||||||
};
|
};
|
||||||
|
|
||||||
int numservers=0;
|
|
||||||
|
|
||||||
char* NULLADDR="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
|
|
||||||
|
|
||||||
int myrand(void * entropy, int len){
|
int myrand(void * entropy, int len){
|
||||||
int i;
|
int i;
|
||||||
unsigned short init;
|
unsigned short init;
|
||||||
@@ -150,7 +91,6 @@ int myrand(void * entropy, int len){
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef WITH_POLL
|
#ifndef WITH_POLL
|
||||||
#ifndef WITH_WSAPOLL
|
|
||||||
int
|
int
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
WINAPI
|
WINAPI
|
||||||
@@ -186,7 +126,6 @@ int
|
|||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
struct sockfuncs so = {
|
struct sockfuncs so = {
|
||||||
socket,
|
socket,
|
||||||
@@ -198,19 +137,15 @@ struct sockfuncs so = {
|
|||||||
getsockname,
|
getsockname,
|
||||||
getsockopt,
|
getsockopt,
|
||||||
setsockopt,
|
setsockopt,
|
||||||
#ifndef WITH_POLL
|
#ifdef WITH_POLL
|
||||||
#ifndef WITH_WSAPOLL
|
|
||||||
mypoll,
|
|
||||||
#else
|
|
||||||
WSAPoll,
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
poll,
|
poll,
|
||||||
|
#else
|
||||||
|
mypoll,
|
||||||
#endif
|
#endif
|
||||||
(void *)send,
|
send,
|
||||||
(void *)sendto,
|
sendto,
|
||||||
(void *)recv,
|
recv,
|
||||||
(void *)recvfrom,
|
recvfrom,
|
||||||
shutdown,
|
shutdown,
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
closesocket
|
closesocket
|
||||||
@@ -266,60 +201,31 @@ int ceparseargs(const char *str){
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int parsehost(int family, unsigned char *host, struct sockaddr *sa){
|
|
||||||
char *sp=NULL,*se=NULL;
|
|
||||||
unsigned short port=0;
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
if(!host) return 2;
|
|
||||||
if(*host == '[') se=strchr((char *)host, ']');
|
|
||||||
if ( (sp = strchr(se?se:(char *)host, ':')) && !strchr(sp+1, ':')) *sp = 0;
|
|
||||||
if(se){
|
|
||||||
*se = 0;
|
|
||||||
}
|
|
||||||
if(sp){
|
|
||||||
port = atoi(sp+1);
|
|
||||||
}
|
|
||||||
ret = !getip46(family, host + (se!=0), (struct sockaddr *)sa);
|
|
||||||
if(se) *se = ']';
|
|
||||||
if(sp) *sp = ':';
|
|
||||||
if(port)*SAPORT(sa) = htons(port);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int parsehostname(char *hostname, struct clientparam *param, unsigned short port){
|
int parsehostname(char *hostname, struct clientparam *param, unsigned short port){
|
||||||
char *sp=NULL,*se=NULL;
|
char *sp;
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
if(!hostname || !*hostname)return 2;
|
if(!hostname || !*hostname)return 1;
|
||||||
if(*hostname == '[') se=strchr(hostname, ']');
|
if ( (sp = strchr(hostname, ':')) ) *sp = 0;
|
||||||
if (sp = strchr(se?se:hostname, ':')) {
|
if(hostname != param->hostname){
|
||||||
if(strchr(sp+1, ':'))sp = NULL;
|
|
||||||
else *sp = 0;
|
|
||||||
}
|
|
||||||
if(se){
|
|
||||||
*se = 0;
|
|
||||||
}
|
|
||||||
if(hostname != (char *)param->hostname){
|
|
||||||
if(param->hostname) myfree(param->hostname);
|
if(param->hostname) myfree(param->hostname);
|
||||||
param->hostname = (unsigned char *)mystrdup(hostname + (se!=0));
|
param->hostname = (unsigned char *)mystrdup(hostname);
|
||||||
}
|
}
|
||||||
if(sp){
|
if(sp){
|
||||||
port = atoi(sp+1);
|
port = atoi(sp+1);
|
||||||
|
*sp = ':';
|
||||||
}
|
}
|
||||||
ret = !getip46(param->srv->family, param->hostname, (struct sockaddr *)¶m->req);
|
param->req.sin_port=htons(port);
|
||||||
if(se) *se = ']';
|
param->req.sin_addr.s_addr = getip(param->hostname);
|
||||||
if(sp) *sp = ':';
|
param->sins.sin_addr.s_addr = 0;
|
||||||
*SAPORT(¶m->req) = htons(port);
|
param->sins.sin_port = 0;
|
||||||
memset(¶m->sinsr, 0, sizeof(param->sinsr));
|
return 0;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int parseusername(char *username, struct clientparam *param, int extpasswd){
|
int parseusername(char *username, struct clientparam *param, int extpasswd){
|
||||||
char *sb = NULL, *se = NULL, *sp = NULL;
|
char *sb = NULL, *se = NULL, *sp = NULL;
|
||||||
|
|
||||||
if(!username || !*username) return 1;
|
if(!username || !*username) return 1;
|
||||||
if(param->srv->needuser && (sb = strchr(username, ':')) && (se = strchr(sb + 1, ':')) && (!extpasswd || (sp = strchr(se + 1, ':')))){
|
if(!param->srv->nouser && (sb = strchr(username, ':')) && (se = strchr(sb + 1, ':')) && (!extpasswd || (sp = strchr(se + 1, ':')))){
|
||||||
*sb = 0;
|
*sb = 0;
|
||||||
*se = 0;
|
*se = 0;
|
||||||
if(sp) *sp = 0;
|
if(sp) *sp = 0;
|
||||||
@@ -354,7 +260,6 @@ int parseconnusername(char *username, struct clientparam *param, int extpasswd,
|
|||||||
if(!username || !*username) return 1;
|
if(!username || !*username) return 1;
|
||||||
if ((sb=strchr(username, conf.delimchar)) == NULL){
|
if ((sb=strchr(username, conf.delimchar)) == NULL){
|
||||||
if(!param->hostname && param->remsock == INVALID_SOCKET) return 2;
|
if(!param->hostname && param->remsock == INVALID_SOCKET) return 2;
|
||||||
if(param->hostname)parsehostname((char *)param->hostname, param, port);
|
|
||||||
return parseusername(username, param, extpasswd);
|
return parseusername(username, param, extpasswd);
|
||||||
}
|
}
|
||||||
while ((se=strchr(sb+1, conf.delimchar)))sb=se;
|
while ((se=strchr(sb+1, conf.delimchar)))sb=se;
|
||||||
@@ -365,95 +270,367 @@ int parseconnusername(char *username, struct clientparam *param, int extpasswd,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void clearstat(struct clientparam * param) {
|
||||||
|
|
||||||
int connectwithpoll(SOCKET sock, struct sockaddr *sa, SASIZETYPE size, int to){
|
|
||||||
struct pollfd fds[1];
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
unsigned long ul = 1;
|
struct timeb tb;
|
||||||
ioctlsocket(sock, FIONBIO, &ul);
|
|
||||||
|
ftime(&tb);
|
||||||
|
param->time_start = (time_t)tb.time;
|
||||||
|
param->msec_start = (unsigned)tb.millitm;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
fcntl(sock,F_SETFL, O_NONBLOCK | fcntl(sock,F_GETFL));
|
struct timeval tv;
|
||||||
|
struct timezone tz;
|
||||||
|
gettimeofday(&tv, &tz);
|
||||||
|
|
||||||
|
param->time_start = (time_t)tv.tv_sec;
|
||||||
|
param->msec_start = (tv.tv_usec / 1000);
|
||||||
#endif
|
#endif
|
||||||
if(so._connect(sock,sa,size)) {
|
param->statscli = param->statssrv = param->nreads = param->nwrites =
|
||||||
if(errno != EAGAIN && errno != EINPROGRESS) return (13);
|
param->nconnects = 0;
|
||||||
}
|
|
||||||
memset(fds, 0, sizeof(fds));
|
|
||||||
fds[0].fd = sock;
|
|
||||||
fds[0].events = POLLOUT;
|
|
||||||
if(so._poll(fds, 1, to*1000) <= 0) {
|
|
||||||
return (13);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char months[12][4] = {
|
||||||
|
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||||
|
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
int dobuf2(struct clientparam * param, unsigned char * buf, const unsigned char *s, const unsigned char * doublec, struct tm* tm, char * format){
|
||||||
|
int i, j;
|
||||||
|
int len;
|
||||||
|
time_t sec;
|
||||||
|
unsigned msec;
|
||||||
|
|
||||||
|
long timezone;
|
||||||
|
unsigned delay;
|
||||||
|
struct in_addr tmpia;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
struct timeb tb;
|
||||||
|
|
||||||
|
ftime(&tb);
|
||||||
|
sec = (time_t)tb.time;
|
||||||
|
msec = (unsigned)tb.millitm;
|
||||||
|
timezone = tm->tm_isdst*60 - tb.timezone;
|
||||||
|
|
||||||
|
#else
|
||||||
|
struct timeval tv;
|
||||||
|
struct timezone tz;
|
||||||
|
gettimeofday(&tv, &tz);
|
||||||
|
|
||||||
|
sec = (time_t)tv.tv_sec;
|
||||||
|
msec = tv.tv_usec / 1000;
|
||||||
|
#ifdef _SOLARIS
|
||||||
|
timezone = -altzone / 60;
|
||||||
|
#else
|
||||||
|
timezone = tm->tm_gmtoff / 60;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
delay = param->time_start?((unsigned) ((sec - param->time_start))*1000 + msec) - param->msec_start : 0;
|
||||||
|
*buf = 0;
|
||||||
|
for(i=0, j=0; format[j] && i < 4040; j++){
|
||||||
|
if(format[j] == '%' && format[j+1]){
|
||||||
|
j++;
|
||||||
|
switch(format[j]){
|
||||||
|
case '%':
|
||||||
|
buf[i++] = '%';
|
||||||
|
break;
|
||||||
|
case 'y':
|
||||||
|
sprintf((char *)buf+i, "%.2d", tm->tm_year%100);
|
||||||
|
i+=2;
|
||||||
|
break;
|
||||||
|
case 'Y':
|
||||||
|
sprintf((char *)buf+i, "%.4d", tm->tm_year+1900);
|
||||||
|
i+=4;
|
||||||
|
break;
|
||||||
|
case 'm':
|
||||||
|
sprintf((char *)buf+i, "%.2d", tm->tm_mon+1);
|
||||||
|
i+=2;
|
||||||
|
break;
|
||||||
|
case 'o':
|
||||||
|
sprintf((char *)buf+i, "%s", months[tm->tm_mon]);
|
||||||
|
i+=3;
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
sprintf((char *)buf+i, "%.2d", tm->tm_mday);
|
||||||
|
i+=2;
|
||||||
|
break;
|
||||||
|
case 'H':
|
||||||
|
sprintf((char *)buf+i, "%.2d", tm->tm_hour);
|
||||||
|
i+=2;
|
||||||
|
break;
|
||||||
|
case 'M':
|
||||||
|
sprintf((char *)buf+i, "%.2d", tm->tm_min);
|
||||||
|
i+=2;
|
||||||
|
break;
|
||||||
|
case 'S':
|
||||||
|
sprintf((char *)buf+i, "%.2d", tm->tm_sec);
|
||||||
|
i+=2;
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
sprintf((char *)buf+i, "%.10u", (unsigned)sec);
|
||||||
|
i+=10;
|
||||||
|
break;
|
||||||
|
case 'b':
|
||||||
|
i+=sprintf((char *)buf+i, "%u", delay?(unsigned)(param->statscli * 1000./delay):0);
|
||||||
|
break;
|
||||||
|
case 'B':
|
||||||
|
i+=sprintf((char *)buf+i, "%u", delay?(unsigned)(param->statssrv * 1000./delay):0);
|
||||||
|
break;
|
||||||
|
case 'D':
|
||||||
|
i+=sprintf((char *)buf+i, "%u", delay);
|
||||||
|
break;
|
||||||
|
case '.':
|
||||||
|
sprintf((char *)buf+i, "%.3u", msec);
|
||||||
|
i+=3;
|
||||||
|
break;
|
||||||
|
case 'z':
|
||||||
|
sprintf((char *)buf+i, "%+.2ld%.2u", timezone / 60, (unsigned)(timezone%60));
|
||||||
|
i+=5;
|
||||||
|
break;
|
||||||
|
case 'U':
|
||||||
|
if(param->username && *param->username){
|
||||||
|
for(len = 0; i< 4000 && param->username[len]; len++){
|
||||||
|
buf[i] = param->username[len];
|
||||||
|
if(param->srv->nonprintable && (buf[i] < 0x20 || strchr((char *)param->srv->nonprintable, buf[i]))) buf[i] = param->srv->replace;
|
||||||
|
if(doublec && strchr((char *)doublec, buf[i])) {
|
||||||
|
buf[i+1] = buf[i];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
buf[i++] = '-';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'n':
|
||||||
|
len = param->hostname? (int)strlen((char *)param->hostname) : 0;
|
||||||
|
if (len > 0) for(len = 0; param->hostname[len] && i < 4000; len++, i++){
|
||||||
|
buf[i] = param->hostname[len];
|
||||||
|
if(param->srv->nonprintable && (buf[i] < 0x20 || strchr((char *)param->srv->nonprintable, buf[i]))) buf[i] = param->srv->replace;
|
||||||
|
if(doublec && strchr((char *)doublec, buf[i])) {
|
||||||
|
buf[i+1] = buf[i];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else i += myinet_ntoa(param->sins.sin_addr, (char *)buf + i);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'N':
|
||||||
|
if(param->service >=0 && param->service < 15) {
|
||||||
|
len = (conf.stringtable)? (int)strlen((char *)conf.stringtable[SERVICES + param->service]) : 0;
|
||||||
|
if(len > 20) len = 20;
|
||||||
|
memcpy(buf+i, (len)?conf.stringtable[SERVICES + param->service]:(unsigned char*)"-", (len)?len:1);
|
||||||
|
i += (len)?len:1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'E':
|
||||||
|
sprintf((char *)buf+i, "%.05d", param->res);
|
||||||
|
i += 5;
|
||||||
|
break;
|
||||||
|
case 'T':
|
||||||
|
if(s){
|
||||||
|
for(len = 0; i<4000 && s[len]; len++){
|
||||||
|
buf[i] = s[len];
|
||||||
|
if(param->srv->nonprintable && (buf[i] < 0x20 || strchr((char *)param->srv->nonprintable, buf[i]))) buf[i] = param->srv->replace;
|
||||||
|
if(doublec && strchr((char *)doublec, buf[i])) {
|
||||||
|
buf[i+1] = buf[i];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'e':
|
||||||
|
tmpia.s_addr = param->extip;
|
||||||
|
i += myinet_ntoa(tmpia, (char *)buf + i);
|
||||||
|
break;
|
||||||
|
case 'C':
|
||||||
|
i += myinet_ntoa(param->sinc.sin_addr, (char *)buf + i);
|
||||||
|
break;
|
||||||
|
case 'R':
|
||||||
|
i += myinet_ntoa(param->sins.sin_addr, (char *)buf + i);
|
||||||
|
break;
|
||||||
|
case 'Q':
|
||||||
|
i += myinet_ntoa(param->req.sin_addr, (char *)buf + i);
|
||||||
|
break;
|
||||||
|
case 'p':
|
||||||
|
sprintf((char *)buf+i, "%hu", ntohs(param->srv->intport));
|
||||||
|
i += (int)strlen((char *)buf+i);
|
||||||
|
break;
|
||||||
|
case 'c':
|
||||||
|
sprintf((char *)buf+i, "%hu", ntohs(param->sinc.sin_port));
|
||||||
|
i += (int)strlen((char *)buf+i);
|
||||||
|
break;
|
||||||
|
case 'r':
|
||||||
|
sprintf((char *)buf+i, "%hu", ntohs(param->sins.sin_port));
|
||||||
|
i += (int)strlen((char *)buf+i);
|
||||||
|
break;
|
||||||
|
case 'q':
|
||||||
|
sprintf((char *)buf+i, "%hu", ntohs(param->req.sin_port));
|
||||||
|
i += (int)strlen((char *)buf+i);
|
||||||
|
break;
|
||||||
|
case 'I':
|
||||||
|
sprintf((char *)buf+i, "%lu", param->statssrv);
|
||||||
|
i += (int)strlen((char *)buf+i);
|
||||||
|
break;
|
||||||
|
case 'O':
|
||||||
|
sprintf((char *)buf+i, "%lu", param->statscli);
|
||||||
|
i += (int)strlen((char *)buf+i);
|
||||||
|
break;
|
||||||
|
case 'h':
|
||||||
|
sprintf((char *)buf+i, "%d", param->redirected);
|
||||||
|
i += (int)strlen((char *)buf+i);
|
||||||
|
break;
|
||||||
|
case '1':
|
||||||
|
case '2':
|
||||||
|
case '3':
|
||||||
|
case '4':
|
||||||
|
case '5':
|
||||||
|
case '6':
|
||||||
|
case '7':
|
||||||
|
case '8':
|
||||||
|
case '9':
|
||||||
|
{
|
||||||
|
int k, pmin=0, pmax=0;
|
||||||
|
for (k = j; isnumber(format[k]); k++);
|
||||||
|
if(format[k] == '-' && isnumber(format[k+1])){
|
||||||
|
pmin = atoi(format + j) - 1;
|
||||||
|
k++;
|
||||||
|
pmax = atoi(format + k) -1;
|
||||||
|
for (; isnumber(format[k]); k++);
|
||||||
|
j = k;
|
||||||
|
}
|
||||||
|
if(!s || format[k]!='T') break;
|
||||||
|
for(k = 0, len = 0; s[len] && i < 4000; len++){
|
||||||
|
if(isspace(s[len])){
|
||||||
|
k++;
|
||||||
|
while(isspace(s[len+1]))len++;
|
||||||
|
if(k == pmin) continue;
|
||||||
|
}
|
||||||
|
if(k>=pmin && k<=pmax) {
|
||||||
|
buf[i] = s[len];
|
||||||
|
if(param->srv->nonprintable && (buf[i] < 0x20 || strchr((char *)param->srv->nonprintable, buf[i]))) buf[i] = param->srv->replace;
|
||||||
|
if(doublec && strchr((char *)doublec, buf[i])) {
|
||||||
|
buf[i+1] = buf[i];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
buf[i++] = format[j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else buf[i++] = format[j];
|
||||||
|
}
|
||||||
|
buf[i] = 0;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
int dobuf(struct clientparam * param, unsigned char * buf, const unsigned char *s, const unsigned char * doublec){
|
||||||
|
struct tm* tm;
|
||||||
|
int i;
|
||||||
|
char * format;
|
||||||
|
time_t t;
|
||||||
|
|
||||||
|
time(&t);
|
||||||
|
if(!param) return 0;
|
||||||
|
if(param->trafcountfunc)(*param->trafcountfunc)(param);
|
||||||
|
format = (char *)param->srv->logformat;
|
||||||
|
if(!format) format = "G%y%m%d%H%M%S.%. %p %E %U %C:%c %R:%r %O %I %h %T";
|
||||||
|
tm = (*format == 'G' || *format == 'g')?
|
||||||
|
gmtime(&t) : localtime(&t);
|
||||||
|
i = dobuf2(param, buf, s, doublec, tm, format + 1);
|
||||||
|
clearstat(param);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
void lognone(struct clientparam * param, const unsigned char *s) {
|
||||||
|
if(param->trafcountfunc)(*param->trafcountfunc)(param);
|
||||||
|
clearstat(param);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void logstdout(struct clientparam * param, const unsigned char *s) {
|
||||||
|
unsigned char buf[4096];
|
||||||
|
FILE *log;
|
||||||
|
|
||||||
|
log = param->srv->stdlog?param->srv->stdlog:conf.stdlog?conf.stdlog:stdout;
|
||||||
|
dobuf(param, buf, s, NULL);
|
||||||
|
if(!param->nolog)if(fprintf(log, "%s\n", buf) < 0) {
|
||||||
|
perror("printf()");
|
||||||
|
};
|
||||||
|
if(log != conf.stdlog)fflush(log);
|
||||||
|
}
|
||||||
|
#ifndef _WIN32
|
||||||
|
void logsyslog(struct clientparam * param, const unsigned char *s) {
|
||||||
|
unsigned char buf[4096];
|
||||||
|
|
||||||
|
dobuf(param, buf, s, NULL);
|
||||||
|
if(!param->nolog)syslog(LOG_INFO, "%s", buf);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int doconnect(struct clientparam * param){
|
int doconnect(struct clientparam * param){
|
||||||
SASIZETYPE size;
|
SASIZETYPE size = sizeof(param->sins);
|
||||||
|
struct sockaddr_in bindsa;
|
||||||
|
|
||||||
if (*SAFAMILY(¶m->sincl) == *SAFAMILY(¶m->req) && !memcmp(SAADDR(¶m->sincl), SAADDR(¶m->req), SAADDRLEN(¶m->req)) &&
|
|
||||||
*SAPORT(¶m->sincl) == *SAPORT(¶m->req)) return 519;
|
|
||||||
|
|
||||||
if (param->operation == ADMIN || param->operation == DNSRESOLVE || param->operation == BIND || param->operation == UDPASSOC)
|
if (param->operation == ADMIN || param->operation == DNSRESOLVE || param->operation == BIND || param->operation == UDPASSOC)
|
||||||
return 0;
|
return 0;
|
||||||
if (param->remsock != INVALID_SOCKET){
|
if (param->remsock != INVALID_SOCKET){
|
||||||
size = sizeof(param->sinsr);
|
if(so._getpeername(param->remsock, (struct sockaddr *)¶m->sins, &size)==-1) {return (15);}
|
||||||
if(so._getpeername(param->remsock, (struct sockaddr *)¶m->sinsr, &size)==-1) {return (15);}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
struct linger lg = {1,conf.timeouts[SINGLEBYTE_S]};
|
struct linger lg;
|
||||||
|
|
||||||
if(SAISNULL(¶m->sinsr)){
|
if(!param->sins.sin_addr.s_addr)
|
||||||
if(SAISNULL(¶m->req)) {
|
if(!(param->sins.sin_addr.s_addr = param->req.sin_addr.s_addr)) return 100;
|
||||||
return 100;
|
if(!param->sins.sin_port)param->sins.sin_port = param->req.sin_port;
|
||||||
}
|
if ((param->remsock=so._socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) {return (11);}
|
||||||
*SAFAMILY(¶m->sinsr) = *SAFAMILY(¶m->req);
|
so._setsockopt(param->remsock, SOL_SOCKET, SO_LINGER, (unsigned char *)&lg, sizeof(lg));
|
||||||
memcpy(SAADDR(¶m->sinsr), SAADDR(¶m->req), SAADDRLEN(¶m->req));
|
memset(&bindsa, 0, sizeof(bindsa));
|
||||||
}
|
bindsa.sin_family = AF_INET;
|
||||||
if(!*SAPORT(¶m->sinsr))*SAPORT(¶m->sinsr) = *SAPORT(¶m->req);
|
bindsa.sin_port = param->extport;
|
||||||
if ((param->remsock=so._socket(SASOCK(¶m->sinsr), SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) {return (11);}
|
bindsa.sin_addr.s_addr = param->extip;
|
||||||
setopts(param->remsock, param->srv->srvsockopts);
|
if (param->srv->targetport && !bindsa.sin_port && ntohs(param->sinc.sin_port) > 1023) bindsa.sin_port = param->sinc.sin_port;
|
||||||
|
if(so._bind(param->remsock, (struct sockaddr*)&bindsa, sizeof(bindsa))==-1) {
|
||||||
so._setsockopt(param->remsock, SOL_SOCKET, SO_LINGER, (char *)&lg, sizeof(lg));
|
memset(&bindsa, 0, sizeof(bindsa));
|
||||||
#ifdef REUSE
|
bindsa.sin_family = AF_INET;
|
||||||
{
|
bindsa.sin_addr.s_addr = param->extip;
|
||||||
int opt;
|
bindsa.sin_port = 0;
|
||||||
|
if(so._bind(param->remsock, (struct sockaddr*)&bindsa, sizeof(bindsa))==-1) {
|
||||||
#ifdef SO_REUSEADDR
|
|
||||||
opt = 1;
|
|
||||||
so._setsockopt(param->remsock, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(int));
|
|
||||||
#endif
|
|
||||||
#ifdef SO_REUSEPORT
|
|
||||||
opt = 1;
|
|
||||||
so._setsockopt(param->remsock, SOL_SOCKET, SO_REUSEPORT, (unsigned char *)&opt, sizeof(int));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#ifdef SO_BINDTODEVICE
|
|
||||||
if(param->srv->obindtodevice) {
|
|
||||||
if(so._setsockopt(param->remsock, SOL_SOCKET, SO_BINDTODEVICE, param->srv->obindtodevice, strlen(param->srv->obindtodevice) + 1))
|
|
||||||
return 12;
|
return 12;
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if(SAISNULL(¶m->sinsl)){
|
|
||||||
#ifndef NOIPV6
|
|
||||||
if(*SAFAMILY(¶m->sinsr) == AF_INET6) param->sinsl = param->srv->extsa6;
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
param->sinsl = param->srv->extsa;
|
|
||||||
}
|
|
||||||
*SAPORT(¶m->sinsl) = 0;
|
|
||||||
if(so._bind(param->remsock, (struct sockaddr*)¶m->sinsl, SASIZE(¶m->sinsl))==-1) {
|
|
||||||
return 12;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(param->operation >= 256 || (param->operation & CONNECT)){
|
|
||||||
if(connectwithpoll(param->remsock,(struct sockaddr *)¶m->sinsr,SASIZE(¶m->sinsr),CONNECT_TO)) {
|
|
||||||
return 13;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
size = sizeof(param->sinsl);
|
|
||||||
if(so._getsockname(param->remsock, (struct sockaddr *)¶m->sinsl, &size)==-1) {return (15);}
|
param->sins.sin_family = AF_INET;
|
||||||
|
if(param->operation >= 256 || (param->operation & CONNECT)){
|
||||||
|
#ifdef _WIN32
|
||||||
|
unsigned long ul = 1;
|
||||||
|
#endif
|
||||||
|
if(so._connect(param->remsock,(struct sockaddr *)¶m->sins,sizeof(param->sins))) {return (13);}
|
||||||
|
param->nconnects++;
|
||||||
|
#ifdef _WIN32
|
||||||
|
ioctlsocket(param->remsock, FIONBIO, &ul);
|
||||||
|
#else
|
||||||
|
fcntl(param->remsock,F_SETFL,O_NONBLOCK);
|
||||||
|
#endif
|
||||||
|
if(so._getsockname(param->remsock, (struct sockaddr *)&bindsa, &size)==-1) {return (15);}
|
||||||
|
param->extip = bindsa.sin_addr.s_addr;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(so._getsockname(param->remsock, (struct sockaddr *)¶m->sins, &size)==-1) {return (15);}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -490,13 +667,11 @@ struct hostent * my_gethostbyname(char *name, char *buf, struct hostent *hp){
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NOIPV6
|
|
||||||
unsigned long getip(unsigned char *name){
|
unsigned long getip(unsigned char *name){
|
||||||
unsigned long retval;
|
unsigned long retval;
|
||||||
int i;
|
int i;
|
||||||
int ndots = 0;
|
int ndots = 0;
|
||||||
struct hostent *hp=NULL;
|
struct hostent *hp=NULL;
|
||||||
RESOLVFUNC tmpresolv;
|
|
||||||
|
|
||||||
#ifdef GETHOSTBYNAME_R
|
#ifdef GETHOSTBYNAME_R
|
||||||
struct hostent he;
|
struct hostent he;
|
||||||
@@ -513,14 +688,15 @@ unsigned long getip(unsigned char *name){
|
|||||||
if(name[i] <'0' || name[i] >'9') break;
|
if(name[i] <'0' || name[i] >'9') break;
|
||||||
}
|
}
|
||||||
if(!name[i] && ndots == 3){
|
if(!name[i] && ndots == 3){
|
||||||
if(scanaddr(name, &retval, NULL) == 4){
|
unsigned long ip;
|
||||||
return retval;
|
if(scanaddr(name, &ip, NULL) == 4){
|
||||||
|
return ip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if((tmpresolv=resolvfunc)){
|
if(resolvfunc){
|
||||||
if((*tmpresolv)(AF_INET, name, (unsigned char *)&retval)) return retval;
|
if((retval = (*resolvfunc)(name))) return retval;
|
||||||
if(conf.demanddialprog) system(conf.demanddialprog);
|
if(conf.demanddialprog) system(conf.demanddialprog);
|
||||||
return (*tmpresolv)(AF_INET, name, (unsigned char *)&retval)?retval:0;
|
return (*resolvfunc)(name);
|
||||||
}
|
}
|
||||||
#if !defined(_WIN32) && !defined(GETHOSTBYNAME_R)
|
#if !defined(_WIN32) && !defined(GETHOSTBYNAME_R)
|
||||||
if(!ghbn_init){
|
if(!ghbn_init){
|
||||||
@@ -543,92 +719,3 @@ unsigned long getip(unsigned char *name){
|
|||||||
#endif
|
#endif
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
int afdetect(unsigned char *name){
|
|
||||||
int ndots=0, ncols=0, nhex=0;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for(i=0; name[i]; i++){
|
|
||||||
if(name[i] == '.'){
|
|
||||||
if(++ndots > 3) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(name[i] == ':'){
|
|
||||||
if(++ncols > 7) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(name[i] == '%' || (name[i] >= 'a' && name[i] <= 'f') || (name[i] >= 'A' && name[i] <= 'F')){
|
|
||||||
nhex++;
|
|
||||||
}
|
|
||||||
else if(name[i] <'0' || name[i] >'9') {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(ndots == 3 && ncols == 0 && nhex == 0){
|
|
||||||
return AF_INET;
|
|
||||||
}
|
|
||||||
if(ncols >= 2) {
|
|
||||||
return AF_INET6;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned long getip46(int family, unsigned char *name, struct sockaddr *sa){
|
|
||||||
#ifndef NOIPV6
|
|
||||||
int detect;
|
|
||||||
struct addrinfo *ai, hint;
|
|
||||||
RESOLVFUNC tmpresolv;
|
|
||||||
|
|
||||||
if(!sa) return 0;
|
|
||||||
if(!family) {
|
|
||||||
family = 4;
|
|
||||||
#else
|
|
||||||
((struct sockaddr_in *)sa)->sin_family = AF_INET;
|
|
||||||
return (((struct sockaddr_in *)sa)->sin_addr.s_addr = getip(name))? AF_INET:0;
|
|
||||||
#endif
|
|
||||||
#ifndef NOIPV6
|
|
||||||
}
|
|
||||||
|
|
||||||
detect = afdetect(name);
|
|
||||||
if(detect != -1){
|
|
||||||
if(family == 4 && detect != AF_INET) return 0;
|
|
||||||
*SAFAMILY(sa) = (family == 6)? AF_INET6 : detect;
|
|
||||||
return inet_pton(*SAFAMILY(sa), (char *)name, SAADDR(sa))? *SAFAMILY(sa) : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if((tmpresolv = resolvfunc)){
|
|
||||||
int f = (family == 6 || family == 64)?AF_INET6:AF_INET;
|
|
||||||
*SAFAMILY(sa) = f;
|
|
||||||
if(tmpresolv(f, name, SAADDR(sa))) return f;
|
|
||||||
if(family == 4 || family == 6) return 0;
|
|
||||||
f = (family == 46)? AF_INET6 : AF_INET;
|
|
||||||
*SAFAMILY(sa) = f;
|
|
||||||
if(tmpresolv(f, name, SAADDR(sa))) return f;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
memset(&hint, 0, sizeof(hint));
|
|
||||||
hint.ai_family = (family == 6 || family == 64)?AF_INET6:AF_INET;
|
|
||||||
if (getaddrinfo((char *)name, NULL, &hint, &ai)) {
|
|
||||||
if(family == 64 || family == 46){
|
|
||||||
hint.ai_family = (family == 64)?AF_INET:AF_INET6;
|
|
||||||
if (getaddrinfo((char *)name, NULL, &hint, &ai)) return 0;
|
|
||||||
}
|
|
||||||
else return 0;
|
|
||||||
}
|
|
||||||
if(ai){
|
|
||||||
if(ai->ai_addr->sa_family == AF_INET || ai->ai_addr->sa_family == AF_INET6){
|
|
||||||
*SAFAMILY(sa)=ai->ai_addr->sa_family;
|
|
||||||
memcpy(SAADDR(sa), SAADDR(ai->ai_addr), SAADDRLEN(ai->ai_addr));
|
|
||||||
freeaddrinfo(ai);
|
|
||||||
return *SAFAMILY(sa);
|
|
||||||
}
|
|
||||||
freeaddrinfo(ai);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
-1878
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,145 @@
|
|||||||
|
/*
|
||||||
|
3APA3A simpliest proxy server
|
||||||
|
(c) 2002-2008 by ZARAZA <3APA3A@security.nnov.ru>
|
||||||
|
|
||||||
|
please read License Agreement
|
||||||
|
|
||||||
|
$Id: common.c,v 1.81 2007/12/18 09:26:44 vlad Exp $
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "proxy.h"
|
||||||
|
|
||||||
|
struct counter_header {
|
||||||
|
unsigned char sig[4];
|
||||||
|
time_t updated;
|
||||||
|
} cheader = {"3CF", (time_t)0};
|
||||||
|
|
||||||
|
|
||||||
|
struct counter_record {
|
||||||
|
unsigned long traf;
|
||||||
|
unsigned long trafgb;
|
||||||
|
time_t cleared;
|
||||||
|
time_t updated;
|
||||||
|
} crecord;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
struct counter_header_old {
|
||||||
|
unsigned char sig[4];
|
||||||
|
DWORD updated;
|
||||||
|
} cheader_old = {"3CF", (time_t)0};
|
||||||
|
|
||||||
|
|
||||||
|
struct counter_record_old {
|
||||||
|
unsigned long traf;
|
||||||
|
unsigned long trafgb;
|
||||||
|
DWORD cleared;
|
||||||
|
DWORD updated;
|
||||||
|
} crecord_old;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]){
|
||||||
|
FILE *txt;
|
||||||
|
int bin;
|
||||||
|
int i;
|
||||||
|
long unsigned lu1, lu2;
|
||||||
|
char buf[256];
|
||||||
|
if(argc!=4){
|
||||||
|
fprintf(stderr, "Usage: %s command binary_file text_file\n"
|
||||||
|
" commands are:\n"
|
||||||
|
"\texport - dump counterfile to text\n"
|
||||||
|
#ifdef _WIN32
|
||||||
|
"\toldexport - export counterfile from older 3proxy version\n"
|
||||||
|
#endif
|
||||||
|
"\timport- import counterfile from text\n"
|
||||||
|
"Examples:\n"
|
||||||
|
#ifdef _WIN32
|
||||||
|
" %s oldexport counterfile.3cf tmpfile\n"
|
||||||
|
#else
|
||||||
|
" %s export counterfilenew.3cf tmpfile\n"
|
||||||
|
#endif
|
||||||
|
" %s import counterfilenew.3cf tmpfile\n"
|
||||||
|
"text file record format:\n"
|
||||||
|
"%%d %%10lu %%10lu %%lu %%lu\n"
|
||||||
|
" 1 - counter number\n"
|
||||||
|
" 2 - traffic (Bytes)\n"
|
||||||
|
" 3 - traffic (GB)\n"
|
||||||
|
" 4 - time counter reset (time_t)\n"
|
||||||
|
" 5 - time counter updated (time_t)\n"
|
||||||
|
,argv[0] , argv[0], argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if(!strcmp(argv[1], "export")){
|
||||||
|
bin = open((char *)argv[2], O_BINARY|O_RDONLY, 0660);
|
||||||
|
if(bin < 0){
|
||||||
|
fprintf(stderr, "Failed to open %s\n", argv[2]);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
if(read(bin, &cheader, sizeof(cheader)) != sizeof(cheader) ||
|
||||||
|
memcmp(&cheader, "3CF", 4)){
|
||||||
|
fprintf(stderr, "Invalid counter file\n");
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
txt = fopen(argv[3], "w");
|
||||||
|
if(!txt) txt = stdout;
|
||||||
|
for(i=1; read(bin, &crecord, sizeof(crecord))==sizeof(crecord); i++)
|
||||||
|
fprintf(txt,"%d %10lu %10lu %lu %lu\n", i,
|
||||||
|
crecord.trafgb,
|
||||||
|
crecord.traf,
|
||||||
|
(unsigned long) crecord.cleared,
|
||||||
|
(unsigned long) crecord.updated);
|
||||||
|
}
|
||||||
|
#ifdef _WIN32
|
||||||
|
else if(!strcmp(argv[1], "oldexport")){
|
||||||
|
bin = open((char *)argv[2], O_BINARY|O_RDONLY, 0660);
|
||||||
|
if(bin < 0){
|
||||||
|
fprintf(stderr, "Failed to open %s\n", argv[2]);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
if(read(bin, &cheader_old, sizeof(cheader_old)) != sizeof(cheader_old) ||
|
||||||
|
memcmp(&cheader, "3CF", 4)){
|
||||||
|
fprintf(stderr, "Invalid counter file\n");
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
txt = fopen(argv[3], "w");
|
||||||
|
if(!txt) txt = stdout;
|
||||||
|
for(i=1; read(bin, &crecord_old, sizeof(crecord_old))==sizeof(crecord_old); i++)
|
||||||
|
fprintf(txt, "%d %10lu %10lu %lu %lu\n", i,
|
||||||
|
crecord_old.trafgb,
|
||||||
|
crecord_old.traf,
|
||||||
|
(unsigned long) crecord_old.cleared,
|
||||||
|
(unsigned long) crecord_old.updated);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
else if(!strcmp(argv[1], "import")){
|
||||||
|
bin = open((char *)argv[2], O_BINARY|O_WRONLY|O_CREAT|O_EXCL, 0660);
|
||||||
|
if(bin < 0){
|
||||||
|
fprintf(stderr, "Failed to open %s\n", argv[2]);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
txt = fopen(argv[3], "r");
|
||||||
|
if(!txt) {
|
||||||
|
fprintf(stderr, "Failed to open %s\n", argv[3]);
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
cheader.updated = time(0);
|
||||||
|
write(bin, &cheader, sizeof(cheader));
|
||||||
|
while(fgets(buf, 256, txt) &&
|
||||||
|
sscanf(buf, "%d %10lu %10lu %lu %lu\n",
|
||||||
|
&i, &crecord.trafgb, &crecord.traf,
|
||||||
|
&lu1, &lu2) == 5){
|
||||||
|
|
||||||
|
crecord.cleared = (time_t) lu1;
|
||||||
|
crecord.updated = (time_t) lu1;
|
||||||
|
lseek(bin,
|
||||||
|
sizeof(struct counter_header) + (i-1) * sizeof(crecord),
|
||||||
|
SEEK_SET);
|
||||||
|
write(bin, &crecord, sizeof(crecord));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(stderr, "Unknown command: %s\n", argv[1]);
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
+132
-136
@@ -1,17 +1,13 @@
|
|||||||
/*
|
/*
|
||||||
(c) 2002-2016 by Vladimir Dubrovin <3proxy@3proxy.ru>
|
* Copyright (c) 2000-2008 3APA3A
|
||||||
|
*
|
||||||
please read License Agreement
|
* please read License Agreement
|
||||||
|
*
|
||||||
*/
|
* $Id: datatypes.c,v 1.28 2009/08/14 09:56:21 v.dubrovin Exp $
|
||||||
|
*/
|
||||||
|
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
|
|
||||||
static void pr_unsigned64(struct node *node, CBFUNC cbf, void*cb){
|
|
||||||
char buf[32];
|
|
||||||
if(node->value)(*cbf)(cb, buf, sprintf(buf, "%"PRINTF_INT64_MODIFIER"u", *(uint64_t *)node->value));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void pr_integer(struct node *node, CBFUNC cbf, void*cb){
|
static void pr_integer(struct node *node, CBFUNC cbf, void*cb){
|
||||||
char buf[16];
|
char buf[16];
|
||||||
if(node->value)(*cbf)(cb, buf, sprintf(buf, "%d", *(int *)node->value));
|
if(node->value)(*cbf)(cb, buf, sprintf(buf, "%d", *(int *)node->value));
|
||||||
@@ -56,29 +52,19 @@ static void pr_datetime(struct node *node, CBFUNC cbf, void*cb){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ipprint(char *buf, unsigned uu){
|
||||||
|
unsigned u = ntohl(uu);
|
||||||
|
|
||||||
|
return sprintf(buf, "%u.%u.%u.%u",
|
||||||
|
((u&0xFF000000)>>24),
|
||||||
|
((u&0x00FF0000)>>16),
|
||||||
|
((u&0x0000FF00)>>8),
|
||||||
|
((u&0x000000FF)));
|
||||||
|
}
|
||||||
|
|
||||||
static void pr_ip(struct node *node, CBFUNC cbf, void*cb){
|
static void pr_ip(struct node *node, CBFUNC cbf, void*cb){
|
||||||
char buf[16];
|
char buf[16];
|
||||||
if(node->value)(*cbf)(cb, buf, myinet_ntop(AF_INET, node -> value, buf, 4));
|
if(node->value)(*cbf)(cb, buf, ipprint(buf, *(unsigned *)node -> value));
|
||||||
}
|
|
||||||
|
|
||||||
#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){
|
|
||||||
#ifdef NOIPV6
|
|
||||||
if(node->value)pr_ip(node, cbf, cb);
|
|
||||||
#else
|
|
||||||
char buf[64];
|
|
||||||
buf[0] = '[';
|
|
||||||
buf[1] = 0;
|
|
||||||
inet_ntop(*SAFAMILY(node->value), SAADDR(node->value), buf+1, sizeof(buf)-10);
|
|
||||||
sprintf(buf + strlen(buf), "]:%hu", (unsigned short)*SAPORT(node->value));
|
|
||||||
if(node->value)(*cbf)(cb, buf, strlen(buf));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pr_wdays(struct node *node, CBFUNC cbf, void*cb){
|
static void pr_wdays(struct node *node, CBFUNC cbf, void*cb){
|
||||||
@@ -239,22 +225,9 @@ static void pr_userlist(struct node *node, CBFUNC cbf, void*cb){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int printiple(char *buf, struct iplist* ipl){
|
|
||||||
int addrlen = (ipl->family == AF_INET6)?16:4, i;
|
|
||||||
i = myinet_ntop(ipl->family, &ipl->ip_from, buf, addrlen);
|
|
||||||
if(memcmp(&ipl->ip_from, &ipl->ip_to, addrlen)){
|
|
||||||
buf[i++] = '-';
|
|
||||||
i += myinet_ntop(ipl->family, &ipl->ip_from, buf+i, addrlen);
|
|
||||||
}
|
|
||||||
if(ipl->next){
|
|
||||||
buf[i++] = ',';
|
|
||||||
buf[i++] = ' ';
|
|
||||||
}
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void pr_iplist(struct node *node, CBFUNC cbf, void*cb){
|
static void pr_iplist(struct node *node, CBFUNC cbf, void*cb){
|
||||||
char buf[128];
|
char buf[20];
|
||||||
|
int i;
|
||||||
struct iplist *il = (struct iplist *)node->value;
|
struct iplist *il = (struct iplist *)node->value;
|
||||||
|
|
||||||
if(!il) {
|
if(!il) {
|
||||||
@@ -262,7 +235,10 @@ static void pr_iplist(struct node *node, CBFUNC cbf, void*cb){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for(; il; il = il->next){
|
for(; il; il = il->next){
|
||||||
(*cbf)(cb, buf, printiple(buf, il));
|
i = ipprint(buf, il->ip);
|
||||||
|
i += cidrprint(buf+i, il->mask);
|
||||||
|
if(il->next)buf[i++] = ',';
|
||||||
|
(*cbf)(cb, buf, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,6 +259,18 @@ static void * ef_iplist_next(struct node *node){
|
|||||||
return (((struct iplist *)node->value) -> next);
|
return (((struct iplist *)node->value) -> next);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void * ef_iplist_ip(struct node *node){
|
||||||
|
return &(((struct iplist *)node->value) -> ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void * ef_iplist_cidr(struct node *node){
|
||||||
|
return &(((struct iplist *)node->value) -> mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void * ef_iplist_mask(struct node *node){
|
||||||
|
return &(((struct iplist *)node->value) -> mask);
|
||||||
|
}
|
||||||
|
|
||||||
static void * ef_userlist_next(struct node * node){
|
static void * ef_userlist_next(struct node * node){
|
||||||
return (((struct userlist *)node->value) -> next);
|
return (((struct userlist *)node->value) -> next);
|
||||||
}
|
}
|
||||||
@@ -345,8 +333,12 @@ static void * ef_chain_type(struct node * node){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * ef_chain_addr(struct node * node){
|
static void * ef_chain_ip(struct node * node){
|
||||||
return &((struct chain *)node->value) -> addr;
|
return &((struct chain *)node->value) -> redirip;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void * ef_chain_port(struct node * node){
|
||||||
|
return &((struct chain *)node->value) -> redirport;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * ef_chain_weight(struct node * node){
|
static void * ef_chain_weight(struct node * node){
|
||||||
@@ -384,10 +376,6 @@ static void * ef_ace_type(struct node * node){
|
|||||||
return "countout";
|
return "countout";
|
||||||
case NOCOUNTOUT:
|
case NOCOUNTOUT:
|
||||||
return "nocountout";
|
return "nocountout";
|
||||||
case COUNTALL:
|
|
||||||
return "countall";
|
|
||||||
case NOCOUNTALL:
|
|
||||||
return "nocountall";
|
|
||||||
default:
|
default:
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
@@ -458,26 +446,12 @@ static void * ef_trafcounter_type(struct node * node){
|
|||||||
return &((struct trafcount *)node->value) -> type;
|
return &((struct trafcount *)node->value) -> type;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * ef_trafcounter_traffic64(struct node * node){
|
static void * ef_trafcounter_traffic(struct node * node){
|
||||||
return &((struct trafcount *)node->value) -> traf64;
|
return &((struct trafcount *)node->value) -> traf;
|
||||||
}
|
|
||||||
static void * ef_trafcounter_limit64(struct node * node){
|
|
||||||
return &((struct trafcount *)node->value) -> traflim64;
|
|
||||||
}
|
|
||||||
static void * ef_client_maxtrafin64(struct node * node){
|
|
||||||
return &((struct clientparam *)node->value) -> maxtrafin64;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * ef_client_maxtrafout64(struct node * node){
|
static void * ef_trafcounter_limit(struct node * node){
|
||||||
return &((struct clientparam *)node->value) -> maxtrafout64;
|
return &((struct trafcount *)node->value) -> traflim;
|
||||||
}
|
|
||||||
|
|
||||||
static void * ef_client_bytesin64(struct node * node){
|
|
||||||
return &((struct clientparam *)node->value) -> statssrv64;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void * ef_client_bytesout64(struct node * node){
|
|
||||||
return &((struct clientparam *)node->value) -> statscli64;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * ef_trafcounter_cleared(struct node * node){
|
static void * ef_trafcounter_cleared(struct node * node){
|
||||||
@@ -513,6 +487,7 @@ static void * ef_server_auth(struct node * node){
|
|||||||
AUTHFUNC af = ((struct srvparam *)node->value) -> authfunc;
|
AUTHFUNC af = ((struct srvparam *)node->value) -> authfunc;
|
||||||
|
|
||||||
if(af == alwaysauth) return "none";
|
if(af == alwaysauth) return "none";
|
||||||
|
if(af == nbnameauth) return "nbname";
|
||||||
if(af == ipauth) return "iponly";
|
if(af == ipauth) return "iponly";
|
||||||
if(af == strongauth) return "strong";
|
if(af == strongauth) return "strong";
|
||||||
return "uknown";
|
return "uknown";
|
||||||
@@ -524,9 +499,6 @@ static void * ef_server_childcount(struct node * node){
|
|||||||
|
|
||||||
static void * ef_server_log(struct node * node){
|
static void * ef_server_log(struct node * node){
|
||||||
if(((struct srvparam *)node->value) -> logfunc == lognone) return "none";
|
if(((struct srvparam *)node->value) -> logfunc == lognone) return "none";
|
||||||
#ifndef NORADIUS
|
|
||||||
else if(((struct srvparam *)node->value) -> logfunc == logradius) return "radius";
|
|
||||||
#endif
|
|
||||||
else if(((struct srvparam *)node->value) -> logfunc == logstdout)
|
else if(((struct srvparam *)node->value) -> logfunc == logstdout)
|
||||||
return (((struct srvparam *)node->value) -> logtarget)?"file":"stdout";
|
return (((struct srvparam *)node->value) -> logtarget)?"file":"stdout";
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
@@ -564,19 +536,21 @@ static void * ef_server_targetport(struct node * node){
|
|||||||
return &((struct srvparam *)node->value) -> targetport;
|
return &((struct srvparam *)node->value) -> targetport;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * ef_server_intsa(struct node * node){
|
static void * ef_server_intip(struct node * node){
|
||||||
return &((struct srvparam *)node->value) -> intsa;
|
return &((struct srvparam *)node->value) -> intip;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * ef_server_extsa(struct node * node){
|
static void * ef_server_extip(struct node * node){
|
||||||
return &((struct srvparam *)node->value) -> extsa;
|
return &((struct srvparam *)node->value) -> extip;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NOIPV6
|
static void * ef_server_intport(struct node * node){
|
||||||
static void * ef_server_extsa6(struct node * node){
|
return &((struct srvparam *)node->value) -> intport;
|
||||||
return &((struct srvparam *)node->value) -> extsa6;
|
}
|
||||||
|
|
||||||
|
static void * ef_server_extport(struct node * node){
|
||||||
|
return &((struct srvparam *)node->value) -> extport;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static void * ef_server_acl(struct node * node){
|
static void * ef_server_acl(struct node * node){
|
||||||
return ((struct srvparam *)node->value) -> acl;
|
return ((struct srvparam *)node->value) -> acl;
|
||||||
@@ -599,6 +573,14 @@ static void * ef_client_next(struct node * node){
|
|||||||
return ((struct clientparam *)node->value) -> next;
|
return ((struct clientparam *)node->value) -> next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void * ef_client_maxtrafin(struct node * node){
|
||||||
|
return &((struct clientparam *)node->value) -> maxtrafin;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void * ef_client_maxtrafout(struct node * node){
|
||||||
|
return &((struct clientparam *)node->value) -> maxtrafout;
|
||||||
|
}
|
||||||
|
|
||||||
static void * ef_client_type(struct node * node){
|
static void * ef_client_type(struct node * node){
|
||||||
int service = ((struct clientparam *)node->value) -> service;
|
int service = ((struct clientparam *)node->value) -> service;
|
||||||
return (service>=0 && service < 15)? (void *)conf.stringtable[SERVICES + service] : (void *)"unknown";
|
return (service>=0 && service < 15)? (void *)conf.stringtable[SERVICES + service] : (void *)"unknown";
|
||||||
@@ -635,16 +617,36 @@ static void * ef_client_extpassword(struct node * node){
|
|||||||
return ((struct clientparam *)node->value) -> extpassword;
|
return ((struct clientparam *)node->value) -> extpassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * ef_client_clisa(struct node * node){
|
static void * ef_client_cliip(struct node * node){
|
||||||
return &((struct clientparam *)node->value) -> sincr;
|
return &((struct clientparam *)node->value) -> sinc.sin_addr.s_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * ef_client_srvsa(struct node * node){
|
static void * ef_client_srvip(struct node * node){
|
||||||
return &((struct clientparam *)node->value) -> sinsr;
|
return &((struct clientparam *)node->value) -> sins.sin_addr.s_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * ef_client_reqsa(struct node * node){
|
static void * ef_client_reqip(struct node * node){
|
||||||
return &((struct clientparam *)node->value) -> req;
|
return &((struct clientparam *)node->value) -> req.sin_addr.s_addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void * ef_client_reqport(struct node * node){
|
||||||
|
return &((struct clientparam *)node->value) -> req.sin_port;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void * ef_client_srvport(struct node * node){
|
||||||
|
return &((struct clientparam *)node->value) -> sins.sin_port;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void * ef_client_cliport(struct node * node){
|
||||||
|
return &((struct clientparam *)node->value) -> sinc.sin_port;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void * ef_client_bytesin(struct node * node){
|
||||||
|
return &((struct clientparam *)node->value) -> statssrv;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void * ef_client_bytesout(struct node * node){
|
||||||
|
return &((struct clientparam *)node->value) -> statscli;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * ef_client_pwtype(struct node * node){
|
static void * ef_client_pwtype(struct node * node){
|
||||||
@@ -655,14 +657,6 @@ static void * ef_client_threadid(struct node * node){
|
|||||||
return &((struct clientparam *)node->value) -> threadid;
|
return &((struct clientparam *)node->value) -> threadid;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * ef_client_clisock(struct node * node){
|
|
||||||
return &((struct clientparam *)node->value) -> clisock;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void * ef_client_remsock(struct node * node){
|
|
||||||
return &((struct clientparam *)node->value) -> remsock;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void * ef_client_starttime(struct node * node){
|
static void * ef_client_starttime(struct node * node){
|
||||||
return &((struct clientparam *)node->value) -> time_start;
|
return &((struct clientparam *)node->value) -> time_start;
|
||||||
}
|
}
|
||||||
@@ -701,12 +695,20 @@ static struct property prop_pwlist[] = {
|
|||||||
{NULL, "next", ef_pwlist_next, TYPE_PWLIST, "next"}
|
{NULL, "next", ef_pwlist_next, TYPE_PWLIST, "next"}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static struct property prop_iplist[] = {
|
||||||
|
{prop_iplist + 1, "ip", ef_iplist_ip, TYPE_IP, "ip address"},
|
||||||
|
{prop_iplist + 2, "cidr", ef_iplist_cidr, TYPE_CIDR, "ip mask length"},
|
||||||
|
{prop_iplist + 3, "mask", ef_iplist_mask, TYPE_IP, "ip mask"},
|
||||||
|
{NULL, "next", ef_iplist_next, TYPE_IPLIST, "next"}
|
||||||
|
};
|
||||||
|
|
||||||
static struct property prop_chain[] = {
|
static struct property prop_chain[] = {
|
||||||
{prop_chain + 1, "addr", ef_chain_addr, TYPE_SA, "parent address"},
|
{prop_chain + 1, "ip", ef_chain_ip, TYPE_IP, "parent ip address"},
|
||||||
{prop_chain + 2, "type", ef_chain_type, TYPE_STRING, "parent type"},
|
{prop_chain + 2, "port", ef_chain_port, TYPE_PORT, "parent port"},
|
||||||
{prop_chain + 3, "weight", ef_chain_weight, TYPE_SHORT, "parent weight 0-1000"},
|
{prop_chain + 3, "type", ef_chain_type, TYPE_STRING, "parent type"},
|
||||||
{prop_chain + 4, "user", ef_chain_user, TYPE_STRING, "parent login"},
|
{prop_chain + 4, "weight", ef_chain_weight, TYPE_SHORT, "parent weight 0-1000"},
|
||||||
{prop_chain + 5, "password", ef_chain_password, TYPE_STRING, "parent password"},
|
{prop_chain + 5, "user", ef_chain_user, TYPE_STRING, "parent login"},
|
||||||
|
{prop_chain + 6, "password", ef_chain_password, TYPE_STRING, "parent password"},
|
||||||
{NULL, "next", ef_chain_next, TYPE_CHAIN, "next"}
|
{NULL, "next", ef_chain_next, TYPE_CHAIN, "next"}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -740,10 +742,8 @@ static struct property prop_trafcounter[] = {
|
|||||||
{prop_trafcounter + 2, "ace", ef_trafcounter_ace, TYPE_ACE, "traffic to count"},
|
{prop_trafcounter + 2, "ace", ef_trafcounter_ace, TYPE_ACE, "traffic to count"},
|
||||||
{prop_trafcounter + 3, "number", ef_trafcounter_number, TYPE_UNSIGNED, "counter number"},
|
{prop_trafcounter + 3, "number", ef_trafcounter_number, TYPE_UNSIGNED, "counter number"},
|
||||||
{prop_trafcounter + 4, "type", ef_trafcounter_type, TYPE_ROTATION, "rotation type"},
|
{prop_trafcounter + 4, "type", ef_trafcounter_type, TYPE_ROTATION, "rotation type"},
|
||||||
|
{prop_trafcounter + 5, "traffic", ef_trafcounter_traffic, TYPE_TRAFFIC, "counter value"},
|
||||||
|
{prop_trafcounter + 6, "limit", ef_trafcounter_limit, TYPE_TRAFFIC, "counter limit"},
|
||||||
{prop_trafcounter + 5, "traffic", ef_trafcounter_traffic64, TYPE_UNSIGNED64, "counter value"},
|
|
||||||
{prop_trafcounter + 6, "limit", ef_trafcounter_limit64, TYPE_UNSIGNED64, "counter limit"},
|
|
||||||
{prop_trafcounter + 7, "cleared", ef_trafcounter_cleared, TYPE_DATETIME, "last rotated"},
|
{prop_trafcounter + 7, "cleared", ef_trafcounter_cleared, TYPE_DATETIME, "last rotated"},
|
||||||
{prop_trafcounter + 8, "updated", ef_trafcounter_updated, TYPE_DATETIME, "last updated"},
|
{prop_trafcounter + 8, "updated", ef_trafcounter_updated, TYPE_DATETIME, "last updated"},
|
||||||
{prop_trafcounter + 9, "comment", ef_trafcounter_comment, TYPE_STRING, "counter comment"},
|
{prop_trafcounter + 9, "comment", ef_trafcounter_comment, TYPE_STRING, "counter comment"},
|
||||||
@@ -758,24 +758,21 @@ 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, "auth", ef_server_auth, TYPE_STRING, "service authentication type"},
|
{prop_server + 5, "intip", ef_server_intip, TYPE_IP, "ip address of internal interface"},
|
||||||
{prop_server + 6, "acl", ef_server_acl, TYPE_ACE, "access control list"},
|
{prop_server + 6, "extip", ef_server_extip, TYPE_IP, "ip address of external interface"},
|
||||||
{prop_server + 7, "singlepacket", ef_server_singlepacket, TYPE_INTEGER, "is single packet redirection"},
|
{prop_server + 7, "intport", ef_server_intport, TYPE_PORT, "port to listen"},
|
||||||
{prop_server + 8, "usentlm", ef_server_usentlm, TYPE_INTEGER, "allow NTLM authentication"},
|
{prop_server + 8, "extport", ef_server_extport, TYPE_PORT, "port to use for outgoing connection"},
|
||||||
{prop_server + 9, "log", ef_server_log, TYPE_STRING, "type of logging"},
|
{prop_server + 9, "auth", ef_server_auth, TYPE_STRING, "service authentication type"},
|
||||||
{prop_server + 10, "logtarget", ef_server_logtarget, TYPE_STRING, "log target options"},
|
{prop_server + 10, "acl", ef_server_acl, TYPE_ACE, "access control list"},
|
||||||
{prop_server + 11, "logformat", ef_server_logformat, TYPE_STRING, "logging format string"},
|
{prop_server + 11, "singlepacket", ef_server_singlepacket, TYPE_INTEGER, "is single packet redirection"},
|
||||||
{prop_server + 12, "nonprintable", ef_server_nonprintable, TYPE_STRING, "non printable characters"},
|
{prop_server + 12, "usentlm", ef_server_usentlm, TYPE_INTEGER, "allow NTLM authentication"},
|
||||||
{prop_server + 13, "replacement", ef_server_replacement, TYPE_CHAR, "replacement character"},
|
{prop_server + 13, "log", ef_server_log, TYPE_STRING, "type of logging"},
|
||||||
{prop_server + 14, "childcount", ef_server_childcount, TYPE_INTEGER, "number of servers connected"},
|
{prop_server + 14, "logtarget", ef_server_logtarget, TYPE_STRING, "log target options"},
|
||||||
{prop_server + 15, "intsa", ef_server_intsa, TYPE_SA, "ip address of internal interface"},
|
{prop_server + 15, "logformat", ef_server_logformat, TYPE_STRING, "logging format string"},
|
||||||
{prop_server + 16, "extsa", ef_server_extsa, TYPE_SA, "ip address of external interface"},
|
{prop_server + 16, "nonprintable", ef_server_nonprintable, TYPE_STRING, "non printable characters"},
|
||||||
#ifndef NOIPV6
|
{prop_server + 17, "replacement", ef_server_replacement, TYPE_CHAR, "replacement character"},
|
||||||
{prop_server + 17, "extsa6", ef_server_extsa6, TYPE_SA, "ipv6 address of external interface"},
|
{prop_server + 18, "childcount", ef_server_childcount, TYPE_INTEGER, "number of servers connected"},
|
||||||
{prop_server + 18, "child", ef_server_child, TYPE_CLIENT, "connected clients"},
|
{prop_server + 19, "child", ef_server_child, TYPE_CLIENT, "connected clients"},
|
||||||
#else
|
|
||||||
{prop_server + 17, "child", ef_server_child, TYPE_CLIENT, "connected clients"},
|
|
||||||
#endif
|
|
||||||
{NULL, "next", ef_server_next, TYPE_SERVER, "next"}
|
{NULL, "next", ef_server_next, TYPE_SERVER, "next"}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -792,16 +789,17 @@ static struct property prop_client[] = {
|
|||||||
{prop_client + 9, "extpassword", ef_client_extpassword, TYPE_STRING, "password for requested host"},
|
{prop_client + 9, "extpassword", ef_client_extpassword, TYPE_STRING, "password for requested host"},
|
||||||
{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, "cliip", ef_client_cliip, TYPE_IP, "client ip"},
|
||||||
{prop_client + 13, "srvsa", ef_client_srvsa, TYPE_SA, "target server sa"},
|
{prop_client + 13, "cliport", ef_client_cliport, TYPE_PORT, "client port"},
|
||||||
{prop_client + 14, "reqsa", ef_client_reqsa, TYPE_SA, "requested server sa"},
|
{prop_client + 14, "srvip", ef_client_srvip, TYPE_IP, "target server ip"},
|
||||||
{prop_client + 15, "bytesin", ef_client_bytesin64, TYPE_UNSIGNED64, "bytes from server to client"},
|
{prop_client + 15, "srvport", ef_client_srvport, TYPE_PORT, "target server port"},
|
||||||
{prop_client + 16, "bytesout", ef_client_bytesout64, TYPE_UNSIGNED64, "bytes from client to server"},
|
{prop_client + 16, "reqip", ef_client_reqip, TYPE_IP, "requested server ip"},
|
||||||
{prop_client + 17, "maxtrafin", ef_client_maxtrafin64, TYPE_UNSIGNED64, "maximum traffic allowed for download"},
|
{prop_client + 17, "reqport", ef_client_reqport, TYPE_PORT, "requested server port"},
|
||||||
{prop_client + 18, "maxtrafout", ef_client_maxtrafout64, TYPE_UNSIGNED64, "maximum traffic allowed for upload"},
|
{prop_client + 18, "bytesin", ef_client_bytesin, TYPE_UNSIGNED, "bytes from server to client"},
|
||||||
{prop_client + 19, "pwtype", ef_client_pwtype, TYPE_INTEGER, "type of client password"},
|
{prop_client + 19, "bytesout", ef_client_bytesout, TYPE_UNSIGNED, "bytes from client to server"},
|
||||||
{prop_client + 20, "clisock", ef_client_clisock, TYPE_INTEGER, "client socket"},
|
{prop_client + 20, "pwtype", ef_client_pwtype, TYPE_INTEGER, "type of client password"},
|
||||||
{prop_client + 21, "remsock", ef_client_remsock, TYPE_INTEGER, "remote socket"},
|
{prop_client + 21, "maxtrafin", ef_client_maxtrafin, TYPE_UNSIGNED, "maximum traffic allowed for download"},
|
||||||
|
{prop_client + 22, "maxtrafout", ef_client_maxtrafout, TYPE_UNSIGNED, "maximum traffic allowed for upload"},
|
||||||
{NULL, "next", ef_client_next, TYPE_CLIENT, "next"}
|
{NULL, "next", ef_client_next, TYPE_CLIENT, "next"}
|
||||||
|
|
||||||
|
|
||||||
@@ -812,18 +810,16 @@ struct datatype datatypes[64] = {
|
|||||||
{"short", NULL, pr_short, NULL},
|
{"short", NULL, pr_short, NULL},
|
||||||
{"char", NULL, pr_char, NULL},
|
{"char", NULL, pr_char, NULL},
|
||||||
{"unsigned", NULL, pr_unsigned, NULL},
|
{"unsigned", NULL, pr_unsigned, NULL},
|
||||||
{"unsigned64", NULL, pr_unsigned64, NULL},
|
|
||||||
{"traffic", NULL, pr_traffic, NULL},
|
{"traffic", NULL, pr_traffic, NULL},
|
||||||
{"port", NULL, pr_port, NULL},
|
{"port", NULL, pr_port, NULL},
|
||||||
{"ip", NULL, pr_ip, NULL},
|
{"ip", NULL, pr_ip, NULL},
|
||||||
{"sa", NULL, pr_sa, NULL},
|
|
||||||
{"cidr", NULL, pr_cidr, NULL},
|
{"cidr", NULL, pr_cidr, NULL},
|
||||||
{"string", NULL, pr_string, NULL},
|
{"string", NULL, pr_string, NULL},
|
||||||
{"datetime", NULL, pr_datetime, NULL},
|
{"datetime", NULL, pr_datetime, NULL},
|
||||||
{"operations", NULL, pr_operations, NULL},
|
{"operations", NULL, pr_operations, NULL},
|
||||||
{"rotation", NULL, pr_rotation, NULL},
|
{"rotation", NULL, pr_rotation, NULL},
|
||||||
{"portlist", ef_portlist_next, pr_portlist, prop_portlist},
|
{"portlist", ef_portlist_next, pr_portlist, prop_portlist},
|
||||||
{"iplist", ef_iplist_next, pr_iplist, NULL},
|
{"iplist", ef_iplist_next, pr_iplist, prop_iplist},
|
||||||
{"userlist", ef_userlist_next, pr_userlist, prop_userlist},
|
{"userlist", ef_userlist_next, pr_userlist, prop_userlist},
|
||||||
{"pwlist", ef_pwlist_next, NULL, prop_pwlist},
|
{"pwlist", ef_pwlist_next, NULL, prop_pwlist},
|
||||||
{"chain", ef_chain_next, NULL, prop_chain},
|
{"chain", ef_chain_next, NULL, prop_chain},
|
||||||
|
|||||||
+142
@@ -0,0 +1,142 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2000-2008 3APA3A
|
||||||
|
*
|
||||||
|
* please read License Agreement
|
||||||
|
*
|
||||||
|
* $Id: dighosts.c,v 1.10 2009/10/06 08:38:00 v.dubrovin Exp $
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "proxy.h"
|
||||||
|
|
||||||
|
|
||||||
|
int sockgetchar(SOCKET sock, int timeosec, int timeousec){
|
||||||
|
unsigned char buf;
|
||||||
|
fd_set fds;
|
||||||
|
struct timeval tv;
|
||||||
|
|
||||||
|
tv.tv_sec = timeosec;
|
||||||
|
tv.tv_usec = timeousec;
|
||||||
|
FD_ZERO(&fds);
|
||||||
|
FD_SET(sock, &fds);
|
||||||
|
if (select (((int)sock)+1, &fds, NULL, NULL, &tv)!=1) return EOF;
|
||||||
|
if (recv(sock, &buf, 1, 0)!=1) return EOF;
|
||||||
|
return((int)buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int sockgetline(SOCKET sock, unsigned char * buf, int bufsize, int delim, int to){
|
||||||
|
int c;
|
||||||
|
int i=0, tos, tou;
|
||||||
|
if(bufsize<2) return 0;
|
||||||
|
c = sockgetchar(sock, to, 0);
|
||||||
|
if (c == EOF) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
tos = to/16;
|
||||||
|
tou = ((to * 1000) / bufsize)%1000;
|
||||||
|
do {
|
||||||
|
buf[i++] = c;
|
||||||
|
if(delim != EOF && c == delim) break;
|
||||||
|
}while(i < bufsize && (c = sockgetchar(sock, tos, tou)) != EOF);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned char request[] = "GET %.1024s HTTP/1.0\r\nHost: %.256s\r\n\r\n";
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]){
|
||||||
|
unsigned char *host, *hostend;
|
||||||
|
SOCKET sock;
|
||||||
|
struct sockaddr_in sa;
|
||||||
|
FILE *fp;
|
||||||
|
unsigned char buf[16000];
|
||||||
|
int i;
|
||||||
|
unsigned x,y,z,w,cidr, x1,y1,z1,w1, mask;
|
||||||
|
int first = 1;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
WSADATA wd;
|
||||||
|
WSAStartup(MAKEWORD( 1, 1 ), &wd);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(argc < 3 || argc > 4 || (argc == 4 && (argv[1][0] != '-' || argv[1][1] != 'm'))) {
|
||||||
|
fprintf(stderr, "Usage: %s [-m] <URL> <FILE>\n"
|
||||||
|
" program retrieves requested <URL> and builds comma delimited list of networks\n"
|
||||||
|
" list than stored in <FILE>\n"
|
||||||
|
" networks are searched in xxx.yyy.zzz.www/cidr format\n"
|
||||||
|
" switches:\n"
|
||||||
|
" -m networks are searched in xxx.yyy.zzz.www mmm.mmm.mmm.mmm format\n"
|
||||||
|
"\n(c)2002 by 3APA3A\n",
|
||||||
|
argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if(strncasecmp(argv[argc-2], "http://", 7)) {
|
||||||
|
fprintf(stderr, "URL must be HTTP://\n");
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
hostend = (unsigned char *)strchr((char *)argv[argc-2] + 7, '/');
|
||||||
|
if(!hostend) {
|
||||||
|
fprintf(stderr, "Wrong URL syntaxis\n");
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
*hostend = 0;
|
||||||
|
if(!(host = (unsigned char *)strdup((char *)argv[argc-2] + 7))) {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
*hostend = '/';
|
||||||
|
if(!(sa.sin_addr.s_addr = getip(host))) {
|
||||||
|
fprintf(stderr, "Unable to resolve %s\n", host);
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
sa.sin_port = htons(80);
|
||||||
|
sa.sin_family = AF_INET;
|
||||||
|
if((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) return 6;
|
||||||
|
sprintf((char *)buf, (char *)request, hostend, host);
|
||||||
|
if(connect(sock,(struct sockaddr *)&sa,sizeof(sa))) {
|
||||||
|
fprintf(stderr, "Unable to connect: %s\n", host);
|
||||||
|
return 8;
|
||||||
|
}
|
||||||
|
if(send(sock, buf, (int)strlen((char *)buf), 0) != (int)strlen((char *)buf)) return 9;
|
||||||
|
while( (i = sockgetline(sock, buf, sizeof(buf) - 1, '\n', 30)) > 2);
|
||||||
|
if(i<1) return 9;
|
||||||
|
if(!(fp = fopen(argv[argc-1], "w"))) {
|
||||||
|
fprintf(stderr, "Unable to open: %s\n", argv[2]);
|
||||||
|
return 7;
|
||||||
|
}
|
||||||
|
while( (i = sockgetline(sock, buf, sizeof(buf) - 1, '\n', 30)) > 0){
|
||||||
|
buf[i] = 0;
|
||||||
|
for(i = 0; buf[i]; i++){
|
||||||
|
if((buf[i]<'0' || buf[i] > '9') && buf[i] != '.' && buf[i] != '/')buf[i] = ' ';
|
||||||
|
}
|
||||||
|
if(argc == 3){
|
||||||
|
if((i=sscanf((char *)buf, "%u.%u.%u.%u/%u", &x, &y, &z, &w, &cidr)) == 5 &&
|
||||||
|
x<256 && y<256 && z<256 && w<256 &&
|
||||||
|
cidr <= 32){
|
||||||
|
if(!first)fprintf(fp, ",");
|
||||||
|
fprintf(fp, "%u.%u.%u.%u/%u", x, y, z, w, cidr);
|
||||||
|
first = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if((i = sscanf((char *)buf, "%u.%u.%u.%u %u.%u.%u.%u", &x, &y, &z, &w, &x1, &y1, &z1, &w1)) == 8 &&
|
||||||
|
x<256 && y<256 && z<256 && w<256 &&
|
||||||
|
x1<256 && y1<256 && z1<256 && w1<256
|
||||||
|
){
|
||||||
|
mask = (x1<<24)|(y1<<16)|(z1<<8)|w1;
|
||||||
|
for(cidr = 0; cidr <= 32; cidr++)if((((unsigned long)(0xFFFFFFFF))<<(32-cidr)) == mask) break;
|
||||||
|
if(cidr > 32) continue;
|
||||||
|
if(!first)fprintf(fp, ",");
|
||||||
|
fprintf(fp, "%u.%u.%u.%u/%u", x, y, z, w, cidr);
|
||||||
|
first = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
shutdown(sock, SHUT_RDWR);
|
||||||
|
#ifdef _WIN32
|
||||||
|
closesocket(sock);
|
||||||
|
#else
|
||||||
|
close(sock);
|
||||||
|
#endif
|
||||||
|
fclose(fp);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
+47
-62
@@ -1,9 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
3APA3A simpliest proxy server
|
3APA3A simpliest proxy server
|
||||||
(c) 2002-2016 by Vladimir Dubrovin <3proxy@3proxy.ru>
|
(c) 2002-2008 by ZARAZA <3APA3A@security.nnov.ru>
|
||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
|
$Id: dnspr.c,v 1.22 2009/09/17 12:21:05 v.dubrovin Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
@@ -13,12 +14,11 @@
|
|||||||
#endif
|
#endif
|
||||||
#define RETURN(xxx) { param->res = xxx; goto CLEANRET; }
|
#define RETURN(xxx) { param->res = xxx; goto CLEANRET; }
|
||||||
|
|
||||||
#define BUFSIZE 16384
|
#define BUFSIZE 4096
|
||||||
|
|
||||||
|
|
||||||
void * dnsprchild(struct clientparam* param) {
|
void * dnsprchild(struct clientparam* param) {
|
||||||
unsigned long ip = 0;
|
unsigned long ip = 0;
|
||||||
unsigned char *bbuf;
|
|
||||||
unsigned char *buf, *s1, *s2;
|
unsigned char *buf, *s1, *s2;
|
||||||
char * host = NULL;
|
char * host = NULL;
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
@@ -27,28 +27,26 @@ void * dnsprchild(struct clientparam* param) {
|
|||||||
int len;
|
int len;
|
||||||
unsigned type=0;
|
unsigned type=0;
|
||||||
unsigned ttl;
|
unsigned ttl;
|
||||||
unsigned char addr[16];
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
unsigned long ul = 1;
|
unsigned long ul = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
if(!(bbuf = myalloc(BUFSIZE+2))){
|
if(!(buf = myalloc(BUFSIZE))){
|
||||||
param->srv->fds.events = POLLIN;
|
param->srv->fds.events = POLLIN;
|
||||||
RETURN (21);
|
RETURN (21);
|
||||||
}
|
}
|
||||||
buf = bbuf+2;
|
size = sizeof(struct sockaddr_in);
|
||||||
size = sizeof(param->sincr);
|
i = so._recvfrom(param->srv->srvsock, buf, BUFSIZE, 0, (struct sockaddr *)¶m->sinc, &size);
|
||||||
i = so._recvfrom(param->srv->srvsock, (char *)buf, BUFSIZE, 0, (struct sockaddr *)¶m->sincr, &size);
|
|
||||||
size = sizeof(param->sinsl);
|
|
||||||
getsockname(param->srv->srvsock, (struct sockaddr *)¶m->sincl, &size);
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if((param->clisock=so._socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) {
|
if((param->clisock=so._socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) {
|
||||||
RETURN(818);
|
RETURN(818);
|
||||||
}
|
}
|
||||||
ioctlsocket(param->clisock, FIONBIO, &ul);
|
ioctlsocket(param->clisock, FIONBIO, &ul);
|
||||||
if(so._setsockopt(param->clisock, SOL_SOCKET, SO_REUSEADDR, (char *)&ul, sizeof(int))) {RETURN(820);};
|
size = sizeof(struct sockaddr_in);
|
||||||
if(so._bind(param->clisock,(struct sockaddr *)¶m->sincl,SASIZE(¶m->sincl))) {
|
if(so._getsockname(param->srv->srvsock, (struct sockaddr *)¶m->sins, &size)) {RETURN(21);};
|
||||||
|
if(so._setsockopt(param->clisock, SOL_SOCKET, SO_REUSEADDR, (unsigned char *)&ul, sizeof(int))) {RETURN(820);};
|
||||||
|
if(so._bind(param->clisock,(struct sockaddr *)¶m->sins,sizeof(struct sockaddr_in))) {
|
||||||
RETURN(822);
|
RETURN(822);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,8 +80,8 @@ void * dnsprchild(struct clientparam* param) {
|
|||||||
*s2 = (len - (int)(s2 - buf)) - 1;
|
*s2 = (len - (int)(s2 - buf)) - 1;
|
||||||
|
|
||||||
type = ((unsigned)buf[len+1])*256 + (unsigned)buf[len+2];
|
type = ((unsigned)buf[len+1])*256 + (unsigned)buf[len+2];
|
||||||
if((type==0x01 || type==0x1c) && !param->srv->singlepacket){
|
if(type==1){
|
||||||
ip = udpresolve((type==0x1c)?AF_INET6:AF_INET, (unsigned char *)host, addr, &ttl, param, 0);
|
ip = udpresolve((unsigned char *)host, &ttl, param, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
len+=5;
|
len+=5;
|
||||||
@@ -97,19 +95,19 @@ void * dnsprchild(struct clientparam* param) {
|
|||||||
memset(buf+len, 0, 16);
|
memset(buf+len, 0, 16);
|
||||||
buf[len] = 0xc0;
|
buf[len] = 0xc0;
|
||||||
buf[len+1] = 0x0c;
|
buf[len+1] = 0x0c;
|
||||||
buf[len+3] = type;
|
buf[len+3] = 1;
|
||||||
buf[len+5] = 1;
|
buf[len+5] = 1;
|
||||||
ttl = htonl(ttl);
|
ttl = htonl(ttl);
|
||||||
memcpy(buf + len + 6, &ttl, 4);
|
memcpy(buf + len + 6, &ttl, 4);
|
||||||
buf[len+11] = type==1? 4:16;
|
buf[len+11] = 4;
|
||||||
memcpy(buf+len+12,(void *)&addr,type==1? 4:16);
|
memcpy(buf+len+12,(void *)&ip,4);
|
||||||
len+=(type==1?16:28);
|
len+=16;
|
||||||
}
|
}
|
||||||
else if(type == 0x0c) {
|
if(type == 0x0c) {
|
||||||
unsigned a, b, c, d;
|
unsigned a, b, c, d;
|
||||||
sscanf(host, "%u.%u.%u.%u", &a, &b, &c, &d);
|
sscanf(host, "%u.%u.%u.%u", &a, &b, &c, &d);
|
||||||
ip = htonl((d<<24) ^ (c<<16) ^ (b<<8) ^ a);
|
ip = htonl((d<<24) ^ (c<<16) ^ (b<<8) ^ a);
|
||||||
if(*SAFAMILY(¶m->sincl) == AF_INET && ip == *(unsigned long*)SAADDR(¶m->sincl)){
|
if(ip == param->srv->intip){
|
||||||
buf[2] = 0x85;
|
buf[2] = 0x85;
|
||||||
buf[3] = 0x80;
|
buf[3] = 0x80;
|
||||||
buf[6] = 0;
|
buf[6] = 0;
|
||||||
@@ -129,52 +127,36 @@ void * dnsprchild(struct clientparam* param) {
|
|||||||
}
|
}
|
||||||
else ip = 0;
|
else ip = 0;
|
||||||
}
|
}
|
||||||
if(!ip && numservers){
|
if(!ip && nservers[0] && type!=1){
|
||||||
if((param->remsock=so._socket(SASOCK(&nservers[0].addr), nservers[0].usetcp? SOCK_STREAM:SOCK_DGRAM, nservers[0].usetcp?IPPROTO_TCP:IPPROTO_UDP)) == INVALID_SOCKET) {
|
if((param->remsock=so._socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) {
|
||||||
RETURN(818);
|
RETURN(818);
|
||||||
}
|
}
|
||||||
memset(¶m->sinsl, 0, sizeof(param->sinsl));
|
#ifdef _WIN32
|
||||||
*SAFAMILY(¶m->sinsl) = *SAFAMILY(&nservers[0].addr);
|
ioctlsocket(param->remsock, FIONBIO, &ul);
|
||||||
if(so._bind(param->remsock,(struct sockaddr *)¶m->sinsl,SASIZE(¶m->sinsl))) {
|
#else
|
||||||
|
fcntl(param->remsock,F_SETFL,O_NONBLOCK);
|
||||||
|
#endif
|
||||||
|
param->sins.sin_family = AF_INET;
|
||||||
|
param->sins.sin_port = htons(0);
|
||||||
|
param->sins.sin_addr.s_addr = htonl(0);
|
||||||
|
if(so._bind(param->remsock,(struct sockaddr *)¶m->sins,sizeof(struct sockaddr_in))) {
|
||||||
RETURN(819);
|
RETURN(819);
|
||||||
}
|
}
|
||||||
param->sinsr = nservers[0].addr;
|
param->sins.sin_addr.s_addr = nservers[0];
|
||||||
if(nservers[0].usetcp) {
|
param->sins.sin_port = htons(53);
|
||||||
if(connectwithpoll(param->remsock,(struct sockaddr *)¶m->sinsr,SASIZE(¶m->sinsr),CONNECT_TO)) RETURN(830);
|
if(socksendto(param->remsock, ¶m->sins, buf, i, conf.timeouts[SINGLEBYTE_L]*1000) != i){
|
||||||
buf-=2;
|
|
||||||
*(unsigned short*)buf = htons(i);
|
|
||||||
i+=2;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
#ifdef _WIN32
|
|
||||||
/* ioctlsocket(param->remsock, FIONBIO, &ul); */
|
|
||||||
#else
|
|
||||||
/* fcntl(param->remsock,F_SETFL,O_NONBLOCK); */
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
if(socksendto(param->remsock, (struct sockaddr *)¶m->sinsr, buf, i, conf.timeouts[SINGLEBYTE_L]*1000) != i){
|
|
||||||
RETURN(820);
|
RETURN(820);
|
||||||
}
|
}
|
||||||
param->statscli64 += i;
|
param->statscli += i;
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
len = sockrecvfrom(param->remsock, (struct sockaddr *)¶m->sinsr, buf, BUFSIZE, conf.timeouts[DNS_TO]*1000);
|
len = sockrecvfrom(param->remsock, ¶m->sins, buf, BUFSIZE, 15000);
|
||||||
if(len <= 13) {
|
if(len <= 13) {
|
||||||
RETURN(821);
|
RETURN(821);
|
||||||
}
|
}
|
||||||
param->statssrv64 += len;
|
param->statssrv += len;
|
||||||
param->nreads++;
|
param->nreads++;
|
||||||
if(nservers[0].usetcp) {
|
|
||||||
unsigned short us;
|
|
||||||
us = ntohs(*(unsigned short *)buf);
|
|
||||||
if(us > 4096) RETURN(833);
|
|
||||||
buf += 2;
|
|
||||||
len -= 2;
|
|
||||||
if(len < us) len += sockgetlinebuf(param, SERVER, buf+len, us - len, 0, conf.timeouts[SINGLEBYTE_L]);
|
|
||||||
if(len != us) RETURN(832);
|
|
||||||
}
|
|
||||||
if(buf[6] || buf[7]){
|
if(buf[6] || buf[7]){
|
||||||
if(socksendto(param->clisock, (struct sockaddr *)¶m->sincr, buf, len, conf.timeouts[SINGLEBYTE_L]*1000) != len){
|
if(socksendto(param->clisock, ¶m->sinc, buf, len, conf.timeouts[SINGLEBYTE_L]*1000) != len){
|
||||||
RETURN(822);
|
RETURN(822);
|
||||||
}
|
}
|
||||||
RETURN(0);
|
RETURN(0);
|
||||||
@@ -185,22 +167,25 @@ void * dnsprchild(struct clientparam* param) {
|
|||||||
buf[2] = 0x85;
|
buf[2] = 0x85;
|
||||||
buf[3] = 0x83;
|
buf[3] = 0x83;
|
||||||
}
|
}
|
||||||
res = socksendto(param->clisock, (struct sockaddr *)¶m->sincr, buf, len, conf.timeouts[SINGLEBYTE_L]*1000);
|
usleep(SLEEPTIME);
|
||||||
|
res = socksendto(param->clisock, ¶m->sinc, buf, len, conf.timeouts[SINGLEBYTE_L]*1000);
|
||||||
if(res != len){RETURN(819);}
|
if(res != len){RETURN(819);}
|
||||||
if(!ip) {RETURN(888);}
|
if(!ip) {RETURN(888);}
|
||||||
|
|
||||||
CLEANRET:
|
CLEANRET:
|
||||||
|
|
||||||
if(param->res!=813){
|
if(param->res!=813){
|
||||||
sprintf((char *)buf, "%04x/%s/",
|
sprintf((char *)buf, "%04x/%s(%u.%u.%u.%u)",
|
||||||
(unsigned)type,
|
(unsigned)type,
|
||||||
host?host:"");
|
host?host:"",
|
||||||
if((ip && type == 0x01) || type == 0x1c){
|
(unsigned)(ntohl(ip)&0xff000000)>>24,
|
||||||
myinet_ntop(type == 0x01? AF_INET:AF_INET6, addr, (char *)buf+strlen((char *)buf), 64);
|
(unsigned)(ntohl(ip)&0x00ff0000)>>16,
|
||||||
}
|
(unsigned)(ntohl(ip)&0x0000ff00)>>8,
|
||||||
dolog(param, buf);
|
(unsigned)(ntohl(ip)&0x000000ff)
|
||||||
|
);
|
||||||
|
(*param->srv->logfunc)(param, buf);
|
||||||
}
|
}
|
||||||
if(bbuf)myfree(bbuf);
|
if(buf)myfree(buf);
|
||||||
if(host)myfree(host);
|
if(host)myfree(host);
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
param->clisock = INVALID_SOCKET;
|
param->clisock = INVALID_SOCKET;
|
||||||
|
|||||||
@@ -1,25 +1,26 @@
|
|||||||
/*
|
/*
|
||||||
(c) 2002-2016 by Vladimir Dubrovin <3proxy@3proxy.ru>
|
* Copyright (c) 2002-2008 3APA3A
|
||||||
|
*
|
||||||
please read License Agreement
|
* please read License Agreement
|
||||||
|
*
|
||||||
|
* $Id: ftp.c,v 1.34 2009/09/17 12:21:06 v.dubrovin Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
|
|
||||||
|
|
||||||
int ftplogin(struct clientparam *param, char *nbuf, int *innbuf) {
|
int ftplogin(struct clientparam *param, char *nbuf, int *innbuf) {
|
||||||
char tbuf[256];
|
char tbuf[1024];
|
||||||
int i;
|
int i;
|
||||||
char *buf;
|
char *buf;
|
||||||
int len;
|
int len;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
buf = nbuf?nbuf:tbuf;
|
buf = nbuf?nbuf:tbuf;
|
||||||
len = nbuf?*innbuf:sizeof(tbuf);
|
len = nbuf?*innbuf:1024;
|
||||||
|
|
||||||
if(innbuf)*innbuf = 0;
|
if(innbuf)*innbuf = 0;
|
||||||
if(len < 140) return 707;
|
if(len < 48) return 707;
|
||||||
while((i = sockgetlinebuf(param, SERVER, (unsigned char *)buf, len - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
|
while((i = sockgetlinebuf(param, SERVER, (unsigned char *)buf, len - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
|
||||||
}
|
}
|
||||||
if(i < 3) return 706;
|
if(i < 3) return 706;
|
||||||
@@ -28,11 +29,11 @@ int ftplogin(struct clientparam *param, char *nbuf, int *innbuf) {
|
|||||||
*innbuf = i;
|
*innbuf = i;
|
||||||
return 702;
|
return 702;
|
||||||
}
|
}
|
||||||
sprintf(buf, "USER %.128s\r\n", param->extusername?param->extusername:(unsigned char *)"anonymous");
|
sprintf(buf, "USER %.32s\r\n", param->extusername?param->extusername:(unsigned char *)"anonymous");
|
||||||
if((int)socksend(param->remsock, (unsigned char *)buf, (int)strlen(buf), conf.timeouts[STRING_S]) != (int)strlen(buf)){
|
if((int)socksend(param->remsock, (unsigned char *)buf, (int)strlen(buf), conf.timeouts[STRING_S]) != (int)strlen(buf)){
|
||||||
return 703;
|
return 703;
|
||||||
}
|
}
|
||||||
param->statscli64 += (int)strlen(buf);
|
param->statscli += (int)strlen(buf);
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
while((i = sockgetlinebuf(param, SERVER, (unsigned char *)buf, len - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
|
while((i = sockgetlinebuf(param, SERVER, (unsigned char *)buf, len - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
|
||||||
}
|
}
|
||||||
@@ -40,7 +41,7 @@ int ftplogin(struct clientparam *param, char *nbuf, int *innbuf) {
|
|||||||
buf[i] = 0;
|
buf[i] = 0;
|
||||||
res = atoi(buf)/100;
|
res = atoi(buf)/100;
|
||||||
if(res == 3){
|
if(res == 3){
|
||||||
sprintf(buf, "PASS %.128s\r\n",
|
sprintf(buf, "PASS %.32s\r\n",
|
||||||
param->extusername?
|
param->extusername?
|
||||||
(param->extpassword?
|
(param->extpassword?
|
||||||
param->extpassword:(unsigned char *)"")
|
param->extpassword:(unsigned char *)"")
|
||||||
@@ -49,7 +50,7 @@ int ftplogin(struct clientparam *param, char *nbuf, int *innbuf) {
|
|||||||
if((int)socksend(param->remsock, (unsigned char *)buf, res, conf.timeouts[STRING_S]) != (int)strlen(buf)){
|
if((int)socksend(param->remsock, (unsigned char *)buf, res, conf.timeouts[STRING_S]) != (int)strlen(buf)){
|
||||||
return 705;
|
return 705;
|
||||||
}
|
}
|
||||||
param->statscli64 += res;
|
param->statscli += res;
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
while((i = sockgetlinebuf(param, SERVER, (unsigned char *)buf, len - 1, '\n', conf.timeouts[STRING_L])) > 0){
|
while((i = sockgetlinebuf(param, SERVER, (unsigned char *)buf, len - 1, '\n', conf.timeouts[STRING_L])) > 0){
|
||||||
buf[i] = 0;
|
buf[i] = 0;
|
||||||
@@ -80,7 +81,7 @@ int ftpcd(struct clientparam *param, unsigned char* path, char *nbuf, int *innbu
|
|||||||
if((int)socksend(param->remsock, (unsigned char *)buf, (int)strlen(buf), conf.timeouts[STRING_S]) != (int)strlen(buf)){
|
if((int)socksend(param->remsock, (unsigned char *)buf, (int)strlen(buf), conf.timeouts[STRING_S]) != (int)strlen(buf)){
|
||||||
return 711;
|
return 711;
|
||||||
}
|
}
|
||||||
param->statscli64 += (int)strlen(buf);
|
param->statscli += (int)strlen(buf);
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
while((i = sockgetlinebuf(param, SERVER, (unsigned char *)buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
|
while((i = sockgetlinebuf(param, SERVER, (unsigned char *)buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
|
||||||
if(nbuf && innbuf && inbuf + i < *innbuf && i > 6) {
|
if(nbuf && innbuf && inbuf + i < *innbuf && i > 6) {
|
||||||
@@ -113,7 +114,7 @@ int ftpsyst(struct clientparam *param, unsigned char *buf, unsigned len){
|
|||||||
if(socksend(param->remsock, (unsigned char *)"SYST\r\n", 6, conf.timeouts[STRING_S]) != 6){
|
if(socksend(param->remsock, (unsigned char *)"SYST\r\n", 6, conf.timeouts[STRING_S]) != 6){
|
||||||
return 721;
|
return 721;
|
||||||
}
|
}
|
||||||
param->statscli64 += 6;
|
param->statscli+=6;
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
while((i = sockgetlinebuf(param, SERVER, buf, len - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
|
while((i = sockgetlinebuf(param, SERVER, buf, len - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
|
||||||
}
|
}
|
||||||
@@ -132,7 +133,7 @@ int ftppwd(struct clientparam *param, unsigned char *buf, unsigned len){
|
|||||||
if(socksend(param->remsock, (unsigned char *)"PWD\r\n", 5, conf.timeouts[STRING_S]) != 5){
|
if(socksend(param->remsock, (unsigned char *)"PWD\r\n", 5, conf.timeouts[STRING_S]) != 5){
|
||||||
return 731;
|
return 731;
|
||||||
}
|
}
|
||||||
param->statscli64 += 5;
|
param->statscli += 5;
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
while((i = sockgetlinebuf(param, SERVER, buf, len - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
|
while((i = sockgetlinebuf(param, SERVER, buf, len - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
|
||||||
}
|
}
|
||||||
@@ -157,7 +158,7 @@ int ftptype(struct clientparam *param, unsigned char* f_type){
|
|||||||
if((int)socksend(param->remsock, (unsigned char *)buf, (int)strlen(buf), conf.timeouts[STRING_S]) != (int)strlen(buf)){
|
if((int)socksend(param->remsock, (unsigned char *)buf, (int)strlen(buf), conf.timeouts[STRING_S]) != (int)strlen(buf)){
|
||||||
return 741;
|
return 741;
|
||||||
}
|
}
|
||||||
param->statscli64 += (int)strlen(buf);
|
param->statscli += (int)strlen(buf);
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
while((i = sockgetlinebuf(param, SERVER, (unsigned char *)buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
|
while((i = sockgetlinebuf(param, SERVER, (unsigned char *)buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
|
||||||
}
|
}
|
||||||
@@ -174,12 +175,11 @@ SOCKET ftpdata(struct clientparam *param){
|
|||||||
SOCKET s = INVALID_SOCKET, rem;
|
SOCKET s = INVALID_SOCKET, rem;
|
||||||
unsigned long b1, b2, b3, b4;
|
unsigned long b1, b2, b3, b4;
|
||||||
unsigned short b5, b6;
|
unsigned short b5, b6;
|
||||||
SASIZETYPE sasize;
|
|
||||||
|
|
||||||
if(socksend(param->remsock, (unsigned char *)"PASV\r\n", 6, conf.timeouts[STRING_S]) != 6){
|
if(socksend(param->remsock, (unsigned char *)"PASV\r\n", 6, conf.timeouts[STRING_S]) != 6){
|
||||||
return INVALID_SOCKET;
|
return INVALID_SOCKET;
|
||||||
}
|
}
|
||||||
param->statscli64 += 6;
|
param->statscli+=6;
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
while((i = sockgetlinebuf(param, SERVER, (unsigned char *)buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
|
while((i = sockgetlinebuf(param, SERVER, (unsigned char *)buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
|
||||||
}
|
}
|
||||||
@@ -188,28 +188,14 @@ SOCKET ftpdata(struct clientparam *param){
|
|||||||
buf[i-2] = 0;
|
buf[i-2] = 0;
|
||||||
if(!(sb = strchr(buf+4, '(')) || !(se= strchr(sb, ')'))) return INVALID_SOCKET;
|
if(!(sb = strchr(buf+4, '(')) || !(se= strchr(sb, ')'))) return INVALID_SOCKET;
|
||||||
if(sscanf(sb+1, "%lu,%lu,%lu,%lu,%hu,%hu", &b1, &b2, &b3, &b4, &b5, &b6)!=6) return INVALID_SOCKET;
|
if(sscanf(sb+1, "%lu,%lu,%lu,%lu,%hu,%hu", &b1, &b2, &b3, &b4, &b5, &b6)!=6) return INVALID_SOCKET;
|
||||||
sasize = sizeof(param->sinsl);
|
|
||||||
if(so._getsockname(param->remsock, (struct sockaddr *)¶m->sinsl, &sasize)){return INVALID_SOCKET;}
|
|
||||||
sasize = sizeof(param->sinsr);
|
|
||||||
if(so._getpeername(param->remsock, (struct sockaddr *)¶m->sinsr, &sasize)){return INVALID_SOCKET;}
|
|
||||||
rem = param->remsock;
|
rem = param->remsock;
|
||||||
param->remsock = INVALID_SOCKET;
|
param->remsock = INVALID_SOCKET;
|
||||||
param->req = param->sinsr;
|
param->req.sin_family = AF_INET;
|
||||||
*SAPORT(¶m->req) = *SAPORT(¶m->sinsr) = htons((unsigned short)((b5<<8)^b6));
|
param->req.sin_port = param->sins.sin_port = htons((unsigned short)((b5<<8)^b6));
|
||||||
*SAPORT(¶m->sinsl) = 0;
|
param->req.sin_addr.s_addr = param->sins.sin_addr.s_addr = htonl((b1<<24)^(b2<<16)^(b3<<8)^b4);
|
||||||
i = param->operation;
|
i = param->operation;
|
||||||
param->operation = FTP_DATA;
|
param->operation = FTP_DATA;
|
||||||
if((param->res = (*param->srv->authfunc)(param))) {
|
if((param->res = (*param->srv->authfunc)(param))) return INVALID_SOCKET;
|
||||||
if(param->remsock != INVALID_SOCKET) {
|
|
||||||
so._closesocket(param->remsock);
|
|
||||||
param->remsock = INVALID_SOCKET;
|
|
||||||
}
|
|
||||||
memset(¶m->sinsl, 0, sizeof(param->sinsl));
|
|
||||||
if((param->res = (*param->srv->authfunc)(param))) {
|
|
||||||
param->remsock = rem;
|
|
||||||
return INVALID_SOCKET;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
param->operation = i;
|
param->operation = i;
|
||||||
s = param->remsock;
|
s = param->remsock;
|
||||||
param->remsock = rem;
|
param->remsock = rem;
|
||||||
@@ -231,7 +217,7 @@ SOCKET ftpcommand(struct clientparam *param, unsigned char * command, unsigned c
|
|||||||
so._closesocket(s);
|
so._closesocket(s);
|
||||||
return INVALID_SOCKET;
|
return INVALID_SOCKET;
|
||||||
}
|
}
|
||||||
param->statscli64 += (int)strlen(buf);
|
param->statscli += (int)strlen(buf);
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
while((i = sockgetlinebuf(param, SERVER, (unsigned char *)buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
|
while((i = sockgetlinebuf(param, SERVER, (unsigned char *)buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
|
||||||
}
|
}
|
||||||
|
|||||||
+40
-49
@@ -1,9 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
3APA3A simpliest proxy server
|
3APA3A simpliest proxy server
|
||||||
(c) 2002-2016 by Vladimir Dubrovin <3proxy@3proxy.ru>
|
(c) 2002-2008 by ZARAZA <3APA3A@security.nnov.ru>
|
||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
|
$Id: ftppr.c,v 1.45 2011-08-15 19:52:27 vlad Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
@@ -70,13 +71,13 @@ void * ftpprchild(struct clientparam* param) {
|
|||||||
param->res = res;
|
param->res = res;
|
||||||
if(inbuf && inbuf != BUFSIZE && socksend(param->ctrlsock, buf, inbuf, conf.timeouts[STRING_S])!=inbuf) {RETURN (807);}
|
if(inbuf && inbuf != BUFSIZE && socksend(param->ctrlsock, buf, inbuf, conf.timeouts[STRING_S])!=inbuf) {RETURN (807);}
|
||||||
if(!res) status = 3;
|
if(!res) status = 3;
|
||||||
sprintf((char *)buf, "%.128s@%.128s%c%hu", param->extusername, param->hostname, (ntohs(*SAPORT(¶m->sinsr))==21)?0:':', ntohs(*SAPORT(¶m->sinsr)));
|
sprintf((char *)buf, "%.64s@%.128s%c%hu", param->extusername, param->hostname, (ntohs(param->sins.sin_port)==21)?0:':', ntohs(param->sins.sin_port));
|
||||||
req = mystrdup((char *)buf);
|
req = mystrdup((char *)buf);
|
||||||
#ifndef WITHMAIN
|
#ifndef WITHMAIN
|
||||||
{
|
{
|
||||||
int action, reqbufsize, reqsize;
|
int action, reqbufsize, reqsize;
|
||||||
reqbufsize = BUFSIZE;
|
reqbufsize = BUFSIZE;
|
||||||
reqsize = (int)strlen((char *)buf) + 1;
|
reqsize = (int)strlen(buf) + 1;
|
||||||
|
|
||||||
action = handlereqfilters(param, &buf, &reqbufsize, 0, &reqsize);
|
action = handlereqfilters(param, &buf, &reqbufsize, 0, &reqsize);
|
||||||
if(action == HANDLED){
|
if(action == HANDLED){
|
||||||
@@ -88,14 +89,13 @@ void * ftpprchild(struct clientparam* param) {
|
|||||||
}
|
}
|
||||||
else if (status >= 3 && (
|
else if (status >= 3 && (
|
||||||
(!strncasecmp((char *)buf, "PASV", 4) && (pasv = 1)) ||
|
(!strncasecmp((char *)buf, "PASV", 4) && (pasv = 1)) ||
|
||||||
(!strncasecmp((char *)buf, "EPSV", 4) && (pasv = 2)) ||
|
|
||||||
(!strncasecmp((char *)buf, "PORT ", 5) && !(pasv = 0))
|
(!strncasecmp((char *)buf, "PORT ", 5) && !(pasv = 0))
|
||||||
)){
|
)){
|
||||||
#ifndef WITHMAIN
|
#ifndef WITHMAIN
|
||||||
{
|
{
|
||||||
int action, reqbufsize, reqsize;
|
int action, reqbufsize, reqsize;
|
||||||
reqbufsize = BUFSIZE;
|
reqbufsize = BUFSIZE;
|
||||||
reqsize = (int)strlen((char *)buf) + 1;
|
reqsize = (int)strlen(buf) + 1;
|
||||||
|
|
||||||
action = handlehdrfilterscli(param, &buf, &reqbufsize, 0, &reqsize);
|
action = handlehdrfilterscli(param, &buf, &reqbufsize, 0, &reqsize);
|
||||||
if(action == HANDLED){
|
if(action == HANDLED){
|
||||||
@@ -119,52 +119,43 @@ void * ftpprchild(struct clientparam* param) {
|
|||||||
so._closesocket(clidatasock);
|
so._closesocket(clidatasock);
|
||||||
clidatasock = INVALID_SOCKET;
|
clidatasock = INVALID_SOCKET;
|
||||||
}
|
}
|
||||||
if ((clidatasock=socket(SASOCK(¶m->sincl), SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) {RETURN(821);}
|
if ((clidatasock=socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) {RETURN(821);}
|
||||||
*SAPORT(¶m->sincl) = 0;
|
sasize = sizeof(struct sockaddr_in);
|
||||||
if(so._bind(clidatasock, (struct sockaddr *)¶m->sincl, SASIZE(¶m->sincl))){RETURN(822);}
|
if(so._getsockname(param->ctrlsock, (struct sockaddr *)¶m->sinc, &sasize)){RETURN(824);}
|
||||||
|
param->sinc.sin_port = 0;
|
||||||
|
if(so._bind(clidatasock, (struct sockaddr *)¶m->sinc, sasize)){RETURN(822);}
|
||||||
if (pasv) {
|
if (pasv) {
|
||||||
if(so._listen(clidatasock, 1)) {RETURN(823);}
|
if(so._listen(clidatasock, 1)) {RETURN(823);}
|
||||||
sasize = sizeof(param->sincl);
|
if(so._getsockname(clidatasock, (struct sockaddr *)¶m->sinc, &sasize)){RETURN(824);}
|
||||||
if(so._getsockname(clidatasock, (struct sockaddr *)¶m->sincl, &sasize)){RETURN(824);}
|
sprintf((char *)buf, "227 OK (%u,%u,%u,%u,%u,%u)\r\n",
|
||||||
if(pasv == 1){
|
(unsigned)(((unsigned char *)(¶m->sinc.sin_addr.s_addr))[0]),
|
||||||
if(*SAFAMILY(¶m->sincl) == AF_INET)
|
(unsigned)(((unsigned char *)(¶m->sinc.sin_addr.s_addr))[1]),
|
||||||
sprintf((char *)buf, "227 OK (%u,%u,%u,%u,%u,%u)\r\n",
|
(unsigned)(((unsigned char *)(¶m->sinc.sin_addr.s_addr))[2]),
|
||||||
(unsigned)(((unsigned char *)(SAADDR(¶m->sincl)))[0]),
|
(unsigned)(((unsigned char *)(¶m->sinc.sin_addr.s_addr))[3]),
|
||||||
(unsigned)(((unsigned char *)(SAADDR(¶m->sincl)))[1]),
|
(unsigned)(((unsigned char *)(¶m->sinc.sin_port))[0]),
|
||||||
(unsigned)(((unsigned char *)(SAADDR(¶m->sincl)))[2]),
|
(unsigned)(((unsigned char *)(¶m->sinc.sin_port))[1])
|
||||||
(unsigned)(((unsigned char *)(SAADDR(¶m->sincl)))[3]),
|
);
|
||||||
(unsigned)(((unsigned char *)(SAPORT(¶m->sincl)))[0]),
|
|
||||||
(unsigned)(((unsigned char *)(SAPORT(¶m->sincl)))[1])
|
|
||||||
);
|
|
||||||
else sprintf((char *)buf, "227 OK (127,0,0,1,%u,%u)\r\n",
|
|
||||||
(unsigned)(((unsigned char *)(SAPORT(¶m->sincl)))[0]),
|
|
||||||
(unsigned)(((unsigned char *)(SAPORT(¶m->sincl)))[1])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sprintf((char *)buf, "229 OK (|||%u|)\r\n",
|
|
||||||
(unsigned)ntohs(*SAPORT(¶m->sincl))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
unsigned long b1, b2, b3, b4;
|
unsigned long b1, b2, b3, b4;
|
||||||
unsigned short b5, b6;
|
unsigned short b5, b6;
|
||||||
|
|
||||||
if(sscanf((char *)buf+5, "%lu,%lu,%lu,%lu,%hu,%hu", &b1, &b2, &b3, &b4, &b5, &b6)!=6) {RETURN(828);}
|
if(sscanf((char *)buf+5, "%lu,%lu,%lu,%lu,%hu,%hu", &b1, &b2, &b3, &b4, &b5, &b6)!=6) {RETURN(828);}
|
||||||
*SAPORT(¶m->sincr) = htons((unsigned short)((b5<<8)^b6));
|
param->sinc.sin_family = AF_INET;
|
||||||
if(connectwithpoll(clidatasock, (struct sockaddr *)¶m->sincr, SASIZE(¶m->sincr),CONNECT_TO)) {
|
param->sinc.sin_port = htons((unsigned short)((b5<<8)^b6));
|
||||||
|
param->sinc.sin_addr.s_addr = htonl((b1<<24)^(b2<<16)^(b3<<8)^b4);
|
||||||
|
if(so._connect(clidatasock, (struct sockaddr *)¶m->sinc, sasize)) {
|
||||||
so._closesocket(clidatasock);
|
so._closesocket(clidatasock);
|
||||||
clidatasock = INVALID_SOCKET;
|
clidatasock = INVALID_SOCKET;
|
||||||
RETURN(826);
|
RETURN(826);
|
||||||
}
|
}
|
||||||
sprintf((char *)buf, "200 OK\r\n");
|
sprintf(buf, "200 OK\r\n");
|
||||||
}
|
}
|
||||||
#ifndef WITHMAIN
|
#ifndef WITHMAIN
|
||||||
{
|
{
|
||||||
int action, reqbufsize, reqsize;
|
int action, reqbufsize, reqsize;
|
||||||
reqbufsize = BUFSIZE;
|
reqbufsize = BUFSIZE;
|
||||||
reqsize = (int)strlen((char *)buf) + 1;
|
reqsize = (int)strlen(buf) + 1;
|
||||||
|
|
||||||
action = handlehdrfilterssrv(param, &buf, &reqbufsize, 0, &reqsize);
|
action = handlehdrfilterssrv(param, &buf, &reqbufsize, 0, &reqsize);
|
||||||
if(action == HANDLED){
|
if(action == HANDLED){
|
||||||
@@ -192,7 +183,7 @@ void * ftpprchild(struct clientparam* param) {
|
|||||||
{
|
{
|
||||||
int action, reqbufsize, reqsize;
|
int action, reqbufsize, reqsize;
|
||||||
reqbufsize = BUFSIZE;
|
reqbufsize = BUFSIZE;
|
||||||
reqsize = (int)strlen((char *)buf) + 1;
|
reqsize = (int)strlen(buf) + 1;
|
||||||
|
|
||||||
action = handlehdrfilterscli(param, &buf, &reqbufsize, 0, &reqsize);
|
action = handlehdrfilterscli(param, &buf, &reqbufsize, 0, &reqsize);
|
||||||
if(action == HANDLED){
|
if(action == HANDLED){
|
||||||
@@ -212,8 +203,8 @@ void * ftpprchild(struct clientparam* param) {
|
|||||||
if(res != 1) {
|
if(res != 1) {
|
||||||
RETURN(857);
|
RETURN(857);
|
||||||
}
|
}
|
||||||
sasize = sizeof(param->sincr);
|
sasize = sizeof(struct sockaddr_in);
|
||||||
ss = so._accept(clidatasock, (struct sockaddr *)¶m->sincr, &sasize);
|
ss = so._accept(clidatasock, (struct sockaddr *)¶m->sinc, &sasize);
|
||||||
if (ss == INVALID_SOCKET) { RETURN (858);}
|
if (ss == INVALID_SOCKET) { RETURN (858);}
|
||||||
so._shutdown(clidatasock, SHUT_RDWR);
|
so._shutdown(clidatasock, SHUT_RDWR);
|
||||||
so._closesocket(clidatasock);
|
so._closesocket(clidatasock);
|
||||||
@@ -247,10 +238,10 @@ void * ftpprchild(struct clientparam* param) {
|
|||||||
}
|
}
|
||||||
sc = param->remsock;
|
sc = param->remsock;
|
||||||
param->remsock = ss;
|
param->remsock = ss;
|
||||||
so._setsockopt(param->remsock, SOL_SOCKET, SO_LINGER, (char *)&lg, sizeof(lg));
|
so._setsockopt(param->remsock, SOL_SOCKET, SO_LINGER, (unsigned char *)&lg, sizeof(lg));
|
||||||
so._setsockopt(clidatasock, SOL_SOCKET, SO_LINGER, (char *)&lg, sizeof(lg));
|
so._setsockopt(clidatasock, SOL_SOCKET, SO_LINGER, (unsigned char *)&lg, sizeof(lg));
|
||||||
param->clisock = clidatasock;
|
param->clisock = clidatasock;
|
||||||
res = mapsocket(param, conf.timeouts[CONNECTION_S]);
|
res = sockmap(param, conf.timeouts[CONNECTION_S]);
|
||||||
if(param->remsock != INVALID_SOCKET) {
|
if(param->remsock != INVALID_SOCKET) {
|
||||||
so._shutdown (param->remsock, SHUT_RDWR);
|
so._shutdown (param->remsock, SHUT_RDWR);
|
||||||
so._closesocket(param->remsock);
|
so._closesocket(param->remsock);
|
||||||
@@ -283,7 +274,7 @@ void * ftpprchild(struct clientparam* param) {
|
|||||||
buf[i++] = '\r';
|
buf[i++] = '\r';
|
||||||
buf[i++] = '\n';
|
buf[i++] = '\n';
|
||||||
if(socksend(param->remsock, buf, i, conf.timeouts[STRING_S])!=i) {RETURN (811);}
|
if(socksend(param->remsock, buf, i, conf.timeouts[STRING_S])!=i) {RETURN (811);}
|
||||||
param->statscli64+=(i);
|
param->statscli += i;
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
while((i = sockgetlinebuf(param, SERVER, buf, BUFSIZE, '\n', conf.timeouts[STRING_L])) > 0){
|
while((i = sockgetlinebuf(param, SERVER, buf, BUFSIZE, '\n', conf.timeouts[STRING_L])) > 0){
|
||||||
if(socksend(param->ctrlsock, buf, i, conf.timeouts[STRING_S])!=i) {RETURN (812);}
|
if(socksend(param->ctrlsock, buf, i, conf.timeouts[STRING_S])!=i) {RETURN (812);}
|
||||||
@@ -292,10 +283,10 @@ void * ftpprchild(struct clientparam* param) {
|
|||||||
if(status == 5) {RETURN (0);}
|
if(status == 5) {RETURN (0);}
|
||||||
if(i < 3) {RETURN (813);}
|
if(i < 3) {RETURN (813);}
|
||||||
}
|
}
|
||||||
sasize = sizeof(param->sincr);
|
sasize = sizeof(struct sockaddr_in);
|
||||||
if(so._getpeername(param->ctrlsock, (struct sockaddr *)¶m->sincr, &sasize)){RETURN(819);}
|
if(so._getpeername(param->ctrlsock, (struct sockaddr *)¶m->sinc, &sasize)){RETURN(819);}
|
||||||
if(req && (param->statscli64 || param->statssrv64)){
|
if(req && (param->statscli || param->statssrv)){
|
||||||
dolog(param, (unsigned char *)req);
|
(*param->srv->logfunc)(param, (unsigned char *)req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,10 +304,10 @@ CLEANRET:
|
|||||||
so._shutdown(clidatasock, SHUT_RDWR);
|
so._shutdown(clidatasock, SHUT_RDWR);
|
||||||
so._closesocket(clidatasock);
|
so._closesocket(clidatasock);
|
||||||
}
|
}
|
||||||
sasize = sizeof(param->sincr);
|
sasize = sizeof(struct sockaddr_in);
|
||||||
so._getpeername(param->ctrlsock, (struct sockaddr *)¶m->sincr, &sasize);
|
so._getpeername(param->ctrlsock, (struct sockaddr *)¶m->sinc, &sasize);
|
||||||
if(param->res != 0 || param->statscli64 || param->statssrv64 ){
|
if(param->res != 0 || param->statscli || param->statssrv ){
|
||||||
dolog(param, (unsigned char *)((req && (param->res > 802))? req:NULL));
|
(*param->srv->logfunc)(param, (unsigned char *)((req && (param->res > 802))? req:NULL));
|
||||||
}
|
}
|
||||||
if(req) myfree(req);
|
if(req) myfree(req);
|
||||||
if(buf) myfree(buf);
|
if(buf) myfree(buf);
|
||||||
|
|||||||
+533
@@ -0,0 +1,533 @@
|
|||||||
|
/*
|
||||||
|
3APA3A simpliest proxy server
|
||||||
|
(c) 2002-2008 by ZARAZA <3APA3A@security.nnov.ru>
|
||||||
|
|
||||||
|
please read License Agreement
|
||||||
|
|
||||||
|
$Id: icqpr.c,v 1.30 2012-04-11 23:01:19 vlad Exp $
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "proxy.h"
|
||||||
|
|
||||||
|
#ifndef PORTMAP
|
||||||
|
#define PORTMAP
|
||||||
|
#endif
|
||||||
|
#define RETURN(xxx) { param->res = xxx; goto CLEANRET; }
|
||||||
|
|
||||||
|
static void hexdump(unsigned char *data, int len){
|
||||||
|
for(; len; data++, len--){
|
||||||
|
printf("%02x", (unsigned)*data);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
struct flap_header {
|
||||||
|
unsigned char id;
|
||||||
|
unsigned char chan;
|
||||||
|
unsigned short seq;
|
||||||
|
unsigned short size;
|
||||||
|
char data[0];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct snack_header {
|
||||||
|
unsigned family;
|
||||||
|
unsigned short flags;
|
||||||
|
unsigned id;
|
||||||
|
char data[0];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct tlv_header {
|
||||||
|
unsigned short type;
|
||||||
|
unsigned short size;
|
||||||
|
char data[0];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
ONBEGIN = 0,
|
||||||
|
ONCHAN,
|
||||||
|
ONSEQ1,
|
||||||
|
ONSEQ2,
|
||||||
|
ONSIZE1,
|
||||||
|
ONSIZE2,
|
||||||
|
ONDATA
|
||||||
|
} ICQSTATE;
|
||||||
|
|
||||||
|
struct icqstate {
|
||||||
|
ICQSTATE state;
|
||||||
|
int leftinstate;
|
||||||
|
unsigned short seq;
|
||||||
|
unsigned short srvseq;
|
||||||
|
unsigned short gotseq;
|
||||||
|
unsigned short resyncseq;
|
||||||
|
char channel;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
ICQUNKNOWN,
|
||||||
|
ICQCLEAR,
|
||||||
|
ICQMD5,
|
||||||
|
ICQCOOKIE
|
||||||
|
} LOGINTYPE;
|
||||||
|
|
||||||
|
|
||||||
|
struct icq_cookie {
|
||||||
|
struct icq_cookie *next;
|
||||||
|
char *id;
|
||||||
|
int size;
|
||||||
|
char * cookie;
|
||||||
|
char * connectstring;
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct icq_cookie *icq_cookies = NULL;
|
||||||
|
pthread_mutex_t icq_cookie_mutex;
|
||||||
|
int icq_cookie_mutex_init = 0;
|
||||||
|
|
||||||
|
|
||||||
|
static void icq_clear(void *fo){
|
||||||
|
};
|
||||||
|
|
||||||
|
static void addbuffer(int increment, struct clientparam * param, unsigned char ** buf_p, int * bufsize_p, int * length_p){
|
||||||
|
int bufsize = *length_p + increment + 40;
|
||||||
|
unsigned char *newbuf;
|
||||||
|
int len = 0;
|
||||||
|
|
||||||
|
|
||||||
|
if(bufsize > *bufsize_p){
|
||||||
|
newbuf = myalloc(bufsize);
|
||||||
|
if(!newbuf) return;
|
||||||
|
memcpy(newbuf, *buf_p, *length_p);
|
||||||
|
myfree(*buf_p);
|
||||||
|
*buf_p = newbuf;
|
||||||
|
*bufsize_p = bufsize;
|
||||||
|
}
|
||||||
|
if(increment) len = sockrecvfrom(param->remsock, ¶m->sins, *buf_p + *length_p, increment, conf.timeouts[STRING_S]*1000);
|
||||||
|
if(len > 0) {
|
||||||
|
*length_p += len;
|
||||||
|
param->nreads++;
|
||||||
|
param->statssrv += len;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static int searchcookie(struct clientparam *param, struct flap_header * flap, int len, int * dif, struct tlv_header *tlv, int extra){
|
||||||
|
struct icq_cookie *ic;
|
||||||
|
char smallbuf[32];
|
||||||
|
struct tlv_header *bostlv = NULL;
|
||||||
|
struct sockaddr_in sa;
|
||||||
|
SASIZETYPE size = sizeof(sa);
|
||||||
|
int movelen = 0;
|
||||||
|
|
||||||
|
if(!icq_cookie_mutex_init){
|
||||||
|
pthread_mutex_init(&icq_cookie_mutex, NULL);
|
||||||
|
icq_cookie_mutex_init = 1;
|
||||||
|
}
|
||||||
|
pthread_mutex_lock(&icq_cookie_mutex);
|
||||||
|
for(ic = icq_cookies; ic; ic = ic->next)if(!strcmp(param->username, ic->id))break;
|
||||||
|
if(!ic){
|
||||||
|
ic = myalloc(sizeof(struct icq_cookie));
|
||||||
|
memset(ic, 0, sizeof(struct icq_cookie));
|
||||||
|
ic->id = mystrdup(param->username);
|
||||||
|
ic->next = icq_cookies;
|
||||||
|
icq_cookies = ic;
|
||||||
|
}
|
||||||
|
for(; ntohs(tlv->size) < 65500 && len >= (ntohs(tlv->size) + 4); len -= (ntohs(tlv->size) + 4), tlv = (struct tlv_header *)(tlv->data + ntohs(tlv->size))){
|
||||||
|
if(ntohs(tlv->type) == 0x0006){
|
||||||
|
if(ic->cookie)myfree(ic->cookie);
|
||||||
|
ic->cookie = myalloc(ntohs(tlv->size));
|
||||||
|
memcpy(ic->cookie, tlv->data, ntohs(tlv->size));
|
||||||
|
ic->size = tlv->size;
|
||||||
|
}
|
||||||
|
else if(ntohs(tlv->type) == 0x0005){
|
||||||
|
if(ic->connectstring)myfree(ic->connectstring);
|
||||||
|
ic->connectstring = myalloc(ntohs(tlv->size)+1);
|
||||||
|
memcpy(ic->connectstring, tlv->data, ntohs(tlv->size));
|
||||||
|
ic->connectstring[ntohs(tlv->size)] = 0;
|
||||||
|
bostlv = tlv;
|
||||||
|
movelen = extra + (len - 4) - ntohs(bostlv->size);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if(!ic->connectstring || !ic->cookie){
|
||||||
|
if(ic->cookie)myfree(ic->cookie);
|
||||||
|
if(ic->connectstring)myfree(ic->connectstring);
|
||||||
|
ic->cookie = NULL;
|
||||||
|
ic->connectstring = NULL;
|
||||||
|
ic->size = 0;
|
||||||
|
bostlv = NULL;
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&icq_cookie_mutex);
|
||||||
|
if(bostlv){
|
||||||
|
if(so._getsockname(param->clisock, (struct sockaddr *)&sa, &size)==-1) return 1;
|
||||||
|
len = myinet_ntoa(sa.sin_addr, smallbuf);
|
||||||
|
if(strchr(ic->connectstring, ':'))sprintf(smallbuf+len, ":%hu", ntohs(sa.sin_port));
|
||||||
|
len = (int)strlen(smallbuf);
|
||||||
|
*dif = len - (int)ntohs(bostlv->size);
|
||||||
|
if(*dif != 0 && movelen > 0){
|
||||||
|
memmove(bostlv->data + len, bostlv->data + ntohs(bostlv->size), movelen);
|
||||||
|
}
|
||||||
|
memcpy(bostlv->data, smallbuf, len);
|
||||||
|
bostlv->size = htons(len);
|
||||||
|
len = ((int)ntohs(flap->size)) + *dif;
|
||||||
|
flap->size = htons(len);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static FILTER_ACTION icq_srv(void *fc, struct clientparam * param, unsigned char ** buf_p, int * bufsize_p, int ioffset, int * length_p){
|
||||||
|
unsigned char * start = *buf_p + ioffset;
|
||||||
|
int len = *length_p - ioffset;
|
||||||
|
struct icqstate *state = (struct icqstate *)fc;
|
||||||
|
int size;
|
||||||
|
int offset;
|
||||||
|
|
||||||
|
while (len > 0){
|
||||||
|
switch(state->state){
|
||||||
|
case ONBEGIN:
|
||||||
|
|
||||||
|
if((*start) == 0x2A) {
|
||||||
|
if(len < 6){
|
||||||
|
offset = (int)(start - *buf_p);
|
||||||
|
addbuffer(6-len, param, buf_p, bufsize_p, length_p);
|
||||||
|
start = *buf_p + offset;
|
||||||
|
len = (int)(*buf_p + *length_p - start);
|
||||||
|
|
||||||
|
}
|
||||||
|
state->state = ONCHAN;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(!state->leftinstate)param->srv->logfunc(param, "Warning: need resync");
|
||||||
|
state->leftinstate++;
|
||||||
|
if(state->leftinstate > 65535){
|
||||||
|
param->srv->logfunc(param, "Out of Sync");
|
||||||
|
return REJECT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
start++;
|
||||||
|
len--;
|
||||||
|
break;
|
||||||
|
case ONCHAN:
|
||||||
|
if (*start >= 10){
|
||||||
|
param->srv->logfunc(param, "Warning: Wrong channel");
|
||||||
|
state->state = ONBEGIN;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
state->state = ONSEQ1;
|
||||||
|
state->channel = *start;
|
||||||
|
start++;
|
||||||
|
len--;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ONSEQ1:
|
||||||
|
state->gotseq = (((unsigned)*start) << 8);
|
||||||
|
state->state = ONSEQ2;
|
||||||
|
*(start) = (state->seq>>8);
|
||||||
|
start++;
|
||||||
|
len--;
|
||||||
|
break;
|
||||||
|
case ONSEQ2:
|
||||||
|
state->gotseq += *start;
|
||||||
|
if(state->gotseq != state->srvseq){
|
||||||
|
char smallbuf[64];
|
||||||
|
if(((state->gotseq < state->srvseq) || ((state->gotseq - state->srvseq) > 10 )) && (!state->resyncseq || state->gotseq != state->resyncseq)){
|
||||||
|
sprintf(smallbuf, "Warning: Wrong sequence, expected: %04hx got: %04hx", state->srvseq, state->gotseq);
|
||||||
|
param->srv->logfunc(param, smallbuf);
|
||||||
|
state->state = ONBEGIN;
|
||||||
|
state->resyncseq = state->gotseq;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
sprintf(smallbuf, "Warning: %hu flaps are lost on resync", state->gotseq - state->srvseq );
|
||||||
|
param->srv->logfunc(param, smallbuf);
|
||||||
|
state->srvseq = state->gotseq;
|
||||||
|
*(start-1) = (state->seq>>8);
|
||||||
|
}
|
||||||
|
*start = (state->seq & 0x00FF);
|
||||||
|
state->srvseq = state->srvseq + 1;
|
||||||
|
state->seq = state->seq + 1;
|
||||||
|
state->state = ONSIZE1;
|
||||||
|
start++;
|
||||||
|
len--;
|
||||||
|
break;
|
||||||
|
case ONSIZE1:
|
||||||
|
state->leftinstate = (((unsigned)(*start))<<8);
|
||||||
|
state->state = ONSIZE2;
|
||||||
|
start++;
|
||||||
|
len--;
|
||||||
|
break;
|
||||||
|
case ONSIZE2:
|
||||||
|
state->leftinstate += *start;
|
||||||
|
state->state = (state->leftinstate)?ONDATA:ONBEGIN;
|
||||||
|
start++;
|
||||||
|
len--;
|
||||||
|
if(state->leftinstate > 30 && state->channel == 2) {
|
||||||
|
|
||||||
|
if(len < state->leftinstate) {
|
||||||
|
offset = (int)(start - *buf_p);
|
||||||
|
addbuffer(state->leftinstate - len, param, buf_p, bufsize_p, length_p);
|
||||||
|
start = *buf_p + offset;
|
||||||
|
len = (int)(*length_p - offset);
|
||||||
|
|
||||||
|
}
|
||||||
|
size = 0;
|
||||||
|
if ((start[4] & 0x80)) {
|
||||||
|
size = htons(*(unsigned short *)(start+10)) + 2;
|
||||||
|
if(size > 8) size = 0;
|
||||||
|
}
|
||||||
|
if (start[0] == 0 && start[1] == 1 &&
|
||||||
|
((start[2] == 0 && start[3] == 5) || (start[2] == 1 && start[3] == 2))){
|
||||||
|
int dif = 0;
|
||||||
|
|
||||||
|
offset = (int)(start - *buf_p);
|
||||||
|
addbuffer(0, param, buf_p, bufsize_p, length_p);
|
||||||
|
start = *buf_p + offset;
|
||||||
|
searchcookie(param, (struct flap_header *) (start-6), state->leftinstate-(size+10), &dif, (struct tlv_header *) (start + size + 10), len - state->leftinstate);
|
||||||
|
*length_p += dif;
|
||||||
|
start += (state->leftinstate + dif);
|
||||||
|
len -= state->leftinstate;
|
||||||
|
state->leftinstate = 0;
|
||||||
|
state->state = ONBEGIN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ONDATA:
|
||||||
|
size = (state->leftinstate > len)? len : state->leftinstate;
|
||||||
|
|
||||||
|
start += size;
|
||||||
|
len -= size;
|
||||||
|
state->leftinstate -= size;
|
||||||
|
if(!state->leftinstate) {
|
||||||
|
state->state = ONBEGIN;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct filter icqfilter = {
|
||||||
|
NULL,
|
||||||
|
"icqfilter",
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
*icq_srv,
|
||||||
|
*icq_clear,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static int readflap(struct clientparam * param, int direction, unsigned char *buf, int buflen){
|
||||||
|
int i, len;
|
||||||
|
|
||||||
|
struct flap_header *flap = (struct flap_header *)buf;
|
||||||
|
|
||||||
|
i = sockgetlinebuf(param, direction, buf, 6, EOF, conf.timeouts[STRING_L]);
|
||||||
|
if(i!=6) return 1;
|
||||||
|
if(flap->id != 0x2a) return 2;
|
||||||
|
len = ntohs(flap->size);
|
||||||
|
if(len > buflen-6) return 3;
|
||||||
|
i = sockgetlinebuf(param, direction, flap->data, len, EOF, conf.timeouts[STRING_S]);
|
||||||
|
if(len != i) return 4;
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#define flap ((struct flap_header *)buf)
|
||||||
|
#define snack ((struct snack_header *)(buf+6))
|
||||||
|
void * icqprchild(struct clientparam* param) {
|
||||||
|
int res;
|
||||||
|
unsigned char tmpsend[1024];
|
||||||
|
unsigned char *buf;
|
||||||
|
int i,j,len,len1;
|
||||||
|
int offset = 0;
|
||||||
|
int buflen = 16384;
|
||||||
|
LOGINTYPE logintype = ICQUNKNOWN;
|
||||||
|
int greet = 0;
|
||||||
|
struct icq_cookie *ic;
|
||||||
|
struct tlv_header *tlv;
|
||||||
|
struct icqstate mystate = {
|
||||||
|
ONBEGIN,
|
||||||
|
0, 0, 0,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
struct filterp icqfilterp = {
|
||||||
|
&icqfilter,
|
||||||
|
(void *)&mystate
|
||||||
|
};
|
||||||
|
struct filterp **newfilters;
|
||||||
|
char handshake[] = {'\052', '\001', '\000', '\000', '\000', '\004', '\000', '\000', '\000', '\001'};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
memcpy(tmpsend, handshake, 10);
|
||||||
|
if(socksend(param->clisock, tmpsend, 10, conf.timeouts[STRING_S])!=10) {RETURN (1101);}
|
||||||
|
buf = myalloc(65600);
|
||||||
|
|
||||||
|
if((res = readflap(param, CLIENT, buf, 1000))) {RETURN (1180 + res);}
|
||||||
|
if(ntohs(flap->size) == 4 || ntohs(flap->size) == 12){
|
||||||
|
tmpsend[2] = buf[2];
|
||||||
|
tmpsend[3] = buf[3];
|
||||||
|
greet = 1;
|
||||||
|
if(readflap(param, CLIENT, buf, 65550)) {RETURN (110);}
|
||||||
|
}
|
||||||
|
if(flap->chan != 1 && (flap->chan != 2 || snack->family != htonl(0x00170006))){
|
||||||
|
RETURN(1104);
|
||||||
|
}
|
||||||
|
|
||||||
|
len = ntohs(flap->size);
|
||||||
|
if(flap->chan == 1){
|
||||||
|
tlv = (struct tlv_header *)(flap->data + 4);
|
||||||
|
len -= 4;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tlv = (struct tlv_header *)(flap->data + 10);
|
||||||
|
len -= 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(; len >= (ntohs(tlv->size) + 4); len -= (ntohs(tlv->size) + 4), tlv = (struct tlv_header *)(tlv->data + ntohs(tlv->size))){
|
||||||
|
switch(ntohs(tlv->type)){
|
||||||
|
case 0x0001:
|
||||||
|
if(flap->chan == 2 && !logintype)logintype = ICQMD5;
|
||||||
|
if(!param->username){
|
||||||
|
param->username = myalloc(ntohs(tlv->size) + 1);
|
||||||
|
for(i=0, j=0; i < ntohs(tlv->size); i++){
|
||||||
|
if(!isspace(tlv->data[i]))param->username[j++]=tolower(tlv->data[i]);
|
||||||
|
}
|
||||||
|
param->username[j] = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 0x0002:
|
||||||
|
logintype = ICQCLEAR;
|
||||||
|
break;
|
||||||
|
case 0x0006:
|
||||||
|
logintype = ICQCOOKIE;
|
||||||
|
|
||||||
|
for(ic = icq_cookies; ic; ic=ic->next){
|
||||||
|
if(ic->size && ic->size == tlv->size && !memcmp(ic->cookie, tlv->data, ntohs(tlv->size))){
|
||||||
|
parsehostname((char *)ic->connectstring, param, ntohs(param->srv->targetport));
|
||||||
|
if(!param->username && ic->id) param->username = mystrdup(ic->id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!ic) RETURN(1132);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!logintype) RETURN(1133);
|
||||||
|
if(logintype != ICQCOOKIE) {
|
||||||
|
parsehostname((char *)param->srv->target, param, ntohs(param->srv->targetport));
|
||||||
|
}
|
||||||
|
param->operation = CONNECT;
|
||||||
|
res = (*param->srv->authfunc)(param);
|
||||||
|
if(res) {RETURN(res);}
|
||||||
|
|
||||||
|
if(greet){
|
||||||
|
if(socksend(param->remsock, tmpsend, 10, conf.timeouts[STRING_S])!=10) {RETURN (1105);}
|
||||||
|
param->statscli += 10;
|
||||||
|
}
|
||||||
|
if(readflap(param, SERVER, tmpsend, 1024)) {RETURN (1111);}
|
||||||
|
param->statssrv += (ntohs(((struct flap_header *)tmpsend)->size) + 6);
|
||||||
|
mystate.srvseq = ntohs(((struct flap_header *)tmpsend)->seq) + 1;
|
||||||
|
mystate.seq = 1;
|
||||||
|
len = ntohs(flap->size) + 6;
|
||||||
|
if((res=handledatfltcli(param, &buf, &buflen, offset, &len))!=PASS) RETURN(res);
|
||||||
|
if(socksend(param->remsock, buf+offset, len, conf.timeouts[STRING_S])!=(ntohs(flap->size)+6)) {RETURN (1106);}
|
||||||
|
offset = 0;
|
||||||
|
param->statscli += len;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(logintype == ICQMD5) {
|
||||||
|
if(readflap(param, SERVER, buf, 65550)) {RETURN (1112);}
|
||||||
|
mystate.srvseq = ntohs(flap->seq) + 1;
|
||||||
|
flap->seq = htons(mystate.seq);
|
||||||
|
mystate.seq++;
|
||||||
|
len = ntohs(flap->size) + 6;
|
||||||
|
if((res=handledatfltsrv(param, &buf, &buflen, offset, &len))!=PASS) RETURN(res);
|
||||||
|
if(socksend(param->clisock, buf+offset, len, conf.timeouts[STRING_S])!=len) {RETURN (1113);}
|
||||||
|
offset = 0;
|
||||||
|
|
||||||
|
if(readflap(param, CLIENT, buf, 65550)) {RETURN (1114);}
|
||||||
|
len = ntohs(flap->size) + 6;
|
||||||
|
if((res=handledatfltcli(param, &buf, &buflen, offset, &len))!=PASS) RETURN(res);
|
||||||
|
if(socksend(param->remsock, buf+offset, len, conf.timeouts[STRING_S])!=len) {RETURN (1115);}
|
||||||
|
param->statscli += len;
|
||||||
|
offset = 0;
|
||||||
|
}
|
||||||
|
if(logintype != ICQCOOKIE) {
|
||||||
|
if(readflap(param, SERVER, buf, 65550)) {RETURN (1116);}
|
||||||
|
mystate.srvseq = ntohs(flap->seq) + 1;
|
||||||
|
flap->seq = htons(mystate.seq);
|
||||||
|
mystate.seq++;
|
||||||
|
len = ntohs(flap->size);
|
||||||
|
|
||||||
|
if(!param->username) {RETURN (1117);}
|
||||||
|
if(flap->chan == 1 || flap->chan == 4){
|
||||||
|
if(flap->data[0] == 0 && flap->data[1] == 0 && flap->data[2] == 0 && flap->data[3] == 1){
|
||||||
|
tlv = (struct tlv_header *)(flap->data + 4);
|
||||||
|
len -= 4;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
tlv = (struct tlv_header *)(flap->data);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tlv = (struct tlv_header *)(flap->data + 10);
|
||||||
|
len -= 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
len1 = ntohs(flap->size);
|
||||||
|
if(searchcookie(param, flap, len, &len1, tlv, 0)){RETURN (1118);}
|
||||||
|
|
||||||
|
len = ntohs(flap->size) + 6;
|
||||||
|
if((res=handledatfltsrv(param, &buf, &buflen, offset, &len))!=PASS) RETURN(res);
|
||||||
|
if(socksend(param->clisock, buf+offset, len, conf.timeouts[STRING_S])!=len) {RETURN (1117);}
|
||||||
|
offset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
param->ndatfilterssrv++;
|
||||||
|
newfilters = myalloc(param->ndatfilterssrv * sizeof(struct filterp *));
|
||||||
|
if(param->ndatfilterssrv > 1){
|
||||||
|
memcpy(newfilters, param->datfilterssrv, (param->ndatfilterssrv - 1) * sizeof(struct filterp *));
|
||||||
|
myfree(param->datfilterssrv);
|
||||||
|
}
|
||||||
|
param->datfilterssrv = newfilters;
|
||||||
|
newfilters[param->ndatfilterssrv - 1] = &icqfilterp;
|
||||||
|
|
||||||
|
param->res = sockmap(param, conf.timeouts[CONNECTION_L]);
|
||||||
|
|
||||||
|
param->ndatfilterssrv--;
|
||||||
|
|
||||||
|
CLEANRET:
|
||||||
|
|
||||||
|
|
||||||
|
(*param->srv->logfunc)(param, NULL);
|
||||||
|
freeparam(param);
|
||||||
|
if(buf) myfree(buf);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef WITHMAIN
|
||||||
|
struct proxydef childdef = {
|
||||||
|
icqprchild,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
S_ICQPR,
|
||||||
|
""
|
||||||
|
};
|
||||||
|
#include "proxymain.c"
|
||||||
|
#endif
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* md4c.c MD4 message-digest algorithm
|
* md4c.c MD4 message-digest algorithm
|
||||||
*
|
*
|
||||||
|
* Version: $Id: md4.c,v 1.1 2010-11-11 11:32:32 v.dubrovin Exp $
|
||||||
|
*
|
||||||
* License to copy and use this software is granted provided that it
|
* License to copy and use this software is granted provided that it
|
||||||
* is identified as the "RSA Data Security, Inc. MD4 Message-Digest
|
* is identified as the "RSA Data Security, Inc. MD4 Message-Digest
|
||||||
* Algorithm" in all material mentioning or referencing this software
|
* Algorithm" in all material mentioning or referencing this software
|
||||||
|
|||||||
@@ -1,354 +0,0 @@
|
|||||||
/*
|
|
||||||
3APA3A simpliest proxy server
|
|
||||||
(c) 2002-2020 by Vladimir Dubrovin <3proxy@3proxy.ru>
|
|
||||||
|
|
||||||
please read License Agreement
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "proxy.h"
|
|
||||||
pthread_mutex_t log_mutex;
|
|
||||||
int havelog = 0;
|
|
||||||
|
|
||||||
|
|
||||||
struct clientparam logparam;
|
|
||||||
struct srvparam logsrv;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void dolog(struct clientparam * param, const unsigned char *s){
|
|
||||||
static int init = 0;
|
|
||||||
|
|
||||||
if(param)param->srv->logfunc(param, s);
|
|
||||||
else {
|
|
||||||
if(!init){
|
|
||||||
srvinit(&logsrv, &logparam);
|
|
||||||
init = 1;
|
|
||||||
}
|
|
||||||
logstdout(&logparam, s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void clearstat(struct clientparam * param) {
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
struct timeb tb;
|
|
||||||
|
|
||||||
ftime(&tb);
|
|
||||||
param->time_start = (time_t)tb.time;
|
|
||||||
param->msec_start = (unsigned)tb.millitm;
|
|
||||||
|
|
||||||
#else
|
|
||||||
struct timeval tv;
|
|
||||||
struct timezone tz;
|
|
||||||
gettimeofday(&tv, &tz);
|
|
||||||
|
|
||||||
param->time_start = (time_t)tv.tv_sec;
|
|
||||||
param->msec_start = (tv.tv_usec / 1000);
|
|
||||||
#endif
|
|
||||||
param->statscli64 = param->statssrv64 = param->nreads = param->nwrites =
|
|
||||||
param->nconnects = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
char months[12][4] = {
|
|
||||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
|
||||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
int dobuf2(struct clientparam * param, unsigned char * buf, const unsigned char *s, const unsigned char * doublec, struct tm* tm, char * format){
|
|
||||||
int i, j;
|
|
||||||
int len;
|
|
||||||
time_t sec;
|
|
||||||
unsigned msec;
|
|
||||||
|
|
||||||
long timezone;
|
|
||||||
unsigned delay;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
struct timeb tb;
|
|
||||||
|
|
||||||
ftime(&tb);
|
|
||||||
sec = (time_t)tb.time;
|
|
||||||
msec = (unsigned)tb.millitm;
|
|
||||||
timezone = tm->tm_isdst*60 - tb.timezone;
|
|
||||||
|
|
||||||
#else
|
|
||||||
struct timeval tv;
|
|
||||||
struct timezone tz;
|
|
||||||
gettimeofday(&tv, &tz);
|
|
||||||
|
|
||||||
sec = (time_t)tv.tv_sec;
|
|
||||||
msec = tv.tv_usec / 1000;
|
|
||||||
#ifdef _SOLARIS
|
|
||||||
timezone = -altzone / 60;
|
|
||||||
#else
|
|
||||||
timezone = tm->tm_gmtoff / 60;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
delay = param->time_start?((unsigned) ((sec - param->time_start))*1000 + msec) - param->msec_start : 0;
|
|
||||||
*buf = 0;
|
|
||||||
for(i=0, j=0; format[j] && i < 4040; j++){
|
|
||||||
if(format[j] == '%' && format[j+1]){
|
|
||||||
j++;
|
|
||||||
switch(format[j]){
|
|
||||||
case '%':
|
|
||||||
buf[i++] = '%';
|
|
||||||
break;
|
|
||||||
case 'y':
|
|
||||||
sprintf((char *)buf+i, "%.2d", tm->tm_year%100);
|
|
||||||
i+=2;
|
|
||||||
break;
|
|
||||||
case 'Y':
|
|
||||||
sprintf((char *)buf+i, "%.4d", tm->tm_year+1900);
|
|
||||||
i+=4;
|
|
||||||
break;
|
|
||||||
case 'm':
|
|
||||||
sprintf((char *)buf+i, "%.2d", tm->tm_mon+1);
|
|
||||||
i+=2;
|
|
||||||
break;
|
|
||||||
case 'o':
|
|
||||||
sprintf((char *)buf+i, "%s", months[tm->tm_mon]);
|
|
||||||
i+=3;
|
|
||||||
break;
|
|
||||||
case 'd':
|
|
||||||
sprintf((char *)buf+i, "%.2d", tm->tm_mday);
|
|
||||||
i+=2;
|
|
||||||
break;
|
|
||||||
case 'H':
|
|
||||||
sprintf((char *)buf+i, "%.2d", tm->tm_hour);
|
|
||||||
i+=2;
|
|
||||||
break;
|
|
||||||
case 'M':
|
|
||||||
sprintf((char *)buf+i, "%.2d", tm->tm_min);
|
|
||||||
i+=2;
|
|
||||||
break;
|
|
||||||
case 'S':
|
|
||||||
sprintf((char *)buf+i, "%.2d", tm->tm_sec);
|
|
||||||
i+=2;
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
sprintf((char *)buf+i, "%.10u", (unsigned)sec);
|
|
||||||
i+=10;
|
|
||||||
break;
|
|
||||||
case 'b':
|
|
||||||
i+=sprintf((char *)buf+i, "%u", delay?(unsigned)(param->statscli64 * 1000./delay):0);
|
|
||||||
break;
|
|
||||||
case 'B':
|
|
||||||
i+=sprintf((char *)buf+i, "%u", delay?(unsigned)(param->statssrv64 * 1000./delay):0);
|
|
||||||
break;
|
|
||||||
case 'D':
|
|
||||||
i+=sprintf((char *)buf+i, "%u", delay);
|
|
||||||
break;
|
|
||||||
case '.':
|
|
||||||
sprintf((char *)buf+i, "%.3u", msec);
|
|
||||||
i+=3;
|
|
||||||
break;
|
|
||||||
case 'z':
|
|
||||||
sprintf((char *)buf+i, "%+.2ld%.2u", timezone / 60, (unsigned)(timezone%60));
|
|
||||||
i+=5;
|
|
||||||
break;
|
|
||||||
case 'U':
|
|
||||||
if(param->username && *param->username){
|
|
||||||
for(len = 0; i< 4000 && param->username[len]; len++){
|
|
||||||
buf[i] = param->username[len];
|
|
||||||
if(param->srv->nonprintable && (buf[i] < 0x20 || strchr((char *)param->srv->nonprintable, buf[i]))) buf[i] = param->srv->replace;
|
|
||||||
if(doublec && strchr((char *)doublec, buf[i])) {
|
|
||||||
buf[i+1] = buf[i];
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
buf[i++] = '-';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'n':
|
|
||||||
len = param->hostname? (int)strlen((char *)param->hostname) : 0;
|
|
||||||
if (len > 0 && !strchr((char *)param->hostname, ':')) for(len = 0; param->hostname[len] && i < 256; len++, i++){
|
|
||||||
buf[i] = param->hostname[len];
|
|
||||||
if(param->srv->nonprintable && (buf[i] < 0x20 || strchr((char *)param->srv->nonprintable, buf[i]))) buf[i] = param->srv->replace;
|
|
||||||
if(doublec && strchr((char *)doublec, buf[i])) {
|
|
||||||
buf[i+1] = buf[i];
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
buf[i++] = '[';
|
|
||||||
i += myinet_ntop(*SAFAMILY(¶m->req), SAADDR(¶m->req), (char *)buf + i, 64);
|
|
||||||
buf[i++] = ']';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'N':
|
|
||||||
if(param->service < 15) {
|
|
||||||
len = (conf.stringtable)? (int)strlen((char *)conf.stringtable[SERVICES + param->service]) : 0;
|
|
||||||
if(len > 20) len = 20;
|
|
||||||
memcpy(buf+i, (len)?conf.stringtable[SERVICES + param->service]:(unsigned char*)"-", (len)?len:1);
|
|
||||||
i += (len)?len:1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'E':
|
|
||||||
sprintf((char *)buf+i, "%.05d", param->res);
|
|
||||||
i += 5;
|
|
||||||
break;
|
|
||||||
case 'T':
|
|
||||||
if(s){
|
|
||||||
for(len = 0; i<4000 && s[len]; len++){
|
|
||||||
buf[i] = s[len];
|
|
||||||
if(param->srv->nonprintable && (buf[i] < 0x20 || strchr((char *)param->srv->nonprintable, buf[i]))) buf[i] = param->srv->replace;
|
|
||||||
if(doublec && strchr((char *)doublec, buf[i])) {
|
|
||||||
buf[i+1] = buf[i];
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'e':
|
|
||||||
i += myinet_ntop(*SAFAMILY(¶m->sinsl), SAADDR(¶m->sinsl), (char *)buf + i, 64);
|
|
||||||
break;
|
|
||||||
case 'i':
|
|
||||||
i += myinet_ntop(*SAFAMILY(¶m->sincl), SAADDR(¶m->sincl), (char *)buf + i, 64);
|
|
||||||
break;
|
|
||||||
case 'C':
|
|
||||||
i += myinet_ntop(*SAFAMILY(¶m->sincr), SAADDR(¶m->sincr), (char *)buf + i, 64);
|
|
||||||
break;
|
|
||||||
case 'R':
|
|
||||||
i += myinet_ntop(*SAFAMILY(¶m->sinsr), SAADDR(¶m->sinsr), (char *)buf + i, 64);
|
|
||||||
break;
|
|
||||||
case 'Q':
|
|
||||||
i += myinet_ntop(*SAFAMILY(¶m->req), SAADDR(¶m->req), (char *)buf + i, 64);
|
|
||||||
break;
|
|
||||||
case 'p':
|
|
||||||
sprintf((char *)buf+i, "%hu", ntohs(*SAPORT(¶m->srv->intsa)));
|
|
||||||
i += (int)strlen((char *)buf+i);
|
|
||||||
break;
|
|
||||||
case 'c':
|
|
||||||
sprintf((char *)buf+i, "%hu", ntohs(*SAPORT(¶m->sincr)));
|
|
||||||
i += (int)strlen((char *)buf+i);
|
|
||||||
break;
|
|
||||||
case 'r':
|
|
||||||
sprintf((char *)buf+i, "%hu", ntohs(*SAPORT(¶m->sinsr)));
|
|
||||||
i += (int)strlen((char *)buf+i);
|
|
||||||
break;
|
|
||||||
case 'q':
|
|
||||||
sprintf((char *)buf+i, "%hu", ntohs(*SAPORT(¶m->req)));
|
|
||||||
i += (int)strlen((char *)buf+i);
|
|
||||||
break;
|
|
||||||
case 'L':
|
|
||||||
sprintf((char *)buf+i, "%"PRINTF_INT64_MODIFIER"u", param->cycles);
|
|
||||||
i += (int)strlen((char *)buf+i);
|
|
||||||
break;
|
|
||||||
case 'I':
|
|
||||||
sprintf((char *)buf+i, "%"PRINTF_INT64_MODIFIER"u", param->statssrv64);
|
|
||||||
i += (int)strlen((char *)buf+i);
|
|
||||||
break;
|
|
||||||
case 'O':
|
|
||||||
sprintf((char *)buf+i, "%"PRINTF_INT64_MODIFIER"u", param->statscli64);
|
|
||||||
i += (int)strlen((char *)buf+i);
|
|
||||||
break;
|
|
||||||
case 'h':
|
|
||||||
sprintf((char *)buf+i, "%d", param->redirected);
|
|
||||||
i += (int)strlen((char *)buf+i);
|
|
||||||
break;
|
|
||||||
case '1':
|
|
||||||
case '2':
|
|
||||||
case '3':
|
|
||||||
case '4':
|
|
||||||
case '5':
|
|
||||||
case '6':
|
|
||||||
case '7':
|
|
||||||
case '8':
|
|
||||||
case '9':
|
|
||||||
{
|
|
||||||
int k, pmin=0, pmax=0;
|
|
||||||
for (k = j; isnumber(format[k]); k++);
|
|
||||||
if(format[k] == '-' && isnumber(format[k+1])){
|
|
||||||
pmin = atoi(format + j) - 1;
|
|
||||||
k++;
|
|
||||||
pmax = atoi(format + k) -1;
|
|
||||||
for (; isnumber(format[k]); k++);
|
|
||||||
j = k;
|
|
||||||
}
|
|
||||||
if(!s || format[k]!='T') break;
|
|
||||||
for(k = 0, len = 0; s[len] && i < 4000; len++){
|
|
||||||
if(isspace(s[len])){
|
|
||||||
k++;
|
|
||||||
while(isspace(s[len+1]))len++;
|
|
||||||
if(k == pmin) continue;
|
|
||||||
}
|
|
||||||
if(k>=pmin && k<=pmax) {
|
|
||||||
buf[i] = s[len];
|
|
||||||
if(param->srv->nonprintable && (buf[i] < 0x20 || strchr((char *)param->srv->nonprintable, buf[i]))) buf[i] = param->srv->replace;
|
|
||||||
if(doublec && strchr((char *)doublec, buf[i])) {
|
|
||||||
buf[i+1] = buf[i];
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
buf[i++] = format[j];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else buf[i++] = format[j];
|
|
||||||
}
|
|
||||||
buf[i] = 0;
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
int dobuf(struct clientparam * param, unsigned char * buf, const unsigned char *s, const unsigned char * doublec){
|
|
||||||
struct tm* tm;
|
|
||||||
int i;
|
|
||||||
char * format;
|
|
||||||
time_t t;
|
|
||||||
|
|
||||||
time(&t);
|
|
||||||
if(!param) return 0;
|
|
||||||
if(param->trafcountfunc)(*param->trafcountfunc)(param);
|
|
||||||
format = param->srv->logformat?(char *)param->srv->logformat : DEFLOGFORMAT;
|
|
||||||
tm = (*format == 'G' || *format == 'g')?
|
|
||||||
gmtime(&t) : localtime(&t);
|
|
||||||
i = dobuf2(param, buf, s, doublec, tm, format + 1);
|
|
||||||
clearstat(param);
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
void lognone(struct clientparam * param, const unsigned char *s) {
|
|
||||||
if(param->trafcountfunc)(*param->trafcountfunc)(param);
|
|
||||||
clearstat(param);
|
|
||||||
}
|
|
||||||
|
|
||||||
void logstdout(struct clientparam * param, const unsigned char *s) {
|
|
||||||
FILE *log;
|
|
||||||
unsigned char tmpbuf[8192];
|
|
||||||
|
|
||||||
dobuf(param, tmpbuf, s, NULL);
|
|
||||||
log = param->srv->stdlog?param->srv->stdlog:conf.stdlog?conf.stdlog:stdout;
|
|
||||||
if(!param->nolog)if(fprintf(log, "%s\n", tmpbuf) < 0) {
|
|
||||||
perror("printf()");
|
|
||||||
};
|
|
||||||
if(log != conf.stdlog)fflush(log);
|
|
||||||
}
|
|
||||||
#ifndef _WIN32
|
|
||||||
void logsyslog(struct clientparam * param, const unsigned char *s) {
|
|
||||||
|
|
||||||
unsigned char tmpbuf[8192];
|
|
||||||
dobuf(param, tmpbuf, s, NULL);
|
|
||||||
if(!param->nolog)syslog(LOG_INFO, "%s", tmpbuf);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
+234
@@ -0,0 +1,234 @@
|
|||||||
|
/*
|
||||||
|
3APA3A simpliest proxy server
|
||||||
|
(c) 2002-2008 by ZARAZA <3APA3A@security.nnov.ru>
|
||||||
|
|
||||||
|
please read License Agreement
|
||||||
|
|
||||||
|
$Id: msnpr.c,v 1.3 2012-04-11 23:01:19 vlad Exp $
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "proxy.h"
|
||||||
|
|
||||||
|
#ifndef PORTMAP
|
||||||
|
#define PORTMAP
|
||||||
|
#endif
|
||||||
|
#define RETURN(xxx) { param->res = xxx; goto CLEANRET; }
|
||||||
|
|
||||||
|
struct msn_cookie {
|
||||||
|
struct msn_cookie *next;
|
||||||
|
unsigned char *userid;
|
||||||
|
char * connectstring;
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct msn_cookie *msn_cookies = NULL;
|
||||||
|
pthread_mutex_t msn_cookie_mutex;
|
||||||
|
int msn_cookie_mutex_init = 0;
|
||||||
|
|
||||||
|
static void msn_clear(void *fo){
|
||||||
|
};
|
||||||
|
|
||||||
|
static FILTER_ACTION msn_srv(void *fc, struct clientparam * param, unsigned char ** buf_p, int * bufsize_p, int offset, int * length_p){
|
||||||
|
unsigned char *data = *buf_p + offset;
|
||||||
|
int len = (int)(*length_p - offset);
|
||||||
|
struct sockaddr_in sa;
|
||||||
|
SASIZETYPE size = sizeof(sa);
|
||||||
|
struct msn_cookie *cookie;
|
||||||
|
char tmpbuf[256];
|
||||||
|
char *sp1, *sp2, *sp3;
|
||||||
|
|
||||||
|
|
||||||
|
if(*bufsize_p - *length_p < 32) return CONTINUE;
|
||||||
|
if(len < 10 || len > 220) return CONTINUE;
|
||||||
|
|
||||||
|
data[len] = 0;
|
||||||
|
|
||||||
|
|
||||||
|
sp1 = data + 3;
|
||||||
|
if(data[0] == 'X' && data[1] == 'F' && data[2] == 'R' && data[3] == ' '){
|
||||||
|
if(!(sp2 = strchr(sp1 + 1, ' ')) || !(sp2 = strchr(sp2 + 1, ' '))|| !(sp3 = strchr(sp2 + 1, ' '))) return CONTINUE;
|
||||||
|
}
|
||||||
|
else if(data[0] == 'R' && data[1] == 'N' && data[2] == 'G' && data[3] == ' '){
|
||||||
|
if(!(sp2 = strchr(sp1 + 1, ' ')) || !(sp3 = strchr(sp2 + 1, ' '))) return CONTINUE;
|
||||||
|
}
|
||||||
|
else return CONTINUE;
|
||||||
|
|
||||||
|
*sp2 = 0;
|
||||||
|
*sp3 = 0;
|
||||||
|
if(getsockname(param->clisock, (struct sockaddr *)&sa, &size)==-1) {
|
||||||
|
return CONTINUE;
|
||||||
|
};
|
||||||
|
cookie = myalloc(sizeof(struct msn_cookie));
|
||||||
|
cookie->connectstring = mystrdup(sp2 + 1);
|
||||||
|
cookie->userid = mystrdup(param->username);
|
||||||
|
|
||||||
|
pthread_mutex_lock(&msn_cookie_mutex);
|
||||||
|
cookie->next = msn_cookies;
|
||||||
|
msn_cookies = cookie;
|
||||||
|
pthread_mutex_unlock(&msn_cookie_mutex);
|
||||||
|
|
||||||
|
strcpy(tmpbuf, data);
|
||||||
|
len = (int)strlen(tmpbuf);
|
||||||
|
tmpbuf[len++] = ' ';
|
||||||
|
|
||||||
|
len+=myinet_ntoa(sa.sin_addr, tmpbuf+len);
|
||||||
|
sprintf(tmpbuf+len, ":%hu %s", ntohs(sa.sin_port), sp3 + 1);
|
||||||
|
len = (int)strlen(tmpbuf);
|
||||||
|
memcpy(*buf_p + offset, tmpbuf, len);
|
||||||
|
*length_p = offset + len;
|
||||||
|
|
||||||
|
return CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static struct filter msnfilter = {
|
||||||
|
NULL,
|
||||||
|
"msnfilter",
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
*msn_srv,
|
||||||
|
*msn_clear,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void * msnprchild(struct clientparam* param) {
|
||||||
|
int res, len;
|
||||||
|
unsigned char *buf;
|
||||||
|
int buflen = 256;
|
||||||
|
char *sp1, *sp2, *sp3;
|
||||||
|
char *verstr = NULL;
|
||||||
|
int id;
|
||||||
|
struct msn_cookie *cookie, *prevcookie=NULL;
|
||||||
|
int sec = 0;
|
||||||
|
struct filterp **newfilters;
|
||||||
|
int skip = 0;
|
||||||
|
struct filterp msnfilterp = {
|
||||||
|
&msnfilter,
|
||||||
|
(void *)&skip
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
if(!msn_cookie_mutex_init){
|
||||||
|
msn_cookie_mutex_init = 1;
|
||||||
|
pthread_mutex_init(&msn_cookie_mutex, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
buf = myalloc(buflen);
|
||||||
|
res = sockgetlinebuf(param, CLIENT, buf, 240, '\n', conf.timeouts[STRING_S]);
|
||||||
|
if(res < 10) RETURN(1201);
|
||||||
|
buf[res] = 0;
|
||||||
|
if(!(sp1 = strchr(buf, ' ')) || !(sp2 = strchr(sp1 + 1, ' ')) || !(sp3 = strchr(sp2 + 1, ' ')) || ((int)(sp3-sp2)) < 6) RETURN(1202);
|
||||||
|
if((buf[0] == 'U' && buf[1] == 'S' && buf[2] == 'R') ||
|
||||||
|
(buf[0] == 'A' && buf[1] == 'N' && buf[2] == 'S')){
|
||||||
|
len = 1 + (int)(sp3 - sp2);
|
||||||
|
param->username = myalloc(len - 1);
|
||||||
|
memcpy(param->username, sp2 + 1, len - 2);
|
||||||
|
sec = 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(buf[0] != 'V' || buf[1] != 'E' || buf[2] != 'R') {RETURN(1203);}
|
||||||
|
else {
|
||||||
|
id = atoi(sp1 + 1);
|
||||||
|
verstr = mystrdup(buf);
|
||||||
|
|
||||||
|
if(socksend(param->clisock, buf, res, conf.timeouts[STRING_S])!=res) {RETURN (1204);}
|
||||||
|
|
||||||
|
res = sockgetlinebuf(param, CLIENT, buf, 240, '\n', conf.timeouts[STRING_S]);
|
||||||
|
if(res < 10) RETURN(1205);
|
||||||
|
buf[res] = 0;
|
||||||
|
if(buf[0] != 'C' || buf[1] != 'V' || buf[2] != 'R' || !(sp1=strrchr(buf,' ')) || (len = (int)strlen(sp1+1)) < 3) RETURN(1206);
|
||||||
|
param->username = myalloc(len - 1);
|
||||||
|
memcpy(param->username, sp1 + 1, len - 2);
|
||||||
|
}
|
||||||
|
param->username[len - 2] = 0;
|
||||||
|
param->operation = CONNECT;
|
||||||
|
|
||||||
|
pthread_mutex_lock(&msn_cookie_mutex);
|
||||||
|
for(cookie = msn_cookies; cookie; cookie = cookie->next){
|
||||||
|
if(!strcmp(param->username, cookie->userid)){
|
||||||
|
parsehostname(cookie->connectstring, param, ntohs(param->srv->targetport));
|
||||||
|
if(prevcookie)prevcookie->next = cookie->next;
|
||||||
|
else msn_cookies = cookie->next;
|
||||||
|
myfree(cookie->connectstring);
|
||||||
|
myfree(cookie->userid);
|
||||||
|
myfree(cookie);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
prevcookie = cookie;
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&msn_cookie_mutex);
|
||||||
|
if(!cookie) {
|
||||||
|
if(sec) RETURN(1233);
|
||||||
|
parsehostname((char *)param->srv->target, param, ntohs(param->srv->targetport));
|
||||||
|
}
|
||||||
|
res = (*param->srv->authfunc)(param);
|
||||||
|
if(res) {RETURN(res);}
|
||||||
|
|
||||||
|
if(!sec){
|
||||||
|
len = (int)strlen(verstr);
|
||||||
|
if(socksend(param->remsock, verstr, len, conf.timeouts[STRING_S])!= len) {RETURN (1207);}
|
||||||
|
param->statscli += len;
|
||||||
|
|
||||||
|
|
||||||
|
myfree(verstr);
|
||||||
|
verstr = mystrdup(buf);
|
||||||
|
|
||||||
|
len = sockgetlinebuf(param, SERVER, buf, 240, '\n', conf.timeouts[STRING_S]);
|
||||||
|
if(len < 10) RETURN(1208);
|
||||||
|
param->statssrv += len;
|
||||||
|
|
||||||
|
strcpy(buf, verstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
len = (int)strlen(buf);
|
||||||
|
if((res=handledatfltcli(param, &buf, &buflen, 0, &len))!=PASS) RETURN(res);
|
||||||
|
if(socksend(param->remsock, buf, len, conf.timeouts[STRING_S])!= len) {RETURN (1207);}
|
||||||
|
|
||||||
|
|
||||||
|
param->statscli += len;
|
||||||
|
|
||||||
|
if(sec){
|
||||||
|
RETURN(sockmap(param, conf.timeouts[CONNECTION_L]));
|
||||||
|
}
|
||||||
|
|
||||||
|
param->ndatfilterssrv++;
|
||||||
|
newfilters = myalloc(param->ndatfilterssrv * sizeof(struct filterp *));
|
||||||
|
if(param->ndatfilterssrv > 1){
|
||||||
|
memcpy(newfilters, param->datfilterssrv, (param->ndatfilterssrv - 1) * sizeof(struct filterp *));
|
||||||
|
myfree(param->datfilterssrv);
|
||||||
|
}
|
||||||
|
param->datfilterssrv = newfilters;
|
||||||
|
newfilters[param->ndatfilterssrv - 1] = &msnfilterp;
|
||||||
|
|
||||||
|
param->res = sockmap(param, conf.timeouts[CONNECTION_L]);
|
||||||
|
|
||||||
|
param->ndatfilterssrv--;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CLEANRET:
|
||||||
|
|
||||||
|
|
||||||
|
if(verstr)myfree(verstr);
|
||||||
|
if(buf)myfree(buf);
|
||||||
|
(*param->srv->logfunc)(param, NULL);
|
||||||
|
freeparam(param);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef WITHMAIN
|
||||||
|
struct proxydef childdef = {
|
||||||
|
msnprchild,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
S_MSNPR,
|
||||||
|
""
|
||||||
|
};
|
||||||
|
#include "proxymain.c"
|
||||||
|
#endif
|
||||||
+367
@@ -0,0 +1,367 @@
|
|||||||
|
/*
|
||||||
|
3APA3A simpliest proxy server
|
||||||
|
(c) 2002-2008 by ZARAZA <3APA3A@security.nnov.ru>
|
||||||
|
|
||||||
|
please read License Agreement
|
||||||
|
|
||||||
|
$Id: myalloc.c,v 1.5 2008/01/08 21:46:38 vlad Exp $
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "proxy.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef WITH_STD_MALLOC
|
||||||
|
|
||||||
|
#include "proxy.h"
|
||||||
|
|
||||||
|
#define MEM64K 65536
|
||||||
|
#define MEM16K 16384
|
||||||
|
#define MEM4K 4096
|
||||||
|
#define MEM1K 1024
|
||||||
|
#define MEM256 256
|
||||||
|
|
||||||
|
#define DEBUGLEVEL 1
|
||||||
|
|
||||||
|
struct mempage{
|
||||||
|
struct mempage *next;
|
||||||
|
unsigned usable;
|
||||||
|
unsigned char bitmap[32];
|
||||||
|
unsigned char data[MEM64K];
|
||||||
|
} * pages[] = {NULL, NULL, NULL, NULL, NULL, NULL};
|
||||||
|
|
||||||
|
unsigned memsizes[] = {MEM64K, MEM16K, MEM4K, MEM1K, MEM256, 0};
|
||||||
|
enum pagesizes {
|
||||||
|
p64k,
|
||||||
|
p16k,
|
||||||
|
p4k,
|
||||||
|
p1k,
|
||||||
|
p256,
|
||||||
|
nomem,
|
||||||
|
};
|
||||||
|
|
||||||
|
pthread_mutex_t mem_mutex;
|
||||||
|
int mem_init = 0;
|
||||||
|
#ifdef _WIN32
|
||||||
|
HANDLE myheap;
|
||||||
|
#define malloc(x) HeapAlloc(myheap, 0, x)
|
||||||
|
#define free(x) HeapFree(myheap, 0, x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void init_mem(void) {
|
||||||
|
mem_init++;
|
||||||
|
pthread_mutex_init(&mem_mutex, NULL);
|
||||||
|
#if DEBUGLEVEL > 2
|
||||||
|
fprintf(stderr, "Memory initialized\n");
|
||||||
|
fflush(stderr);
|
||||||
|
#endif
|
||||||
|
#ifdef _WIN32
|
||||||
|
myheap = HeapCreate(0, MEM64K*16, 0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void * myalloc64k(){
|
||||||
|
|
||||||
|
struct mempage *newpage;
|
||||||
|
|
||||||
|
if(!mem_init)init_mem();
|
||||||
|
if(!(newpage = (struct mempage *)malloc(sizeof(struct mempage)))){
|
||||||
|
#if DEBUGLEVEL > 0
|
||||||
|
fprintf(stderr, "Failed to allocate p64k\n");
|
||||||
|
fflush(stderr);
|
||||||
|
#endif
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
memset(newpage->bitmap, 0, 32);
|
||||||
|
newpage->usable = 0;
|
||||||
|
pthread_mutex_lock(&mem_mutex);
|
||||||
|
newpage->next = pages[p64k];
|
||||||
|
pages[p64k] = newpage;
|
||||||
|
pthread_mutex_unlock(&mem_mutex);
|
||||||
|
#if DEBUGLEVEL > 2
|
||||||
|
fprintf(stderr, "New p64k created, address %X region: %X\n", newpage, newpage->data);
|
||||||
|
fflush(stderr);
|
||||||
|
#endif
|
||||||
|
#if DEBUGLEVEL == 2
|
||||||
|
fprintf(stderr, "myalloc64 %p\n", newpage->data);
|
||||||
|
fflush(stderr);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return newpage->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
int alloced = 0;
|
||||||
|
|
||||||
|
void * myalloc(size_t size){
|
||||||
|
struct mempage *newpage, *page;
|
||||||
|
unsigned pagesize;
|
||||||
|
unsigned i=0, j, k=0;
|
||||||
|
int p;
|
||||||
|
|
||||||
|
|
||||||
|
alloced++;
|
||||||
|
if(!mem_init)init_mem();
|
||||||
|
for(p = nomem; ; ) {
|
||||||
|
if(!p){
|
||||||
|
#if DEBUGLEVEL > 2
|
||||||
|
fprintf(stderr, "Page is too large (%u), requesting malloc instead\n", size);
|
||||||
|
fflush(stderr);
|
||||||
|
#endif
|
||||||
|
return malloc(size);
|
||||||
|
}
|
||||||
|
p--;
|
||||||
|
if(size<memsizes[p]){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(p == p64k){
|
||||||
|
#if DEBUGLEVEL > 2
|
||||||
|
fprintf(stderr, "Page will p64k\n");
|
||||||
|
fflush(stderr);
|
||||||
|
#endif
|
||||||
|
return myalloc64k();
|
||||||
|
}
|
||||||
|
|
||||||
|
pagesize = memsizes[p];
|
||||||
|
#if DEBUGLEVEL > 2
|
||||||
|
fprintf(stderr, "Calculated pagesize: %u\n", pagesize);
|
||||||
|
fflush(stderr);
|
||||||
|
#endif
|
||||||
|
pthread_mutex_lock(&mem_mutex);
|
||||||
|
newpage = pages[p];
|
||||||
|
if(newpage && newpage->usable){
|
||||||
|
#if DEBUGLEVEL > 2
|
||||||
|
fprintf(stderr, "Useful page found: %X,", newpage);
|
||||||
|
fflush(stderr);
|
||||||
|
#endif
|
||||||
|
for(j=0; j<32; j++){
|
||||||
|
register unsigned c = newpage->bitmap[j];
|
||||||
|
if(c){
|
||||||
|
for(k=0; ;k++)if(c & (1<<k))break;
|
||||||
|
i = (j<<11) + (k<<8);
|
||||||
|
#if DEBUGLEVEL > 2
|
||||||
|
fprintf(stderr, "region: %X, offset %u, byte %u, %u, %u\n", newpage->data + i, i, j, k, newpage->bitmap[j]);
|
||||||
|
fflush(stderr);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(!(newpage = (struct mempage *)malloc(sizeof(struct mempage)))){
|
||||||
|
pthread_mutex_unlock(&mem_mutex);
|
||||||
|
#if DEBUGLEVEL > 0
|
||||||
|
fprintf(stderr, "Failed to allocate p64k\n");
|
||||||
|
fflush(stderr);
|
||||||
|
#endif
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#if DEBUGLEVEL > 2
|
||||||
|
fprintf(stderr, "New page used: %X,", newpage);
|
||||||
|
fflush(stderr);
|
||||||
|
#endif
|
||||||
|
memset(newpage->bitmap, 0, 32);
|
||||||
|
for(i = 0; i<MEM64K; i+=pagesize){
|
||||||
|
j = (i >> 11);
|
||||||
|
k = ((i & 0x000007FF) >> 8);
|
||||||
|
newpage->bitmap[j] |= (1<<k);
|
||||||
|
}
|
||||||
|
i-=pagesize;
|
||||||
|
newpage->next = pages[p];
|
||||||
|
newpage->usable = MEM64K;
|
||||||
|
pages[p] = newpage;
|
||||||
|
}
|
||||||
|
#if DEBUGLEVEL > 2
|
||||||
|
fprintf(stderr, "Byte was %d/%d/%d\n", j, k, newpage->bitmap[j]);
|
||||||
|
fflush(stderr);
|
||||||
|
#endif
|
||||||
|
newpage->bitmap[j] ^= (1<<k);
|
||||||
|
#if DEBUGLEVEL > 2
|
||||||
|
fprintf(stderr, "Byte set %d/%d/%d\n", j, k, newpage->bitmap[j]);
|
||||||
|
fflush(stderr);
|
||||||
|
#endif
|
||||||
|
newpage->usable -= pagesize;
|
||||||
|
#if DEBUGLEVEL > 2
|
||||||
|
fprintf(stderr, "usable amount after allocation: %u\n", newpage->usable);
|
||||||
|
fflush(stderr);
|
||||||
|
#endif
|
||||||
|
if(!newpage->usable){
|
||||||
|
#if DEBUGLEVEL > 2
|
||||||
|
fprintf(stderr, "No usable amount left\n", newpage->usable);
|
||||||
|
fflush(stderr);
|
||||||
|
#endif
|
||||||
|
if((page = newpage->next) && page->usable){
|
||||||
|
#if DEBUGLEVEL > 2
|
||||||
|
fprintf(stderr, "Moving to end of list\n", newpage->usable);
|
||||||
|
fflush(stderr);
|
||||||
|
#endif
|
||||||
|
pages[p] = page;
|
||||||
|
while(page->next && page->next->usable)page = page->next;
|
||||||
|
newpage->next = page->next;
|
||||||
|
page->next = newpage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&mem_mutex);
|
||||||
|
#if DEBUGLEVEL > 2
|
||||||
|
fprintf(stderr, "All done, returning: %x\n", newpage->data + i);
|
||||||
|
fflush(stderr);
|
||||||
|
#endif
|
||||||
|
#if DEBUGLEVEL == 2
|
||||||
|
fprintf(stderr, "malloc %p\n", (void *)(newpage->data + i));
|
||||||
|
fflush(stderr);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return (void *)(newpage->data + i);
|
||||||
|
}
|
||||||
|
|
||||||
|
int myfindsize(void * p, struct mempage ***prevpagep, struct mempage **pagep){
|
||||||
|
int i;
|
||||||
|
struct mempage *prevpage, *page;
|
||||||
|
|
||||||
|
for (i=0; i<nomem; i++){
|
||||||
|
for(page = pages[i], prevpage = NULL; page; page=page->next){
|
||||||
|
if( p >= (void *)page->data && p < (void *)(page->data + MEM64K))break;
|
||||||
|
prevpage = page;
|
||||||
|
}
|
||||||
|
if(page){
|
||||||
|
if(pagep)*pagep = page;
|
||||||
|
if(prevpagep)*prevpagep = prevpage?&prevpage->next:&pages[i];
|
||||||
|
#if DEBUGLEVEL > 2
|
||||||
|
fprintf(stderr, "%x belongs to page: %x with data %x\n", p, page, page->data);
|
||||||
|
fflush(stderr);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void myfree(void *p){
|
||||||
|
struct mempage **prevpage, *page;
|
||||||
|
int i;
|
||||||
|
unsigned pagesize;
|
||||||
|
unsigned size, j, k;
|
||||||
|
|
||||||
|
alloced--;
|
||||||
|
#if DEBUGLEVEL == 2
|
||||||
|
fprintf(stderr, "free %p\n", p);
|
||||||
|
fflush(stderr);
|
||||||
|
#endif
|
||||||
|
pthread_mutex_lock(&mem_mutex);
|
||||||
|
i = myfindsize(p, &prevpage, &page);
|
||||||
|
if (i == nomem) {
|
||||||
|
#if DEBUGLEVEL > 2
|
||||||
|
fprintf(stderr, "Page does not exists, trying free()\n");
|
||||||
|
fflush(stderr);
|
||||||
|
#endif
|
||||||
|
pthread_mutex_unlock(&mem_mutex);
|
||||||
|
free(p);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pagesize = memsizes[i];
|
||||||
|
#if DEBUGLEVEL > 2
|
||||||
|
fprintf(stderr, "Calculated pagesize: %u\n", pagesize);
|
||||||
|
fflush(stderr);
|
||||||
|
#endif
|
||||||
|
size = (unsigned)((unsigned char*)p - page->data);
|
||||||
|
if(size%pagesize) {
|
||||||
|
#if DEBUGLEVEL > 0
|
||||||
|
write(2, p, 4);
|
||||||
|
fprintf(stderr, "\nGiven address is not block aligned, ignoring\n");
|
||||||
|
fflush(stderr);
|
||||||
|
#endif
|
||||||
|
pthread_mutex_unlock(&mem_mutex);
|
||||||
|
return; /* Hmmmmm */
|
||||||
|
}
|
||||||
|
*prevpage = page->next;
|
||||||
|
page->usable += pagesize;
|
||||||
|
#if DEBUGLEVEL > 2
|
||||||
|
fprintf(stderr, "New usable space: %u\n", page->usable);
|
||||||
|
fflush(stderr);
|
||||||
|
#endif
|
||||||
|
if(page->usable >= MEM64K && ((pagesize == MEM64K) || (pages[i] && pages[i]->usable))) {
|
||||||
|
#if DEBUGLEVEL > 2
|
||||||
|
fprintf(stderr, "Free this page\n");
|
||||||
|
fflush(stderr);
|
||||||
|
#endif
|
||||||
|
free(page);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
j = (size>>11);
|
||||||
|
k = ((size & 0x000007FF) >> 8);
|
||||||
|
k = ('\01'<<k);
|
||||||
|
if(page->bitmap[j] & k) {
|
||||||
|
#if DEBUGLEVEL > 0
|
||||||
|
fprintf(stderr, "Error: double free() %d/%d/%d\n", j, k, page->bitmap[j]);
|
||||||
|
fflush(stderr);
|
||||||
|
#endif
|
||||||
|
page->usable += pagesize;
|
||||||
|
}
|
||||||
|
page->bitmap[j] |= k;
|
||||||
|
page->next = pages[i];
|
||||||
|
pages[i] = page;
|
||||||
|
#if DEBUGLEVEL > 2
|
||||||
|
fprintf(stderr, "This page will be reused next time\n");
|
||||||
|
fflush(stderr);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&mem_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
char * mystrdup(const char *str){
|
||||||
|
unsigned l;
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
if(!str) return NULL;
|
||||||
|
l = ((unsigned)strlen(str))+1;
|
||||||
|
p = myalloc(l);
|
||||||
|
if(p)memcpy(p, str, l);
|
||||||
|
#if DEBUGLEVEL == 2
|
||||||
|
fprintf(stderr, "strdup %p\n", p);
|
||||||
|
fflush(stderr);
|
||||||
|
#endif
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void *myrealloc(void *ptr, size_t size){
|
||||||
|
unsigned l;
|
||||||
|
void * p;
|
||||||
|
l = myfindsize(ptr, NULL, NULL);
|
||||||
|
if(size <= memsizes[l]) return ptr;
|
||||||
|
p = myalloc(size);
|
||||||
|
if(p){
|
||||||
|
memcpy(p,ptr,size);
|
||||||
|
myfree(ptr);
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef WITH_MAIN
|
||||||
|
int main(){
|
||||||
|
void *p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8, *p9, *p10, *p11, *p12, *p13;
|
||||||
|
p1 = myalloc(5000);
|
||||||
|
p2 = myalloc(5000);
|
||||||
|
p3 = myalloc(5000);
|
||||||
|
p4 = myalloc(5000);
|
||||||
|
p5 = myalloc(5000);
|
||||||
|
p6 = myalloc(5000);
|
||||||
|
p7 = myalloc(5000);
|
||||||
|
p8 = myalloc(5000);
|
||||||
|
p9 = myalloc(5000);
|
||||||
|
p10 = myalloc(5000);
|
||||||
|
myfree(p2);
|
||||||
|
myfree(p8);
|
||||||
|
p11 = myalloc(5000);
|
||||||
|
p12 = myalloc(5000);
|
||||||
|
p13 = myalloc(5000);
|
||||||
|
p2 = myalloc(5000);
|
||||||
|
p8 = myalloc(5000);
|
||||||
|
myalloc(5000);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
+2
-1
@@ -1,9 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
3APA3A simpliest proxy server
|
3APA3A simpliest proxy server
|
||||||
(c) 2002-2016 by Vladimir Dubrovin <3proxy@3proxy.ru>
|
(c) 2002-2008 by ZARAZA <3APA3A@security.nnov.ru>
|
||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
|
$Id: mycrypt.c,v 1.8 2008/01/08 21:46:38 vlad Exp $
|
||||||
*/
|
*/
|
||||||
#include "libs/md5.h"
|
#include "libs/md5.h"
|
||||||
#include "libs/md4.h"
|
#include "libs/md4.h"
|
||||||
|
|||||||
Loaded 100 of 166 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user