mirror of
https://github.com/3proxy/3proxy.git
synced 2026-04-13 00:10:11 +08:00
Compare commits
5 Commits
858f361de1
...
28969bbc5a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
28969bbc5a | ||
|
|
d502ecb0fd | ||
|
|
b0db65dfde | ||
|
|
d27afd05cd | ||
|
|
6417f1acd1 |
@ -509,6 +509,83 @@ if(NOT WIN32)
|
|||||||
install(FILES scripts/add3proxyuser.sh DESTINATION ${CMAKE_INSTALL_BINDIR})
|
install(FILES scripts/add3proxyuser.sh DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Install service files (systemd, init.d, or rc.d)
|
||||||
|
if(NOT WIN32)
|
||||||
|
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD|Darwin|OpenBSD|NetBSD")
|
||||||
|
# BSD/macOS - install rc.d script
|
||||||
|
set(RCD_DIR "/usr/local/etc/rc.d")
|
||||||
|
|
||||||
|
configure_file(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/scripts/rc.d/3proxy.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/3proxy.rc
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/3proxy.rc
|
||||||
|
DESTINATION ${RCD_DIR}
|
||||||
|
RENAME 3proxy
|
||||||
|
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
||||||
|
)
|
||||||
|
|
||||||
|
message(STATUS " rc.d: YES (${RCD_DIR})")
|
||||||
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||||
|
# Linux - check for systemd
|
||||||
|
find_package(PkgConfig QUIET)
|
||||||
|
if(PkgConfig_FOUND)
|
||||||
|
pkg_check_modules(SYSTEMD QUIET systemd)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(SYSTEMD_FOUND)
|
||||||
|
# systemd is available - install systemd service
|
||||||
|
# Get systemd unit directory
|
||||||
|
pkg_get_variable(SYSTEMD_UNIT_DIR systemd systemdsystemunitdir)
|
||||||
|
if(NOT SYSTEMD_UNIT_DIR)
|
||||||
|
# Fallback to common location
|
||||||
|
set(SYSTEMD_UNIT_DIR "/lib/systemd/system")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Configure and install systemd service file
|
||||||
|
configure_file(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/scripts/3proxy.service.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/3proxy.service
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/3proxy.service
|
||||||
|
DESTINATION ${SYSTEMD_UNIT_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Install tmpfiles.d configuration for runtime directory
|
||||||
|
configure_file(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/scripts/3proxy.tmpfiles.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/3proxy.conf
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/3proxy.conf
|
||||||
|
DESTINATION /usr/lib/tmpfiles.d
|
||||||
|
)
|
||||||
|
|
||||||
|
message(STATUS " systemd: YES (${SYSTEMD_UNIT_DIR})")
|
||||||
|
else()
|
||||||
|
# No systemd - install init.d script
|
||||||
|
install(FILES scripts/init.d/3proxy.sh
|
||||||
|
DESTINATION /etc/init.d
|
||||||
|
RENAME 3proxy
|
||||||
|
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
||||||
|
)
|
||||||
|
|
||||||
|
message(STATUS " systemd: NO (using init.d)")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
# Other Unix - install init.d script
|
||||||
|
install(FILES scripts/init.d/3proxy.sh
|
||||||
|
DESTINATION /etc/init.d
|
||||||
|
RENAME 3proxy
|
||||||
|
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
||||||
|
)
|
||||||
|
|
||||||
|
message(STATUS " init.d: YES (/etc/init.d)")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
# Install man pages
|
# Install man pages
|
||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
file(GLOB MAN3_FILES "${CMAKE_CURRENT_SOURCE_DIR}/man/*.3")
|
file(GLOB MAN3_FILES "${CMAKE_CURRENT_SOURCE_DIR}/man/*.3")
|
||||||
|
|||||||
@ -50,6 +50,7 @@ install: all
|
|||||||
if [ ! -d "/usr/local/3proxy/bin" ]; then mkdir -p /usr/local/3proxy/bin/; fi
|
if [ ! -d "/usr/local/3proxy/bin" ]; then mkdir -p /usr/local/3proxy/bin/; fi
|
||||||
install bin/3proxy /usr/local/3proxy/bin/3proxy
|
install bin/3proxy /usr/local/3proxy/bin/3proxy
|
||||||
install bin/mycrypt /usr/local/3proxy/bin/mycrypt
|
install bin/mycrypt /usr/local/3proxy/bin/mycrypt
|
||||||
|
install scripts/rc.d/3proxy /usr/local/etc/rc.d/3proxy
|
||||||
install scripts/add3proxyuser.sh /usr/local/3proxy/bin/
|
install scripts/add3proxyuser.sh /usr/local/3proxy/bin/
|
||||||
if [ -s /usr/local/etc/3proxy/3proxy.cfg ]; then /usr/local/3proxy/3proxy.cfg already exists ; else install scripts/3proxy.cfg /usr/local/etc/3proxy/; fi
|
if [ -s /usr/local/etc/3proxy/3proxy.cfg ]; then /usr/local/3proxy/3proxy.cfg already exists ; else install scripts/3proxy.cfg /usr/local/etc/3proxy/; fi
|
||||||
if [ ! -d /var/log/3proxy/ ]; then mkdir /var/log/3proxy/; fi
|
if [ ! -d /var/log/3proxy/ ]; then mkdir /var/log/3proxy/; fi
|
||||||
|
|||||||
@ -72,8 +72,8 @@ INSTALL_OBJS = bin/3proxy \
|
|||||||
|
|
||||||
|
|
||||||
INSTALL_CFG = scripts/3proxy.cfg.chroot
|
INSTALL_CFG = scripts/3proxy.cfg.chroot
|
||||||
INSTALL_CFG_OBJS = scripts/3proxy.cfg \
|
INSTALL_CFG_INCHROOT = scripts/3proxy.cfg.inchroot
|
||||||
scripts/add3proxyuser.sh
|
INSTALL_CFG_OBJS = scripts/add3proxyuser.sh
|
||||||
|
|
||||||
INSTALL_CFG_OBJS2 = counters bandlimiters
|
INSTALL_CFG_OBJS2 = counters bandlimiters
|
||||||
|
|
||||||
@ -117,6 +117,7 @@ install-etc-default-config: install-chroot-dir
|
|||||||
ln -s $(CHROOTREL)/conf $(INSTALL_CFG_DEST); \
|
ln -s $(CHROOTREL)/conf $(INSTALL_CFG_DEST); \
|
||||||
$(INSTALL_BIN) $(INSTALL_CFG) $(ETCDIR)/3proxy.cfg; \
|
$(INSTALL_BIN) $(INSTALL_CFG) $(ETCDIR)/3proxy.cfg; \
|
||||||
$(INSTALL_BIN) $(INSTALL_CFG_OBJS) $(INSTALL_CFG_DEST); \
|
$(INSTALL_BIN) $(INSTALL_CFG_OBJS) $(INSTALL_CFG_DEST); \
|
||||||
|
$(INSTALL_BIN) $(INSTALL_CFG_INCHROOT) $(INSTALL_CFG_DEST)/3proxy.cfg; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
install-etc: install-etc-dir install-etc-default-config
|
install-etc: install-etc-dir install-etc-default-config
|
||||||
|
|||||||
@ -48,23 +48,17 @@ endif
|
|||||||
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/3proxy/bin" ]; then mkdir -p /usr/local/3proxy/bin/; fi
|
||||||
install bin/3proxy /usr/local/etc/3proxy/bin/3proxy
|
install bin/3proxy /usr/local/3proxy/bin/3proxy
|
||||||
install bin/mycrypt /usr/local/etc/3proxy/bin/mycrypt
|
install bin/mycrypt /usr/local/3proxy/bin/mycrypt
|
||||||
install scripts/rc.d/proxy.sh /usr/local/etc/rc.d/proxy.sh
|
install scripts/rc.d/3proxy /usr/local/etc/rc.d/3proxy
|
||||||
install scripts/add3proxyuser.sh /usr/local/etc/3proxy/bin/
|
install scripts/add3proxyuser.sh /usr/local/3proxy/bin/
|
||||||
if [ -s /usr/local/etc/3proxy/3proxy.cfg ]; then
|
if [ -s /usr/local/etc/3proxy/3proxy.cfg ]; then /usr/local/3proxy/3proxy.cfg already exists ; else install scripts/3proxy.cfg /usr/local/etc/3proxy/; fi
|
||||||
echo /usr/local/etc/3proxy/3proxy.cfg already exists
|
if [ ! -d /var/log/3proxy/ ]; then mkdir /var/log/3proxy/; fi
|
||||||
else
|
touch /usr/local/3proxy/passwd
|
||||||
install scripts/3proxy.cfg /usr/local/etc/3proxy/
|
touch /usr/local/3proxy/counters
|
||||||
if [ ! -d /var/log/3proxy/ ]; then
|
touch /usr/local/3proxy/bandlimiters
|
||||||
mkdir /var/log/3proxy/
|
echo Run /usr/local/3proxy/bin/add3proxyuser.sh to add \'admin\' user
|
||||||
fi
|
|
||||||
touch /usr/local/etc/3proxy/passwd
|
|
||||||
touch /usr/local/etc/3proxy/counters
|
|
||||||
touch /usr/local/etc/3proxy/bandlimiters
|
|
||||||
echo Run /usr/local/etc/3proxy/bin/add3proxyuser.sh to add \'admin\' user
|
|
||||||
fi
|
|
||||||
|
|
||||||
allplugins:
|
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
|
||||||
|
|||||||
@ -1,59 +0,0 @@
|
|||||||
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 = bin/3proxy \
|
|
||||||
bin/ftppr \
|
|
||||||
bin/mycrypt \
|
|
||||||
bin/pop3p \
|
|
||||||
bin/proxy \
|
|
||||||
bin/socks \
|
|
||||||
bin/tcppm \
|
|
||||||
bin/udppm \
|
|
||||||
scripts/add3proxyuser.sh
|
|
||||||
|
|
||||||
INSTALL_CFG_OBJS = scripts/3proxy.cfg
|
|
||||||
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 $(MANDIR1)
|
|
||||||
$(INSTALL_BIN) -d $(MANDIR3)
|
|
||||||
$(INSTALL_BIN) -d $(MANDIR8)
|
|
||||||
$(INSTALL_DATA) man/*.1 $(MANDIR1)
|
|
||||||
$(INSTALL_DATA) man/*.3 $(MANDIR3)
|
|
||||||
$(INSTALL_DATA) man/*.8 $(MANDIR8)
|
|
||||||
|
|
||||||
install: install-bin install-etc install-man
|
|
||||||
|
|
||||||
@ -1,32 +0,0 @@
|
|||||||
#
|
|
||||||
# 3 proxy Makefile for GCC/windows
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# remove -DNOODBC from CFLAGS and add -lodbc to LDFLAGS to compile with ODBC
|
|
||||||
# library support
|
|
||||||
|
|
||||||
|
|
||||||
BUILDDIR = ../bin/
|
|
||||||
CC = /opt/cegcc/arm-wince-cegcc/bin/gcc
|
|
||||||
CFLAGS = -O2 -s -c -mthreads -DNOODBC -D_WINCE -D_WIN32 -DNORADIUS -D__USE_W32_SOCKETS
|
|
||||||
COUT = -o
|
|
||||||
LN = /opt/cegcc/arm-wince-cegcc/bin/gcc
|
|
||||||
LDFLAGS = -O2 -s -mthreads
|
|
||||||
DLFLAGS = -shared
|
|
||||||
DLSUFFICS = .dll
|
|
||||||
LIBS = -lws2
|
|
||||||
LNOUT = -o
|
|
||||||
EXESUFFICS = .exe
|
|
||||||
OBJSUFFICS = .o
|
|
||||||
DEFINEOPTION = -D
|
|
||||||
COMPFILES = *.tmp
|
|
||||||
REMOVECOMMAND = rm -f
|
|
||||||
TYPECOMMAND = more
|
|
||||||
COMPATLIBS =
|
|
||||||
MAKEFILE = Makefile.winCE
|
|
||||||
PLUGINS = TrafficPlugin StringsPlugin
|
|
||||||
|
|
||||||
include Makefile.inc
|
|
||||||
|
|
||||||
allplugins:
|
|
||||||
@list='$(PLUGINS)'; for p in $$list; do cp Makefile Makefile.var plugins/$$p; cd plugins/$$p ; make ; rm *.o ; cd ../.. ; done
|
|
||||||
@ -5,15 +5,14 @@
|
|||||||
<li><A HREF="#COMPILE">Compilation</A>
|
<li><A HREF="#COMPILE">Compilation</A>
|
||||||
<ul>
|
<ul>
|
||||||
<li><A HREF="#MSVC">How to compile 3proxy with Visual C++</A>
|
<li><A HREF="#MSVC">How to compile 3proxy with Visual C++</A>
|
||||||
<li><A HREF="#INTL">How to compile 3proxy with Intel C Compiler under Windows</A>
|
<li><A HREF="#CMAKE">How to compile 3proxy with CMake</A>
|
||||||
<li><A HREF="#GCCWIN">How to compile 3proxy with GCC under Windows</A>
|
|
||||||
<li><A HREF="#GCCUNIX">How to compile 3proxy with GCC under Unix/Linux</A>
|
<li><A HREF="#GCCUNIX">How to compile 3proxy with GCC under Unix/Linux</A>
|
||||||
</ul>
|
</ul>
|
||||||
<li><A HREF="#INSTALL">Proxy server installation and removal</A>
|
<li><A HREF="#INSTALL">Proxy server installation and removal</A>
|
||||||
<ul>
|
<ul>
|
||||||
<li><A HREF="#INSTNT">How to install/remove 3proxy under Windows NT/2000/XP</A>
|
<li><A HREF="#INSTNT">How to install/remove 3proxy under Windows NT/2000/XP</A>
|
||||||
<li><A HREF="#INST95">How to install/remove 3proxy under Windows 95/98/ME</A>
|
|
||||||
<li><A HREF="#INSTUNIX">How to install/remove 3proxy under Unix/Linux</A>
|
<li><A HREF="#INSTUNIX">How to install/remove 3proxy under Unix/Linux</A>
|
||||||
|
<li><A HREF="#INSTDOCKER">How to use 3proxy with Docker</A>
|
||||||
</ul>
|
</ul>
|
||||||
<li><A HREF="#SERVER">Server configuration</A>
|
<li><A HREF="#SERVER">Server configuration</A>
|
||||||
<ul>
|
<ul>
|
||||||
@ -66,35 +65,56 @@
|
|||||||
<li><A NAME="MSVC">How to compile 3proxy with Visual C++</A>
|
<li><A NAME="MSVC">How to compile 3proxy with Visual C++</A>
|
||||||
<p>
|
<p>
|
||||||
Extract source code files from 3proxy.tgz (with WinZip or another utility).
|
Extract source code files from 3proxy.tgz (with WinZip or another utility).
|
||||||
Use nmake /f Makefile.msvc command
|
For 64-bit Windows use:
|
||||||
|
<pre>
|
||||||
|
nmake /f Makefile.msvc64
|
||||||
|
</pre>
|
||||||
|
For ARM64 Windows use:
|
||||||
|
<pre>
|
||||||
|
nmake /f Makefile.msvcARM64
|
||||||
|
</pre>
|
||||||
|
Binaries will be placed in the <code>bin/</code> directory.
|
||||||
</p>
|
</p>
|
||||||
<li><A NAME="INTL">How to compile 3proxy with Intel C Compiler under Windows</A>
|
<li><A NAME="CMAKE">How to compile 3proxy with CMake</A>
|
||||||
<p>
|
<p>
|
||||||
See <A HREF="#MSVC">How to compile 3proxy with Visual C++</A>
|
CMake provides a cross-platform build system. It works on Windows (MSVC, MinGW), Linux, macOS, and BSD.
|
||||||
Use Makefile.intl instead of Makefile.msvc
|
<br>Basic build steps:
|
||||||
</p>
|
<pre>
|
||||||
<li><A NAME="GCCWIN">How to compile 3proxy with GCC under Windows</A></li>
|
mkdir build
|
||||||
<p>
|
cd build
|
||||||
Extract source files from 3proxy.tgz (for example with tar -xzf 3proxy.tgz command if you have tar installed)
|
cmake ..
|
||||||
Use make -f Makefile.win command.
|
cmake --build .
|
||||||
If you want to use POSIX emulation Cygwin library (normally you shouldn't) - use make -f Makefile.unix instead.
|
</pre>
|
||||||
Windows specific things (like installing as service) will not be available if compiled with Cygwin emulation.
|
On Windows with Visual Studio, you can also generate a solution file:
|
||||||
|
<pre>
|
||||||
|
cmake -G "Visual Studio 17 2022" -A x64 ..
|
||||||
|
cmake --build . --config Release
|
||||||
|
</pre>
|
||||||
|
Optional features can be controlled with cmake options:
|
||||||
|
<pre>
|
||||||
|
cmake -D3PROXY_USE_OPENSSL=ON -D3PROXY_USE_PCRE2=ON ..
|
||||||
|
</pre>
|
||||||
|
Available options: 3PROXY_USE_OPENSSL, 3PROXY_USE_PCRE2, 3PROXY_USE_PAM, 3PROXY_USE_ODBC.
|
||||||
|
<br>Binaries will be placed in the <code>build/bin/</code> directory.
|
||||||
</p>
|
</p>
|
||||||
<li><A NAME="GCCUNIX">How to compile 3proxy with GCC under Unix/Linux</A></li>
|
<li><A NAME="GCCUNIX">How to compile 3proxy with GCC under Unix/Linux</A></li>
|
||||||
<p>
|
<p>
|
||||||
Use
|
For Linux, use:
|
||||||
<pre>
|
<pre>
|
||||||
make -f Makefile.Linux
|
ln -sf Makefile.Linux Makefile
|
||||||
|
make
|
||||||
</pre>
|
</pre>
|
||||||
for Linux or Cygwin, Makefile.Solaris* (depending on compiler version) for Solaris
|
For FreeBSD, use:
|
||||||
and Makefile.unix for different Unix-like OSes. On BSD-derived systems, make
|
<pre>
|
||||||
|
ln -sf Makefile.FreeBSD Makefile
|
||||||
|
make
|
||||||
|
</pre>
|
||||||
|
For other Unix-like systems, use Makefile.unix. On BSD-derived systems, make
|
||||||
sure to use GNU make; sometimes it's called gmake instead of make.
|
sure to use GNU make; sometimes it's called gmake instead of make.
|
||||||
<br>Compilation is tested under FreeBSD/i386, NetBSD/i386, OpenBSD/i386,
|
<br>Compilation is tested under FreeBSD, NetBSD, OpenBSD, Linux, Solaris, and macOS.
|
||||||
RH Linux/Alpha, Debian/i386, Gentoo/i386, Gentoo/PPC, Solaris/x86, but you
|
<br>For ODBC support, install Unix ODBC libraries, remove -DNOODBC from the makefile,
|
||||||
shouldn't have problems under different Solaris, BSD, or Linux-compatible systems.
|
and add the ODBC library to the linker variable.
|
||||||
For different systems, you may be required to patch the Makefile or even the source code.
|
<br>Binaries will be placed in the <code>bin/</code> directory.
|
||||||
If you want to use ODBC support, make sure to install ODBC for Unix, remove the -DNOODBC
|
|
||||||
option from the makefile compiler options, and add the ODBC library to the linker variable.
|
|
||||||
</p>
|
</p>
|
||||||
</ul>
|
</ul>
|
||||||
<hr>
|
<hr>
|
||||||
@ -106,11 +126,7 @@ option from the makefile compiler options, and add the ODBC library to the linke
|
|||||||
Unpack 3proxy.zip to any directory, for example
|
Unpack 3proxy.zip to any directory, for example
|
||||||
c:\Program Files\3proxy. If needed, create a directory for storing log files,
|
c:\Program Files\3proxy. If needed, create a directory for storing log files,
|
||||||
ODBC sources, etc. Create 3proxy.cfg in the 3proxy installation directory (see <A HREF="#SERVER">Server configuration</A>).
|
ODBC sources, etc. Create 3proxy.cfg in the 3proxy installation directory (see <A HREF="#SERVER">Server configuration</A>).
|
||||||
If you use 3proxy before version 0.6, add the
|
Now, start a command prompt (cmd.exe).
|
||||||
<pre>
|
|
||||||
service
|
|
||||||
</pre>
|
|
||||||
string into 3proxy.cfg. Now, start a command prompt (cmd.exe).
|
|
||||||
Change to the 3proxy installation directory and run 3proxy.exe --install:
|
Change to the 3proxy installation directory and run 3proxy.exe --install:
|
||||||
<pre>
|
<pre>
|
||||||
D:\>C:
|
D:\>C:
|
||||||
@ -118,8 +134,7 @@ C:\>cd C:\Program Files\3proxy
|
|||||||
C:\Program Files\3proxy>3proxy.exe --install
|
C:\Program Files\3proxy>3proxy.exe --install
|
||||||
</pre>
|
</pre>
|
||||||
Now, you should have the 3proxy service installed and running. If the service is not
|
Now, you should have the 3proxy service installed and running. If the service is not
|
||||||
started, remove the "service" string from 3proxy.cfg, run 3proxy.exe manually
|
started, run 3proxy.exe manually and correct all errors.
|
||||||
and correct all errors.
|
|
||||||
</p><p>
|
</p><p>
|
||||||
To remove 3proxy, run 3proxy --remove:
|
To remove 3proxy, run 3proxy --remove:
|
||||||
<pre>
|
<pre>
|
||||||
@ -129,40 +144,75 @@ C:\Program Files\3proxy>net stop 3proxy
|
|||||||
C:\Program Files\3proxy>3proxy.exe --remove
|
C:\Program Files\3proxy>3proxy.exe --remove
|
||||||
</pre>
|
</pre>
|
||||||
Now you can simply remove the 3proxy installation directory.
|
Now you can simply remove the 3proxy installation directory.
|
||||||
</p>
|
|
||||||
<li><A NAME="INST95">How to install/remove 3proxy under Windows 95/98/ME</A>
|
|
||||||
<p>
|
|
||||||
Unpack 3proxy.zip to any directory, for example
|
|
||||||
c:\Program Files\3proxy. If needed, create a directory for storing log files,
|
|
||||||
ODBC sources, etc. Create 3proxy.cfg in the 3proxy installation directory (see <A HREF="#SERVER">Server configuration</A>).
|
|
||||||
Remove the string
|
|
||||||
<pre>
|
|
||||||
service
|
|
||||||
</pre>
|
|
||||||
from 3proxy.cfg and add
|
|
||||||
<pre>
|
|
||||||
daemon
|
|
||||||
</pre>
|
|
||||||
if you want 3proxy to run in the background.
|
|
||||||
Create a shortcut for 3proxy.exe and place it in the autostart folder or add
|
|
||||||
it to the registry with regedit.exe:
|
|
||||||
<br>HKLM\Software\Microsoft\Windows\CurrentVersion\Run</br>
|
|
||||||
Type: String
|
|
||||||
<br>3proxy = "c:\Program Files\3proxy.exe" "C:\Program Files\3proxy.cfg"<br>
|
|
||||||
You must use quotes if the path contains spaces. If necessary, restart Windows.
|
|
||||||
If the service is not started, check the log. Remove the "daemon" command from 3proxy.cfg,
|
|
||||||
start 3proxy.exe manually and correct all errors.
|
|
||||||
</p>
|
</p>
|
||||||
<li><A NAME="INSTUNIX">How to install/remove 3proxy under Unix/Linux</A>
|
<li><A NAME="INSTUNIX">How to install/remove 3proxy under Unix/Linux</A>
|
||||||
<p>
|
<p>
|
||||||
Compile 3proxy (see <A HREF="#COMPILE">Compilation</A>). Copy
|
<b>Using Makefile:</b>
|
||||||
executables to any appropriate location (for example, /usr/local/3proxy/sbin
|
<br>Compile 3proxy (see <A HREF="#COMPILE">Compilation</A>) then run:
|
||||||
for servers and /usr/local/3proxy/bin for utilities).
|
<pre>
|
||||||
Create /usr/local/etc/3proxy.cfg.
|
sudo make install
|
||||||
(see <A HREF="#SERVER">Server configuration</A>).
|
</pre>
|
||||||
You can change the default configuration file location by specifying the configuration file
|
This installs binaries to <code>/usr/local/3proxy/sbin/</code>, configuration to <code>/etc/3proxy/</code>,
|
||||||
in the 3proxy command line.
|
and sets up chroot directories. Default configuration file is <code>/etc/3proxy/3proxy.cfg</code>.
|
||||||
Add 3proxy to the system startup scripts.
|
</p>
|
||||||
|
<p>
|
||||||
|
<b>Using CMake:</b>
|
||||||
|
<pre>
|
||||||
|
mkdir build && cd build
|
||||||
|
cmake ..
|
||||||
|
cmake --build .
|
||||||
|
sudo cmake --install .
|
||||||
|
</pre>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<b>Using pre-built packages from GitHub:</b>
|
||||||
|
<br>Download .deb or .rpm packages from <a href="https://github.com/3proxy/3proxy/releases">GitHub Releases</a>.
|
||||||
|
<br>For Debian/Ubuntu:
|
||||||
|
<pre>
|
||||||
|
sudo dpkg -i 3proxy_*.deb
|
||||||
|
</pre>
|
||||||
|
For RHEL/CentOS/Fedora:
|
||||||
|
<pre>
|
||||||
|
sudo rpm -i 3proxy-*.rpm
|
||||||
|
</pre>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Add 3proxy to the system startup scripts or use systemd:
|
||||||
|
<pre>
|
||||||
|
sudo systemctl enable 3proxy
|
||||||
|
sudo systemctl start 3proxy
|
||||||
|
</pre>
|
||||||
|
</p>
|
||||||
|
<li><A NAME="INSTDOCKER">How to use 3proxy with Docker</A>
|
||||||
|
<p>
|
||||||
|
<b>Using pre-built images from GitHub Container Registry:</b>
|
||||||
|
<pre>
|
||||||
|
docker pull ghcr.io/3proxy/3proxy:latest
|
||||||
|
</pre>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<b>Building Docker images:</b>
|
||||||
|
<br>Two Dockerfiles are provided:
|
||||||
|
<ul>
|
||||||
|
<li><code>Dockerfile.minimal</code> - minimal static build, no plugins, configuration from stdin:
|
||||||
|
<pre>
|
||||||
|
docker build -f Dockerfile.minimal -t 3proxy.minimal .
|
||||||
|
docker run -i -p 3129:3129 --name 3proxy 3proxy.minimal
|
||||||
|
</pre>
|
||||||
|
Then enter configuration followed by "end" command.
|
||||||
|
</li>
|
||||||
|
<li><code>Dockerfile.full</code> - full build with plugins (SSL, PCRE, Transparent):
|
||||||
|
<pre>
|
||||||
|
docker build -f Dockerfile.full -t 3proxy.full .
|
||||||
|
docker run -p 3129:3129 -v /path/to/config:/usr/local/3proxy/conf 3proxy.full
|
||||||
|
</pre>
|
||||||
|
The configuration file must be placed at <code>/path/to/config/3proxy.cfg</code>.
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
By default, 3proxy runs in chroot environment with uid/gid 65535. Use <code>nserver</code> in config for DNS resolution in chroot.
|
||||||
|
For non-chroot execution, mount config to <code>/etc/3proxy</code>.
|
||||||
</p>
|
</p>
|
||||||
</ul>
|
</ul>
|
||||||
<hr>
|
<hr>
|
||||||
@ -486,22 +536,43 @@ proxy -p8080 -i192.168.2.1
|
|||||||
to extract hostnames from TLS to use in ACLs in combination with SOCKS or HTTP(s) proxy and/or the Transparent plugin. It can also be used to require TLS or mTLS between services. The TLS handshake contains no
|
to extract hostnames from TLS to use in ACLs in combination with SOCKS or HTTP(s) proxy and/or the Transparent plugin. It can also be used to require TLS or mTLS between services. The TLS handshake contains no
|
||||||
port information; if tlspr is used as a standalone service, the destination port may be either detected with the Transparent plugin or configured with the -P option (default 443).
|
port information; if tlspr is used as a standalone service, the destination port may be either detected with the Transparent plugin or configured with the -P option (default 443).
|
||||||
</p><p>
|
</p><p>
|
||||||
The -c option is used to specify the level of TLS check:
|
<b>Options:</b>
|
||||||
</p><pre>
|
</p><pre>
|
||||||
0 (default) - allow non-TLS traffic
|
-P <port> - destination port (default: 443)
|
||||||
1 - require TLS, only check client HELLO packet
|
-c <level> - TLS check level:
|
||||||
2 - require TLS, check both client and server HELLO
|
0 (default) - allow non-TLS traffic
|
||||||
3 - require TLS, check that the server sends a certificate (not compatible with TLS 1.3)
|
1 - require TLS, only check client HELLO packet
|
||||||
4 - require mutual TLS, check that the server sends a certificate request and the client sends a certificate (not compatible with TLS 1.3)
|
2 - require TLS, check both client and server HELLO
|
||||||
|
3 - require TLS, check that the server sends a certificate (not compatible with TLS 1.3)
|
||||||
|
4 - require mutual TLS, check that the server sends a certificate request and the client sends a certificate (not compatible with TLS 1.3)
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
Configuration examples:
|
<b>SNI Break (DPI Bypass):</b>
|
||||||
1. Port 1443 may be used to redirect traffic to destination port 143. SNI is used to find the destination host.
|
<br>tlspr can be used as a parent with the "tls" type to implement SNI splitting for DPI bypass (similar to NoDPI/GoodByeDPI).
|
||||||
<pre>
|
The client sends the first part of the TLS ClientHello, tlspr splits it at the SNI extension and sends it in two TCP packets,
|
||||||
|
which can bypass some DPI systems that look for blocked hostnames in TLS handshakes.
|
||||||
|
<br>To enable SNI break, use <code>parent ... tls 0.0.0.0 0</code> and the <code>-s</code> option on the listening service with TCP_NODELAY:
|
||||||
|
</p><pre>
|
||||||
|
auth iponly
|
||||||
|
allow *
|
||||||
|
parent 1000 tls 0.0.0.0 0
|
||||||
|
allow *
|
||||||
|
proxy -s -i127.0.0.1 -ocTCP_NODELAY -osTCP_NODELAY -p1443
|
||||||
|
</pre>
|
||||||
|
<p>
|
||||||
|
TCP_NODELAY is required to prevent the kernel from merging the split packets.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<b>Configuration examples:</b>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
1. Standalone SNI proxy on port 1443 redirecting to destination port 443:
|
||||||
|
</p><pre>
|
||||||
tlspr -p1443 -P443 -c1
|
tlspr -p1443 -P443 -c1
|
||||||
</pre>
|
</pre>
|
||||||
2. Used as a parent TLS proxy to detect the destination hostname from TLS in socks:
|
<p>
|
||||||
<pre>
|
2. Using tlspr as parent in SOCKS to detect destination hostname from TLS (even when client connects by IP):
|
||||||
|
</p><pre>
|
||||||
allow * * * 80
|
allow * * * 80
|
||||||
parent 1000 http 0.0.0.0 0
|
parent 1000 http 0.0.0.0 0
|
||||||
allow * * * * CONNECT
|
allow * * * * CONNECT
|
||||||
@ -509,6 +580,17 @@ parent 1000 tls 0.0.0.0 0
|
|||||||
deny * * some.not.allowed.host
|
deny * * some.not.allowed.host
|
||||||
allow *
|
allow *
|
||||||
socks
|
socks
|
||||||
|
</pre>
|
||||||
|
<p>
|
||||||
|
3. Using tlspr with HTTP proxy for TLS hostname-based ACL:
|
||||||
|
</p><pre>
|
||||||
|
allow * * * 80
|
||||||
|
parent 1000 http 0.0.0.0 0
|
||||||
|
allow * * * 443
|
||||||
|
parent 1000 tls 0.0.0.0 0
|
||||||
|
deny * * blocked.example.com
|
||||||
|
allow *
|
||||||
|
proxy
|
||||||
</pre>
|
</pre>
|
||||||
</p>
|
</p>
|
||||||
<li><A NAME="AUTH">How to limit service access</A>
|
<li><A NAME="AUTH">How to limit service access</A>
|
||||||
|
|||||||
@ -5,16 +5,14 @@
|
|||||||
<li><a href="#COMPILE">Компиляция</a>
|
<li><a href="#COMPILE">Компиляция</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#MSVC">Как скомпилировать 3proxy Visual C++</a>
|
<li><a href="#MSVC">Как скомпилировать 3proxy Visual C++</a>
|
||||||
<li><a href="#INTL">Как скомпилировать 3proxy Intel C Compiler под Windows</a>
|
<li><a href="#CMAKE">Как скомпилировать 3proxy с помощью CMake</a>
|
||||||
<li><a href="#GCCWIN">Как скомпилировать 3proxy GCC под Windows</a>
|
|
||||||
<li><a href="#GCCUNIX">Как скомпилировать 3proxy GCC под Unix/Linux</a>
|
<li><a href="#GCCUNIX">Как скомпилировать 3proxy GCC под Unix/Linux</a>
|
||||||
<li><a href="#CCCUNIX">Как скомпилировать 3proxy Compaq C Compiler под Unix/Linux</a>
|
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="#INSTALL">Установка и удаление 3proxy</a>
|
<li><a href="#INSTALL">Установка и удаление 3proxy</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#INSTNT">Как установить/удалить 3proxy под Windows 95/98/ME/NT/2000/XP как службу</a>
|
<li><a href="#INSTNT">Как установить/удалить 3proxy под Windows NT/2000/XP/2003 как службу</a>
|
||||||
<li><a href="#INST95">Как установить/удалить 3proxy под Windows 95/98/ME</a>
|
|
||||||
<li><a href="#INSTUNIX">Как установить/удалить 3proxy под Unix/Linux</a>
|
<li><a href="#INSTUNIX">Как установить/удалить 3proxy под Unix/Linux</a>
|
||||||
|
<li><a href="#INSTDOCKER">Как использовать 3proxy с Docker</a>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="#SERVER">Конфигурация сервера</a>
|
<li><a href="#SERVER">Конфигурация сервера</a>
|
||||||
<ul>
|
<ul>
|
||||||
@ -73,63 +71,69 @@
|
|||||||
<li><a name="MSVC"><i>Как скомпилировать 3proxy Visual C++</i></a>
|
<li><a name="MSVC"><i>Как скомпилировать 3proxy Visual C++</i></a>
|
||||||
<p>
|
<p>
|
||||||
Извлеките файлы из архива 3proxy.tgz (например, с помощью WinZip).
|
Извлеките файлы из архива 3proxy.tgz (например, с помощью WinZip).
|
||||||
Используйте команду nmake /f Makefile.msvc.
|
Для 64-битной Windows используйте:
|
||||||
|
<pre>
|
||||||
|
nmake /f Makefile.msvc64</pre>
|
||||||
|
Для Windows ARM64 используйте:
|
||||||
|
<pre>
|
||||||
|
nmake /f Makefile.msvcARM64</pre>
|
||||||
|
Исполняемые файлы будут помещены в каталог <code>bin/</code>.
|
||||||
</p>
|
</p>
|
||||||
<li><a name="INTL"><i>Как скомпилировать 3proxy Intel C Compiler под Windows</i></a>
|
<li><a name="CMAKE"><i>Как скомпилировать 3proxy с помощью CMake</i></a>
|
||||||
<p>
|
<p>
|
||||||
См. <a href="#MSVC">Как скомпилировать 3proxy Visual C++</a>.
|
CMake предоставляет кроссплатформенную систему сборки. Работает на Windows (MSVC, MinGW), Linux, macOS и BSD.
|
||||||
Используйте Makefile.intl вместо Makefile.msvc
|
<br>Базовые шаги сборки:
|
||||||
</p>
|
<pre>
|
||||||
<li><a name="GCCWIN"><i>Как скомпилировать 3proxy GCC под Windows</i></a></li>
|
mkdir build
|
||||||
<p>
|
cd build
|
||||||
Извлеките файлы из архива 3proxy.tgz (например, с помощью WinZip или, при наличии
|
cmake ..
|
||||||
Cygwin, tar -xzf 3proxy.tgz).
|
cmake --build .</pre>
|
||||||
Используйте команду make -f Makefile.win. Если по каким-то причинам вы хотите использовать
|
На Windows с Visual Studio можно также сгенерировать файл решения:
|
||||||
библиотеку POSIX-эмуляции CygWin - используйте make -f Makefile.unix.
|
<pre>
|
||||||
При использовании CygWin, функции, специфичные для Windows (такие, как запуск в
|
cmake -G "Visual Studio 17 2022" -A x64 ..
|
||||||
качестве службы) будут недоступны.
|
cmake --build . --config Release</pre>
|
||||||
|
Опциональные функции можно включить через параметры cmake:
|
||||||
|
<pre>
|
||||||
|
cmake -D3PROXY_USE_OPENSSL=ON -D3PROXY_USE_PCRE2=ON ..</pre>
|
||||||
|
Доступные опции: 3PROXY_USE_OPENSSL, 3PROXY_USE_PCRE2, 3PROXY_USE_PAM, 3PROXY_USE_ODBC.
|
||||||
|
<br>Исполняемые файлы будут помещены в каталог <code>build/bin/</code>.
|
||||||
</p>
|
</p>
|
||||||
<li><a name="GCCUNIX"><i>Как скомпилировать 3proxy GCC под Unix/Linux</i></a></li>
|
<li><a name="GCCUNIX"><i>Как скомпилировать 3proxy GCC под Unix/Linux</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
Используйте make -f Makefile.unix. Должен использоваться GNU make, на
|
Для Linux используйте:
|
||||||
некоторых системах необходимо использовать gmake вместо make. Под Linux
|
<pre>
|
||||||
необходимо использовать Makefile.Linux, под Solaris - Makefile.Solaris-* (в
|
ln -sf Makefile.Linux Makefile
|
||||||
зависимости от используемого компилятора). Компиляция проверена в FreeBSD/i386,
|
make</pre>
|
||||||
OpenBSD/i386, NetBSD/i386, RH Linux/Alpha, Debian/i386, Gentoo/i386, Gentoo/PPC,
|
Для FreeBSD используйте:
|
||||||
Solaris 10, но должно собираться в любых версиях *BSD/Linux/Solaris.
|
<pre>
|
||||||
В других системах может потребоваться модификация make-файла и/или исходных текстов.
|
ln -sf Makefile.FreeBSD Makefile
|
||||||
Для компиляции с поддержкой ODBC необходимо убрать -DNOODBC из флагов
|
make</pre>
|
||||||
компиляции и добавить -lodbc (или другую ODBC-библиотеку) к флагам линковщика.
|
Для других Unix-подобных систем используйте Makefile.unix. На BSD-производных системах
|
||||||
</p>
|
убедитесь, что используете GNU make; иногда он называется gmake вместо make.
|
||||||
<li><a name="CCCUNIX"><i>Как скомпилировать 3proxy Compaq C Compiler под Unix/Linux</i></a></li>
|
<br>Компиляция проверена на FreeBSD, NetBSD, OpenBSD, Linux, Solaris и macOS.
|
||||||
<p>
|
<br>Для поддержки ODBC необходимо установить Unix ODBC, убрать -DNOODBC из флагов
|
||||||
Используйте make -f Makefile.ccc. Компиляция проверена в RH Linux 7.1/Alpha.
|
компиляции и добавить ODBC-библиотеку к флагам линковщика.
|
||||||
В других системах может потребоваться модификация файла и/или исходных текстов.
|
<br>Исполняемые файлы будут помещены в каталог <code>bin/</code>.
|
||||||
</p>
|
</p>
|
||||||
</ul>
|
</ul>
|
||||||
<hr>
|
<hr>
|
||||||
<li><a name="INSTALL"><b>Установка и удаление 3proxy</b></a>
|
<li><a name="INSTALL"><b>Установка и удаление 3proxy</b></a>
|
||||||
<p>
|
<p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a name="INSTNT"><i>Как установить/удалить 3proxy под Windows 95/98/ME/NT/2000/XP/2003 как службу</i></a>
|
<li><a name="INSTNT"><i>Как установить/удалить 3proxy под Windows NT/2000/XP/2003 как службу</i></a>
|
||||||
<p>
|
<p>
|
||||||
Извлеките файлы из архива 3proxy.zip в любой каталог
|
Извлеките файлы из архива 3proxy.zip в любой каталог
|
||||||
(например, c:\Program Files\3proxy). Если необходимо, создайте каталог для
|
(например, c:\Program Files\3proxy). Если необходимо, создайте каталог для
|
||||||
хранения файлов журналов. Создайте файл конфигурации 3proxy.cfg в
|
хранения файлов журналов. Создайте файл конфигурации 3proxy.cfg в
|
||||||
каталоге 3proxy (см. раздел <a href="#SERVER">Конфигурация сервера</a>).
|
каталоге 3proxy (см. раздел <a href="#SERVER">Конфигурация сервера</a>).
|
||||||
Если используется версия более ранняя, чем 0.6, добавьте строку
|
Откройте командную строку (cmd.exe).
|
||||||
<pre>
|
|
||||||
service</pre>
|
|
||||||
в файл 3proxy.cfg. Откройте командную строку (cmd.exe).
|
|
||||||
Перейдите в каталог с 3proxy и дайте команду 3proxy.exe --install:
|
Перейдите в каталог с 3proxy и дайте команду 3proxy.exe --install:
|
||||||
<pre>
|
<pre>
|
||||||
D:\>C:
|
D:\>C:
|
||||||
C:\>cd C:\Program Files\3proxy
|
C:\>cd C:\Program Files\3proxy
|
||||||
C:\Program Files\3proxy>3proxy.exe --install</pre>
|
C:\Program Files\3proxy>3proxy.exe --install</pre>
|
||||||
Сервис должен быть установлен и запущен. Если сервис не запускается,
|
Сервис должен быть установлен и запущен. Если сервис не запускается,
|
||||||
проверьте содержимое файла журнала,
|
попробуйте запустить 3proxy.exe вручную и проанализировать сообщения об ошибках.
|
||||||
попробуйте удалить строку service из 3proxy.cfg, запустить 3proxy.exe вручную
|
|
||||||
и проанализировать сообщения об ошибках.
|
|
||||||
</p><p>
|
</p><p>
|
||||||
Для удаления 3proxy необходимо остановить сервис и дать
|
Для удаления 3proxy необходимо остановить сервис и дать
|
||||||
команду 3proxy.exe --remove:
|
команду 3proxy.exe --remove:
|
||||||
@ -139,43 +143,68 @@
|
|||||||
C:\Program Files\3proxy>net stop 3proxy
|
C:\Program Files\3proxy>net stop 3proxy
|
||||||
C:\Program Files\3proxy>3proxy.exe --remove</pre>
|
C:\Program Files\3proxy>3proxy.exe --remove</pre>
|
||||||
после чего каталог 3proxy можно удалить.
|
после чего каталог 3proxy можно удалить.
|
||||||
<p>
|
|
||||||
Установка в качестве системной службы под Windows 9x поддерживается с версии 0.5
|
|
||||||
</p>
|
|
||||||
<li><a name="INST95"><i>Как установить/удалить 3proxy под Windows 95/98/ME</i></a>
|
|
||||||
<p>
|
|
||||||
Извлеките файлы из архива 3proxy.zip в любой каталог
|
|
||||||
(например, c:\Program Files\3proxy). Если необходимо, создайте каталог для
|
|
||||||
хранения файлов журналов. Создайте файл конфигурации 3proxy.cfg в
|
|
||||||
каталоге 3proxy (См. раздел <a href="#SERVER">Конфигурация сервера</a>).
|
|
||||||
В файле конфигурации удалите строку
|
|
||||||
<pre>
|
|
||||||
service</pre>
|
|
||||||
и добавьте строку
|
|
||||||
<pre>
|
|
||||||
daemon</pre>
|
|
||||||
Создайте ярлык для 3proxy.exe и поместите его в автозагрузку либо с помощью
|
|
||||||
редактора реестра regedit.exe добавьте в разделе
|
|
||||||
<br>HKLM\Software\Microsoft\Windows\CurrentVersion\Run</br>
|
|
||||||
строковый параметр
|
|
||||||
<br>3proxy = "c:\Program Files\3proxy.exe" "C:\Program Files\3proxy.cfg"<br>
|
|
||||||
Использование кавычек при наличии в пути пробела обязательно.
|
|
||||||
Перезагрузитесь.
|
|
||||||
Если сервер не запускается,
|
|
||||||
проверьте содержимое файла журнала,
|
|
||||||
попробуйте удалить строку daemon из 3proxy.cfg, запустить 3proxy.exe вручную
|
|
||||||
и проанализировать сообщения об ошибках.
|
|
||||||
</p>
|
</p>
|
||||||
<li><a name="INSTUNIX"><i>Как установить/удалить 3proxy под Unix/Linux</i></a>
|
<li><a name="INSTUNIX"><i>Как установить/удалить 3proxy под Unix/Linux</i></a>
|
||||||
<p>
|
<p>
|
||||||
Скомпилируйте 3proxy (см. раздел <a href="#COMPILE">Компиляция</a>). Скопируйте
|
<b>С помощью Makefile:</b>
|
||||||
исполняемые файлы в подходящий каталог (например, /usr/local/3proxy/sbin для
|
<br>Скомпилируйте 3proxy (см. раздел <a href="#COMPILE">Компиляция</a>), затем выполните:
|
||||||
серверных приложений или /usr/local/3proxy/bin для клиентских утилит).
|
<pre>
|
||||||
Создайте файл /usr/local/etc/3proxy.cfg.
|
sudo make install</pre>
|
||||||
(См. раздел <a href="#SERVER">Конфигурация сервера</a>).
|
Это установит исполняемые файлы в <code>/usr/local/3proxy/sbin/</code>,
|
||||||
Изменить расположение файла конфигурации можно, задав параметр при вызове
|
конфигурацию в <code>/etc/3proxy/</code> и настроит chroot-каталоги.
|
||||||
3proxy или изменив путь в файле 3proxy.c до компиляции.
|
Файл конфигурации по умолчанию: <code>/etc/3proxy/3proxy.cfg</code>.
|
||||||
Добавьте вызов 3proxy в скрипты начальной инициализации.
|
</p>
|
||||||
|
<p>
|
||||||
|
<b>С помощью CMake:</b>
|
||||||
|
<pre>
|
||||||
|
mkdir build && cd build
|
||||||
|
cmake ..
|
||||||
|
cmake --build .
|
||||||
|
sudo cmake --install .</pre>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<b>С помощью готовых пакетов из GitHub:</b>
|
||||||
|
<br>Скачайте .deb или .rpm пакеты со страницы <a href="https://github.com/3proxy/3proxy/releases">GitHub Releases</a>.
|
||||||
|
<br>Для Debian/Ubuntu:
|
||||||
|
<pre>
|
||||||
|
sudo dpkg -i 3proxy_*.deb</pre>
|
||||||
|
Для RHEL/CentOS/Fedora:
|
||||||
|
<pre>
|
||||||
|
sudo rpm -i 3proxy-*.rpm</pre>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Добавьте 3proxy в скрипты автозапуска или используйте systemd:
|
||||||
|
<pre>
|
||||||
|
sudo systemctl enable 3proxy
|
||||||
|
sudo systemctl start 3proxy</pre>
|
||||||
|
</p>
|
||||||
|
<li><a name="INSTDOCKER"><i>Как использовать 3proxy с Docker</i></a>
|
||||||
|
<p>
|
||||||
|
<b>Использование готовых образов из GitHub Container Registry:</b>
|
||||||
|
<pre>
|
||||||
|
docker pull ghcr.io/3proxy/3proxy:latest</pre>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<b>Сборка Docker-образов:</b>
|
||||||
|
<br>Предоставляются два Dockerfile:
|
||||||
|
<ul>
|
||||||
|
<li><code>Dockerfile.minimal</code> - минимальная статическая сборка без плагинов, конфигурация из stdin:
|
||||||
|
<pre>
|
||||||
|
docker build -f Dockerfile.minimal -t 3proxy.minimal .
|
||||||
|
docker run -i -p 3129:3129 --name 3proxy 3proxy.minimal</pre>
|
||||||
|
Затем введите конфигурацию, завершив командой "end".
|
||||||
|
</li>
|
||||||
|
<li><code>Dockerfile.full</code> - полная сборка с плагинами (SSL, PCRE, Transparent):
|
||||||
|
<pre>
|
||||||
|
docker build -f Dockerfile.full -t 3proxy.full .
|
||||||
|
docker run -p 3129:3129 -v /path/to/config:/usr/local/3proxy/conf 3proxy.full</pre>
|
||||||
|
Файл конфигурации должен находиться по пути <code>/path/to/config/3proxy.cfg</code>.
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
По умолчанию 3proxy работает в chroot-окружении с uid/gid 65535. Используйте <code>nserver</code> в конфигурации для DNS-разрешения в chroot.
|
||||||
|
Для запуска без chroot монтируйте конфигурацию в <code>/etc/3proxy</code>.
|
||||||
</p>
|
</p>
|
||||||
</ul>
|
</ul>
|
||||||
<hr>
|
<hr>
|
||||||
@ -511,29 +540,49 @@
|
|||||||
</p>
|
</p>
|
||||||
<li><a name="TLSPR"><i>Как настроить SNI proxy (tlspr)</i></a></li>
|
<li><a name="TLSPR"><i>Как настроить SNI proxy (tlspr)</i></a></li>
|
||||||
<p>
|
<p>
|
||||||
|
SNI proxy может быть использован для транспарентного перенаправления любого TLS трафика (например HTTPS) на внешнем маршрутизаторе
|
||||||
SNI proxy может быть использовать для транспарентного перенаправления любого TLS трафика (например HTTPS) на внешнем маршрутизаторе
|
|
||||||
или локальными правилами. Так же можно использовать его для извлечения имени хоста из TLS хендшейка с целью логгирования или использования в ACL.
|
или локальными правилами. Так же можно использовать его для извлечения имени хоста из TLS хендшейка с целью логгирования или использования в ACL.
|
||||||
Еще одна задача которую может решать модуль - требование наличия TLS или mTLS (mutual TLS).
|
Еще одна задача которую может решать модуль - требование наличия TLS или mTLS (mutual TLS).
|
||||||
Если tlspr используется как отдельный сервис без исползования плагина Transparent, то необходимо задать порт назначения через опцию -T (по умолчанию 443),
|
Если tlspr используется как отдельный сервис без использования плагина Transparent, то необходимо задать порт назначения через опцию -P (по умолчанию 443),
|
||||||
т.к. TLS хендшейк не содержит информации о порте назначения.
|
т.к. TLS хендшейк не содержит информации о порте назначения.
|
||||||
</p><p>
|
</p><p>
|
||||||
-c контролирует уровень требования к TLS:
|
<b>Опции:</b>
|
||||||
</p><pre>
|
</p><pre>
|
||||||
0 (по умолчанию) - пропустить трафик без TLS
|
-P <порт> - порт назначения (по умолчанию: 443)
|
||||||
1 - требовать TLS, проверять наличие client HELLO
|
-c <уровень> - уровень проверки TLS:
|
||||||
2 - требовать TLS, проверять наличие client и server HELLO
|
0 (по умолчанию) - пропустить трафик без TLS
|
||||||
3 - требовать TLS, проверять наличие серверного сертификата (не совместим с TLS 1.3+)
|
1 - требовать TLS, проверять наличие client HELLO
|
||||||
4 - требовать взаимный (mutual) TLS, проверять что сервер запрашивает сертификат и клиент его отправляет (не совместим с TLS 1.3+)
|
2 - требовать TLS, проверять наличие client и server HELLO
|
||||||
|
3 - требовать TLS, проверять наличие серверного сертификата (не совместим с TLS 1.3+)
|
||||||
|
4 - требовать взаимный (mutual) TLS, проверять что сервер запрашивает сертификат и клиент его отправляет (не совместим с TLS 1.3+)
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
примеры конфигурации:
|
<b>SNI Break (обход DPI):</b>
|
||||||
1. Порт 1443 можно использовать для перенаправления в него HTTPS трафика по порту 443 (например с внешнего маршрутизатора)
|
<br>tlspr может использоваться как родительский прокси типа "tls" для реализации SNI-фрагментации (аналог NoDPI/GoodByeDPI).
|
||||||
<pre>
|
Клиент отправляет первую часть TLS ClientHello, tlspr разбивает его на расширении SNI и отправляет двумя TCP-пакетами,
|
||||||
|
что позволяет обойти некоторые DPI-системы, ищущие заблокированные имена хостов в TLS-рукопожатиях.
|
||||||
|
<br>Для включения SNI break используйте <code>parent ... tls 0.0.0.0 0</code> и опцию <code>-s</code> на слушающем сервисе с TCP_NODELAY:
|
||||||
|
</p><pre>
|
||||||
|
auth iponly
|
||||||
|
allow *
|
||||||
|
parent 1000 tls 0.0.0.0 0
|
||||||
|
allow *
|
||||||
|
proxy -s -i127.0.0.1 -ocTCP_NODELAY -osTCP_NODELAY -p1443
|
||||||
|
</pre>
|
||||||
|
<p>
|
||||||
|
TCP_NODELAY необходим, чтобы ядро не объединяло разделенные пакеты.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<b>Примеры конфигурации:</b>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
1. Отдельный SNI proxy на порту 1443 с перенаправлением на порт назначения 443:
|
||||||
|
</p><pre>
|
||||||
tlspr -p1443 -P443 -c1
|
tlspr -p1443 -P443 -c1
|
||||||
</pre>
|
</pre>
|
||||||
2. tlspr используется как родительский прокси в SOCKS чтобы обнаруживать реальный hostname назначения (даже если запрашивается подклюение по IP адресу)
|
<p>
|
||||||
<pre>
|
2. Использование tlspr как родительского прокси в SOCKS для обнаружения hostname из TLS (даже если клиент подключается по IP):
|
||||||
|
</p><pre>
|
||||||
allow * * * 80
|
allow * * * 80
|
||||||
parent 1000 http 0.0.0.0 0
|
parent 1000 http 0.0.0.0 0
|
||||||
allow * * * * CONNECT
|
allow * * * * CONNECT
|
||||||
@ -541,6 +590,17 @@ parent 1000 tls 0.0.0.0 0
|
|||||||
deny * * some.not.allowed.host
|
deny * * some.not.allowed.host
|
||||||
allow *
|
allow *
|
||||||
socks
|
socks
|
||||||
|
</pre>
|
||||||
|
<p>
|
||||||
|
3. Использование tlspr с HTTP proxy для ACL по имени хоста TLS:
|
||||||
|
</p><pre>
|
||||||
|
allow * * * 80
|
||||||
|
parent 1000 http 0.0.0.0 0
|
||||||
|
allow * * * 443
|
||||||
|
parent 1000 tls 0.0.0.0 0
|
||||||
|
deny * * blocked.example.com
|
||||||
|
allow *
|
||||||
|
proxy
|
||||||
</pre>
|
</pre>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|||||||
@ -55,6 +55,9 @@ Recursion is not allowed.
|
|||||||
.B pop3p
|
.B pop3p
|
||||||
[options]
|
[options]
|
||||||
.br
|
.br
|
||||||
|
.B smtpp
|
||||||
|
[options]
|
||||||
|
.br
|
||||||
.B ftppr
|
.B ftppr
|
||||||
[options]
|
[options]
|
||||||
.br
|
.br
|
||||||
@ -256,13 +259,17 @@ alternate config file. Think twice before using it.
|
|||||||
.br
|
.br
|
||||||
LOGTYPE is one of:
|
LOGTYPE is one of:
|
||||||
.br
|
.br
|
||||||
M Monthly
|
c Minutely
|
||||||
.br
|
.br
|
||||||
W Weekly (starting from Sunday)
|
H Hourly
|
||||||
.br
|
.br
|
||||||
D Daily
|
D Daily
|
||||||
.br
|
.br
|
||||||
H Hourly
|
W Weekly (starting from Sunday)
|
||||||
|
.br
|
||||||
|
M Monthly
|
||||||
|
.br
|
||||||
|
Y Annually
|
||||||
.br
|
.br
|
||||||
if logfile is not specified logging goes to stdout. You can specify individual logging options for gateway by using -l
|
if logfile is not specified logging goes to stdout. You can specify individual logging options for gateway by using -l
|
||||||
option in gateway configuration.
|
option in gateway configuration.
|
||||||
@ -369,6 +376,14 @@ traffic is achieved for connection, without waiting for connection to finish.
|
|||||||
It may be useful to prevent information about long-lasting downloads on server
|
It may be useful to prevent information about long-lasting downloads on server
|
||||||
shutdown.
|
shutdown.
|
||||||
|
|
||||||
|
.br
|
||||||
|
.B delimchar
|
||||||
|
<char>
|
||||||
|
.br
|
||||||
|
Sets the delimiter character used to separate username from hostname in proxy
|
||||||
|
authentication strings (e.g. for FTP, POP3 proxies). Default is \'@\'. For example,
|
||||||
|
to use \'#\' instead: delimchar #. This allows usernames to contain the \'@\' character.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B archiver
|
.B archiver
|
||||||
<ext> <commandline>
|
<ext> <commandline>
|
||||||
@ -401,6 +416,14 @@ can use %A as produced archive name and %F as filename.
|
|||||||
.br
|
.br
|
||||||
default timeouts 1 5 30 60 180 1800 15 60 15 5
|
default timeouts 1 5 30 60 180 1800 15 60 15 5
|
||||||
|
|
||||||
|
.br
|
||||||
|
.B maxseg
|
||||||
|
<value>
|
||||||
|
.br
|
||||||
|
Sets TCP maximum segment size (MSS) for outgoing connections. This can be used
|
||||||
|
to work around path MTU discovery issues or to optimize traffic for specific
|
||||||
|
network conditions.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B radius
|
.B radius
|
||||||
<NAS_SECRET> <radius_server_1[:port][/local_address_1]> <radius_server_2[:port][/local_address_2]>
|
<NAS_SECRET> <radius_server_1[:port][/local_address_1]> <radius_server_2[:port][/local_address_2]>
|
||||||
@ -434,6 +457,13 @@ used. Optional port number may be specified.
|
|||||||
If optional /tcp is added to IP address, name resolution is
|
If optional /tcp is added to IP address, name resolution is
|
||||||
performed over TCP.
|
performed over TCP.
|
||||||
|
|
||||||
|
.br
|
||||||
|
.B authnserver
|
||||||
|
<ipaddr>[:port][/tcp]
|
||||||
|
.br
|
||||||
|
Nameserver to use for DNS-based authentication (e.g. dnsname auth type).
|
||||||
|
If not specified, nserver is used. The syntax is the same as for nserver.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B nscache
|
.B nscache
|
||||||
<cachesize>
|
<cachesize>
|
||||||
@ -598,6 +628,10 @@ Use auth type \'cache\' for cached authentication
|
|||||||
.B deny
|
.B deny
|
||||||
<userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
<userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
||||||
<weekdayslist> <timeperiodslist>
|
<weekdayslist> <timeperiodslist>
|
||||||
|
.br
|
||||||
|
.B redirect
|
||||||
|
<ip> <port> <userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
||||||
|
<weekdayslist> <timeperiodslist>
|
||||||
.br
|
.br
|
||||||
Access control entries. All lists are comma-separated, no spaces are
|
Access control entries. All lists are comma-separated, no spaces are
|
||||||
allowed. Usernames are case sensitive (if used with authtype nbname
|
allowed. Usernames are case sensitive (if used with authtype nbname
|
||||||
@ -791,6 +825,12 @@ local HTTP proxy parses requests and allows only GET and POST requests.
|
|||||||
Optional username and password are used to authenticate on parent
|
Optional username and password are used to authenticate on parent
|
||||||
proxy. Username of \'*\' means username must be supplied by user.
|
proxy. Username of \'*\' means username must be supplied by user.
|
||||||
|
|
||||||
|
.br
|
||||||
|
.B parentretries
|
||||||
|
<number>
|
||||||
|
.br
|
||||||
|
Number of retries to connect to parent proxy. Default is 1.
|
||||||
|
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B nolog
|
.B nolog
|
||||||
@ -971,6 +1011,8 @@ username[:pwtype:password] ...
|
|||||||
CR - password is crypt-style password
|
CR - password is crypt-style password
|
||||||
.br
|
.br
|
||||||
NT - password is NT password (in hex)
|
NT - password is NT password (in hex)
|
||||||
|
.br
|
||||||
|
LM - password is LM password (in hex)
|
||||||
.br
|
.br
|
||||||
example:
|
example:
|
||||||
.br
|
.br
|
||||||
|
|||||||
@ -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/3proxy/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
|
|
||||||
@ -1,25 +1,2 @@
|
|||||||
nscache 65536
|
#!/usr/local/bin/3proxy
|
||||||
nserver 8.8.8.8
|
#path to plugins:
|
||||||
nserver 8.8.4.4
|
|
||||||
|
|
||||||
config /conf/3proxy.cfg
|
|
||||||
monitor /conf/3proxy.cfg
|
|
||||||
|
|
||||||
log /logs/3proxy-%y%m%d.log D
|
|
||||||
rotate 60
|
|
||||||
counter /count/3proxy.3cf
|
|
||||||
|
|
||||||
users $/conf/passwd
|
|
||||||
|
|
||||||
include /conf/counters
|
|
||||||
include /conf/bandlimiters
|
|
||||||
|
|
||||||
auth strong
|
|
||||||
deny * * 127.0.0.1
|
|
||||||
allow *
|
|
||||||
proxy -n
|
|
||||||
socks
|
|
||||||
flush
|
|
||||||
allow admin
|
|
||||||
|
|
||||||
admin -p8080
|
|
||||||
25
scripts/3proxy.cfg.inchroot
Normal file
25
scripts/3proxy.cfg.inchroot
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
nscache 65536
|
||||||
|
nserver 8.8.8.8
|
||||||
|
nserver 8.8.4.4
|
||||||
|
|
||||||
|
config /conf/3proxy.cfg
|
||||||
|
monitor /conf/3proxy.cfg
|
||||||
|
|
||||||
|
log /logs/3proxy-%y%m%d.log D
|
||||||
|
rotate 60
|
||||||
|
counter /count/3proxy.3cf
|
||||||
|
|
||||||
|
users $/conf/passwd
|
||||||
|
|
||||||
|
include /conf/counters
|
||||||
|
include /conf/bandlimiters
|
||||||
|
|
||||||
|
auth strong
|
||||||
|
deny * * 127.0.0.1
|
||||||
|
allow *
|
||||||
|
proxy -n
|
||||||
|
socks
|
||||||
|
flush
|
||||||
|
allow admin
|
||||||
|
|
||||||
|
admin -p8080
|
||||||
19
scripts/3proxy.service.in
Normal file
19
scripts/3proxy.service.in
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=3proxy tiny proxy server
|
||||||
|
Documentation=man:3proxy(1)
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Environment=CONFIGFILE=/etc/3proxy/3proxy.cfg
|
||||||
|
ExecStart=@CMAKE_INSTALL_FULL_BINDIR@/3proxy ${CONFIGFILE}
|
||||||
|
ExecReload=/bin/kill -SIGUSR1 $MAINPID
|
||||||
|
KillMode=process
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=60s
|
||||||
|
LimitNOFILE=65536
|
||||||
|
LimitNPROC=32768
|
||||||
|
RuntimeDirectory=3proxy
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
Alias=3proxy.service
|
||||||
3
scripts/3proxy.tmpfiles.in
Normal file
3
scripts/3proxy.tmpfiles.in
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# tmpfiles.d configuration for 3proxy
|
||||||
|
# This creates the runtime directory for 3proxy
|
||||||
|
d /run/3proxy 0755 root root -
|
||||||
@ -1,22 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
cd ..
|
|
||||||
cp Makefile.unix Makefile
|
|
||||||
make
|
|
||||||
if [ ! -d /usr/local/etc/3proxy/bin ]; then mkdir -p /usr/local/etc/3proxy/bin/; fi
|
|
||||||
install bin/3proxy /usr/local/bin/3proxy
|
|
||||||
install bin/mycrypt /usr/local/bin/mycrypt
|
|
||||||
install scripts/rc.d/proxy.sh /usr/local/etc/rc.d/proxy.sh
|
|
||||||
install scripts/add3proxyuser.sh /usr/local/etc/3proxy/bin/
|
|
||||||
if [ -s /usr/local/etc/3proxy/3proxy.cfg ]; then
|
|
||||||
echo /usr/local/etc/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/etc/3proxy/passwd
|
|
||||||
touch /usr/local/etc/3proxy/counters
|
|
||||||
touch /usr/local/etc/3proxy/bandlimiters
|
|
||||||
echo Run /usr/local/etc/3proxy/bin/add3proxyuser.sh to add \'admin\' user
|
|
||||||
fi
|
|
||||||
|
|
||||||
27
scripts/rc.d/3proxy
Normal file
27
scripts/rc.d/3proxy
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# PROVIDE: 3proxy
|
||||||
|
# REQUIRE: LOGIN DAEMON
|
||||||
|
# KEYWORD: shutdown
|
||||||
|
|
||||||
|
. /etc/rc.subr
|
||||||
|
|
||||||
|
name="3proxy"
|
||||||
|
rcvar="3proxy_enable"
|
||||||
|
|
||||||
|
command="/usr/local/3proxy/bin/3proxy"
|
||||||
|
pidfile="/var/run/3proxy/${name}.pid"
|
||||||
|
command_args="${3proxy_config:-/usr/local/etc/3proxy/3proxy.cfg}"
|
||||||
|
required_files="${3proxy_config:-/usr/local/etc/3proxy/3proxy.cfg}"
|
||||||
|
|
||||||
|
start_precmd="3proxy_precmd"
|
||||||
|
|
||||||
|
3proxy_precmd()
|
||||||
|
{
|
||||||
|
if [ ! -d /var/run/3proxy ]; then
|
||||||
|
mkdir -p /var/run/3proxy
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
load_rc_config $name
|
||||||
|
run_rc_command "$1"
|
||||||
27
scripts/rc.d/3proxy.in
Normal file
27
scripts/rc.d/3proxy.in
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# PROVIDE: 3proxy
|
||||||
|
# REQUIRE: LOGIN DAEMON
|
||||||
|
# KEYWORD: shutdown
|
||||||
|
|
||||||
|
. /etc/rc.subr
|
||||||
|
|
||||||
|
name="3proxy"
|
||||||
|
rcvar="3proxy_enable"
|
||||||
|
|
||||||
|
command="@CMAKE_INSTALL_FULL_BINDIR@/3proxy"
|
||||||
|
pidfile="/var/run/3proxy/${name}.pid"
|
||||||
|
command_args="${3proxy_config:-/etc/3proxy/3proxy.cfg}"
|
||||||
|
required_files="${3proxy_config:-/etc/3proxy/3proxy.cfg}"
|
||||||
|
|
||||||
|
start_precmd="3proxy_precmd"
|
||||||
|
|
||||||
|
3proxy_precmd()
|
||||||
|
{
|
||||||
|
if [ ! -d /var/run/3proxy ]; then
|
||||||
|
mkdir -p /var/run/3proxy
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
load_rc_config $name
|
||||||
|
run_rc_command "$1"
|
||||||
Loading…
Reference in New Issue
Block a user