mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-26 23:59:41 +08:00
Compare commits
350
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c902525e5 | ||
|
|
129d26475e | ||
|
|
29f8867a9e | ||
|
|
252c4cb36b | ||
|
|
07603ceea7 | ||
|
|
8ec14c131d | ||
|
|
1225dbced7 | ||
|
|
3cd9bdffcb | ||
|
|
336a4acd46 | ||
|
|
c5abe51e26 | ||
|
|
31062bdc3c | ||
|
|
8943099dfb | ||
|
|
09f007e741 | ||
|
|
4487fd4a73 | ||
|
|
5498a79115 | ||
|
|
9c7fc9fddc | ||
|
|
4d63f957c2 | ||
|
|
828e00e668 | ||
|
|
3ba16310c5 | ||
|
|
7aaa9c18dd | ||
|
|
72923879a3 | ||
|
|
b1cc2c7c70 | ||
|
|
d88c927ba9 | ||
|
|
cf58e62baa | ||
|
|
daf4a56665 | ||
|
|
05bc297ea7 | ||
|
|
7ea9ec89be | ||
|
|
f23b6b0d96 | ||
|
|
d2dcf4bb69 | ||
|
|
1ff0fabf15 | ||
|
|
e013cc2ab8 | ||
|
|
99a744abda | ||
|
|
062d60e9d6 | ||
|
|
b777ffec66 | ||
|
|
8a2050e7fa | ||
|
|
9fbb88238e | ||
|
|
36f8cde2fb | ||
|
|
f64cd475af | ||
|
|
a29d2ab66b | ||
|
|
fd1b7ce2a2 | ||
|
|
e0ccb34c10 | ||
|
|
ba29f38959 | ||
|
|
a6dfc81e98 | ||
|
|
fe05526472 | ||
|
|
a6445334e2 | ||
|
|
e5db29d1cb | ||
|
|
7bf7de53b2 | ||
|
|
312c40359c | ||
|
|
021314d6f5 | ||
|
|
ff67464aa1 | ||
|
|
c113f236e4 | ||
|
|
596dee0c5b | ||
|
|
32d5dc05c3 | ||
|
|
3a31da9b3d | ||
|
|
9356db8de6 | ||
|
|
dbbbe59ef2 | ||
|
|
c1c5875356 | ||
|
|
b81089f22e | ||
|
|
ee0eac51d6 | ||
|
|
6ecb4993fd | ||
|
|
285a7e6765 | ||
|
|
b2f82ed04f | ||
|
|
01ec2f12d5 | ||
|
|
624c3e6ae1 | ||
|
|
0d713dacc1 | ||
|
|
582f9d7be4 | ||
|
|
3f2659cb0f | ||
|
|
aeb0f4caa5 | ||
|
|
22555b58ec | ||
|
|
5448329c8a | ||
|
|
a8b000b7f1 | ||
|
|
edaee895e6 | ||
|
|
47f1bbc8d7 | ||
|
|
c9097154c6 | ||
|
|
9f6a8460ac | ||
|
|
637cb2e76d | ||
|
|
47affa0add | ||
|
|
eb829b062b | ||
|
|
3dd1969657 | ||
|
|
b6629850e5 | ||
|
|
e3840d2258 | ||
|
|
8c92470124 | ||
|
|
024c0fb749 | ||
|
|
ebd7b34159 | ||
|
|
d0725163d1 | ||
|
|
cc6ec2445c | ||
|
|
1075370594 | ||
|
|
1fd759d327 | ||
|
|
dd75eaa35e | ||
|
|
c30b4637a5 | ||
|
|
8c511a19e9 | ||
|
|
35153001ed | ||
|
|
3b5fa46e27 | ||
|
|
19eef46d7e | ||
|
|
c532958b9f | ||
|
|
936724f4f7 | ||
|
|
1e7e94d7ac | ||
|
|
859713d10f | ||
|
|
9eac5c13a8 | ||
|
|
041134007d | ||
|
|
37c380f4f7 | ||
|
|
9996856698 | ||
|
|
22cf9254c5 | ||
|
|
e7e7d2fddf | ||
|
|
336b411ea2 | ||
|
|
cb217d79c1 | ||
|
|
8ad8a9ccd2 | ||
|
|
70ed1233fb | ||
|
|
5471e0faf4 | ||
|
|
e85b064b52 | ||
|
|
9f6c0b5b8d | ||
|
|
3b67dc8447 | ||
|
|
bf4ef2284b | ||
|
|
19203381db | ||
|
|
4e2d4d56ac | ||
|
|
a905d00008 | ||
|
|
38a1ab80bc | ||
|
|
43b4c893ad | ||
|
|
96c28c6cba | ||
|
|
189b227853 | ||
|
|
d89134be33 | ||
|
|
3a1f8c2328 | ||
|
|
158bacc087 | ||
|
|
b88d07a1a7 | ||
|
|
e07054e8d0 | ||
|
|
536c8327ff | ||
|
|
0565cf050b | ||
|
|
ac429c8d52 | ||
|
|
09507a2fe9 | ||
|
|
5ee553e9a9 | ||
|
|
eed6e2962e | ||
|
|
76b040bfb8 | ||
|
|
941baaa311 | ||
|
|
92fbb0d2f5 | ||
|
|
1c7ce8744c | ||
|
|
02d52e89e9 | ||
|
|
d7373be071 | ||
|
|
ede4aee619 | ||
|
|
8af9ea8de8 | ||
|
|
603ab8187f | ||
|
|
953959efab | ||
|
|
480f999d21 | ||
|
|
03efdc451b | ||
|
|
54e9f9cedd | ||
|
|
930d9823ea | ||
|
|
6fe36b01d1 | ||
|
|
dec10d4edd | ||
|
|
37cebe08af | ||
|
|
3f2e621902 | ||
|
|
b7e3a85e88 | ||
|
|
79ea433caf | ||
|
|
a0591c9786 | ||
|
|
cc503ba925 | ||
|
|
68823c2921 | ||
|
|
46be58ab1d | ||
|
|
3d9ac1e1fb | ||
|
|
68fed46ea0 | ||
|
|
92b3dd8638 | ||
|
|
d8b5900be6 | ||
|
|
20fa72bd42 | ||
|
|
eb09ae7c58 | ||
|
|
b8127257f9 | ||
|
|
a5f7222a19 | ||
|
|
b56c294c01 | ||
|
|
b583e423c8 | ||
|
|
951304e18e | ||
|
|
0376e54196 | ||
|
|
572a5b3c34 | ||
|
|
9bd81a18b9 | ||
|
|
f35f0a0608 | ||
|
|
12b5ad143f | ||
|
|
73438cc378 | ||
|
|
f860ea9e54 | ||
|
|
836fffddbe | ||
|
|
4a9b924064 | ||
|
|
4fce1f41b5 | ||
|
|
46630a9b1b | ||
|
|
52ec3738d8 | ||
|
|
775530e28e | ||
|
|
1af6e65fba | ||
|
|
acc64b03fd | ||
|
|
0f9a9d6e37 | ||
|
|
8d36bb6453 | ||
|
|
b7c667a682 | ||
|
|
97b97a5664 | ||
|
|
531e0707cf | ||
|
|
b3abf80a50 | ||
|
|
fd588949c9 | ||
|
|
0b0de0d2ee | ||
|
|
d971601316 | ||
|
|
24127196ce | ||
|
|
0425cbbdb5 | ||
|
|
d2705df891 | ||
|
|
a4bc89dc8f | ||
|
|
a42bb38d76 | ||
|
|
db485dd4c4 | ||
|
|
93e410cd7a | ||
|
|
819d63caad | ||
|
|
78e180a054 | ||
|
|
de21bd0f6a | ||
|
|
39be30ba5d | ||
|
|
e2906f1219 | ||
|
|
b76b3b49fa | ||
|
|
83441eebc7 | ||
|
|
e469e9e369 | ||
|
|
d1b527b523 | ||
|
|
098b6194df | ||
|
|
50277692f4 | ||
|
|
819d61f5b6 | ||
|
|
63fdeb4bff | ||
|
|
6c3a5db52f | ||
|
|
d07500687c | ||
|
|
439373abd3 | ||
|
|
8afad700f8 | ||
|
|
a8b79d5df5 | ||
|
|
10a8febb0d | ||
|
|
747828d3ab | ||
|
|
9b8e6b33c7 | ||
|
|
05b23a840e | ||
|
|
5c9bb58a81 | ||
|
|
f8557187cd | ||
|
|
23623a22ff | ||
|
|
5149996b20 | ||
|
|
68e05d54d7 | ||
|
|
be5aa53106 | ||
|
|
95f79e6f02 | ||
|
|
25028ed1b8 | ||
|
|
93357d8157 | ||
|
|
a0ae9ee6fa | ||
|
|
7423cd0112 | ||
|
|
dc55d2b724 | ||
|
|
22ac04576f | ||
|
|
8b548dccc7 | ||
|
|
19d047dcbe | ||
|
|
6e240defdb | ||
|
|
ff91a6fe72 | ||
|
|
e076fff33c | ||
|
|
2d1720c15f | ||
|
|
9ac7503c4e | ||
|
|
a816ed2343 | ||
|
|
4a553de100 | ||
|
|
8702a4c7ab | ||
|
|
0bda7f332e | ||
|
|
d60d00b7b6 | ||
|
|
6e715df9e1 | ||
|
|
2a781c4a9d | ||
|
|
acb248c035 | ||
|
|
18e41cfbe9 | ||
|
|
930a959779 | ||
|
|
ff1a560547 | ||
|
|
7ba3e25813 | ||
|
|
4bb706d140 | ||
|
|
215171ad46 | ||
|
|
c20a04b752 | ||
|
|
3f859fdb11 | ||
|
|
556681a829 | ||
|
|
ee0bb55c06 | ||
|
|
2c0bc19f75 | ||
|
|
286aa51e78 | ||
|
|
145eb580e4 | ||
|
|
46211c26d2 | ||
|
|
e0262c23b0 | ||
|
|
7f80f4f958 | ||
|
|
6a54b37181 | ||
|
|
2c8bf28065 | ||
|
|
8c372572fc | ||
|
|
18c1ce0a22 | ||
|
|
b99fa7aaa4 | ||
|
|
105522b24e | ||
|
|
41b7b03db2 | ||
|
|
8e2a87421c | ||
|
|
b3b76fe682 | ||
|
|
695bfc89ac | ||
|
|
2fd9f945c8 | ||
|
|
6bbe4181fc | ||
|
|
29b834cf56 | ||
|
|
e588dce959 | ||
|
|
2f5265bee6 | ||
|
|
4d3062c62a | ||
|
|
984efe193b | ||
|
|
2554f06759 | ||
|
|
ff9c94f616 | ||
|
|
8c0dc7d8c9 | ||
|
|
b033b150b1 | ||
|
|
9b4ab2e126 | ||
|
|
8d5bc73643 | ||
|
|
ea44750268 | ||
|
|
55c294ac24 | ||
|
|
41ae455ee2 | ||
|
|
b17b36cbce | ||
|
|
6010190940 | ||
|
|
d9e118e754 | ||
|
|
481b9e389f | ||
|
|
177fbb1117 | ||
|
|
7a23f84001 | ||
|
|
b118fa6c8f | ||
|
|
305f01acb5 | ||
|
|
372e5625c3 | ||
|
|
c0bb608acc | ||
|
|
4631335aca | ||
|
|
94c58b3db4 | ||
|
|
b4043e944c | ||
|
|
2983575952 | ||
|
|
1996b11451 | ||
|
|
883784dcc3 | ||
|
|
21ce72dcf0 | ||
|
|
b51465a8d4 | ||
|
|
513fc1aa20 | ||
|
|
e75b329e62 | ||
|
|
4251322aad | ||
|
|
4e4c090373 | ||
|
|
d75dcf0b54 | ||
|
|
28581b1738 | ||
|
|
d40e5d458c | ||
|
|
dbdeaa337c | ||
|
|
256319bd06 | ||
|
|
2049886dcf | ||
|
|
1b12f365ba | ||
|
|
34443d6515 | ||
|
|
cfc10e9efd | ||
|
|
c1beee44ef | ||
|
|
2ed83b0d6e | ||
|
|
68deec5bcd | ||
|
|
e2884b182a | ||
|
|
3c9ff54ae8 | ||
|
|
16f094168a | ||
|
|
42ca640769 | ||
|
|
d1d86ed9b3 | ||
|
|
c5f8a8e139 | ||
|
|
7b4a34f6fc | ||
|
|
bfe7e89bd0 | ||
|
|
e7433d633c | ||
|
|
5cb3947c45 | ||
|
|
f709255d62 | ||
|
|
d159c57e1f | ||
|
|
34876b7616 | ||
|
|
1ab549036c | ||
|
|
6696b35d74 | ||
|
|
d3395cf649 | ||
|
|
7b48714993 | ||
|
|
945c30c5ee | ||
|
|
a9fb0ea969 | ||
|
|
afbc27eac4 | ||
|
|
953c7efafc | ||
|
|
c650d32206 | ||
|
|
88af9d6050 | ||
|
|
9c8e18f0b5 | ||
|
|
0f695a4248 | ||
|
|
88263ebde9 | ||
|
|
a8f8a4d624 |
No files matched your search
+9
-3
@@ -5,7 +5,12 @@
|
|||||||
*.pydevproject
|
*.pydevproject
|
||||||
.project
|
.project
|
||||||
.metadata
|
.metadata
|
||||||
bin/
|
*.exe
|
||||||
|
*.dll
|
||||||
|
*.exp
|
||||||
|
*.lib
|
||||||
|
*.key
|
||||||
|
*.pem
|
||||||
bin64/
|
bin64/
|
||||||
dll/
|
dll/
|
||||||
tmp/
|
tmp/
|
||||||
@@ -18,6 +23,9 @@ tmp/
|
|||||||
*.err
|
*.err
|
||||||
res
|
res
|
||||||
version.c
|
version.c
|
||||||
|
version
|
||||||
|
version.sh
|
||||||
|
buildlinux.sh
|
||||||
3proxy.res
|
3proxy.res
|
||||||
|
|
||||||
src/3proxy
|
src/3proxy
|
||||||
@@ -38,7 +46,6 @@ doc/html/man8/
|
|||||||
*.var
|
*.var
|
||||||
verfile.sh
|
verfile.sh
|
||||||
Makefile
|
Makefile
|
||||||
Changelog
|
|
||||||
copytgz.sh
|
copytgz.sh
|
||||||
*~.nib
|
*~.nib
|
||||||
local.properties
|
local.properties
|
||||||
@@ -77,7 +84,6 @@ local.properties
|
|||||||
[Rr]elease/
|
[Rr]elease/
|
||||||
x64/
|
x64/
|
||||||
build/
|
build/
|
||||||
[Bb]in/
|
|
||||||
[Oo]bj/
|
[Oo]bj/
|
||||||
|
|
||||||
# MSTest test Results
|
# MSTest test Results
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
# 3proxy.full is fully functional 3proxy build based on busibox:glibc
|
||||||
|
#
|
||||||
|
#to build:
|
||||||
|
# docker build -f Dockerfile.full -t 3proxy.full .
|
||||||
|
#to run:
|
||||||
|
# by default 3proxy uses safe chroot environment with chroot to /usr/local/3proxy with uid/gid 65535/65535 and expects
|
||||||
|
# configuration file to be placed in /usr/local/etc/3proxy.
|
||||||
|
# Paths in configuration file must be relative to /usr/local/3proxy, that is use /logs instead of
|
||||||
|
# /usr/local/3proxy/logs. nserver in chroot is required for DNS resolution. An example:
|
||||||
|
#
|
||||||
|
# echo nserver 8.8.8.8 >/path/to/local/config/directory/3proxy.cfg
|
||||||
|
# echo proxy -p3129 >>/path/to/local/config/directory/3proxy.cfg
|
||||||
|
# docker run -p 3129:3129 -v /path/to/local/config/directory:/usr/local/3proxy/conf -name 3proxy.full 3proxy.full
|
||||||
|
#
|
||||||
|
# /path/to/local/config/directory in this example must conrain 3proxy.cfg
|
||||||
|
# if you need 3proxy to be executed without chroot with root permissions, replace /etc/3proxy/3proxy.cfg by e.g. mounting config
|
||||||
|
# dir to /etc/3proxy ot by providing config file /etc/3proxy/3proxy.cfg
|
||||||
|
# docker run -p 3129:3129 -v /path/to/local/config/directory:/etc/3proxy -name 3proxy.full 3proxy.full
|
||||||
|
#
|
||||||
|
# use "log" without pathname in config to log to stdout.
|
||||||
|
# plugins are located in /usr/local/3proxy/libexec (/libexec for chroot config).
|
||||||
|
|
||||||
|
|
||||||
|
FROM gcc AS buildenv
|
||||||
|
COPY . 3proxy
|
||||||
|
RUN cd 3proxy &&\
|
||||||
|
echo "">> Makefile.Linux &&\
|
||||||
|
echo PLUGINS = StringsPlugin TrafficPlugin PCREPlugin TransparentPlugin SSLPlugin>>Makefile.Linux &&\
|
||||||
|
echo LIBS = -l:libcrypto.a -l:libssl.a -ldl >>Makefile.Linux &&\
|
||||||
|
make -f Makefile.Linux &&\
|
||||||
|
strip bin/3proxy &&\
|
||||||
|
strip bin/StringsPlugin.ld.so &&\
|
||||||
|
strip bin/TrafficPlugin.ld.so &&\
|
||||||
|
strip bin/PCREPlugin.ld.so &&\
|
||||||
|
strip bin/TransparentPlugin.ld.so &&\
|
||||||
|
strip bin/SSLPlugin.ld.so
|
||||||
|
|
||||||
|
FROM busybox:glibc
|
||||||
|
COPY --from=buildenv /lib/x86_64-linux-gnu/libdl.so.* /lib/
|
||||||
|
COPY --from=buildenv 3proxy/bin/3proxy /bin/
|
||||||
|
COPY --from=buildenv 3proxy/bin/*.ld.so /usr/local/3proxy/libexec/
|
||||||
|
RUN mkdir /usr/local/3proxy/logs &&\
|
||||||
|
mkdir /usr/local/3proxy/conf &&\
|
||||||
|
chown -R 65535:65535 /usr/local/3proxy &&\
|
||||||
|
chmod -R 550 /usr/local/3proxy &&\
|
||||||
|
chmod 750 /usr/local/3proxy/logs &&\
|
||||||
|
chmod -R 555 /usr/local/3proxy/libexec &&\
|
||||||
|
chown -R root /usr/local/3proxy/libexec &&\
|
||||||
|
mkdir /etc/3proxy/ &&\
|
||||||
|
echo chroot /usr/local/3proxy 65535 65535 >/etc/3proxy/3proxy.cfg &&\
|
||||||
|
echo include /conf/3proxy.cfg >>/etc/3proxy/3proxy.cfg &&\
|
||||||
|
chmod 440 /etc/3proxy/3proxy.cfg
|
||||||
|
|
||||||
|
|
||||||
|
CMD ["/bin/3proxy", "/etc/3proxy/3proxy.cfg"]
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
# dockerfile for "interactive" minimal 3proxy execution, no configuration mounting is required, configuration
|
||||||
|
# is accepted from stdin. Use "end" command to indicate the end of configuration. Use "log" for stdout logging.
|
||||||
|
#
|
||||||
|
# This is busybox based docker with only 3proxy static executable and empty non-writable "run" directory.
|
||||||
|
#
|
||||||
|
# "plugin" is not supported
|
||||||
|
#
|
||||||
|
# Build:
|
||||||
|
#
|
||||||
|
# docker build -f Dockerfile.minimal -t 3proxy.minimal .
|
||||||
|
#
|
||||||
|
# Run example:
|
||||||
|
#
|
||||||
|
# docker run -i -p 3129:3129 --name 3proxy 3proxy.minimal
|
||||||
|
#or
|
||||||
|
# docker start -i 3proxy
|
||||||
|
#<chroot run 65535 65535
|
||||||
|
#<nserver 8.8.8.8
|
||||||
|
#<nscache 65535
|
||||||
|
#<log
|
||||||
|
#<proxy -p3129
|
||||||
|
#<end
|
||||||
|
#
|
||||||
|
# use "chroot run 65536 65536" in config for safe chroot environment. nserver is required for DNS resolutions in chroot.
|
||||||
|
|
||||||
|
|
||||||
|
FROM gcc AS buildenv
|
||||||
|
COPY . /3proxy
|
||||||
|
RUN cd /3proxy &&\
|
||||||
|
echo "">>Makefile.Linux&&\
|
||||||
|
echo LDFLAGS = -fPIE -O2 -fno-strict-aliasing -pthread >>Makefile.Linux&&\
|
||||||
|
echo PLUGINS = >>Makefile.Linux&&\
|
||||||
|
echo LIBS = >>Makefile.Linux&&\
|
||||||
|
echo 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 -DNOPLUGINS >>Makefile.Linux&&\
|
||||||
|
make -f Makefile.Linux&&\
|
||||||
|
strip bin/3proxy
|
||||||
|
|
||||||
|
|
||||||
|
FROM busybox:glibc
|
||||||
|
COPY --from=buildenv /3proxy/bin/3proxy /bin/3proxy
|
||||||
|
RUN mkdir /run && chmod 555 /run
|
||||||
|
CMD ["/bin/3proxy"]
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
#
|
||||||
|
# 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
|
||||||
|
AFTERCLEAN = (find . -type f -name "*.o" -delete && find src/ -type f -name "Makefile.var" -delete && find bin/ -type f -executable -delete) || true
|
||||||
|
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
|
||||||
+68
-27
@@ -4,17 +4,17 @@
|
|||||||
# 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 LDFLAGS to compile with ODBC
|
# remove -DNOODBC from CFLAGS and add -lodbc to LIBS 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 =
|
BUILDDIR = ../bin/
|
||||||
CC = gcc
|
CC = gcc
|
||||||
|
|
||||||
CFLAGS = -g -O2 -c -pthread -DGETHOSTBYNAME_R -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL
|
CFLAGS = -g -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
|
||||||
COUT = -o
|
COUT = -o
|
||||||
LN = gcc
|
LN = $(CC)
|
||||||
DCFLAGS = -fpic
|
DCFLAGS =
|
||||||
LDFLAGS = -O2 -pthread
|
LDFLAGS = -fPIE -O2 -fno-strict-aliasing -pthread
|
||||||
DLFLAGS = -shared
|
DLFLAGS = -shared
|
||||||
DLSUFFICS = .ld.so
|
DLSUFFICS = .ld.so
|
||||||
# -lpthreads may be reuqired on some platforms instead of -pthreads
|
# -lpthreads may be reuqired on some platforms instead of -pthreads
|
||||||
@@ -26,6 +26,7 @@ OBJSUFFICS = .o
|
|||||||
DEFINEOPTION = -D
|
DEFINEOPTION = -D
|
||||||
COMPFILES = *~
|
COMPFILES = *~
|
||||||
REMOVECOMMAND = rm -f
|
REMOVECOMMAND = rm -f
|
||||||
|
AFTERCLEAN = (find . -type f -name "*.o" -delete && find src/ -type f -name "Makefile.var" -delete && find bin/ -type f -executable -delete) || true
|
||||||
TYPECOMMAND = cat
|
TYPECOMMAND = cat
|
||||||
COMPATLIBS =
|
COMPATLIBS =
|
||||||
MAKEFILE = Makefile.Linux
|
MAKEFILE = Makefile.Linux
|
||||||
@@ -42,54 +43,76 @@ 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 = /usr/local
|
prefix =
|
||||||
exec_prefix = $(prefix)
|
exec_prefix = $(prefix)
|
||||||
man_prefix = $(prefix)/share
|
man_prefix = /usr/share
|
||||||
|
chroot_prefix = /usr/local
|
||||||
|
|
||||||
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 = src/3proxy \
|
INSTALL_OBJS = bin/3proxy \
|
||||||
src/dighosts \
|
bin/ftppr \
|
||||||
src/ftppr \
|
bin/mycrypt \
|
||||||
src/mycrypt \
|
bin/pop3p \
|
||||||
src/pop3p \
|
bin/proxy \
|
||||||
src/proxy \
|
bin/socks \
|
||||||
src/socks \
|
bin/tcppm \
|
||||||
src/tcppm \
|
bin/udppm
|
||||||
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 = passwd counters bandlimiters
|
INSTALL_CFG_OBJS2 = counters bandlimiters
|
||||||
|
|
||||||
|
INSTALL_INITD_SCRIPT = scripts/init.d/3proxy.sh
|
||||||
|
INSTALL_SYSTEMD_SCRIPT = scripts/3proxy.service
|
||||||
|
|
||||||
|
CHROOTDIR = $(DESTDIR)$(chroot_prefix)/3proxy
|
||||||
|
CHROOTREL = ../..$(chroot_prefix)/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)/etc/3proxy
|
||||||
|
INITDDIR = $(DESTDIR)/etc/init.d
|
||||||
|
RUNBASE = $(DESTDIR)/var/run
|
||||||
|
RUNDIR = $(RUNBASE)/3proxy
|
||||||
|
LOGBASE = $(DESTDIR)/var/log
|
||||||
|
LOGDIR = $(LOGBASE)/3proxy
|
||||||
|
INSTALL_CFG_DEST = $(ETCDIR)/conf
|
||||||
|
SYSTEMDDIR = $(DESTDIR)/usr/lib/systemd/system/
|
||||||
|
|
||||||
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 [ -f $(ETCDIR)/$(INSTALL_CFG_DEST) ]; then \
|
if [ ! -d $(INSTALL_CFG_DEST) ]; then \
|
||||||
: ; \
|
ln -s $(CHROOTREL)/conf $(INSTALL_CFG_DEST); \
|
||||||
else \
|
$(INSTALL_BIN) $(INSTALL_CFG) $(ETCDIR)/3proxy.cfg; \
|
||||||
$(INSTALL_DATA) $(INSTALL_CFG_OBJS) $(ETCDIR)/$(INSTALL_CFG_DEST) \
|
$(INSTALL_BIN) $(INSTALL_CFG_OBJS) $(INSTALL_CFG_DEST); \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
install-etc: install-etc-dir
|
install-etc: install-etc-dir install-etc-default-config
|
||||||
for file in $(INSTALL_CFG_OBJS2); \
|
for file in $(INSTALL_CFG_OBJS2); \
|
||||||
do \
|
do \
|
||||||
touch $(ETCDIR)/$$file; chmod 0600 $(ETCDIR)/$$file; \
|
touch $(INSTALL_CFG_DEST)/$$file; chmod 0600 $(INSTALL_CFG_DEST)/$$file; \
|
||||||
done;
|
done;
|
||||||
|
|
||||||
install-man:
|
install-man:
|
||||||
@@ -98,5 +121,23 @@ install-man:
|
|||||||
$(INSTALL_DATA) man/*.3 $(MANDIR3)
|
$(INSTALL_DATA) man/*.3 $(MANDIR3)
|
||||||
$(INSTALL_DATA) man/*.8 $(MANDIR8)
|
$(INSTALL_DATA) man/*.8 $(MANDIR8)
|
||||||
|
|
||||||
install: install-bin install-etc install-man
|
install-init:
|
||||||
|
$(INSTALL_BIN) -d $(INITDDIR)
|
||||||
|
$(INSTALL_BIN) $(INSTALL_INITD_SCRIPT) $(INITDDIR)/3proxy
|
||||||
|
$(INSTALL_BIN) -d $(SYSTEMDDIR)
|
||||||
|
$(INSTALL_DATA) $(INSTALL_SYSTEMD_SCRIPT) $(SYSTEMDDIR)
|
||||||
|
|
||||||
|
install-run:
|
||||||
|
$(INSTALL_BIN) -d $(RUNDIR)
|
||||||
|
|
||||||
|
install-log:
|
||||||
|
$(INSTALL_BIN) -d $(LOGBASE)
|
||||||
|
@if [ ! -d $(LOGDIR) ]; then \
|
||||||
|
ln -s $(CHROOTREL)/logs $(LOGDIR);\
|
||||||
|
fi
|
||||||
|
|
||||||
|
install: install-chroot-dir install-bin install-etc install-log install-man install-run install-init
|
||||||
|
@if [ "$(DESTDIR)" = "" ]; then \
|
||||||
|
sh scripts/debian/preinst; \
|
||||||
|
sh scripts/debian/postinst; \
|
||||||
|
fi
|
||||||
+5
-4
@@ -7,13 +7,13 @@
|
|||||||
# 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 =
|
BUILDDIR = ../bin/
|
||||||
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
|
||||||
@@ -25,10 +25,11 @@ OBJSUFFICS = .o
|
|||||||
DEFINEOPTION = -D
|
DEFINEOPTION = -D
|
||||||
COMPFILES = *~
|
COMPFILES = *~
|
||||||
REMOVECOMMAND = rm -f
|
REMOVECOMMAND = rm -f
|
||||||
|
AFTERCLEAN = (find . -type f -name "*.o" -delete && find src/ -type f -name "Makefile.var" -delete && find bin/ -type f -executable -delete) || true
|
||||||
TYPECOMMAND = cat
|
TYPECOMMAND = cat
|
||||||
COMPATLIBS =
|
COMPATLIBS =
|
||||||
MAKEFILE = Makefile.Solaris
|
MAKEFILE = Makefile.Solaris
|
||||||
PLUGINS = StringsPlugin TrafficPlugin PCREPlugin
|
PLUGINS = StringsPlugin TrafficPlugin PCREPlugin TransparentPlugin
|
||||||
|
|
||||||
include Makefile.inc
|
include Makefile.inc
|
||||||
|
|
||||||
|
|||||||
@@ -8,13 +8,13 @@
|
|||||||
# library support. Add -DSAFESQL for poorely written ODBC library / drivers.
|
# library support. Add -DSAFESQL for poorely written ODBC library / drivers.
|
||||||
|
|
||||||
|
|
||||||
BUILDDIR =
|
BUILDDIR = ../bin/
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -O3 -c -D_SOLARIS -D_THREAD_SAFE -DGETHOSTBYNAME_R -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL
|
CFLAGS = -O2 -fno-strict-aliasing -c -D_SOLARIS -D_THREAD_SAFE -DGETHOSTBYNAME_R -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL
|
||||||
COUT = -o ./
|
COUT = -o ./
|
||||||
LN = gcc
|
LN = $(CC)
|
||||||
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
|
||||||
@@ -26,6 +26,7 @@ OBJSUFFICS = .o
|
|||||||
DEFINEOPTION = -D
|
DEFINEOPTION = -D
|
||||||
COMPFILES = *~
|
COMPFILES = *~
|
||||||
REMOVECOMMAND = rm -f
|
REMOVECOMMAND = rm -f
|
||||||
|
AFTERCLEAN = (find . -type f -name "*.o" -delete && find src/ -type f -name "Makefile.var" -delete && find bin/ -type f -executable -delete) || true
|
||||||
TYPECOMMAND = cat
|
TYPECOMMAND = cat
|
||||||
COMPATLIBS =
|
COMPATLIBS =
|
||||||
MAKEFILE = Makefile.Solaris-gcc
|
MAKEFILE = Makefile.Solaris-gcc
|
||||||
|
|||||||
+4
-3
@@ -3,10 +3,11 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
all:
|
all:
|
||||||
$(TYPECOMMAND) $(MAKEFILE) > src/Makefile.var
|
@$(TYPECOMMAND) $(MAKEFILE) > src/Makefile.var
|
||||||
@cd src && $(MAKE)
|
@cd src && $(MAKE)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@$(REMOVECOMMAND) *$(OBJSUFFICS) $(COMPFILES)
|
@cd src && $(REMOVECOMMAND) *$(OBJSUFFICS) $(COMPFILES) && cd ..
|
||||||
@cd src && $(MAKE) clean
|
@$(AFTERCLEAN)
|
||||||
|
|
||||||
|
|
||||||
+4
-3
@@ -10,10 +10,10 @@
|
|||||||
|
|
||||||
BUILDDIR = ../bin/
|
BUILDDIR = ../bin/
|
||||||
CC = clang
|
CC = clang
|
||||||
CFLAGS = -O2 -c -pthread -static -DWITH_STD_MALLOC -DNOIPV6
|
CFLAGS = -O2 -fno-strict-aliasing -c -pthread -static -DWITH_STD_MALLOC -DNOIPV6
|
||||||
COUT = -o
|
COUT = -o
|
||||||
LN = clang
|
LN = $(CC)
|
||||||
LDFLAGS = -O2 -static -s
|
LDFLAGS = -O2 -fno-strict-aliasing -static -s
|
||||||
DLFLAGS = -shared
|
DLFLAGS = -shared
|
||||||
DLSUFFICS = .dll
|
DLSUFFICS = .dll
|
||||||
LIBS = -lws2_32 -lodbc32 -ladvapi32
|
LIBS = -lws2_32 -lodbc32 -ladvapi32
|
||||||
@@ -25,6 +25,7 @@ OBJSUFFICS = .o
|
|||||||
DEFINEOPTION = -D
|
DEFINEOPTION = -D
|
||||||
COMPFILES = *.tmp
|
COMPFILES = *.tmp
|
||||||
REMOVECOMMAND = rm -f
|
REMOVECOMMAND = rm -f
|
||||||
|
AFTERCLEAN = find src/ -type f -name "*.o" -delete && find src/ -type f -name "Makefile.var" -delete && find bin/ -type f -executable -delete
|
||||||
TYPECOMMAND = cat
|
TYPECOMMAND = cat
|
||||||
COMPATLIBS =
|
COMPATLIBS =
|
||||||
MAKEFILE = Makefile.win
|
MAKEFILE = Makefile.win
|
||||||
|
|||||||
+10
-9
@@ -8,13 +8,13 @@
|
|||||||
|
|
||||||
BUILDDIR = ../bin/
|
BUILDDIR = ../bin/
|
||||||
CC = cl
|
CC = cl
|
||||||
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
|
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)
|
||||||
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 libeay32MT.lib ssleay32MT.lib
|
LIBS = ws2_32.lib advapi32.lib odbc32.lib user32.lib kernel32.lib Gdi32.lib libeay32.lib ssleay32.lib
|
||||||
LIBSOLD = libeay32MT.lib ssleay32MT.lib
|
LIBSOLD = libeay32MT.lib ssleay32MT.lib
|
||||||
LIBSPREFIX =
|
LIBSPREFIX =
|
||||||
LIBSSUFFIX = .lib
|
LIBSSUFFIX = .lib
|
||||||
@@ -24,20 +24,21 @@ EXESUFFICS = .exe
|
|||||||
OBJSUFFICS = .obj
|
OBJSUFFICS = .obj
|
||||||
DEFINEOPTION = /D
|
DEFINEOPTION = /D
|
||||||
COMPFILES = *.pch *.idb
|
COMPFILES = *.pch *.idb
|
||||||
REMOVECOMMAND = del 2>NUL >NUL
|
REMOVECOMMAND = del
|
||||||
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 FilePlugin SSLPlugin
|
||||||
VERFILE = $(VERFILE)
|
VERFILE = 3proxy.res $(VERFILE)
|
||||||
|
VERSION = $(VERSION)
|
||||||
|
VERSIONDEP = 3proxy.res $(VERSIONDEP)
|
||||||
|
BUILDDATE = $(BUILDDATE)
|
||||||
|
AFTERCLEAN = if exist src\*.res (del src\*.res) && if exist src\*.err (del src\*.err)
|
||||||
|
|
||||||
include Makefile.inc
|
include Makefile.inc
|
||||||
|
|
||||||
../3proxy.res:
|
3proxy.res:
|
||||||
rc /fo../3proxy.res ../3proxy.rc
|
rc 3proxy.rc
|
||||||
|
|
||||||
3proxyres.obj: ../3proxy.res
|
|
||||||
cvtres /out:3proxyres.obj /MACHINE:I386 ../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
-13
@@ -8,14 +8,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 "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /Fp"proxy.pch" /FD /c
|
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
|
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 libeay32MT.lib ssleay32MT.lib
|
LIBS = ws2_32.lib advapi32.lib odbc32.lib user32.lib kernel32.lib Gdi32.lib libeay32.lib ssleay32.lib
|
||||||
LIBSOLD = libeay32MT.lib ssleay32MT.lib
|
LIBSOLD = libeay32.lib ssleay32.lib
|
||||||
LIBSPREFIX =
|
LIBSPREFIX =
|
||||||
LIBSSUFFIX = .lib
|
LIBSSUFFIX = .lib
|
||||||
LIBEXT = .lib
|
LIBEXT = .lib
|
||||||
@@ -27,20 +27,15 @@ COMPFILES = *.pch *.idb
|
|||||||
REMOVECOMMAND = del 2>NUL >NUL
|
REMOVECOMMAND = del 2>NUL >NUL
|
||||||
TYPECOMMAND = type
|
TYPECOMMAND = type
|
||||||
COMPATLIBS =
|
COMPATLIBS =
|
||||||
MAKEFILE = Makefile.msvc64
|
VERFILE = 3proxy.res $(VERFILE)
|
||||||
|
VERSIONDEP = 3proxy.res $(VERSIONDEP)
|
||||||
PLUGINS = utf8tocp1251 WindowsAuthentication TrafficPlugin StringsPlugin PCREPlugin FilePlugin SSLPlugin
|
PLUGINS = utf8tocp1251 WindowsAuthentication TrafficPlugin StringsPlugin PCREPlugin FilePlugin SSLPlugin
|
||||||
VERFILE = $(VERFILE)
|
AFTERCLEAN = del src\*.res
|
||||||
|
|
||||||
#../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
|
rc 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
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
#
|
||||||
|
# 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 = 3proxy.res $(VERFILE)
|
||||||
|
VERSIONDEP = 3proxy.res $(VERSIONDEP)
|
||||||
|
AFTERCLEAN = del src\*.res
|
||||||
|
|
||||||
|
|
||||||
|
include Makefile.inc
|
||||||
|
|
||||||
|
3proxy.res:
|
||||||
|
rc 3proxy.rc
|
||||||
|
|
||||||
|
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 ..\..)
|
||||||
|
|
||||||
+1
-1
@@ -8,7 +8,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" /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" /D "PRINTF_INT64_MODIFIER=\"I64\"" /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
|
||||||
|
|||||||
@@ -0,0 +1,102 @@
|
|||||||
|
#
|
||||||
|
# 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 = $(CC)
|
||||||
|
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
|
||||||
|
AFTERCLEAN = (find . -type f -name "*.o" -delete && find src/ -type f -name "Makefile.var" -delete && find bin/ -type f -executable -delete) || true
|
||||||
|
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
|
||||||
|
|
||||||
+9
-8
@@ -7,17 +7,17 @@
|
|||||||
# 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 =
|
BUILDDIR = ../bin/
|
||||||
CC = gcc
|
CC = gcc
|
||||||
|
|
||||||
# you may need -L/usr/pkg/lib for older NetBSD versions
|
# you may need -L/usr/pkg/lib for older NetBSD versions
|
||||||
CFLAGS = -g -O2 -c -pthread -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL
|
CFLAGS = -g -O2 -fno-strict-aliasing -c -pthread -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL
|
||||||
COUT = -o
|
COUT = -o
|
||||||
LN = gcc
|
LN = $(CC)
|
||||||
LDFLAGS = -O2 -pthread
|
LDFLAGS = -O2 -fno-strict-aliasing -pthread
|
||||||
# -lpthreads may be reuqired on some platforms instead of -pthreads
|
# -lpthreads may be reuqired on some platforms instead of -pthreads
|
||||||
# -ldl or -lld may be required for some platforms
|
# -ldl or -lld may be required for some platforms
|
||||||
DCFLAGS = -fpic
|
DCFLAGS = -fPIC
|
||||||
DLFLAGS = -shared
|
DLFLAGS = -shared
|
||||||
DLSUFFICS = .ld.so
|
DLSUFFICS = .ld.so
|
||||||
LIBS =
|
LIBS =
|
||||||
@@ -29,17 +29,18 @@ OBJSUFFICS = .o
|
|||||||
DEFINEOPTION = -D
|
DEFINEOPTION = -D
|
||||||
COMPFILES = *~
|
COMPFILES = *~
|
||||||
REMOVECOMMAND = rm -f
|
REMOVECOMMAND = rm -f
|
||||||
|
AFTERCLEAN = (find . -type f -name "*.o" -delete && find src/ -type f -name "Makefile.var" -delete && find bin/ -type f -executable -delete) || true
|
||||||
TYPECOMMAND = cat
|
TYPECOMMAND = cat
|
||||||
COMPATLIBS =
|
COMPATLIBS =
|
||||||
MAKEFILE = Makefile.unix
|
MAKEFILE = Makefile.unix
|
||||||
PLUGINS = StringsPlugin TrafficPlugin PCREPlugin PamAuth
|
PLUGINS = StringsPlugin TrafficPlugin PCREPlugin PamAuth TransparentPlugin
|
||||||
|
|
||||||
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 src/3proxy /usr/local/etc/3proxy/bin/3proxy
|
install bin/3proxy /usr/local/etc/3proxy/bin/3proxy
|
||||||
install src/mycrypt /usr/local/etc/3proxy/bin/mycrypt
|
install bin/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
|
||||||
|
|||||||
@@ -6,15 +6,14 @@ 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 = src/3proxy \
|
INSTALL_OBJS = bin/3proxy \
|
||||||
src/dighosts \
|
bin/ftppr \
|
||||||
src/ftppr \
|
bin/mycrypt \
|
||||||
src/mycrypt \
|
bin/pop3p \
|
||||||
src/pop3p \
|
bin/proxy \
|
||||||
src/proxy \
|
bin/socks \
|
||||||
src/socks \
|
bin/tcppm \
|
||||||
src/tcppm \
|
bin/udppm \
|
||||||
src/udppm \
|
|
||||||
scripts/add3proxyuser.sh
|
scripts/add3proxyuser.sh
|
||||||
|
|
||||||
INSTALL_CFG_OBJS = scripts/3proxy.cfg
|
INSTALL_CFG_OBJS = scripts/3proxy.cfg
|
||||||
|
|||||||
+36
-7
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
BUILDDIR = ../bin/
|
BUILDDIR = ../bin/
|
||||||
CC = cl
|
CC = cl
|
||||||
CFLAGS = /nologo /Ox /MT /D "NOIPV6" /D "NODEBUG" /D "NOODBC" /D "MSVC" /D "WITH_STD_MALLOC" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /c
|
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
|
COUT = /Fo
|
||||||
LN = link
|
LN = link
|
||||||
LDFLAGS = /nologo /subsystem:console /incremental:no
|
LDFLAGS = /nologo /subsystem:console /incremental:no
|
||||||
@@ -30,14 +30,43 @@ COMPATLIBS =
|
|||||||
MAKEFILE = Makefile.watcom
|
MAKEFILE = Makefile.watcom
|
||||||
PLUGINS = utf8tocp1251 WindowsAuthentication TrafficPlugin StringsPlugin PCREPlugin
|
PLUGINS = utf8tocp1251 WindowsAuthentication TrafficPlugin StringsPlugin PCREPlugin
|
||||||
VERFILE = $(VERFILE)
|
VERFILE = $(VERFILE)
|
||||||
|
VERSION = $(VERSION)
|
||||||
|
VERSIONDEP = 3proxy.res $(VERSIONDEP)
|
||||||
|
BUILDDATE = $(BUILDDATE)
|
||||||
|
|
||||||
include Makefile.inc
|
include Makefile.inc
|
||||||
|
|
||||||
../3proxy.res:
|
3proxy.res:
|
||||||
rc /fo../3proxy.res ../3proxy.rc
|
rc 3proxy.rc
|
||||||
|
|
||||||
3proxyres.obj: ../3proxy.res
|
|
||||||
cvtres /out:3proxyres.obj ../3proxy.res
|
|
||||||
|
|
||||||
allplugins:
|
allplugins:
|
||||||
call ../makeplugins.bat
|
copy Makefile plugins\utf8tocp1251
|
||||||
|
copy Makefile.var plugins\utf8tocp1251
|
||||||
|
cd plugins\utf8tocp1251
|
||||||
|
nmake
|
||||||
|
del *.obj *.idb
|
||||||
|
cd ../../
|
||||||
|
copy Makefile plugins\WindowsAuthentication
|
||||||
|
copy Makefile.var plugins\WindowsAuthentication
|
||||||
|
cd plugins\WindowsAuthentication
|
||||||
|
nmake
|
||||||
|
del *.obj *.idb
|
||||||
|
cd ../../
|
||||||
|
copy Makefile plugins\TrafficPlugin
|
||||||
|
copy Makefile.var plugins\TrafficPlugin
|
||||||
|
cd plugins\TrafficPlugin
|
||||||
|
nmake
|
||||||
|
del *.obj *.idb
|
||||||
|
cd ../../
|
||||||
|
copy Makefile plugins\StringsPlugin
|
||||||
|
copy Makefile.var plugins\StringsPlugin
|
||||||
|
cd plugins\StringsPlugin
|
||||||
|
nmake
|
||||||
|
del *.obj *.idb
|
||||||
|
cd ../../
|
||||||
|
copy Makefile plugins\PCREPlugin
|
||||||
|
copy Makefile.var plugins\PCREPlugin
|
||||||
|
cd plugins\PCREPlugin
|
||||||
|
nmake
|
||||||
|
del *.obj *.idb
|
||||||
|
cd ../../
|
||||||
+1
-1
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
BUILDDIR = ../bin/
|
BUILDDIR = ../bin/
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -O2 -s -c -mthreads -DWITH_STD_MALLOC -DNOIPV6
|
CFLAGS = -O2 -s -c -mthreads -DWITH_STD_MALLOC -DNOIPV6 -DNORADIUS
|
||||||
COUT = -o
|
COUT = -o
|
||||||
LN = gcc
|
LN = gcc
|
||||||
LDFLAGS = -O2 -s -mthreads
|
LDFLAGS = -O2 -s -mthreads
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
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 -D__USE_W32_SOCKETS
|
CFLAGS = -O2 -s -c -mthreads -DWITH_STD_MALLOC -DNOODBC -D_WINCE -D_WIN32 -DNORADIUS -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 = -O2 -s -mthreads
|
||||||
|
|||||||
@@ -1,86 +1,142 @@
|
|||||||
/*
|
# 3APA3A 3proxy tiny proxy server
|
||||||
3APA3A 3proxy tiny proxy server
|
(c) 2002-2020 by Vladimir '3APA3A' Dubrovin <3proxy@3proxy.ru>
|
||||||
(c) 2002-2016 by Vladimir '3APA3A' Dubrovin <3proxy@3proxy.ru>
|
|
||||||
|
|
||||||
please read License Agreement
|
|
||||||
*/
|
Branches:
|
||||||
|
Master (stable) branch - 3proxy 0.9
|
||||||
|
Devel branch - 3proxy 10
|
||||||
|
|
||||||
|
|
||||||
|
Download:
|
||||||
|
Binaries for released (master) versions (Windows, Linux):
|
||||||
|
https://github.com/z3APA3A/3proxy/releases
|
||||||
|
Binaries for devel version (Windows, Linux):
|
||||||
|
https://3proxy.org/download/devel/
|
||||||
|
Docker images:
|
||||||
|
https://hub.docker.com/repository/docker/3proxy/3proxy
|
||||||
|
Archive of old versions: https://github.com/z3APA3A/3proxy-archive
|
||||||
|
|
||||||
|
|
||||||
|
Windows installation:
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
Default configuration (for Linux/Unix):
|
||||||
|
3proxy uses 2 configuration files:
|
||||||
|
/etc/3proxy/3proxy.cfg (before-chroot). This configuration file is executed before chroot and should not be modified.
|
||||||
|
/usr/local/3proxy/conf/3proxy.cfg symlinked from /etc/3proxy/conf/3proxy.cfg (after-chroot) is a main configuration file. Modify this file, if required.
|
||||||
|
All paths in /usr/local/3proxy/conf/3proxy.cfg are relative to chroot directory (/usr/local/3proxy). For future versions it's planned to move
|
||||||
|
3proxy chroot direcory to /var.
|
||||||
|
Log files are created in /usr/local/3proxy/logs symlinked from /var/log/3proxy.
|
||||||
|
By default, socks is started on 0.0.0.0:1080 and proxy on 0.0.0.0:3128 with basic auth, no users are added by default.
|
||||||
|
|
||||||
|
use /etc/3proxy/conf/add3proxyuser.sh script to add users.
|
||||||
|
|
||||||
|
usage: /etc/3proxy/conf/add3proxyuser.sh username password [day_limit] [bandwidth]
|
||||||
|
day_limit - traffic limit in MB per day
|
||||||
|
bandwidth - bandwith in bits per second 1048576 = 1Mbps
|
||||||
|
|
||||||
|
or modify /etc/3proxy/conf/ files directly.
|
||||||
|
|
||||||
Please read doc/html/index.html and man pages.
|
Please read doc/html/index.html and man pages.
|
||||||
|
|
||||||
Features:
|
Features:
|
||||||
1. General
|
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,
|
+ HTTP/1.1 Proxy with keep-alive client and server support,
|
||||||
transparent proxy support.
|
transparent proxy support.
|
||||||
+ Anonymous and random client emulation HTTP proxy mode
|
+ HTTPS (CONNECT) proxy (compatible with HTTP/2 / SPDY)
|
||||||
|
+ Anonymous and random client IP emulation for HTTP proxy mode
|
||||||
+ FTP over HTTP support.
|
+ FTP over HTTP support.
|
||||||
+ DNS caching with built-in resolver
|
+ DNS caching with built-in resolver
|
||||||
+ HTTPS (CONNECT) proxy
|
+ DNS proxy
|
||||||
|
+ DNS over TCP support, redirecting DNS traffic via parent
|
||||||
|
proxy
|
||||||
+ SOCKSv4/4.5 Proxy
|
+ SOCKSv4/4.5 Proxy
|
||||||
+ SOCKSv5 Proxy
|
+ SOCKSv5 Proxy
|
||||||
+ UDP and bind support for SOCKSv5 (fully compatible with
|
+ SOCKSv5 UDP and BIND support (fully compatible with
|
||||||
SocksCAP/FreeCAP for UDP)
|
SocksCAP/FreeCAP for UDP)
|
||||||
+ Transparent SOCKS redirection for HTTP, POP3, FTP, SMTP, ICQ
|
+ Transparent SOCKS redirection for HTTP, POP3, FTP, SMTP
|
||||||
+ POP3 Proxy
|
+ POP3 Proxy
|
||||||
+ FTP proxy
|
+ FTP proxy
|
||||||
+ DNS proxy
|
+ TCP port mapper (port forwarding)
|
||||||
+ TCP port mapper
|
+ UDP port mapper (port forwarding)
|
||||||
+ UDP port mapper
|
|
||||||
+ SMTP proxy
|
+ SMTP proxy
|
||||||
+ ICQ/AOL proxy
|
|
||||||
+ Threaded application (no child process).
|
+ Threaded application (no child process).
|
||||||
+ Web administration and statistics
|
+ Web administration and statistics
|
||||||
+ Plugins for functionality extension
|
+ Plugins for functionality extension
|
||||||
+ Native 64 bit application for 64 bit OS, including 64-bit editions of
|
+ Native 32/64 bit application
|
||||||
Windows.
|
|
||||||
+ IPv6 support
|
|
||||||
2. Proxy chaining and network connections
|
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
|
+ Connect back proxy support to bypass firewalls
|
||||||
+ Parent proxy support for any type of incoming connection
|
+ Parent proxy support for any type of incoming connection
|
||||||
+ Username/password authentication for parent proxy(s).
|
+ Username/password authentication for parent proxy(s).
|
||||||
+ HTTPS/SOCKS4/SOCKS5 and redirection parent support
|
+ HTTPS/SOCKS4/SOCKS5 and ip/port redirection parent support
|
||||||
+ Random parent selection
|
+ Random parent selection
|
||||||
+ Chain building (multihop proxing)
|
+ Chain building (multihop proxing)
|
||||||
+ Load balancing between few network connections by choosing network
|
+ Load balancing between few network connections by choosing network
|
||||||
interface
|
interface
|
||||||
3. Logging
|
3. Logging
|
||||||
+ turnable log format compatible with any log parser
|
+ tuneable log format compatible with any log parser
|
||||||
+ stdout logging
|
+ stdout logging
|
||||||
+ file logging
|
+ file logging
|
||||||
+ syslog logging (Unix)
|
+ syslog logging (Unix)
|
||||||
+ ODBC logging
|
+ ODBC logging
|
||||||
+ log file rotation (hourly, daily, weekly, monthly)
|
+ RADIUS accounting
|
||||||
+ automatic log file comperssion with external archiver (for files)
|
+ log file rotation
|
||||||
+ automatic removal of older log files
|
+ automatic log file processing with external archiver (for files)
|
||||||
+ Character filtering for log files
|
+ Character filtering for log files
|
||||||
+ different log files for different servces are supported
|
+ different log files for different servces are supported
|
||||||
4. Access control
|
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
|
+ ACL-driven (user/source/destination/protocol/weekday/daytime or
|
||||||
combined) bandwith limitation for incoming and (!)outgoing trafic.
|
combined) bandwith limitation for incoming and (!)outgoing trafic.
|
||||||
+ ACL-driven (user/source/destination/protocol/weekday/daytime or
|
+ ACL-driven traffic limitation per day, week or month for incoming and
|
||||||
combined) traffic limitation per day, week or month for incoming and
|
outgoing traffic
|
||||||
(!) outgoing traffic
|
+ Connection limitation and ratelimting
|
||||||
+ User authentication by DNS hostname
|
|
||||||
+ User authentication by username / password
|
+ User authentication by username / password
|
||||||
+ Access control by username, source IP, destination IP, destination
|
+ RADIUS Authentication and Authorization
|
||||||
port and destination action (POST, PUT, GET, etc), weekday and daytime.
|
+ 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
|
+ Access control by username/password for SOCKSv5 and HTTP/HTTPS/FTP
|
||||||
+ Cleartext or encrypted (crypt/MD5 or NT) passwords.
|
+ Cleartext or encrypted (crypt/MD5 or NT) passwords.
|
||||||
+ Connection redirection
|
+ Connection redirection
|
||||||
+ Access control by requested action (CONNECT/BIND,
|
+ Access control by requested action (CONNECT/BIND,
|
||||||
HTTP GET/POST/PUT/HEAD/OTHER).
|
HTTP GET/POST/PUT/HEAD/OTHER).
|
||||||
+ NTLM (v1 only) authentication for HTTP proxy access
|
|
||||||
+ All access control entries now support weekday and time limitations
|
+ All access control entries now support weekday and time limitations
|
||||||
+ Hostnames and * templates are supported instead of IP address
|
+ Hostnames and * templates are supported instead of IP address
|
||||||
5. Extensions
|
5. Extensions
|
||||||
+ Regular expression filtering (with PCRE) via PCREPlugin
|
+ 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)
|
||||||
+ Authentication with Windows username/password (cleartext only!)
|
|
||||||
+ SSL/TLS decryptions with certificate spoofing
|
+ SSL/TLS decryptions with certificate spoofing
|
||||||
+ NAT support under Linux
|
+ Transparent redirection support for Linux and *BSD
|
||||||
6. Configuration
|
6. Configuration
|
||||||
+ support for configuration files
|
+ support for configuration files
|
||||||
+ support for includes in configuration files
|
+ support for includes in configuration files
|
||||||
+ interface binding
|
+ interface binding
|
||||||
|
+ socket options
|
||||||
+ running as daemon process
|
+ running as daemon process
|
||||||
+ utility for automated networks list building
|
+ utility for automated networks list building
|
||||||
+ configuration reload on any file change
|
+ configuration reload on any file change
|
||||||
@@ -88,7 +144,7 @@ Please read doc/html/index.html and man pages.
|
|||||||
+ support for chroot
|
+ support for chroot
|
||||||
+ support for setgid
|
+ support for setgid
|
||||||
+ support for setuid
|
+ support for setuid
|
||||||
+ support for signals
|
+ support for signals (SIGUSR1 to reload configuration)
|
||||||
Windows
|
Windows
|
||||||
+ support --install as service
|
+ support --install as service
|
||||||
+ support --remove as service
|
+ support --remove as service
|
||||||
@@ -100,6 +156,7 @@ Please read doc/html/index.html and man pages.
|
|||||||
+ support --remove as service
|
+ support --remove as service
|
||||||
6. Compilation
|
6. Compilation
|
||||||
+ MSVC (static)
|
+ MSVC (static)
|
||||||
|
+ OpenWatcom (static)
|
||||||
+ Intel Windows Compiler (msvcrt.dll)
|
+ Intel Windows Compiler (msvcrt.dll)
|
||||||
+ Windows/gcc (msvcrt.dll)
|
+ Windows/gcc (msvcrt.dll)
|
||||||
+ Cygwin/gcc (cygwin.dll)
|
+ Cygwin/gcc (cygwin.dll)
|
||||||
@@ -115,13 +172,10 @@ Please read doc/html/index.html and man pages.
|
|||||||
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 Windows 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
|
||||||
@@ -131,17 +185,14 @@ 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.somehost.ru, to obtains mail for someuser
|
set someuser@pop.example.org, 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.somehost.ru, to send mail as someuser
|
set someuser@mail.example.org, 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
|
|
||||||
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
|
||||||
@@ -157,11 +208,10 @@ mycrypt Program to obtain crypted password fro cleartext. Supports
|
|||||||
produces NT password
|
produces NT password
|
||||||
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.
|
|
||||||
|
|
||||||
|
|
||||||
Run utility with --help option for command line reference.
|
Run utility with --help option for command line reference.
|
||||||
|
|
||||||
Latest version is available from http://3proxy.ru/
|
Latest version is available from https://3proxy.org/
|
||||||
|
|
||||||
Want to donate the project? http://3proxy.ru/donations/
|
Want to donate the project? https://3proxy.org/donations/
|
||||||
-106
@@ -1,106 +0,0 @@
|
|||||||
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).
|
|
||||||
|
|
||||||
@@ -1 +1 @@
|
|||||||
(c) 2002-2014 by Vladimir '3APA3A' Dubrovin <3proxy@3proxy.ru>
|
(c) 2002-2019 by Vladimir '3APA3A' Dubrovin <vlad@3proxy.ru>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
*.cfg
|
||||||
|
*.old
|
||||||
@@ -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 /usr/local/etc/3proxy/logs/3proxy.log D
|
#log /var/log/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
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
3proxy 0.7 Public License Agreement
|
3proxy 0.9 Public License Agreement
|
||||||
|
|
||||||
(c) 2000-2014 by 3APA3A (3APA3A@security.nnov.ru)
|
(c) 2000-2020 by 3APA3A (3APA3A@3proxy.ru)
|
||||||
(c) 2000-2014 by SecurityVulns.com (http://3proxy.ru/)
|
(c) 2000-2020 by 3proxy.org (https://3proxy.org/)
|
||||||
(c) 2000-2014 by Vladimir Dubrovin (vlad@sandy.ru)
|
(c) 2000-2020 by Vladimir Dubrovin (vlad@3proxy.ru)
|
||||||
|
|
||||||
This software uses:
|
|
||||||
RSA Data Security, Inc. MD4 Message-Digest Algorithm
|
|
||||||
RSA Data Security, Inc. MD5 Message-Digest Algorithm
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
@@ -39,7 +35,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
|
1. Apache License, Version 2.0 or (at your option) any later version
|
||||||
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
|
||||||
|
|||||||
+1
-162
@@ -1,163 +1,2 @@
|
|||||||
<h3>Why ... doesn't work?</h3>
|
|
||||||
|
|
||||||
<p><i>Q: Why does nothing work?</i></p>
|
<H2><A href="hotoe.html">See HowTo:</a></H2>
|
||||||
A: Valid configuration file is required.
|
|
||||||
|
|
||||||
<p><i>Q: Why restrictions (redirections, limits, etc) do not work?</i></p>
|
|
||||||
A: Most probable reasons: 'auth none' or no auth is used. For any ACL based feature one of 'iponly', 'nbname' or 'strong' auths required. Sequence of commands may be invalid. Commands are executed one-by-one and 'proxy', 'tcppm', 'socks' or another service commands must follow valid configuration. Invalid sequence of ACLs. First matching ACL is used (except of internal redirections, see below). If ACL contains at least one records last record is assumed to be 'deny *'.
|
|
||||||
|
|
||||||
<p><i>Q: Why doesn't 3proxy work as service under Windows?</i></p>
|
|
||||||
Possible reasons:
|
|
||||||
<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,
|
|
||||||
log files, etc. Always use absolute paths. For example
|
|
||||||
$"c:\3proxy\networks.local" instead of $networks.local. For debugging remove
|
|
||||||
'service' and 'daemon', log to stdout an try to execute 3proxy from command
|
|
||||||
line from some different directory (for example from disk root).
|
|
||||||
<li>SYSTEM account doesn't have access to executable file, configuration files,
|
|
||||||
log files, etc.
|
|
||||||
<li>configuration files is not located in default path (3proxy.cfg in same
|
|
||||||
location with 3proxy.exe). For alternative configuration file location use
|
|
||||||
<pre>
|
|
||||||
3proxy --install full_path_to_configuration_file
|
|
||||||
</pre>
|
|
||||||
<li>user has no rights to install or start service
|
|
||||||
<li>service is already installed and/or started
|
|
||||||
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<p><A NAME="INTEXT"><i>Q: Why doesn't internal and external commands work as expected</i></A></li></p>
|
|
||||||
A: Check your expectations first.
|
|
||||||
Both internal and external IPs are IPs of the host running 3proxy itself.
|
|
||||||
This configuration option is usefull in situation 3proxy is running on the
|
|
||||||
border host with 2 (or more) connections: e.g. LAN and WAN with different IPs
|
|
||||||
<pre>
|
|
||||||
LAN connection +-------------+ Internet connection
|
|
||||||
LAN <-------------->| 3proxy host |<-------------------> INTERNET
|
|
||||||
^+-------------+^
|
|
||||||
| |
|
|
||||||
Internal IP External IP
|
|
||||||
</pre>
|
|
||||||
If 3proxy is used on the host with single connection, both internal and
|
|
||||||
external are usually same IP.
|
|
||||||
<br>Internal should exist and be UP on the moment 3proxy is started and
|
|
||||||
should never be disconnected/DOWN. If this interface is periodically
|
|
||||||
disconnected (e.g. direct link between 2 hosts), do not specify internal
|
|
||||||
address or use 0.0.0.0 instead. In this case, if you have 2 or more
|
|
||||||
interfaces you must use firewall (preferably) or 3proxy ACLs to avoid open
|
|
||||||
proxy situation.
|
|
||||||
<br>
|
|
||||||
External IP (if specified) must exist in the momet 3proxy
|
|
||||||
serves client request. If external interface is no specified (or 0.0.0.0),
|
|
||||||
system select external IP. It may be possible to access resources of internal
|
|
||||||
network, to prevent this use ACLs. In addition, SOCKSv5 will not support BIND
|
|
||||||
operation, required for incoming connections (this operation is quite rarely
|
|
||||||
implemented in SOCKSv5 clients and usually is not required). In case of
|
|
||||||
dynamic address, do not specify external or use external 0.0.0.0 or, if
|
|
||||||
external address is required, create a script to determine current external
|
|
||||||
IP and save it to file, and use external "$path_to_file" with "monitor" command
|
|
||||||
to automatically reload configuration on address change.
|
|
||||||
|
|
||||||
<p><i>Q: Why doesn't ODBC loggind work?</i></p>
|
|
||||||
A: Check you use system DSN.
|
|
||||||
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.
|
|
||||||
Under Unix, you may also want to adjust 'stacksize' parameter.
|
|
||||||
|
|
||||||
<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>
|
|
||||||
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.
|
|
||||||
|
|
||||||
<h3>Redirection to local proxy</h3>
|
|
||||||
|
|
||||||
<p><i>Q: What is it for?</i></p>
|
|
||||||
A: To have control based on request and to have URLs and another protocol specific parameters to be logged.
|
|
||||||
|
|
||||||
<p><i>Q: What are restrictions?</i></p>
|
|
||||||
A: It's hard to redirect services for non-default ports; Internet Explorer supports only SOCKSv4 with no password authentication (Internet Explorer sends username, but not password), for SOCKSv5 only cleartext password authentication is supported.
|
|
||||||
|
|
||||||
<p><i>Q: What are advantages?</i></p>
|
|
||||||
A: You need only to setup SOCKS proxy in browser settings. You can use socksifier, i.e. FreeCAP or SocksCAP with application which is not proxy aware.
|
|
||||||
|
|
||||||
<p><i>Q: How to setup?</i></p>
|
|
||||||
A: You should specify parent proxy with IP of 0.0.0.0 and port 0. Examples:
|
|
||||||
<pre>
|
|
||||||
auth iponly
|
|
||||||
allow * * * 80,8080-8088
|
|
||||||
parent 1000 http 0.0.0.0 0
|
|
||||||
allow * * * 80,8080-8088
|
|
||||||
#redirect ports 80 and 8080-8088 to local HTTP proxy
|
|
||||||
#Second allow is required, because ACLs are checked
|
|
||||||
#twice: first time by socks and second by http proxy.
|
|
||||||
|
|
||||||
allow * * * 21,2121
|
|
||||||
parent 1000 ftp 0.0.0.0 0
|
|
||||||
allow * * * 21,2121
|
|
||||||
#redirect ports 21 and 2121 to local
|
|
||||||
#ftp proxy
|
|
||||||
|
|
||||||
|
|
||||||
allow *
|
|
||||||
#allow rest of connections directly
|
|
||||||
|
|
||||||
socks
|
|
||||||
#now let socks server to start
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<p><i>Q: How it affects different ACL rules?</i></p>
|
|
||||||
A: After local redirections rules are applied again to protocol-level request. Redirection rule itself is skipped. It makes it possible to redirect request again on the external proxy depending on request itself.
|
|
||||||
<pre>
|
|
||||||
allow * * * 80,8080-8088
|
|
||||||
parent 1000 http 0.0.0.0 0
|
|
||||||
#redirect http traffic to internal proxy
|
|
||||||
|
|
||||||
allow * * $c:\3proxy\local.nets 80,8080-8088
|
|
||||||
#allow direct access to local.nets networks
|
|
||||||
allow * * * 80,8080-8088
|
|
||||||
parent 1000 http proxy.3proxy.ru 3128
|
|
||||||
#use parent caching proxy for rest of the networks
|
|
||||||
|
|
||||||
allow *
|
|
||||||
#allow direct connections for rest of socks
|
|
||||||
#requests
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h3>Can I ...?</h3>
|
|
||||||
|
|
||||||
<p><i>Q: Is it possible to resolve names through parent proxy?</i></p>
|
|
||||||
A: Yes, use 'proxy', 'connect+', 'socks4+' or 'socks5+' as parent proxy type.
|
|
||||||
3proxy itself requires name resolutions for ACL checks, so, if it's impossible
|
|
||||||
to resolve names from 3proxy host, use
|
|
||||||
<pre>
|
|
||||||
fakeresolve
|
|
||||||
</pre>
|
|
||||||
command. Fakeresolve resolves any name to 127.0.0.2.
|
|
||||||
|
|
||||||
|
|
||||||
<p><i>Q: Can I use 3proxy as FTP proxy?</i></p>
|
|
||||||
A: There are two kinds of FTP proxy supported: FTP over HTTP support (known as FTP proxy inside Internet Explorer, Mozilla and another browsers) and real FTP proxy (usable in Far and different FTP clients). Both are supported in 3proxy: first one as a part of HTTP 'proxy' and second one as 'ftppr'.
|
|
||||||
|
|
||||||
<p><i>Q: Can I bind any 3proxy service to non-default port?</i></p>
|
|
||||||
A: proxy -p8080
|
|
||||||
|
|
||||||
<h3>Why so ...?</h3>
|
|
||||||
|
|
||||||
<p><i>Q: Why traffic accounting is incomplete? It differs for what my provider (or another accounting application) shows to me?</i></p>
|
|
||||||
A: 3proxy accounts protocol level traffic. Provider counts channel or IP-level traffic with network and transport headers. In additions, 3proxy doesn't counts DNS resolutions, pings, floods, scans, etc. It makes approx. 10% of difference. That's why you should have 15% reserve if you use 3proxy to limit your traffic. If difference with your provider is significantly above 10% you should look for traffic avoiding proxy server, for example connections through NAT, traffic originated from the host with proxy installed, traffic from server applications, etc.
|
|
||||||
|
|
||||||
<p><i>Q: Why configuration is so difficult and non-intuitive?</i></p>
|
|
||||||
A: Configuration format is created in a way it's easy to parse and matches to internal 3proxy structures. In addition, there are some older things left for compatibility to be cleaned in 3proxy release. And last, I think it's easy and intuitive.
|
|
||||||
|
|
||||||
<p><i>Q: Why the code is so difficult and non-intuitive?</i></p>
|
|
||||||
A: First, I'm not programmer. Second, 3proxy was 'proof of concept' in reply for some conference post. Request was to write proxy server in 100 lines of code. First version of 3proxy had less, with HTTP and SOCKS support and portmappers. Third, there are peoples who want to use 3proxy code in trojans. I don't want to help them. Fourth, the aim is to support different platforms. It's well known - the worse code is, the better it compiles.
|
|
||||||
|
|
||||||
<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.
|
|
||||||
+2
-288
@@ -1,288 +1,2 @@
|
|||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
||||||
3APA3A 3proxy tiny proxy server Frequently Asked Questions (FAQ)
|
<H2><A href="hotoe.html">См. HowTo</a></H2>
|
||||||
<ul>
|
|
||||||
<li><a href="#TROUBLE">Почему не работает...</a></li>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#NOTHING">Q: Почему ничего не работает?</a></li>
|
|
||||||
<li><a href="#LIMITS">Q: Почему не работают ограничения доступа (перенаправления, ограничения по скорости, трафику и т.д.)?</a></li>
|
|
||||||
<li><a href="#SERVICE">Q: Почему 3proxy не запускается как служба?</a></li>
|
|
||||||
<li><a href="#INTEXT">Q: Почему не получается указать internal и external?</a></li>
|
|
||||||
<li><a href="#ODBC">Q: Почему не работает ведение журналов в ODBC?</a></li>
|
|
||||||
<li><a href="#CHAP">Q: Почему не поддерживаются APOP и CRAM-MD5 в POP3 прокси?</a></li>
|
|
||||||
<li><a href="#CRASH">Q: Почему прокси крэшится при обработке запроса?</a></li>
|
|
||||||
</ul>
|
|
||||||
<li><a href="#SOCKSREDIR">Перенаправление socks соединений в локальный прокси</a></li>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#REDIR">Q: Для чего это надо?</a></li>
|
|
||||||
<li><a href="#REDIRLIMIT">Q: Какие недостатки?</a></li>
|
|
||||||
<li><a href="#REDIRADV">Q: Какие преимущества?</a></li>
|
|
||||||
<li><a href="#REDIRHOW">Q: Как настраивается?</a></li>
|
|
||||||
<li><a href="#REDIINTER">Q: Как взаимодействует с другими правилами в ACL?</a></li>
|
|
||||||
</ul>
|
|
||||||
<li><a href="#ISIT">А есть ли...</a></li>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#NAMES">Можно ли разрешать имена на родительском прокси?</a></li>
|
|
||||||
<li><a href="#ISFTP">Существует ли сейчас поддержка FTP прокси в продукте?</a></li>
|
|
||||||
<li><a href="#PORT">Каким образом можно прибиндить сервисы на свой порт, к примеру, HTTP прокси к 8080, а не 3128 как по-умолчанию?</a></li>
|
|
||||||
<li><a href="#BANDLIM">Как ограничить ширину канала?</a></li>
|
|
||||||
</ul>
|
|
||||||
<li><a href="#BRRR">Почему так криво...</a></li>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#TRAF">Почему так криво считается трафик? Не совпадает с ...</a></li>
|
|
||||||
<li><a href="#CONFIG">Почему такая кривая конфигурация и ничерта не понятно?</a></li>
|
|
||||||
<li><a href="#CODE">Почему так криво написан код?</a>
|
|
||||||
<li><a href="#UNSAFE">Почему так много strcpy, sprintf и т.д., это ж дыры!</a>
|
|
||||||
</ul>
|
|
||||||
</ul>
|
|
||||||
<hr>
|
|
||||||
<li><b><a name="TROUBLE">Почему не работает...<a></b></li>
|
|
||||||
<ul>
|
|
||||||
<li><a name="NOTHING"><i>Q: Почему ничего не работает?</i></a></li>
|
|
||||||
<p>
|
|
||||||
<i>A:</i> Потому что для работы нужен правильный файл конфигурации.
|
|
||||||
</p>
|
|
||||||
<li><a name="LIMITS"><i>Q: Почему не работают ограничения доступа (перенаправления, ограничения по скорости,
|
|
||||||
трафику и т.д.)?</i></a></li>
|
|
||||||
<p>
|
|
||||||
<i>A:</i> Обычные ошибки - использование auth none (для работы любых
|
|
||||||
функций, основанных на ACL, требуется auth iponly, nbname или strong),
|
|
||||||
нарушение порядка ввода команд (команды выполняются последовательно,
|
|
||||||
запуск сервиса proxy, socks, tcppm и т.д. должен осуществляться после
|
|
||||||
того, как указана его конфигурация), неправильный порядок записей в ACL
|
|
||||||
(записи просматриваются последовательно до первой, удовлетворяющей
|
|
||||||
критериям). Если в ACL имеется хотя бы одна запись, то считается, что
|
|
||||||
последняя запись в ACL - это неявная deny *.
|
|
||||||
</p>
|
|
||||||
<li><a name="SERVICE"><i>Q: Почему 3proxy не запускается как служба?</i></a></li>
|
|
||||||
<p>
|
|
||||||
<i>A:</i> Наиболее вероятные причины:
|
|
||||||
<ul>
|
|
||||||
<li>Отсутствие команды service в файле конфигурации - команда необходима в 3proxy 0.5.2 и более ранних, чтобы 3proxy вел себя как системная служба Windows
|
|
||||||
<li>Использование относительных (неполных) путей файлов в файле конфигурации
|
|
||||||
При использовании файлов журналов, файлов вставок ($filename) используйте
|
|
||||||
полные пути, например, $"c:\3proxy\include files\networks.local". Тоже самое
|
|
||||||
относится к файлам журналов и любым другим.
|
|
||||||
Для отладки лучше запускать 3proxy с ведением журнала на стандартный вывод.
|
|
||||||
Не забудьте в таком случае отключить daemon и service в файле конфигурации.
|
|
||||||
Для чистоты эксперимента запускать 3proxy из коммандной строки в таком случае
|
|
||||||
следует, находясь в другой папке.
|
|
||||||
<li>Отсутствие у системной записи прав на доступ к исполняемому файлу, каким-либо файлам конфигурации, журнала и т.п.
|
|
||||||
<li>Отсутствие файла конфигурации по стандартному расположению -
|
|
||||||
3proxy.cfg в одном каталоге с исполняемым файлом. Если файл расположен по
|
|
||||||
другому пути, необходимо использовать команду
|
|
||||||
<pre>
|
|
||||||
3proxy --install path_to_configuration_file</pre>
|
|
||||||
<li>Отсутствие у пользователя прав на установку или запуск службы
|
|
||||||
<li>Служба уже установлена или запущена
|
|
||||||
</ul>
|
|
||||||
</p>
|
|
||||||
<li><a name="INTEXT"><i>Q: Почему не получается указать internal и external?</i></a></li></li>
|
|
||||||
<p>
|
|
||||||
<i>A:</i> Убедитесь, что выправильно понимаете что такое internal и external адреса.
|
|
||||||
Оба адреса - это адреса, принадлежищие хосту, на котором установлен 3proxy.
|
|
||||||
Эта опция конфигурации необходима в классической ситуации, когда 3proxy
|
|
||||||
установлен на граничном компьютере с двумя (или более) подключениями:
|
|
||||||
<pre>
|
|
||||||
LAN connection +-------------+ Internet connection
|
|
||||||
LAN <-------------->| 3proxy host |<-------------------> INTERNET
|
|
||||||
^+-------------+^
|
|
||||||
| |
|
|
||||||
Internal IP External IP</pre>
|
|
||||||
Если 3proxy работает на хосте с одним интерфейсом, то его адрес будет и
|
|
||||||
internal и external.
|
|
||||||
<br>Интерфейс с адресом internal должен существовать и быть рабочим на момент
|
|
||||||
запуска 3proxy, и не должен отключаться. Если internal интерфейс
|
|
||||||
периодически отключается, то не следует его указывать, или можно указать адрес
|
|
||||||
0.0.0.0. При этом прокси будет принимать запросы на всех интерфейсах, поэтому
|
|
||||||
при наличии нескольких интерфейсов для ограничения доступа следует использовать
|
|
||||||
фаервол или хотя бы ACL.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Интерфейс с адресом external, если он указан, должен быть рабочим на момент
|
|
||||||
получения запроса клиента. При отсутствии external или адресе 0.0.0.0 внешний
|
|
||||||
адрес будет выбираться системой при установке соединения. При этом, может быть
|
|
||||||
возможность доступа через прокси к ресурсам локальной сети, поэтому для
|
|
||||||
предотвращения несанкционированного доступа следует использовать ACL. Кроме
|
|
||||||
того, могут быть проблемы с приемом входящих соединений через SOCKSv5
|
|
||||||
(SOCKSv5 используется в клиентах исключительно редко).
|
|
||||||
В случае, если адрес динамический, можно либо не
|
|
||||||
указывать external, либо использовать адрес 0.0.0.0, либо, если необходима
|
|
||||||
поддержка входящих соединений в SOCKSv5, использовать скрипт,
|
|
||||||
который будет получать текущий адрес и сохранять его в файл, который будет
|
|
||||||
отслуживаться через команду monitor.
|
|
||||||
</p>
|
|
||||||
<li><a name="ODBC"><i>Q: Почему не работает ведение журналов в ODBC?</i></a></li>
|
|
||||||
<p>
|
|
||||||
<i>A:</i> Убедитесь, что используется системный, а не
|
|
||||||
пользовательский DSN. Убедитесь, что выполняется правильный SQL запрос. Наиболее
|
|
||||||
распространенная проблема связана с отсутствием кавычек или неправильным
|
|
||||||
форматом данных. Самый простой способ - сделать ведение журнала в файл или
|
|
||||||
на стандартный вывод, просмотреть выдаваемые SQL запросы и попробовать
|
|
||||||
дать такой запрос вручную.
|
|
||||||
</p>
|
|
||||||
<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.
|
|
||||||
</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>
|
|
||||||
<hr>
|
|
||||||
<li><b><a name="SOCKSREDIR">Перенаправление socks соединений в локальный прокси</a></b></li>
|
|
||||||
<ul>
|
|
||||||
<li><a name="REDIR"><i>Q: Для чего это надо?</i></a></li>
|
|
||||||
<p>
|
|
||||||
<i>A:</i> Чтобы иметь в логах URL запросов, если пользователь SOCKS пользуется
|
|
||||||
Web, FTP или POP3.
|
|
||||||
</p>
|
|
||||||
<li><a name="REDIRLIMIT"><i>Q: Какие недостатки?</i></a></li>
|
|
||||||
<p>
|
|
||||||
<i>A:</i> Перенапраление невозможно для web-серверов или FTP, висящих на
|
|
||||||
нестандартных портах, для SOCKSv4 не поддрживается авторизация с
|
|
||||||
паролем (IE поддерживает только SOCKSv4), но при этом IE передает
|
|
||||||
имя пользователя по SOCKSv4 (имя, с которым пользователь вошел в систему).
|
|
||||||
Для SOCKSv5 не поддерживается NTLM авторизация, пароли передаются в открытом
|
|
||||||
тексте.
|
|
||||||
</p>
|
|
||||||
<li><a name="REDIRADV"><i>Q: Какие преимущества?</i></a></li>
|
|
||||||
<p>
|
|
||||||
<i>A:</i> Достаточно в настройках IE только указать адрес SOCKS прокси. В
|
|
||||||
больших сетях можно для этого использовать WPAD (автоматическое
|
|
||||||
обнаружение прокси). В 3proxy достаточно запускать только одну службу
|
|
||||||
(socks). Если используется только Internet Explorer, то можно
|
|
||||||
автоматически получать имя пользователя в логах, не запрашивая
|
|
||||||
логин/пароль.
|
|
||||||
</p>
|
|
||||||
<li><a name="REDIRHOW"><i>Q: Как настраивается?</i></a></li>
|
|
||||||
<p>
|
|
||||||
<i>A:</i> Указывается parent http proxy со специальным адресом 0.0.0.0 и портом
|
|
||||||
0. Пример:
|
|
||||||
<pre>
|
|
||||||
allow * * * 80,8080-8088
|
|
||||||
parent 1000 http 0.0.0.0 0
|
|
||||||
allow * * * 80,8080-8088
|
|
||||||
#перенаправить соединения по портам 80 и 8080-8088 в локальный
|
|
||||||
#http прокси. Вторая команда allow необходима, т.к. контроль доступа
|
|
||||||
#осуществляется 2 раза - на уровне socks и на уровне HTTP прокси
|
|
||||||
allow * * * 21,2121
|
|
||||||
parent 1000 ftp 0.0.0.0 0
|
|
||||||
allow * * * 21,2121
|
|
||||||
#перенаправить соединения по портам 21 и 2121 в локальный
|
|
||||||
#ftp прокси
|
|
||||||
allow *
|
|
||||||
#пустить все соединения напрямую
|
|
||||||
socks</pre>
|
|
||||||
</p>
|
|
||||||
<li><a name="REDIINTER"><i>Q: Как взаимодействует с другими правилами в ACL?</i></a></li>
|
|
||||||
<p>
|
|
||||||
<i>A:</i> После внутреннего перенаправления правила рассматриваются еще раз за
|
|
||||||
исключением самого правила с перенаправлением (т.е. обработка правил не
|
|
||||||
прекращается). Это позволяет сделать дальнейшие перенаправления на
|
|
||||||
внешний прокси. По этой же причине локальное перенаправление не должно
|
|
||||||
быть последним правилом (т.е. должно быть еще хотя бы правило allow,
|
|
||||||
чтобы разрешить внешние соединения через HTTP прокси).
|
|
||||||
Например,
|
|
||||||
<pre>
|
|
||||||
allow * * * 80,8080-8088
|
|
||||||
parent 1000 http 0.0.0.0 0
|
|
||||||
#перенаправить во внутренний прокси
|
|
||||||
allow * * $c:\3proxy\local.nets 80,8080-8088
|
|
||||||
#разрешить прямой web-доступ к сетям из local.nets
|
|
||||||
allow * * * 80,8080-8088
|
|
||||||
parent 1000 http proxy.3proxy.ru 3128
|
|
||||||
#все остальные веб-запросы перенаправить на внешний прокси-сервер
|
|
||||||
allow *
|
|
||||||
#разрешить socks-запросы по другим портам</pre>
|
|
||||||
</p>
|
|
||||||
</ul>
|
|
||||||
<hr>
|
|
||||||
<li><b><a name="ISIT">А есть ли...</a></b></li>
|
|
||||||
<ul>
|
|
||||||
<li><a name="NAMES"><i>Q: Можно ли разрешать имена на родительском прокси?</i></a></li>
|
|
||||||
<p>
|
|
||||||
<i>A:</i> Можно. Для этого надо использовать тип родительского прокси http,
|
|
||||||
connect+, socks4+ и socks5+. Однако, при это надо помнить, что самому 3proxy
|
|
||||||
требуется разрешение имени для управления ACL. Поэтому, если с прокси-хоста
|
|
||||||
не работают разрешения имени, необходимо в конфигурации дать команду
|
|
||||||
<pre>
|
|
||||||
fakeresolve</pre>
|
|
||||||
которая разрешает любое имя в адрес 127.0.0.2.
|
|
||||||
</p>
|
|
||||||
<li><a name="ISFTP"><i>Q: Существует ли сейчас поддержка FTP прокси в продукте?</i></a></li>
|
|
||||||
<p>
|
|
||||||
Есть поддержка как FTP через HTTP (то, что называется FTP прокси в Internet
|
|
||||||
Explorer, Netscape, Opera) так и настоящего FTP прокси (то, что называется
|
|
||||||
FTP proxy в FAR и FTP клиентах).
|
|
||||||
</p>
|
|
||||||
<li><a name="PORT"><i>Q: Каким образом можно прибиндить сервисы на свой порт, к примеру, HTTP прокси к 8080, а не 3128 как по-умолчанию?</i></a></li>
|
|
||||||
<p>
|
|
||||||
А:
|
|
||||||
<pre>
|
|
||||||
proxy -p8080</pre>
|
|
||||||
</p>
|
|
||||||
<li><a name="BANDLIM"><i>Q: Как ограничить ширину канала?</i></a></li>
|
|
||||||
<p>
|
|
||||||
<i>A:</i> Читайте HowTo <a href="http://3proxy.ru/howtor.asp#BANDLIM">http://3proxy.ru/howtor.asp#BANDLIM</a>
|
|
||||||
</p>
|
|
||||||
</ul>
|
|
||||||
<hr>
|
|
||||||
<li><b><a name="BRRR">Почему так криво...</a></b></li>
|
|
||||||
<ul>
|
|
||||||
<li><a name="TRAF"><i>Q: Почему так криво считается трафик? Не совпадает с ...</i></a></li>
|
|
||||||
<p>
|
|
||||||
<i>A:</i> Следует учитывать, что 3proxy считает трафик только на прикладном уровне и
|
|
||||||
только проходящий через прокси-сервер. Провайдеры и другие средства учета
|
|
||||||
трафика считают трафик на сетевом уровне, что уже дает расхождение порядка 10%
|
|
||||||
за счет информации из заголовков пакетов. Кроме того, часть трафика, как
|
|
||||||
минимум DNS-разрешения, различный флудовый трафик и т.д. идут мимо прокси.
|
|
||||||
Уровень "шумового" трафика в Internet сейчас составляет порядка 50KB/день на
|
|
||||||
каждый реальный IP адрес, но может сильно варьироваться в зависимости от сети,
|
|
||||||
наличия открытых портов, реакции на ping-запросы и текущего уровня вирусной
|
|
||||||
активности. По этим причинам, если 3proxy используется чтобы не "выжрать"
|
|
||||||
трафик, выделенный провайдером, всегда следует делать некий запас порядка
|
|
||||||
15%.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Если на одной с 3proxy машине имеются какие-либо сервисы или
|
|
||||||
работает пользователь, то их трафик не проходит через proxy-сервер и так же
|
|
||||||
не будет учтен. Если где-то есть NAT, то клиенты, выходящие через NAT мимо
|
|
||||||
прокси, так же останутся неучтенными. Если расхождение с провайдером превышает
|
|
||||||
10% - нужно искать причину именно в этом.
|
|
||||||
</p>
|
|
||||||
<li><a name="CONFIG"><i>Q: Почему такая кривая конфигурация и ничерта не понятно?</i></a></li>
|
|
||||||
<p>
|
|
||||||
<i>A:</i> Есть несколько причин. Во-первых, до выхода релиза (т.е. версии 1.0) я буду изо
|
|
||||||
всех сил добиваться совместимости конфигурации между версиями. Во-вторых,
|
|
||||||
конфигурация сделана так, чтобы ее можно было легко разбирать программно.
|
|
||||||
В-третьих, все там понятно. При желании. Если знать как все работает.
|
|
||||||
</p>
|
|
||||||
<li><a name="CODE"><i>Q: Почему так криво написан код?</i></a></li>
|
|
||||||
<p>
|
|
||||||
<i>A:</i> Есть несколько причин. Во-первых, я не программист. Во-вторых, 3proxy изначально
|
|
||||||
писался на коленке (в отет на "слабо" в одной из конференций). Никто
|
|
||||||
не мог предположить, что им кто-то реально будет пользоваться. В-третьих, у многих
|
|
||||||
возникает желание разобраться в коде 3proxy чтобы внедрить его в какой-нибудь
|
|
||||||
троян. Очень не хочется облегчать эту задачу. В-четвертых, мне надо добиться
|
|
||||||
компиляции кода в как можно большем числе систем. Замечено, что чем кривее код в
|
|
||||||
C, тем он лучше переносится.
|
|
||||||
</p>
|
|
||||||
<li><a name="UNSAFE"><i>Q: Почему так много strcpy, sprintf и т.д., это ж дыры!</i></a><li>
|
|
||||||
<p>
|
|
||||||
<i>A:</i> Есть несколько причин. Во-первых, несмотря на дурной тон использования этих
|
|
||||||
функций, они наиболее совместимы между разными системами и компиляторами.
|
|
||||||
Во-вторых, само по себе их использование не означает присутствие дыры, если их
|
|
||||||
параметры должным образом контролируются. Найдете дыру - обязательно сообщите.
|
|
||||||
В третьих, может быть я уберу их перед конечным релизом, чтобы никого не
|
|
||||||
пугать.
|
|
||||||
</p>
|
|
||||||
</ul>
|
|
||||||
@@ -0,0 +1,287 @@
|
|||||||
|
<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.
|
||||||
+184
-39
@@ -8,7 +8,6 @@
|
|||||||
<li><A HREF="#INTL">How to compile 3proxy with Intel C Compiler under Windows</A>
|
<li><A HREF="#INTL">How to compile 3proxy with Intel C Compiler under Windows</A>
|
||||||
<li><A HREF="#GCCWIN">How to compile 3proxy with GCC under Windows</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>
|
||||||
<li><A HREF="#CCCUNIX">How to compile 3proxy with Compaq C Compiler 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>
|
||||||
@@ -18,20 +17,31 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<li><A HREF="#SERVER">Server configuration</A>
|
<li><A HREF="#SERVER">Server configuration</A>
|
||||||
<ul>
|
<ul>
|
||||||
<li><A HREF="#SAMPLE">Where to find configuration example</A>
|
<li><a href="#NOTHING">How to make 3proxy start</a></li>
|
||||||
|
<li><a href="#LIMITS">How to make limitation (access, bandwidth, traffic, connections) work</a></li>
|
||||||
|
<li><a href="#SERVICE">How to make 3proxy to run as a service</a></li>
|
||||||
|
<li><a href="#INTEXT">How to understand internal ¨ external</a></li>
|
||||||
|
<li><a href="#ODBC">How to make ODBC logging work?</a></li>
|
||||||
|
<li><a href="#IPV6">How to make IPv6 work</a></li>
|
||||||
|
<li><a href="#CRASH">How to fix 3proxy crashes</a></li>
|
||||||
|
<li><A HREF="#SAMPLE">Where to find configuration example</A>
|
||||||
<li><A HREF="#LOGGING">How to set up logging</A>
|
<li><A HREF="#LOGGING">How to set up logging</A>
|
||||||
<li><A HREF="#LOGFORMAT">How to setup logging format</A>
|
<li><A HREF="#LOGFORMAT">How to setup logging format</A>
|
||||||
<li><A HREF="#LOGANALIZERS">How to use log analizers with 3proxy</A>
|
<li><A HREF="#LOGANALIZERS">How to use log analizers with 3proxy</A>
|
||||||
<li><A HREF="#LAUNCH">How to start any of proxy services (HTTP, SOCKS etc)</A>
|
<li><A HREF="#LAUNCH">How to start any of proxy services (HTTP, SOCKS etc)</A>
|
||||||
<li><A HREF="#BIND">How to bind service to specific interface and port?</A>
|
<li><a href="#BIND">How to bind service to specific interface or port</a>
|
||||||
|
<li><a href="#NAMES">How to resolve names through a parent proxy</a></li>
|
||||||
|
<li><a href="#ISFTP">How to setup FTP proxy</a></li>
|
||||||
<li><A HREF="#AUTH">How to limit service access</A>
|
<li><A HREF="#AUTH">How to limit service access</A>
|
||||||
<li><A HREF="#USERS">How to create user list</A>
|
<li><A HREF="#USERS">How to create user list</A>
|
||||||
<li><A HREF="#ACL">How to limit user access to resources</A>
|
<li><A HREF="#ACL">How to limit user access to resources</A>
|
||||||
<li><A HREF="#REDIR">How to manage redirections</A>
|
<li><A HREF="#REDIR">How to manage redirections</A>
|
||||||
|
<li><a href="#SOCKSREDIR">How to manage local redirections</a>
|
||||||
<li><A HREF="#ROUNDROBIN">How to balance traffic between few external channgels?</A>
|
<li><A HREF="#ROUNDROBIN">How to balance traffic between few external channgels?</A>
|
||||||
<li><A HREF="#CHAIN">How to manage proxy chains</A>
|
<li><A HREF="#CHAIN">How to manage proxy chains</A>
|
||||||
<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="#TRAF">How to fix incorrect traffic accounting</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="#NSCACHING">How to configure name resolution and DNS caching</a>
|
||||||
<li><a href="#IPV6">How to use IPv6</a>
|
<li><a href="#IPV6">How to use IPv6</a>
|
||||||
@@ -84,12 +94,6 @@ shouldn't have problems under different Solaris, BSD or linux compatible systems
|
|||||||
For different systems you may be required to patch Makefile or even source codes.
|
For different systems you may be required to patch Makefile or even source codes.
|
||||||
If you want to use ODBC support, make sure to install ODBC for unix, remove -DNOODBC
|
If you want to use ODBC support, make sure to install ODBC for unix, remove -DNOODBC
|
||||||
option from makefile compiler options and add ODBC library to linker variable.
|
option from makefile compiler options and add ODBC library to linker variable.
|
||||||
</p>
|
|
||||||
</ul>
|
|
||||||
<hr>
|
|
||||||
<li><A NAME="CCCUNIX">How to compile 3proxy with Compaq C Compiler under Unix/Linux</A></li>
|
|
||||||
<p>
|
|
||||||
See <A HREF="#GCCUNIX">How to compile 3proxy with GCC under Unix/Linux</A>, use Makefile.ccc instead of Makefile.unix.
|
|
||||||
</p>
|
</p>
|
||||||
</ul>
|
</ul>
|
||||||
<hr>
|
<hr>
|
||||||
@@ -164,6 +168,83 @@ Add 3proxy to system startup scripts.
|
|||||||
<li><A NAME="SERVER">Server configuration</A>
|
<li><A NAME="SERVER">Server configuration</A>
|
||||||
<p>
|
<p>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li><a name="NOTHING">How to make 3proxy start</a>
|
||||||
|
<p>Valid configuration file is required.
|
||||||
|
|
||||||
|
<li><a name="IMITS">How to make limitation (access, bandwidth, traffic, connections) work</a>
|
||||||
|
<p> Most probable reasons for non-working limitations: 'auth none' or no auth is used. For any ACL based feature one of 'iponly', 'nbname' or 'strong' auths required. Sequence of commands may be invalid. Commands are executed one-by-one and 'proxy', 'tcppm', 'socks' or another service commands must follow valid configuration. Invalid sequence of ACLs. First matching ACL is used (except of internal redirections, see below). If ACL contains at least one records last record is assumed to be 'deny *'.
|
||||||
|
|
||||||
|
<li><a name="SERVICE">How to make 3proxy to run as a service</a>
|
||||||
|
<p>Possible reasons for 3proxy starts manually but fails to start as a service:
|
||||||
|
<ul>
|
||||||
|
<li>there are relative paths in configuration file for included files,
|
||||||
|
log files, etc. Always use absolute paths. For example
|
||||||
|
$"c:\3proxy\networks.local" instead of $networks.local. For debugging remove
|
||||||
|
'service' and 'daemon', log to stdout an try to execute 3proxy from command
|
||||||
|
line from some different directory (for example from disk root).
|
||||||
|
<li>SYSTEM account doesn't have access to executable file, configuration files,
|
||||||
|
log files, etc.
|
||||||
|
<li>configuration files is not located in default path (3proxy.cfg in same
|
||||||
|
location with 3proxy.exe). For alternative configuration file location use
|
||||||
|
<pre>
|
||||||
|
3proxy --install full_path_to_configuration_file
|
||||||
|
</pre>
|
||||||
|
<li>user has no rights to install or start service
|
||||||
|
<li>service is already installed and/or started
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<p><A NAME="INTEXT">How to understant internal and external</A>
|
||||||
|
<p>
|
||||||
|
Both internal and external IPs are IPs of the host running 3proxy itself.
|
||||||
|
This configuration option is usefull in situation 3proxy is running on the
|
||||||
|
border host with 2 (or more) connections: e.g. LAN and WAN with different IPs
|
||||||
|
<pre>
|
||||||
|
LAN connection +-------------+ Internet connection
|
||||||
|
LAN <-------------->| 3proxy host |<-------------------> INTERNET
|
||||||
|
^+-------------+^
|
||||||
|
| |
|
||||||
|
Internal IP External IP
|
||||||
|
</pre>
|
||||||
|
If 3proxy is used on the host with single connection, both internal and
|
||||||
|
external are usually same IP.
|
||||||
|
<br>Internal should exist and be UP on the moment 3proxy is started and
|
||||||
|
should never be disconnected/DOWN. If this interface is periodically
|
||||||
|
disconnected (e.g. direct link between 2 hosts), do not specify internal
|
||||||
|
address or use 0.0.0.0 instead. In this case, if you have 2 or more
|
||||||
|
interfaces you must use firewall (preferably) or 3proxy ACLs to avoid open
|
||||||
|
proxy situation.
|
||||||
|
<br>
|
||||||
|
External IP (if specified) must exist in the momet 3proxy
|
||||||
|
serves client request. If external interface is no specified (or 0.0.0.0),
|
||||||
|
system select external IP. It may be possible to access resources of internal
|
||||||
|
network, to prevent this use ACLs. In addition, SOCKSv5 will not support BIND
|
||||||
|
operation, required for incoming connections (this operation is quite rarely
|
||||||
|
implemented in SOCKSv5 clients and usually is not required). In case of
|
||||||
|
dynamic address, do not specify external or use external 0.0.0.0 or, if
|
||||||
|
external address is required, create a script to determine current external
|
||||||
|
IP and save it to file, and use external "$path_to_file" with "monitor" command
|
||||||
|
to automatically reload configuration on address change.
|
||||||
|
|
||||||
|
<li><a name="ODBC">How to make ODBC logging work?</a>
|
||||||
|
<p>
|
||||||
|
Check you use system DSN.
|
||||||
|
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.
|
||||||
|
Under Unix, you may also want to adjust 'stacksize' parameter.
|
||||||
|
|
||||||
|
<li><a name="IPV6">How to make IPv6 work</a>
|
||||||
|
<p> 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.
|
||||||
|
|
||||||
|
<li><a name="CRASH">How to fix 3proxy crashes</a>
|
||||||
|
<p> 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.
|
||||||
|
|
||||||
|
|
||||||
<li><A NAME="SAMPLE">Where to find configuration example</A>
|
<li><A NAME="SAMPLE">Where to find configuration example</A>
|
||||||
<p>
|
<p>
|
||||||
Server configuration example 3proxy.cfg.sample is in any 3proxy distribution.
|
Server configuration example 3proxy.cfg.sample is in any 3proxy distribution.
|
||||||
@@ -219,7 +300,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>‘, minutely
|
<li>C, minutely
|
||||||
</ul>
|
</ul>
|
||||||
<pre>
|
<pre>
|
||||||
rotate NUMBER
|
rotate NUMBER
|
||||||
@@ -280,7 +361,7 @@ 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.ru/ 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.org/ HTTP/1.1
|
||||||
</font>
|
</font>
|
||||||
<br>(no line breaks)
|
<br>(no line breaks)
|
||||||
</p>
|
</p>
|
||||||
@@ -382,6 +463,22 @@ proxy -p8080 -i192.168.1.1
|
|||||||
proxy -p8080 -i192.168.2.1
|
proxy -p8080 -i192.168.2.1
|
||||||
</pre>
|
</pre>
|
||||||
</p>
|
</p>
|
||||||
|
<li><a name="NAMES">How to resolve names through a parent proxy</a></li>
|
||||||
|
<p>
|
||||||
|
<i>A:</i> Use one of proxy, connect+, socks4+ or socks5+ as a parent type. 3proxy
|
||||||
|
itself still performs a name resolution, it's required e.g. to ACLs matching.
|
||||||
|
So, if no name resolution must be performed by 3proxy itself add a command
|
||||||
|
<pre>
|
||||||
|
fakeresolve</pre>
|
||||||
|
this command resolves any name to 127.0.0.2 address.
|
||||||
|
</p>
|
||||||
|
<li><a name="ISFTP"><i>How to setup FTP proxy</i></a></li>
|
||||||
|
<p>
|
||||||
|
There is FTP over HTTP (what is called FTP proxy in browsers) and FTP over FTP ¯à®ªá¨
|
||||||
|
(what is called FTP proxy in file managers and FTP clients). For browsers, there is no need to start additional
|
||||||
|
proxy service, 'proxy' supports FTP over HTTP, configure 'proxy' port as an FTP proxy. For ftp clients and file
|
||||||
|
managers use ftppr. FTP proxy supports both active and passive mode with client, but always use passive mode with FTP servers.
|
||||||
|
</p>
|
||||||
<li><A NAME="AUTH">How to limit service access</A>
|
<li><A NAME="AUTH">How to limit service access</A>
|
||||||
<p>
|
<p>
|
||||||
First, always specify internal interface to accept incoming connection with
|
First, always specify internal interface to accept incoming connection with
|
||||||
@@ -461,7 +558,12 @@ 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.
|
||||||
@@ -513,7 +615,7 @@ allow <userlist> <sourcelist> <targetlist> <targetportlist&
|
|||||||
'flush' command is used to finish with existing ACL and to start new one.
|
'flush' command is used to finish with existing ACL and to start new one.
|
||||||
It's required to have different ACLs for different services.
|
It's required to have different ACLs for different services.
|
||||||
'allow' is used to allow connection and 'deny' to deny connection. 'allow'
|
'allow' is used to allow connection and 'deny' to deny connection. 'allow'
|
||||||
command can be extended by 'parent' command to manage redirections (see <A NAME="REDIR">How to manage redirections</A>)). If ACL
|
command can be extended by 'parent' command to manage redirections (see <A href="#REDIR">How to manage redirections</A>)). If ACL
|
||||||
is empty it allow everything. If ACL is not empty, first matching ACL entry
|
is empty it allow everything. If ACL is not empty, first matching ACL entry
|
||||||
is searched for user request and ACL action (allow or deny) performed. If
|
is searched for user request and ACL action (allow or deny) performed. If
|
||||||
no matching record found, connection is denied and user will be asked to
|
no matching record found, connection is denied and user will be asked to
|
||||||
@@ -602,6 +704,60 @@ no need to run these services expicitly. Local redirections are usefull if
|
|||||||
you want to see and control via ACLs protocol specific parameters, e.g.
|
you want to see and control via ACLs protocol specific parameters, e.g.
|
||||||
filenames requests thorugh FTP while clients are using SOCKS.
|
filenames requests thorugh FTP while clients are using SOCKS.
|
||||||
</p>
|
</p>
|
||||||
|
<li><a name="SOCKSREDIR">Š ª ã¯à ¢«ïâì «®ª «ì묨 ¯¥à¥ ¯à ¢«¥¨ï¬¨</a>
|
||||||
|
<p>
|
||||||
|
<p><i>Q: What is it for?</i></p>
|
||||||
|
A: To have control based on request and to have URLs and another protocol specific parameters to be logged.
|
||||||
|
|
||||||
|
<p><i>Q: What are restrictions?</i></p>
|
||||||
|
A: It's hard to redirect services for non-default ports; Internet Explorer supports only SOCKSv4 with no password authentication (Internet Explorer sends username, but not password), for SOCKSv5 only cleartext password authentication is supported.
|
||||||
|
|
||||||
|
<p><i>Q: What are advantages?</i></p>
|
||||||
|
A: You need only to setup SOCKS proxy in browser settings. You can use socksifier, i.e. FreeCAP or SocksCAP with application which is not proxy aware.
|
||||||
|
|
||||||
|
<p><i>Q: How to setup?</i></p>
|
||||||
|
A: You should specify parent proxy with IP of 0.0.0.0 and port 0. Examples:
|
||||||
|
<pre>
|
||||||
|
auth iponly
|
||||||
|
allow * * * 80,8080-8088
|
||||||
|
parent 1000 http 0.0.0.0 0
|
||||||
|
allow * * * 80,8080-8088
|
||||||
|
#redirect ports 80 and 8080-8088 to local HTTP proxy
|
||||||
|
#Second allow is required, because ACLs are checked
|
||||||
|
#twice: first time by socks and second by http proxy.
|
||||||
|
|
||||||
|
allow * * * 21,2121
|
||||||
|
parent 1000 ftp 0.0.0.0 0
|
||||||
|
allow * * * 21,2121
|
||||||
|
#redirect ports 21 and 2121 to local
|
||||||
|
#ftp proxy
|
||||||
|
|
||||||
|
|
||||||
|
allow *
|
||||||
|
#allow rest of connections directly
|
||||||
|
|
||||||
|
socks
|
||||||
|
#now let socks server to start
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<p><i>Q: How it affects different ACL rules</i></p>
|
||||||
|
A: After local redirections rules are applied again to protocol-level request. Redirection rule itself is skipped. It makes it possible to redirect request again on the external proxy depending on request itself.
|
||||||
|
<pre>
|
||||||
|
allow * * * 80,8080-8088
|
||||||
|
parent 1000 http 0.0.0.0 0
|
||||||
|
#redirect http traffic to internal proxy
|
||||||
|
|
||||||
|
allow * * $c:\3proxy\local.nets 80,8080-8088
|
||||||
|
#allow direct access to local.nets networks
|
||||||
|
allow * * * 80,8080-8088
|
||||||
|
parent 1000 http proxy.3proxy.org 3128
|
||||||
|
#use parent caching proxy for rest of the networks
|
||||||
|
|
||||||
|
allow *
|
||||||
|
#allow direct connections for rest of socks
|
||||||
|
#requests
|
||||||
|
</pre>
|
||||||
|
|
||||||
<li><A NAME="ROUNDROBIN">How to balance traffic between few external channgels?</A>
|
<li><A NAME="ROUNDROBIN">How to balance traffic between few external channgels?</A>
|
||||||
<p>
|
<p>
|
||||||
Proxy itself doesn't manage network level routing. The only way to control
|
Proxy itself doesn't manage network level routing. The only way to control
|
||||||
@@ -717,30 +873,9 @@ reportpath specifies location of text reports, type parameter of 'counter'
|
|||||||
command controls how often text reports are created. amount is amount of
|
command controls how often text reports are created. amount is amount of
|
||||||
allowed traffic in Megabytes (MB). nocountin allows you to set exclusions.
|
allowed traffic in Megabytes (MB). nocountin allows you to set exclusions.
|
||||||
</p>
|
</p>
|
||||||
<li><A NAME="NETLIST">How to build network lists</A>
|
<li><a name="TRAF"><i>How to fix incorrect traffic accounting</i></a>
|
||||||
<p>Networks or users lists are often very huge. 3proxy doesn't currently
|
|
||||||
supports user groups, but ones can be created by the means of include files.
|
<p>3proxy accounts protocol level traffic. Provider counts channel or IP-level traffic with network and transport headers. In additions, 3proxy doesn't counts DNS resolutions, pings, floods, scans, etc. It makes approx. 10% of difference. That's why you should have 15% reserve if you use 3proxy to limit your traffic. If difference with your provider is significantly above 10% you should look for traffic avoiding proxy server, for example connections through NAT, traffic originated from the host with proxy installed, traffic from server applications, etc.
|
||||||
You can store comma-delimited lists of networks or users in the separate
|
|
||||||
file and use $ macro to insert this list into 3proxy.cfg.
|
|
||||||
3proxy comes with 'dighosts'
|
|
||||||
utility. This utility helps to grab the list of the network from HTTP page.
|
|
||||||
It may be usefull to e.g. obtain a regullary updated list of local networks
|
|
||||||
from ISP's server. A network list can be either in form of NETWORK MASK,
|
|
||||||
e.g. 192.168.1.0 255.255.255.0 or NETWORK/LENGTH, e.g. 192.168.1.0/24. You can
|
|
||||||
launch dighosts from 3proxy.cfg to be executed on every 3proxy startup or
|
|
||||||
configuration reload:
|
|
||||||
<pre>
|
|
||||||
system "dighosts http://provider/network.html local.networks"
|
|
||||||
allow * * $local.networks
|
|
||||||
allow *
|
|
||||||
parent 1000 proxy.provider 3128 *
|
|
||||||
proxy
|
|
||||||
flush
|
|
||||||
</pre>
|
|
||||||
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
|
|
||||||
connection to external networks to provider's proxy.
|
|
||||||
</p>
|
|
||||||
<li><a name="NSCACHING"><i>How to configure name resolution and DNS caching</i></a>
|
<li><a name="NSCACHING"><i>How to configure name resolution and DNS caching</i></a>
|
||||||
<p>
|
<p>
|
||||||
For name resolution and caching use commands nserver, nscache / nscache6 and nsrecord.
|
For name resolution and caching use commands nserver, nscache / nscache6 and nsrecord.
|
||||||
@@ -812,7 +947,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.ru/">here</A>.
|
<A HREF="http://3proxy.org/">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.
|
||||||
@@ -865,6 +1000,16 @@ 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
|
||||||
@@ -888,7 +1033,7 @@ 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="http://3proxy.ru/board4.html">3proxy forum</A>.
|
Ask it in <A HREF="https://github.com/z3APA3A/3proxy/issues">Github</A>.
|
||||||
Don't try to ask something before reading this document.
|
Don't try to ask something before reading this document.
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|||||||
+233
-44
@@ -1,5 +1,5 @@
|
|||||||
3APA3A 3proxy tiny proxy server HowTo
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
3APA3A 3proxy tiny proxy server HowTo
|
||||||
<br>В стадии разработки
|
<br>В стадии разработки
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#COMPILE">Компиляция</a>
|
<li><a href="#COMPILE">Компиляция</a>
|
||||||
@@ -18,25 +18,34 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<li><a href="#SERVER">Конфигурация сервера</a>
|
<li><a href="#SERVER">Конфигурация сервера</a>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li><a href="#NOTHING">Как заставить 3proxy запускаться</a></li>
|
||||||
|
<li><a href="#LIMITS">Как заставить ограничения (по ширине канала, трафику, ACL и. т.п.) работать</a></li>
|
||||||
|
<li><a href="#SERVICE">Как заставить 3proxy запускаться как службу</a></li>
|
||||||
|
<li><a href="#INTEXT">Как разобраться с internal и external</a></li>
|
||||||
|
<li><a href="#ODBC">Как починить ведение журналов в ODBC?</a></li>
|
||||||
|
<li><a href="#IPV6">Как заставить IPv6 работать</a></li>
|
||||||
|
<li><a href="#CRASH">Как сделать чтобы 3proxy не крешился</a></li>
|
||||||
<li><a href="#SAMPLE">Как посмотреть пример файла конфигурации</a>
|
<li><a href="#SAMPLE">Как посмотреть пример файла конфигурации</a>
|
||||||
<li><a href="#LOGGING">Как настроить ведение журнала</a>
|
<li><a href="#LOGGING">Как настроить ведение журнала</a>
|
||||||
<li><a href="#LOGFORMAT">Как настроить формат журнала</a>
|
<li><a href="#LOGFORMAT">Как настроить формат журнала</a>
|
||||||
<li><a href="#LOGANALIZERS">Как использовать лог-анализаторы с 3proxy</a>
|
<li><a href="#LOGANALIZERS">Как использовать лог-анализаторы с 3proxy</a>
|
||||||
<li><a href="#LAUNCH">Как запустить конкретную службу (HTTP, SOCKS и т.д)</a>
|
<li><a href="#LAUNCH">Как запустить конкретную службу (HTTP, SOCKS и т.д)</a>
|
||||||
<li><a href="#BIND">Как повесить службу на определенный интерфейс или порт</a>
|
<li><a href="#BIND">Как повесить службу на определенный интерфейс или порт</a>
|
||||||
|
<li><a href="#NAMES">Как разрешать имена на родительском прокси?</a></li>
|
||||||
|
<li><a href="#ISFTP">Как настроить FTP прокси?</a></li>
|
||||||
<li><a href="#AUTH">Как ограничить доступ к службе</a>
|
<li><a href="#AUTH">Как ограничить доступ к службе</a>
|
||||||
<li><a href="#USERS">Как создать список пользователей</a>
|
<li><a href="#USERS">Как создать список пользователей</a>
|
||||||
<li><a href="#ACL">Как ограничить доступ пользователей к ресурсам</a>
|
<li><a href="#ACL">Как ограничить доступ пользователей к ресурсам</a>
|
||||||
<li><a href="#REDIR">Как управлять перенаправлениями</a>
|
<li><a href="#REDIR">Как управлять перенаправлениями</a>
|
||||||
|
<li><a href="#SOCKSREDIR">Как управлять локальными перенаправлениями</a>
|
||||||
<li><a href="#ROUNDROBIN">Как организовать балансировку между несколькими каналами</a>
|
<li><a href="#ROUNDROBIN">Как организовать балансировку между несколькими каналами</a>
|
||||||
<li><a href="#CHAIN">Как составлять цепочки прокси</a>
|
<li><a href="#CHAIN">Как составлять цепочки прокси</a>
|
||||||
<li><a href="#BANDLIM">Как ограничивать скорости приема</a>
|
<li><a href="#BANDLIM">Как ограничивать скорости приема</a>
|
||||||
<li><a href="#TRAFLIM">Как ограничивать объем принимаемого трафика</a>
|
<li><a href="#TRAFLIM">Как ограничивать объем принимаемого трафика</a>
|
||||||
<li><a href="#NETLIST">Как строить списки сетей</a>
|
<li><a href="#TRAF">Как пофиксить некорректный подсчет трафика</a></li>
|
||||||
<li><a href="#NSCACHING">Как управлять разрешением имен и кэшированием DNS</a>
|
<li><a href="#NSCACHING">Как управлять разрешением имен и кэшированием DNS</a>
|
||||||
<li><a href="#IPV6">Как использовать IPv6</a>
|
<li><a href="#IPV6">Как использовать IPv6</a>
|
||||||
<li><a href="#CONNBACK">Как использовать connect back</a>
|
<li><a href="#CONNBACK">Как использовать connect back</a>
|
||||||
<li><a href="#DEMANDDIAL">Как устанавливать соединение по требованию</a>
|
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="#CLIENT">Конфигурация и настройка клиентов</a>
|
<li><a href="#CLIENT">Конфигурация и настройка клиентов</a>
|
||||||
<ul>
|
<ul>
|
||||||
@@ -172,6 +181,101 @@
|
|||||||
<li><a name="SERVER"><b>Конфигурация сервера</b></a>
|
<li><a name="SERVER"><b>Конфигурация сервера</b></a>
|
||||||
<p>
|
<p>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li><a name="NOTHING">Как заставить прокси работать</a></li>
|
||||||
|
<p>
|
||||||
|
Для работы требуется корректный файл конфигурации. Если прокси не запускается, значит в конфигурации есть ошибка.
|
||||||
|
</p>
|
||||||
|
<li><a name="LIMITS">Как заставить работать ограничения (контроль доступа, ограничения ширины канала, счетчики и т.п.)</a></li>
|
||||||
|
<p>
|
||||||
|
<i>A:</i> Обычные ошибки - использование auth none (для работы любых
|
||||||
|
функций, основанных на ACL, требуется auth iponly, nbname или strong),
|
||||||
|
нарушение порядка ввода команд (команды выполняются последовательно,
|
||||||
|
запуск сервиса proxy, socks, tcppm и т.д. должен осуществляться после
|
||||||
|
того, как указана его конфигурация), неправильный порядок записей в ACL
|
||||||
|
(записи просматриваются последовательно до первой, удовлетворяющей
|
||||||
|
критериям). Если в ACL имеется хотя бы одна запись, то считается, что
|
||||||
|
последняя запись в ACL - это неявная deny *.
|
||||||
|
</p>
|
||||||
|
<li><a name="SERVICE">Как починить запуск 3proxy службой</a></li>
|
||||||
|
<p>
|
||||||
|
Чаще всего 3proxy не запускается службой (но запускается вручную) по одной из следующих причин:
|
||||||
|
<ul>
|
||||||
|
<li>Использование относительных (неполных) путей файлов в файле конфигурации
|
||||||
|
При использовании файлов журналов, файлов вставок ($filename) используйте
|
||||||
|
полные пути, например, $"c:\3proxy\include files\networks.local". Тоже самое
|
||||||
|
относится к файлам журналов и любым другим.
|
||||||
|
Для отладки лучше запускать 3proxy с ведением журнала на стандартный вывод.
|
||||||
|
Не забудьте в таком случае отключить daemon и service в файле конфигурации.
|
||||||
|
Для чистоты эксперимента запускать 3proxy из коммандной строки в таком случае
|
||||||
|
следует, находясь в другой папке.
|
||||||
|
<li>Отсутствие у системной записи прав на доступ к исполняемому файлу, каким-либо файлам конфигурации, журнала и т.п.
|
||||||
|
<li>Отсутствие файла конфигурации по стандартному расположению -
|
||||||
|
3proxy.cfg в одном каталоге с исполняемым файлом. Если файл расположен по
|
||||||
|
другому пути, необходимо использовать команду
|
||||||
|
<pre>
|
||||||
|
3proxy --install path_to_configuration_file</pre>
|
||||||
|
<li>Отсутствие у пользователя прав на установку или запуск службы
|
||||||
|
<li>Служба уже установлена или запущена
|
||||||
|
</ul>
|
||||||
|
</p>
|
||||||
|
<li><a name="INTEXT">Как разобраться с internal и external</a></li></li>
|
||||||
|
<p>
|
||||||
|
Убедитесь, что выправильно понимаете что такое internal и external адреса.
|
||||||
|
Оба адреса - это адреса, принадлежищие хосту, на котором установлен 3proxy.
|
||||||
|
Эта опция конфигурации необходима в классической ситуации, когда 3proxy
|
||||||
|
установлен на граничном компьютере с двумя (или более) подключениями:
|
||||||
|
<pre>
|
||||||
|
LAN connection +-------------+ Internet connection
|
||||||
|
LAN <-------------->| 3proxy host |<-------------------> INTERNET
|
||||||
|
^+-------------+^
|
||||||
|
| |
|
||||||
|
Internal IP External IP</pre>
|
||||||
|
Если 3proxy работает на хосте с одним интерфейсом, то его адрес будет и
|
||||||
|
internal и external.
|
||||||
|
<br>Интерфейс с адресом internal должен существовать и быть рабочим на момент
|
||||||
|
запуска 3proxy, и не должен отключаться. Если internal интерфейс
|
||||||
|
периодически отключается, то не следует его указывать, или можно указать адрес
|
||||||
|
0.0.0.0. При этом прокси будет принимать запросы на всех интерфейсах, поэтому
|
||||||
|
при наличии нескольких интерфейсов для ограничения доступа следует использовать
|
||||||
|
фаервол или хотя бы ACL.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Интерфейс с адресом external, если он указан, должен быть рабочим на момент
|
||||||
|
получения запроса клиента. При отсутствии external или адресе 0.0.0.0 внешний
|
||||||
|
адрес будет выбираться системой при установке соединения. При этом, может быть
|
||||||
|
возможность доступа через прокси к ресурсам локальной сети, поэтому для
|
||||||
|
предотвращения несанкционированного доступа следует использовать ACL. Кроме
|
||||||
|
того, могут быть проблемы с приемом входящих соединений через SOCKSv5
|
||||||
|
(SOCKSv5 используется в клиентах исключительно редко).
|
||||||
|
В случае, если адрес динамический, можно либо не
|
||||||
|
указывать external, либо использовать адрес 0.0.0.0, либо, если необходима
|
||||||
|
поддержка входящих соединений в SOCKSv5, использовать скрипт,
|
||||||
|
который будет получать текущий адрес и сохранять его в файл, который будет
|
||||||
|
отслуживаться через команду monitor.
|
||||||
|
</p>
|
||||||
|
<li><a name="ODBC">Как починить ведение журналов в ODBC</a></li>
|
||||||
|
<p>
|
||||||
|
Убедитесь, что используется системный, а не
|
||||||
|
пользовательский DSN. Убедитесь, что выполняется правильный SQL запрос. Наиболее
|
||||||
|
распространенная проблема связана с отсутствием кавычек или неправильным
|
||||||
|
форматом данных. Самый простой способ - сделать ведение журнала в файл или
|
||||||
|
на стандартный вывод, просмотреть выдаваемые SQL запросы и попробовать
|
||||||
|
дать такой запрос вручную.
|
||||||
|
</p>
|
||||||
|
<li><a name="IPv6">Как починить IPv6</a></li>
|
||||||
|
<p>
|
||||||
|
Прокси не может обращаться напрямую к IPv6 сети если в запросе от клиента
|
||||||
|
указан IPv4. В запросе от клиента должен быть IPv6 адрес или имя хоста, чаще
|
||||||
|
всего это решается включением опции разрешения имен через прокси-сервер на стороне
|
||||||
|
клиента.
|
||||||
|
</p>
|
||||||
|
<li><a name="CRASH">Как починить падения 3proxy</a></li>
|
||||||
|
<p>
|
||||||
|
Возможно, недостаточен размер стека потока по-умолчанию, это может
|
||||||
|
быть при использовани каких-либо сторонних плагинов (PAM, ODBC) или на
|
||||||
|
некоторых платформах (некоторые версии FreeBSD на amd64). Можно решить
|
||||||
|
проблему с помощью опции 'stacksize' или '-S', поддерживаемых в 0.8.4 и выше.
|
||||||
|
</p>
|
||||||
<li><a name="SAMPLE"><i>Как посмотреть пример файла конфигурации</i></a>
|
<li><a name="SAMPLE"><i>Как посмотреть пример файла конфигурации</i></a>
|
||||||
<p>
|
<p>
|
||||||
Пример файла конфигурации 3proxy.cfg.sample поставляется с любым дистрибутивом
|
Пример файла конфигурации 3proxy.cfg.sample поставляется с любым дистрибутивом
|
||||||
@@ -225,7 +329,7 @@
|
|||||||
<li>W, еженедельная ротация
|
<li>W, еженедельная ротация
|
||||||
<li>D, ежедневная ротация
|
<li>D, ежедневная ротация
|
||||||
<li>H, ежечасная ротация
|
<li>H, ежечасная ротация
|
||||||
<li>С, ежеминутная ротация
|
<li>C, ежеминутная ротация
|
||||||
</ul>
|
</ul>
|
||||||
<pre>
|
<pre>
|
||||||
rotate NUMBER</pre>
|
rotate NUMBER</pre>
|
||||||
@@ -386,6 +490,24 @@
|
|||||||
<pre>
|
<pre>
|
||||||
proxy -p8080 -i192.168.1.1
|
proxy -p8080 -i192.168.1.1
|
||||||
proxy -p8080 -i192.168.2.1</pre>
|
proxy -p8080 -i192.168.2.1</pre>
|
||||||
|
<li><a name="NAMES"><i>Как разрешать имена на родительском прокси?</i></a></li>
|
||||||
|
<p>
|
||||||
|
<i>A:</i> Для этого надо использовать тип родительского прокси http,
|
||||||
|
connect+, socks4+ и socks5+. Однако, при это надо помнить, что самому 3proxy
|
||||||
|
требуется разрешение имени для управления ACL. Поэтому, если с прокси-хоста
|
||||||
|
не работают разрешения имени, необходимо в конфигурации дать команду
|
||||||
|
<pre>
|
||||||
|
fakeresolve</pre>
|
||||||
|
которая разрешает любое имя в адрес 127.0.0.2.
|
||||||
|
</p>
|
||||||
|
<li><a name="ISFTP"><i>Как настроить FTP прокси?</i></a></li>
|
||||||
|
<p>
|
||||||
|
Есть поддержка как FTP через HTTP (то, что называется FTP прокси в браузерах) так и настоящего FTP прокси (то, что называется
|
||||||
|
FTP proxy в командных оболочках и FTP клиентах). В браузерах в качестве FTP прокси следует прописывать порт службы proxy,
|
||||||
|
т.е. FTP организован
|
||||||
|
через http прокси, дополнительного прокси поднимать не надо. Для FTP-клиентов необходимо поднять ftppr. FTP прокси всегда работает
|
||||||
|
с FTP сервером в пассивном режиме.
|
||||||
|
</p>
|
||||||
<li><a name="AUTH"><i>Как ограничить доступ к службе</i></a>
|
<li><a name="AUTH"><i>Как ограничить доступ к службе</i></a>
|
||||||
<p>
|
<p>
|
||||||
Во-первых, для ограничения доступа необходимо указать внутренний интерфейс,
|
Во-первых, для ограничения доступа необходимо указать внутренний интерфейс,
|
||||||
@@ -469,6 +591,13 @@
|
|||||||
использовать кэширование для доступа к критичным ресурсам, в частности к
|
использовать кэширование для доступа к критичным ресурсам, в частности к
|
||||||
интерфейсу администрирования.
|
интерфейсу администрирования.
|
||||||
</p>
|
</p>
|
||||||
|
<p>authcache так же может использоваться для привязки сессий пользователя к ip с
|
||||||
|
с помощью опции limit
|
||||||
|
<pre>
|
||||||
|
autchcache ip,user,pass,limit 120
|
||||||
|
auth cache strong</pre>
|
||||||
|
запретит пользователю использовать более одного адреса в течении времени кеширования.
|
||||||
|
</p>
|
||||||
<li><a name="USERS"><i>Как создать список пользователей</i></a>
|
<li><a name="USERS"><i>Как создать список пользователей</i></a>
|
||||||
<p>
|
<p>
|
||||||
Список пользователей задается с помощью команды users.
|
Список пользователей задается с помощью команды users.
|
||||||
@@ -607,6 +736,74 @@
|
|||||||
того, чтобы видеть в логах записи о посещаемых пользвоателем ресурсах и
|
того, чтобы видеть в логах записи о посещаемых пользвоателем ресурсах и
|
||||||
загружаемых файлах даже в том случае, если он подключается через SOCKS.
|
загружаемых файлах даже в том случае, если он подключается через SOCKS.
|
||||||
</p>
|
</p>
|
||||||
|
<li><a name="SOCKSREDIR">Как управлять локальными перенаправлениями</a>
|
||||||
|
<p>
|
||||||
|
<ul>
|
||||||
|
<li><a name="REDIR"><i>Q: Для чего это надо?</i></a></li>
|
||||||
|
<p>
|
||||||
|
<i>A:</i> Чтобы иметь в логах URL запросов, если пользователь SOCKS пользуется
|
||||||
|
Web, FTP или POP3.
|
||||||
|
</p>
|
||||||
|
<li><a name="REDIRLIMIT"><i>Q: Какие недостатки?</i></a></li>
|
||||||
|
<p>
|
||||||
|
<i>A:</i> Перенапраление невозможно для web-серверов или FTP, висящих на
|
||||||
|
нестандартных портах, для SOCKSv4 не поддрживается авторизация с
|
||||||
|
паролем (IE поддерживает только SOCKSv4), но при этом IE передает
|
||||||
|
имя пользователя по SOCKSv4 (имя, с которым пользователь вошел в систему).
|
||||||
|
Для SOCKSv5 не поддерживается NTLM авторизация, пароли передаются в открытом
|
||||||
|
тексте.
|
||||||
|
</p>
|
||||||
|
<li><a name="REDIRADV"><i>Q: Какие преимущества?</i></a></li>
|
||||||
|
<p>
|
||||||
|
<i>A:</i> Достаточно в настройках IE только указать адрес SOCKS прокси. В
|
||||||
|
больших сетях можно для этого использовать WPAD (автоматическое
|
||||||
|
обнаружение прокси). В 3proxy достаточно запускать только одну службу
|
||||||
|
(socks). Если используется только Internet Explorer, то можно
|
||||||
|
автоматически получать имя пользователя в логах, не запрашивая
|
||||||
|
логин/пароль.
|
||||||
|
</p>
|
||||||
|
<li><a name="REDIRHOW"><i>Q: Как настраивается?</i></a></li>
|
||||||
|
<p>
|
||||||
|
<i>A:</i> Указывается parent http proxy со специальным адресом 0.0.0.0 и портом
|
||||||
|
0. Пример:
|
||||||
|
<pre>
|
||||||
|
allow * * * 80,8080-8088
|
||||||
|
parent 1000 http 0.0.0.0 0
|
||||||
|
allow * * * 80,8080-8088
|
||||||
|
#перенаправить соединения по портам 80 и 8080-8088 в локальный
|
||||||
|
#http прокси. Вторая команда allow необходима, т.к. контроль доступа
|
||||||
|
#осуществляется 2 раза - на уровне socks и на уровне HTTP прокси
|
||||||
|
allow * * * 21,2121
|
||||||
|
parent 1000 ftp 0.0.0.0 0
|
||||||
|
allow * * * 21,2121
|
||||||
|
#перенаправить соединения по портам 21 и 2121 в локальный
|
||||||
|
#ftp прокси
|
||||||
|
allow *
|
||||||
|
#пустить все соединения напрямую
|
||||||
|
socks</pre>
|
||||||
|
</p>
|
||||||
|
<li><a name="REDIINTER"><i>Q: Как взаимодействует с другими правилами в ACL?</i></a></li>
|
||||||
|
<p>
|
||||||
|
<i>A:</i> После внутреннего перенаправления правила рассматриваются еще раз за
|
||||||
|
исключением самого правила с перенаправлением (т.е. обработка правил не
|
||||||
|
прекращается). Это позволяет сделать дальнейшие перенаправления на
|
||||||
|
внешний прокси. По этой же причине локальное перенаправление не должно
|
||||||
|
быть последним правилом (т.е. должно быть еще хотя бы правило allow,
|
||||||
|
чтобы разрешить внешние соединения через HTTP прокси).
|
||||||
|
Например,
|
||||||
|
<pre>
|
||||||
|
allow * * * 80,8080-8088
|
||||||
|
parent 1000 http 0.0.0.0 0
|
||||||
|
#перенаправить во внутренний прокси
|
||||||
|
allow * * $c:\3proxy\local.nets 80,8080-8088
|
||||||
|
#разрешить прямой web-доступ к сетям из local.nets
|
||||||
|
allow * * * 80,8080-8088
|
||||||
|
parent 1000 http proxy.3proxy.ru 3128
|
||||||
|
#все остальные веб-запросы перенаправить на внешний прокси-сервер
|
||||||
|
allow *
|
||||||
|
#разрешить socks-запросы по другим портам</pre>
|
||||||
|
</p>
|
||||||
|
</ul>
|
||||||
<li><a name="ROUNDROBIN"><i>Как организовать балансировку между несоклькими каналами</i></a>
|
<li><a name="ROUNDROBIN"><i>Как организовать балансировку между несоклькими каналами</i></a>
|
||||||
<p>
|
<p>
|
||||||
Сам по себе прокси не может управлять маршрутизацией пакетов сетевого уровня.
|
Сам по себе прокси не может управлять маршрутизацией пакетов сетевого уровня.
|
||||||
@@ -735,33 +932,26 @@
|
|||||||
<br>
|
<br>
|
||||||
amount - объем трафика на указанный период в мегабайтах.
|
amount - объем трафика на указанный период в мегабайтах.
|
||||||
</p>
|
</p>
|
||||||
<li><a name="NETLIST"><i>Как строить списки сетей</i></a>
|
<li><a name="TRAF">Как пофиксить некорректный подсчет трафика</a>
|
||||||
<p>
|
<p>
|
||||||
Очень часто списки сетей и пользователей бывают достаточно громоздкими.
|
Следует учитывать, что 3proxy считает трафик только на прикладном уровне и
|
||||||
3proxy не поддерживает создание групп, но позволяет включение файлов. Это
|
только проходящий через прокси-сервер. Провайдеры и другие средства учета
|
||||||
означает, что для удобства администрирования выгодно хранить списки
|
трафика считают трафик на сетевом уровне, что уже дает расхождение порядка 10%
|
||||||
пользователей и списки сетей в отдельных файлах и при необходимости дать
|
за счет информации из заголовков пакетов. Кроме того, часть трафика, как
|
||||||
пользователю доступ к тому или иному ресурсу, править файл со списком
|
минимум DNS-разрешения, различный флудовый трафик и т.д. идут мимо прокси.
|
||||||
пользователей или сетей вместо того, чтобы править сам файл 3proxy.cfg. В файле
|
Уровень "шумового" трафика в Internet сейчас составляет порядка 50KB/день на
|
||||||
3proxy.cfg файл со списком можно включить с помощью макроса $.
|
каждый реальный IP адрес, но может сильно варьироваться в зависимости от сети,
|
||||||
Поскольку в 3proxy есть ограничения на максимальный размер элемента
|
наличия открытых портов, реакции на ping-запросы и текущего уровня вирусной
|
||||||
конфигурации, большие списки следует разбивать на несколько файлов и
|
активности. По этим причинам, если 3proxy используется чтобы не "выжрать"
|
||||||
использовать несколько записей списка контроля доступом.
|
трафик, выделенный провайдером, всегда следует делать некий запас порядка
|
||||||
В комплекте с 3proxy поставляется утилита dighosts, которая позволяет построить
|
15%.
|
||||||
список сетей по странице Web. Утилита осуществляет поиск адресов на Web-странице
|
</p>
|
||||||
в формате АДРЕС МАСКА или АДРЕС/ДЛИНА. Утилиту dighosts можно вызвать во время
|
<p>
|
||||||
старта 3proxy, используя команду system. Например:
|
Если на одной с 3proxy машине имеются какие-либо сервисы или
|
||||||
<pre>
|
работает пользователь, то их трафик не проходит через proxy-сервер и так же
|
||||||
system "dighosts http://provider/network.html local.networks"
|
не будет учтен. Если где-то есть NAT, то клиенты, выходящие через NAT мимо
|
||||||
allow * * $local.networks
|
прокси, так же останутся неучтенными. Если расхождение с провайдером превышает
|
||||||
allow *
|
10% - нужно искать причину именно в этом.
|
||||||
parent 1000 proxy.provider 3128 *
|
|
||||||
proxy
|
|
||||||
flush</pre>
|
|
||||||
В данном случае в файле local.networks генерируется список локальных сетей по
|
|
||||||
странице networklist.html. Далее используется список контроля доступа для того,
|
|
||||||
чтобы разрешить локальному прокси-серверу доступ к локальным сетям напрямую,
|
|
||||||
а все остальные запросы перенаправить на прокси-сервер провайдера.
|
|
||||||
</p>
|
</p>
|
||||||
<li><a name="NSCACHING"><i>Как управлять разрешением имен и кэшированием DNS</i></a>
|
<li><a name="NSCACHING"><i>Как управлять разрешением имен и кэшированием DNS</i></a>
|
||||||
<p>
|
<p>
|
||||||
@@ -820,19 +1010,6 @@
|
|||||||
tcppm -R0.0.0.0:1234 3128 1.1.1.1 3128</pre>
|
tcppm -R0.0.0.0:1234 3128 1.1.1.1 3128</pre>
|
||||||
В настройках браузера указывается host.dyndns.example.org:3128.
|
В настройках браузера указывается host.dyndns.example.org:3128.
|
||||||
</p>
|
</p>
|
||||||
<li><a name="DEMANDDIAL"><i>Как устанавливать соединение по требованию</i></a>
|
|
||||||
<p>
|
|
||||||
Команда dialer задает программу, которая будет запускаться при
|
|
||||||
невозможности разрешить имя компьютера, например:
|
|
||||||
<pre>
|
|
||||||
dialer "rasdial PROVIDER"</pre>
|
|
||||||
(описание rasdial можно найти на сервере поддержки Microsoft).
|
|
||||||
Есть два аспекта: невозможность разрешения имени еще не свидетельствует
|
|
||||||
об отсутствии соединения (это должна учитывать вызываемая программа),
|
|
||||||
при использовании nscache имя может разрешиться при отсутствии
|
|
||||||
соединения. В таких случаях полезно запрашивать заведомо несуществующий
|
|
||||||
ресурс, например, http://dial.right.now/.
|
|
||||||
</p>
|
|
||||||
</ul>
|
</ul>
|
||||||
<hr>
|
<hr>
|
||||||
<li><a name="CLIENT"><b>Конфигурация клиентов</b></a>
|
<li><a name="CLIENT"><b>Конфигурация клиентов</b></a>
|
||||||
@@ -1039,6 +1216,18 @@
|
|||||||
<li>50-69 - ошибки перенаправления SOCKS5
|
<li>50-69 - ошибки перенаправления SOCKS5
|
||||||
<li>70-79 ошибки установки родительского соединения, аналогичны 1x
|
<li>70-79 ошибки установки родительского соединения, аналогичны 1x
|
||||||
<li>90-99 - ошибки разрыва соединения
|
<li>90-99 - ошибки разрыва соединения
|
||||||
|
<li>с версии 0.9
|
||||||
|
<li>90 - неожиданная системная ошибка (не должно происходить)
|
||||||
|
<li>91 - ошибка poll (не должно происходить)
|
||||||
|
<li>92 - соединение прервано по таймауту на сетевую операцию (см. timeouts)
|
||||||
|
<li>93 - соединение прервано по таймауту связанному с рейтлимитом или из-за превышения числа ошибок
|
||||||
|
<li>94 - клиент или сервер закрыли соединение или произошла сетевая ошибка, остались неотправленные данные
|
||||||
|
<li>95 - клиент "грязно" закрыл соединение или сетевая ошибка
|
||||||
|
<li>96 - сервер "грязно" закрыл соединение или сетевая ошибка
|
||||||
|
<li>97 - клиент и сервер "грязно" закрыли соединение или сетевая ошибка
|
||||||
|
<li>98 - исчерпан лимит данных сервера (не должно быть в журнале)
|
||||||
|
<li>99 - исчерпан лимит данных клиента (не должно быть в журнале)
|
||||||
|
<li>до версии 0.9
|
||||||
<li>90 - ошибка сокета или соединение неожиданно прервано
|
<li>90 - ошибка сокета или соединение неожиданно прервано
|
||||||
<li>91 - общий сбой стека TCP/IP
|
<li>91 - общий сбой стека TCP/IP
|
||||||
<li>92 - соединение прервано по таймауту
|
<li>92 - соединение прервано по таймауту
|
||||||
@@ -1062,7 +1251,7 @@
|
|||||||
<hr>
|
<hr>
|
||||||
<li><a name="QUEST"><b>Как задать вопрос, которого нет в HowTo</b></a>
|
<li><a name="QUEST"><b>Как задать вопрос, которого нет в HowTo</b></a>
|
||||||
<p>
|
<p>
|
||||||
Задайте его на <a href="http://3proxy.ru/board3.html">форуме</a>.
|
Задайте его на <a href="https://github.com/z3APA3A/3proxy/issues">Github</a>.
|
||||||
Только не пытайтесь задавать какие-либо вопросы, если вы просто не поняли этот
|
Только не пытайтесь задавать какие-либо вопросы, если вы просто не поняли этот
|
||||||
HowTo.
|
HowTo.
|
||||||
</ul>
|
</ul>
|
||||||
+1
-2
@@ -1,9 +1,8 @@
|
|||||||
<html><title>3proxy documentation</title><body><h2>3proxy documentation</h2>
|
<html><title>3proxy documentation</title><body><h2>3proxy documentation</h2>
|
||||||
<a href="securityen.html">Security recommendations</a><br>
|
<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="howtoe.html">How To (English, very incomplete)</a><br>
|
||||||
<a href="howtor.html">How To (Russian)</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>
|
<h3>Man pages:</h>
|
||||||
<br><A HREF="man8/3proxy.8.html">3proxy.8</A>
|
<br><A HREF="man8/3proxy.8.html">3proxy.8</A>
|
||||||
<br><A HREF="man8/ftppr.8.html">ftppr.8</A>
|
<br><A HREF="man8/ftppr.8.html">ftppr.8</A>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<h3>3proxy TransparentPlugin plugin (Linux only)</h3>
|
<h3>3proxy TransparentPlugin plugin (Linux/BSD only)</h3>
|
||||||
|
|
||||||
Plugin can turn 3proxy into transparent proxy for virtually any TCP-based protocol
|
Plugin can turn 3proxy into transparent proxy for virtually any TCP-based protocol
|
||||||
and use all 3proxy features - redirections, parent proxies, ACLs, traffic limitations,
|
and use all 3proxy features - redirections, parent proxies, ACLs, traffic limitations,
|
||||||
@@ -13,7 +13,10 @@ allow * * * 80
|
|||||||
parent 1000 http 0.0.0.0 0
|
parent 1000 http 0.0.0.0 0
|
||||||
allow *
|
allow *
|
||||||
parent 1000 socks5 SOCKS5_IP SOCKS5_PORT USER PASSWORD
|
parent 1000 socks5 SOCKS5_IP SOCKS5_PORT USER PASSWORD
|
||||||
|
transparent
|
||||||
tcppm -iLOCAL_IP 12345 127.0.0.1 11111
|
tcppm -iLOCAL_IP 12345 127.0.0.1 11111
|
||||||
|
notransparent
|
||||||
|
proxy
|
||||||
</pre>
|
</pre>
|
||||||
Now, any TCP traffic transparently redirected to port 12345 will be routed via
|
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.
|
parent SOCKSv5 proxy and logged, all URLs for web requests are visible in logs.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<h3>Плагин TransparentPlugin 3proxy (только для Linux)</h3>
|
<h3>Плагин TransparentPlugin 3proxy (только для Linux/BSD)</h3>
|
||||||
|
|
||||||
Плагин превращает 3proxy в транспарентный прокси для практически любых TCP-соединений
|
Плагин превращает 3proxy в транспарентный прокси для практически любых TCP-соединений
|
||||||
и позволяет прозрачно для клиентов использовать весь фунционал прокси - редиректоры,
|
и позволяет прозрачно для клиентов использовать весь фунционал прокси - редиректоры,
|
||||||
@@ -15,7 +15,10 @@ allow * * * 80
|
|||||||
parent 1000 http 0.0.0.0 0
|
parent 1000 http 0.0.0.0 0
|
||||||
allow *
|
allow *
|
||||||
parent 1000 socks5 SOCKS5_IP SOCKS5_PORT USER PASSWORD
|
parent 1000 socks5 SOCKS5_IP SOCKS5_PORT USER PASSWORD
|
||||||
|
transparent
|
||||||
tcppm -iLOCAL_IP 12345 127.0.0.1 11111
|
tcppm -iLOCAL_IP 12345 127.0.0.1 11111
|
||||||
|
notransparent
|
||||||
|
proxy
|
||||||
</pre>
|
</pre>
|
||||||
Теперь любые TCP-соединения транспарентно перенаправленные в локальный порт 12345
|
Теперь любые TCP-соединения транспарентно перенаправленные в локальный порт 12345
|
||||||
будут прологгированы и перенаправлены в родительский SOCKSv5 proxy, при этом для
|
будут прологгированы и перенаправлены в родительский SOCKSv5 proxy, при этом для
|
||||||
|
|||||||
+6507
-1738
File diff suppressed because it is too large.
Load diff
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
.TH 3proxy "8" "January 2016" "3proxy 0.8" "Universal proxy server"
|
.TH 3proxy "8" "January 2019" "3proxy 0.9" "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
|
||||||
@@ -143,7 +143,7 @@ Report all bugs to
|
|||||||
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
|
||||||
http://3proxy.ru/
|
https://3proxy.org/
|
||||||
.SH TRIVIA
|
.SH TRIVIA
|
||||||
3APA3A is pronounced as \`\`zaraza\'\'.
|
3APA3A is pronounced as \`\`zaraza\'\'.
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
|
|||||||
+311
-197
@@ -1,7 +1,7 @@
|
|||||||
.TH 3proxy.cfg "3" "January 2016" "3proxy 0.8" "Universal proxy server"
|
.TH 3proxy.cfg "8" "January 2019" "3proxy 0.9" "Universal proxy server"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.B 3proxy.cfg
|
.B 3proxy.cfg
|
||||||
\- 3proxy configuration file
|
3proxy configuration file
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
Common structure:
|
Common structure:
|
||||||
.br
|
.br
|
||||||
@@ -25,7 +25,7 @@ ignored. <LF>s are ignored. <CR> is end of command.
|
|||||||
Quotation character is " (double quote). Quotation must be used to quote
|
Quotation character is " (double quote). Quotation must be used to quote
|
||||||
spaces or another special characters. To use quotation character inside
|
spaces or another special characters. To use quotation character inside
|
||||||
quotation character must be dubbed (BASIC convention). For example to use
|
quotation character must be dubbed (BASIC convention). For example to use
|
||||||
HELLO "WORLD" as an argument you should use it as "HELLO ""WORLD"""\.
|
HELLO "WORLD" as an argument you should use it as "HELLO ""WORLD""".
|
||||||
Good practice is to quote any argument you use.
|
Good practice is to quote any argument you use.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
@@ -33,7 +33,7 @@ Good practice is to quote any argument you use.
|
|||||||
.br
|
.br
|
||||||
You can include file by using $FILENAME macro (replace FILENAME with a path
|
You can include file by using $FILENAME macro (replace FILENAME with a path
|
||||||
to file, for example $/usr/local/etc/3proxy/conf.incl or
|
to file, for example $/usr/local/etc/3proxy/conf.incl or
|
||||||
$"c:\\Program Files\\3proxy\\include.cfg" Quotation is
|
$"c:\\\\Program Files\\3proxy\\include.cfg" Quotation is
|
||||||
required in last example because path contains space character.
|
required in last example because path contains space character.
|
||||||
For included file <CR> (end of line characters) is treated as space character
|
For included file <CR> (end of line characters) is treated as space character
|
||||||
(arguments delimiter instead of end of command delimiter).
|
(arguments delimiter instead of end of command delimiter).
|
||||||
@@ -44,95 +44,94 @@ Recursion is not allowed.
|
|||||||
|
|
||||||
.br
|
.br
|
||||||
Next commands start gateway services:
|
Next commands start gateway services:
|
||||||
.br
|
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B proxy
|
.B proxy
|
||||||
[options]
|
[options]
|
||||||
.br
|
.br
|
||||||
.B socks
|
.B socks
|
||||||
[options]
|
[options]
|
||||||
.br
|
.br
|
||||||
.B pop3p
|
.B pop3p
|
||||||
[options]
|
[options]
|
||||||
.br
|
.br
|
||||||
.B ftppr
|
.B ftppr
|
||||||
[options]
|
[options]
|
||||||
.br
|
.br
|
||||||
.B admin
|
.B admin
|
||||||
[options]
|
[options]
|
||||||
.br
|
.br
|
||||||
.B dnspr
|
.B dnspr
|
||||||
[options]
|
[options]
|
||||||
.br
|
.br
|
||||||
.B tcppm
|
.B tcppm
|
||||||
[options]
|
[options]
|
||||||
<SRCPORT> <DSTADDR> <DSTPORT>
|
<SRCPORT> <DSTADDR> <DSTPORT>
|
||||||
.br
|
.br
|
||||||
.B udppm
|
.B udppm
|
||||||
[options]
|
[options]
|
||||||
<SRCPORT> <DSTADDR> <DSTPORT>
|
<SRCPORT> <DSTADDR> <DSTPORT>
|
||||||
.br
|
.br
|
||||||
Descriptions:
|
Descriptions:
|
||||||
.br
|
.br
|
||||||
.B proxy
|
.B proxy
|
||||||
\- HTTP/HTTPS proxy (default port 3128)
|
HTTP/HTTPS proxy (default port 3128)
|
||||||
.br
|
.br
|
||||||
.B socks
|
.B socks
|
||||||
\- SOCKS 4/4.5/5 proxy (default port 1080)
|
SOCKS 4/4.5/5 proxy (default port 1080)
|
||||||
.br
|
.br
|
||||||
.B pop3p
|
.B pop3p
|
||||||
\- POP3 proxy (default port 110)
|
POP3 proxy (default port 110)
|
||||||
.br
|
.br
|
||||||
.B ftppr
|
.B ftppr
|
||||||
\- FTP proxy (default port 21)
|
FTP proxy (default port 21)
|
||||||
.br
|
.br
|
||||||
.B admin
|
.B admin
|
||||||
\- Web interface (default port 80)
|
Web interface (default port 80)
|
||||||
.br
|
.br
|
||||||
.B dnspr
|
.B dnspr
|
||||||
\- caching DNS proxy (default port 53)
|
caching DNS proxy (default port 53)
|
||||||
.br
|
.br
|
||||||
.B tcppm
|
.B tcppm
|
||||||
\- TCP portmapper
|
TCP portmapper
|
||||||
.br
|
.br
|
||||||
.B udppm
|
.B udppm
|
||||||
\- UDP portmapper
|
UDP portmapper
|
||||||
.br
|
|
||||||
|
|
||||||
|
.br
|
||||||
Options:
|
Options:
|
||||||
.br
|
.br
|
||||||
.B -pNUMBER
|
.B -pNUMBER
|
||||||
change default server port to NUMBER
|
change default server port to NUMBER
|
||||||
.br
|
.br
|
||||||
.B -n
|
.B -n
|
||||||
disable NTLM authentication (required if passwords are stored in Unix crypt format.
|
disable NTLM authentication (required if passwords are stored in Unix crypt format).
|
||||||
.br
|
.br
|
||||||
.B -n1
|
.B -n1
|
||||||
enable NTLMv1 authentication.
|
enable NTLMv1 authentication.
|
||||||
.br
|
.br
|
||||||
.B -s
|
.B -s
|
||||||
(for admin) - secure, allow only secure operations (currently only traffic counters
|
(for admin) secure, allow only secure operations, currently only traffic counters
|
||||||
view without ability to reset).
|
view without ability to reset.
|
||||||
.br
|
.br
|
||||||
(for dnspr) - simple, do not use 'resolver' and 3proxy cache, always use external DNS server.
|
(for dnspr) simple, do not use resolver and 3proxy cache, always use external DNS server.
|
||||||
.br
|
.br
|
||||||
(for udppm) - singlepacket, expect only one packet from both client and server
|
(for udppm) singlepacket, expect only one packet from both client and server
|
||||||
.br
|
.br
|
||||||
.B -u
|
.B -u
|
||||||
Never ask for username/password
|
Never ask for username/password
|
||||||
.br
|
.br
|
||||||
.B -u2
|
.B -u2
|
||||||
(socks) require username/password in authentication methods
|
(for socks) require username/password in authentication methods
|
||||||
.br
|
.br
|
||||||
.B -a
|
.B -a
|
||||||
(for proxy) - anonymous proxy (no information about client reported)
|
(for proxy) anonymous proxy (no information about client reported)
|
||||||
.br
|
.br
|
||||||
.B -a1
|
.B -a1
|
||||||
(for proxy) - anonymous proxy (random client information reported)
|
(for proxy) anonymous proxy (random client information reported)
|
||||||
.br
|
.br
|
||||||
.B -a2
|
.B -a2
|
||||||
(for proxy) - generate Via: and X-Forwared-For: instead of Forwarded:
|
(for proxy) generate Via: and X-Forwared-For: instead of Forwarded:
|
||||||
.br
|
.br
|
||||||
.B -6
|
.B -6
|
||||||
Only resolve IPv6 addresses. IPv4 addresses are packed in IPv6 in IPV6_V6ONLY compatible way.
|
Only resolve IPv6 addresses. IPv4 addresses are packed in IPv6 in IPV6_V6ONLY compatible way.
|
||||||
@@ -151,6 +150,28 @@ listen on given local HOST:port for incoming connections instead of making remot
|
|||||||
.br
|
.br
|
||||||
.B -rHOST:port
|
.B -rHOST:port
|
||||||
connect to given remote HOST:port instead of listening local connection on -p or default port. Can be used with another 3proxy service running -R option for connect back functionality. Most commonly used with proxy or socks. HOST can be given as IP or hostname, useful in case of dynamic DNS.
|
connect to given remote HOST:port instead of listening local connection on -p or default port. Can be used with another 3proxy service running -R option for connect back functionality. Most commonly used with proxy or socks. HOST can be given as IP or hostname, useful in case of dynamic DNS.
|
||||||
|
.br
|
||||||
|
.B -ocOPTIONS, -osOPTIONS, -olOPTIONS, -orOPTIONS, -oROPTIONS
|
||||||
|
options for proxy-to-client (oc), proxy-to-server (os), proxy listening (ol), connect back client (or), connect back listening (oR) sockets.
|
||||||
|
Options like TCP_CORK, TCP_NODELAY, TCP_DEFER_ACCEPT, TCP_QUICKACK, TCP_TIMESTAMPS, USE_TCP_FASTOPEN, SO_REUSEADDR, SO_REUSEPORT, SO_PORT_SCALABILITY, SO_REUSE_UNICASTPORT, SO_KEEPALIVE, SO_DONTROUTE may be supported depending on OS.
|
||||||
|
.br
|
||||||
|
.B -DiINTERFACE, -DeINTERFACE
|
||||||
|
bind internal interface / external inteface to given INTERFACE (e.g. eth0) if SO_BINDTODEVICE supported by system. You may need to run as root or to have CAP_NET_RAW capability in order to bind to interface, depending on system, so this option may require root privileges and can be incompatible with some configuraton commands like chroot and setuid (and daemon if setcap is used).
|
||||||
|
.br
|
||||||
|
.B -e
|
||||||
|
External address. IP address of interface proxy should initiate connections
|
||||||
|
from. External IP must be specified if you need incoming connections.
|
||||||
|
By default system will deside which address to use in accordance
|
||||||
|
with routing table.
|
||||||
|
.br
|
||||||
|
.B -i
|
||||||
|
Internal address. IP address proxy accepts connections to.
|
||||||
|
By default connection to any interface is accepted.
|
||||||
|
.br
|
||||||
|
.B -N
|
||||||
|
(for socks) 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)
|
||||||
.br
|
.br
|
||||||
Also, all options mentioned for
|
Also, all options mentioned for
|
||||||
.BR proxy (8)
|
.BR proxy (8)
|
||||||
@@ -200,8 +221,9 @@ proxy on a client with FTP proxy support. Username format is one of
|
|||||||
.B writable
|
.B writable
|
||||||
.br
|
.br
|
||||||
ReOpens configuration file for write access via Web interface,
|
ReOpens configuration file for write access via Web interface,
|
||||||
and re-reads it. Usually should be first command on config file
|
and rereads it. Usually should be first command on config file
|
||||||
but in combination with "config" it can be used anywhere to open
|
but in combination with config
|
||||||
|
it can be used anywhere to open
|
||||||
alternate config file. Think twice before using it.
|
alternate config file. Think twice before using it.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
@@ -215,26 +237,28 @@ alternate config file. Think twice before using it.
|
|||||||
.br
|
.br
|
||||||
sets logfile for all gateways
|
sets logfile for all gateways
|
||||||
.br
|
.br
|
||||||
@ - (for Unix) use syslog, filename is used as ident name
|
@ (for Unix) use syslog, filename is used as ident name
|
||||||
.br
|
.br
|
||||||
& - use ODBC, filename consists of comma-delimited datasource,username,password (username and password are optional)
|
& use ODBC, filename consists of comma-delimited datasource,username,password (username and password are optional)
|
||||||
|
.br
|
||||||
|
radius - use RADIUS for logging
|
||||||
.br
|
.br
|
||||||
LOGTYPE is one of:
|
LOGTYPE is one of:
|
||||||
.br
|
.br
|
||||||
M - Monthly
|
M Monthly
|
||||||
.br
|
.br
|
||||||
W - Weekly (starting from Sunday)
|
W Weekly (starting from Sunday)
|
||||||
.br
|
.br
|
||||||
D - Daily
|
D Daily
|
||||||
.br
|
.br
|
||||||
H - Hourly
|
H Hourly
|
||||||
.br
|
.br
|
||||||
if logfile is not specified logging goes to stdout. You can specify individual logging options for gateway by using
|
if logfile is not specified logging goes to stdout. You can specify individual logging options for gateway by using -l
|
||||||
-l option in gateway configuration.
|
option in gateway configuration.
|
||||||
.br
|
.br
|
||||||
"log" command supports same format specifications for filename template
|
log command supports same format specifications for filename template
|
||||||
as "logformat" (if filename contains '%' sign it's believed to be template).
|
as "logformat" (if filename contains \'%\' sign it\'s believed to be template).
|
||||||
As with "logformat" filename must begin with 'L' or 'G' to specify Local or
|
As with "logformat" filename must begin with \'L\' or \'G\' to specify Local or
|
||||||
Grinwitch time zone for all time-based format specificators.
|
Grinwitch time zone for all time-based format specificators.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
@@ -257,73 +281,73 @@ with space and all time based elemnts are in local time zone.
|
|||||||
You can use:
|
You can use:
|
||||||
|
|
||||||
.br
|
.br
|
||||||
%y - Year in 2 digit format
|
%y Year in 2 digit format
|
||||||
.br
|
.br
|
||||||
%Y - Year in 4 digit format
|
%Y Year in 4 digit format
|
||||||
.br
|
.br
|
||||||
%m - Month number
|
%m Month number
|
||||||
.br
|
.br
|
||||||
%o - Month abbriviature
|
%o Month abbriviature
|
||||||
.br
|
.br
|
||||||
%d - Day
|
%d Day
|
||||||
.br
|
.br
|
||||||
%H - Hour
|
%H Hour
|
||||||
.br
|
.br
|
||||||
%M - Minute
|
%M Minute
|
||||||
.br
|
.br
|
||||||
%S - Second
|
%S Second
|
||||||
.br
|
.br
|
||||||
%t - Timstamp (in seconds since 01-Jan-1970)
|
%t Timstamp (in seconds since 01-Jan-1970)
|
||||||
.br
|
.br
|
||||||
%. - milliseconds
|
%. milliseconds
|
||||||
.br
|
.br
|
||||||
%z - timeZone (from Grinvitch)
|
%z timeZone (from Grinvitch)
|
||||||
.br
|
.br
|
||||||
%D - request duration (in milliseconds)
|
%D request duration (in milliseconds)
|
||||||
.br
|
.br
|
||||||
%b - average send rate per request (in Bytes per second) this speed is typically below connection speed shown by download manager.
|
%b average send rate per request (in Bytes per second) this speed is typically below connection speed shown by download manager.
|
||||||
.br
|
.br
|
||||||
%B - average receive rate per request (in Bytes per second) this speed is typically below connection speed shown by download manager.
|
%B average receive rate per request (in Bytes per second) this speed is typically below connection speed shown by download manager.
|
||||||
.br
|
.br
|
||||||
%U - Username
|
%U Username
|
||||||
.br
|
.br
|
||||||
%N - service Name
|
%N service Name
|
||||||
.br
|
.br
|
||||||
%p - service Port
|
%p service Port
|
||||||
.br
|
.br
|
||||||
%E - Error code
|
%E Error code
|
||||||
.br
|
.br
|
||||||
%C - Client IP
|
%C Client IP
|
||||||
.br
|
.br
|
||||||
%c - Client port
|
%c Client port
|
||||||
.br
|
.br
|
||||||
%R - Remote IP
|
%R Remote IP
|
||||||
.br
|
.br
|
||||||
%r - Remote port
|
%r Remote port
|
||||||
.br
|
.br
|
||||||
%i - Internal IP used to accept client connection
|
%i Internal IP used to accept client connection
|
||||||
.br
|
.br
|
||||||
%e - External IP used to establish connection
|
%e External IP used to establish connection
|
||||||
.br
|
.br
|
||||||
%Q - Requested IP
|
%Q Requested IP
|
||||||
.br
|
.br
|
||||||
%q - Requested port
|
%q Requested port
|
||||||
.br
|
.br
|
||||||
%n - requested hostname
|
%n requested hostname
|
||||||
.br
|
.br
|
||||||
%I - bytes In
|
%I bytes In
|
||||||
.br
|
.br
|
||||||
%O - bytes Out
|
%O bytes Out
|
||||||
.br
|
.br
|
||||||
%h - Hops (redirections) count
|
%h Hops (redirections) count
|
||||||
.br
|
.br
|
||||||
%T - service specific Text
|
%T service specific Text
|
||||||
.br
|
.br
|
||||||
%N1-N2T - (N1 and N2 are positive numbers) - log only fields from N1 thorugh N2 of service specific text
|
%N1-N2T (N1 and N2 are positive numbers) log only fields from N1 thorugh N2 of service specific text
|
||||||
.br
|
.br
|
||||||
in case of ODBC logging logformat specifies SQL statement, for exmample:
|
in the case of ODBC logging logformat specifies SQL statement, for exmample:
|
||||||
.br
|
.br
|
||||||
logformat "-'+_Linsert into log (l_date, l_user, l_service, l_in, l_out, l_descr) values ('%d-%m-%Y %H:%M:%S', '%U', '%N', %I, %O, '%T')"
|
logformat "-\'+_Linsert into log (l_date, l_user, l_service, l_in, l_out, l_descr) values (\'%d-%m-%Y %H:%M:%S\', \'%U\', \'%N\', %I, %O, \'%T\')"
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B logdump
|
.B logdump
|
||||||
@@ -344,36 +368,59 @@ can use %A as produced archive name and %F as filename.
|
|||||||
|
|
||||||
.br
|
.br
|
||||||
.B timeouts
|
.B timeouts
|
||||||
<BYTE_SHORT> <BYTE_LONG> <STRING_SHORT> <STRING_LONG> <CONNECTION_SHORT> <CONNECTION_LONG> <DNS> <CHAIN>
|
<BYTE_SHORT> <BYTE_LONG> <STRING_SHORT> <STRING_LONG> <CONNECTION_SHORT> <CONNECTION_LONG> <DNS> <CHAIN> <CONNECT> <CONNECTBACK>
|
||||||
.br
|
.br
|
||||||
Sets timeout values
|
Sets timeout values, defaults 1, 5, 30, 60, 180, 1800, 15, 60, 15, 5.
|
||||||
.br
|
.br
|
||||||
BYTE_SHORT - short timeout for single byte, is usually used for receiving single byte from stream.
|
BYTE_SHORT short timeout for single byte, is usually used for receiving single byte from stream.
|
||||||
.br
|
.br
|
||||||
BYTE_LONG - long timeout for single byte, is usually used for receiving first byte in frame (for example first byte in socks request).
|
BYTE_LONG long timeout for single byte, is usually used for receiving first byte in frame (for example first byte in socks request).
|
||||||
.br
|
.br
|
||||||
STRING_SHORT - short timeout, for character string within stream (for example to wait between 2 HTTP headers)
|
STRING_SHORT short timeout, for character string within stream (for example to wait between 2 HTTP headers)
|
||||||
.br
|
.br
|
||||||
STRING_LONG - long timeout, for first string in stream (for example to wait for HTTP request).
|
STRING_LONG long timeout, for first string in stream (for example to wait for HTTP request).
|
||||||
.br
|
.br
|
||||||
CONNECTION_SHORT - inactivity timeout for short connections (HTTP, POP3, etc).
|
CONNECTION_SHORT inactivity timeout for short connections (HTTP, POP3, etc).
|
||||||
.br
|
.br
|
||||||
CONNECTION_LONG - inactivity timeout for long connection (SOCKS, portmappers, etc).
|
CONNECTION_LONG inactivity timeout for long connection (SOCKS, portmappers, etc).
|
||||||
.br
|
.br
|
||||||
DNS - timeout for DNS request before requesting next server
|
DNS timeout for DNS request before requesting next server
|
||||||
.br
|
.br
|
||||||
CHAIN - timeout for reading data from chained connection
|
CHAIN timeout for reading data from chained connection
|
||||||
.br
|
.br
|
||||||
|
default timeouts 1 5 30 60 180 1800 15 60 15 5
|
||||||
|
|
||||||
|
.br
|
||||||
|
.B radius
|
||||||
|
<NAS_SECRET> <radius_server_1[:port][/local_address_1]> <radius_server_2[:port][/local_address_2]>
|
||||||
|
.br
|
||||||
|
Configures RADIUS servers to be used for logging and authentication (log and auth types
|
||||||
|
must be set to radius). port and local address to use with given server may be specified.
|
||||||
|
.br
|
||||||
|
Attributes within request: User-Name, Password: (username and password if presented by client),
|
||||||
|
Service Type: Authenticate-Only,
|
||||||
|
NAS-Port-Type: NAS-Port-Virtual,
|
||||||
|
NAS-Port-ID: (proxy service port, e.g. 1080),
|
||||||
|
NAS-IPv6-Address / NAS-IP-Address: (proxy interface accessed by client),
|
||||||
|
NAS-Identifier: (text identifing proxy, e.g. PROXY or SOCKSv5),
|
||||||
|
Framed-IPv6-Address / Framed-IP-Address: (IP address of the client),
|
||||||
|
Called-Station-ID: (requested Hostname, if presents),
|
||||||
|
Login-Service: (type of request, e.g. 1001 - SOCKS CONNECT, 1010 - HTTP GET, 1013 - HTTP CONNECT),
|
||||||
|
Login-TCP-Port: (requested port),
|
||||||
|
Login-IPv6-Host / Login-IP-Host: (requested IP).
|
||||||
|
.br
|
||||||
|
Supported reply attributes for authentication:
|
||||||
|
Framed-IP-Address / Framed-IPv6-Address (IP to assign to user), Reply-Message.
|
||||||
|
Use authcache to speedup authentication. RADIUS feature is currently experimental.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B nserver
|
.B nserver
|
||||||
<ipaddr>[:port][/tcp]
|
<ipaddr>[:port][/tcp]
|
||||||
.br
|
.br
|
||||||
Nameserver to use for name resolutions. If none specified
|
Nameserver to use for name resolutions. If none specified
|
||||||
or name server fails system routines for name resolution will be
|
system routines for name resolution is
|
||||||
used. It's better to specify nserver because gethostbyname() may
|
used. Optional port number may be specified.
|
||||||
be thread unsafe. 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 will be
|
|
||||||
performed over TCP.
|
performed over TCP.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
@@ -406,7 +453,7 @@ redirected to parent proxy with http, socks4+, connect+ or socks5+.
|
|||||||
.B dialer
|
.B dialer
|
||||||
<progname>
|
<progname>
|
||||||
.br
|
.br
|
||||||
Execute progname if external name can't be resolved.
|
Execute progname if external name can\'t be resolved.
|
||||||
Hint: if you use nscache, dialer may not work, because names will
|
Hint: if you use nscache, dialer may not work, because names will
|
||||||
be resolved through cache. In this case you can use something like
|
be resolved through cache. In this case you can use something like
|
||||||
http://dial.right.now/ from browser to set up connection.
|
http://dial.right.now/ from browser to set up connection.
|
||||||
@@ -425,8 +472,8 @@ gateways. Since 0.8 version, IPv6 address may be used.
|
|||||||
<ipaddr>
|
<ipaddr>
|
||||||
.br
|
.br
|
||||||
sets ip address of external interface. This IP address will be source
|
sets ip address of external interface. This IP address will be source
|
||||||
address for all connections made by proxy. Alternatively you can use
|
address for all connections made by proxy. Alternatively you can use -e
|
||||||
-e option to specify individual address for gateway. Since 0.8 version
|
option to specify individual address for gateway. Since 0.8 version
|
||||||
External or -e can be given twice: once with IPv4 and once with IPv6 address.
|
External or -e can be given twice: once with IPv4 and once with IPv6 address.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
@@ -447,8 +494,8 @@ to reinstall service.
|
|||||||
.br
|
.br
|
||||||
.B daemon
|
.B daemon
|
||||||
.br
|
.br
|
||||||
Should be specified to close console. Do not use 'daemon' with 'service'.
|
Should be specified to close console. Do not use \'daemon\' with \'service\'.
|
||||||
At least under FreeBSD 'daemon' should preceed any proxy service
|
At least under FreeBSD \'daemon\' should preceed any proxy service
|
||||||
and log commands to avoid sockets problem. Always place it in the beginning
|
and log commands to avoid sockets problem. Always place it in the beginning
|
||||||
of the configuration file.
|
of the configuration file.
|
||||||
|
|
||||||
@@ -458,39 +505,41 @@ of the configuration file.
|
|||||||
.br
|
.br
|
||||||
Type of user authorization. Currently supported:
|
Type of user authorization. Currently supported:
|
||||||
.br
|
.br
|
||||||
none - no authentication or authorization required.
|
none - no authentication or authorization required.
|
||||||
.br
|
.br
|
||||||
Note: is auth is none any ip based limitation, redirection, etc will not work.
|
Note: is auth is none any ip based limitation, redirection, etc will not work.
|
||||||
This is default authentication type
|
This is default authentication type
|
||||||
.br
|
.br
|
||||||
iponly - authentication by access control list with username ignored.
|
iponly - authentication by access control list with username ignored.
|
||||||
Appropriate for most cases
|
Appropriate for most cases
|
||||||
.br
|
.br
|
||||||
useronly - authentication by username without checking for any password with
|
useronly - authentication by username without checking for any password with
|
||||||
authorization by ACLs. Useful for e.g. SOCKSv4 proxy and icqpr (icqpr set UIN /
|
authorization by ACLs. Useful for e.g. SOCKSv4 proxy and icqpr (icqpr set UIN /
|
||||||
AOL screen name as a username)
|
AOL screen name as a username)
|
||||||
.br
|
.br
|
||||||
dnsname - authentication by DNS hostnname with authorization by ACLs.
|
dnsname - authentication by DNS hostnname with authorization by ACLs.
|
||||||
DNS hostname is resolved via PTR (reverse) record and validated (resolved
|
DNS hostname is resolved via PTR (reverse) record and validated (resolved
|
||||||
name must resolve to same IP address). It's recommended to use authcache by
|
name must resolve to same IP address). It\'s recommended to use authcache by
|
||||||
ip for this authentication.
|
ip for this authentication.
|
||||||
NB: there is no any password check, name may be spoofed.
|
NB: there is no any password check, name may be spoofed.
|
||||||
.br
|
.br
|
||||||
strong - username/password authentication required. It will work with
|
strong - username/password authentication required. It will work with
|
||||||
SOCKSv5, FTP, POP3 and HTTP proxy.
|
SOCKSv5, FTP, POP3 and HTTP proxy.
|
||||||
.br
|
.br
|
||||||
cache - cached authentication, may be used with 'authcache'.
|
cache - cached authentication, may be used with \'authcache\'.
|
||||||
|
.br
|
||||||
|
radius - authentication with RADIUS.
|
||||||
.br
|
.br
|
||||||
Plugins may add additional authentication types.
|
Plugins may add additional authentication types.
|
||||||
.br
|
|
||||||
|
|
||||||
It's possible to use few authentication types in the same commands. E.g.
|
|
||||||
.br
|
.br
|
||||||
auth iponly strong
|
It\'s possible to use few authentication types in the same commands. E.g.
|
||||||
.br
|
.br
|
||||||
In this case 'strong' authentication will be used only in case resource
|
auth iponly strong
|
||||||
access can not be performed with 'iponly' authentication, that is username is
|
.br
|
||||||
required in ACL. It's usefull to protect access to some resources with
|
In this case \'strong\' authentication will be used only in case resource
|
||||||
|
access can not be performed with \'iponly\' authentication, that is username is
|
||||||
|
required in ACL. It\'s usefull to protect access to some resources with
|
||||||
password allowing passwordless access to another resources, or to use
|
password allowing passwordless access to another resources, or to use
|
||||||
IP-based authentication for dedicated laptops and request username/password for
|
IP-based authentication for dedicated laptops and request username/password for
|
||||||
shared ones.
|
shared ones.
|
||||||
@@ -502,17 +551,23 @@ shared ones.
|
|||||||
Cache authentication information to given amount of time (cachetime) in seconds.
|
Cache authentication information to given amount of time (cachetime) in seconds.
|
||||||
Cahtype is one of:
|
Cahtype is one of:
|
||||||
.br
|
.br
|
||||||
ip - after successful authentication all connections during caching time
|
ip - after successful authentication all connections during caching time
|
||||||
from same IP are assigned to the same user, username is not requested.
|
from same IP are assigned to the same user, username is not requested.
|
||||||
.br
|
.br
|
||||||
ip,user username is requested and all connections from the same IP are
|
ip,user username is requested and all connections from the same IP are
|
||||||
assigned to the same user without actual authentication.
|
assigned to the same user without actual authentication.
|
||||||
.br
|
.br
|
||||||
user - same as above, but IP is not checked.
|
user - same as above, but IP is not checked.
|
||||||
.br
|
.br
|
||||||
user,password - both username and password are checked against cached ones.
|
user,password - both username and password are checked against cached ones.
|
||||||
.br
|
.br
|
||||||
Use auth type 'cache' for cached authentication
|
limit - limit user to use only one ip, \'ip\' and \'user\' are required
|
||||||
|
.br
|
||||||
|
acl - only use cached auth if user access service with same ACL
|
||||||
|
.br
|
||||||
|
ext - cache external IP
|
||||||
|
.br
|
||||||
|
Use auth type \'cache\' for cached authentication
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B allow
|
.B allow
|
||||||
@@ -526,13 +581,13 @@ Use auth type 'cache' for cached authentication
|
|||||||
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
|
||||||
username must be in uppercase). Source and target lists may contain
|
username must be in uppercase). Source and target lists may contain
|
||||||
IP addresses (W.X.Y.Z), ranges A.B.C.D - W.X.Y.Z (since 0.8) or CIDRs
|
IP addresses (W.X.Y.Z), ranges A.B.C.D - W.X.Y.Z (since 0.8) or CIDRs (W.X.Y.Z/L).
|
||||||
(W.X.Y.Z/L). Since 0.6, targetlist may also contain host names,
|
Since 0.6, targetlist may also contain host names,
|
||||||
instead of addresses. It's possible to use wildmask in
|
instead of addresses. It\'s possible to use wildmask in
|
||||||
the begginning and in the the end of hostname, e.g. *badsite.com or
|
the begginning and in the the end of hostname, e.g. *badsite.com or *badcontent*.
|
||||||
*badcontent*. Hostname is only checked if hostname presents in request.
|
Hostname is only checked if hostname presents in request.
|
||||||
Targetportlist may contain ports (X) or port ranges lists (X-Y). For any field
|
Targetportlist may contain ports (X) or port ranges lists (X-Y). For any field *
|
||||||
* sign means "ANY" If access list is empty it's assumed to be
|
sign means ANY. If access list is empty it\'s assumed to be
|
||||||
.br
|
.br
|
||||||
allow *
|
allow *
|
||||||
.br
|
.br
|
||||||
@@ -540,54 +595,57 @@ Targetportlist may contain ports (X) or port ranges lists (X-Y). For any field
|
|||||||
.br
|
.br
|
||||||
deny *
|
deny *
|
||||||
.br
|
.br
|
||||||
You may want explicitly add "deny *" to the end of access list to prevent
|
You may want explicitly add deny * to the end of access list to prevent
|
||||||
HTTP proxy from requesting user's password.
|
HTTP proxy from requesting user\'s password.
|
||||||
Access lists are checked after user have requested any resource.
|
Access lists are checked after user have requested any resource.
|
||||||
If you want 3proxy to reject connections from specific addresses
|
If you want 3proxy to reject connections from specific addresses
|
||||||
immediately without any conditions you should either bind proxy
|
immediately without any conditions you should either bind proxy
|
||||||
to appropriate interface only or to use ip filters.
|
to appropriate interface only or to use ip filters.
|
||||||
.br
|
|
||||||
|
|
||||||
Operation is one of:
|
|
||||||
.br
|
.br
|
||||||
CONNECT - establish outgoing TCP connection
|
Operation is one of:
|
||||||
.br
|
.br
|
||||||
BIND - bind TCP port for listening
|
CONNECT establish outgoing TCP connection
|
||||||
.br
|
.br
|
||||||
UDPASSOC - make UDP association
|
BIND bind TCP port for listening
|
||||||
.br
|
.br
|
||||||
ICMPASSOC - make ICMP association (for future use)
|
UDPASSOC make UDP association
|
||||||
.br
|
.br
|
||||||
HTTP_GET - HTTP GET request
|
ICMPASSOC make ICMP association (for future use)
|
||||||
.br
|
.br
|
||||||
HTTP_PUT - HTTP PUT request
|
HTTP_GET HTTP GET request
|
||||||
.br
|
.br
|
||||||
HTTP_POST - HTTP POST request
|
HTTP_PUT HTTP PUT request
|
||||||
.br
|
.br
|
||||||
HTTP_HEAD - HTTP HEAD request
|
HTTP_POST HTTP POST request
|
||||||
.br
|
.br
|
||||||
HTTP_CONNECT - HTTP CONNECT request
|
HTTP_HEAD HTTP HEAD request
|
||||||
.br
|
.br
|
||||||
HTTP_OTHER - over HTTP request
|
HTTP_CONNECT HTTP CONNECT request
|
||||||
.br
|
.br
|
||||||
HTTP - matches any HTTP request except HTTP_CONNECT
|
HTTP_OTHER over HTTP request
|
||||||
.br
|
.br
|
||||||
HTTPS - same as HTTP_CONNECT
|
HTTP matches any HTTP request except HTTP_CONNECT
|
||||||
.br
|
.br
|
||||||
FTP_GET - FTP get request
|
HTTPS same as HTTP_CONNECT
|
||||||
.br
|
.br
|
||||||
FTP_PUT - FTP put request
|
FTP_GET FTP get request
|
||||||
.br
|
.br
|
||||||
FTP_LIST - FTP list request
|
FTP_PUT FTP put request
|
||||||
.br
|
.br
|
||||||
FTP_DATA - FTP data connection. Note: FTP_DATA requires access to dynamic
|
FTP_LIST FTP list request
|
||||||
|
.br
|
||||||
|
FTP_DATA FTP data connection. Note: FTP_DATA requires access to dynamic
|
||||||
non-ptivileged (1024-65535) ports on remote side.
|
non-ptivileged (1024-65535) ports on remote side.
|
||||||
.br
|
.br
|
||||||
FTP - matches any FTP/FTP Data request
|
FTP matches any FTP/FTP Data request
|
||||||
.br
|
.br
|
||||||
ADMIN - access to administration interface
|
ADMIN access to administration interface
|
||||||
|
|
||||||
.br
|
.br
|
||||||
Weeksdays are week days numbers or periods, 0 or 7 means Sunday, 1 is Monday, 1-5 means Monday through Friday. Timeperiodlists is a list of time
|
Weeksdays are week days numbers or periods, 0 or 7 means Sunday, 1 is Monday, 1-5 means Monday through Friday.
|
||||||
|
.br
|
||||||
|
Timeperiodlists is a list of time
|
||||||
periods in HH:MM:SS-HH:MM:SS format. For example, 00:00:00-08:00:00,17:00:00-24:00:00 lists non-working hours.
|
periods in HH:MM:SS-HH:MM:SS format. For example, 00:00:00-08:00:00,17:00:00-24:00:00 lists non-working hours.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
@@ -624,51 +682,52 @@ connections. These 2 proxies form 1 group (summarized weight is 1000).
|
|||||||
.br
|
.br
|
||||||
creates chain of 3 proxies: 192.168.10.1, 192.168.20.1 and third
|
creates chain of 3 proxies: 192.168.10.1, 192.168.20.1 and third
|
||||||
is (192.168.30.1 with probability of 0.3 or 192.168.40.1
|
is (192.168.30.1 with probability of 0.3 or 192.168.40.1
|
||||||
with probability of 0.7) for outgoing web connections.
|
with probability of 0.7) for outgoing web connections. Chains are only applied to new connections, pipelined (keep-alive) requests in the same connection use the same chain.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
type is one of:
|
type is one of:
|
||||||
.br
|
.br
|
||||||
tcp - simply redirect connection. TCP is always last in chain.
|
extip does not actully redirect request, it sets external address for this request to <ip>. It can be chained with another parent types. It's usefaul to set external IP based on ACL or make it random.
|
||||||
.br
|
.br
|
||||||
http - redirect to HTTP proxy. HTTP is always last chain.
|
tcp simply redirect connection. TCP is always last in chain. This type of proxy is a simple TCP redirection, it does not support parent authentication.
|
||||||
.br
|
.br
|
||||||
pop3 - redirect to POP3 proxy (only local redirection is supported, can not be
|
http redirect to HTTP proxy. HTTP is always the last chain. It should only be used with http (proxy) service,
|
||||||
used for chaining)
|
if used with different service, it works as tcp redirection.
|
||||||
.br
|
.br
|
||||||
ftp - redirect to FTP proxy (only local redirection is supported, can not be
|
pop3 redirect to POP3 proxy (only local redirection is supported, can only be used as a first hop in chaining)
|
||||||
used for chaining)
|
|
||||||
.br
|
.br
|
||||||
connect - parent is HTTP CONNECT method proxy
|
ftp redirect to FTP proxy (only local redirection is supported, can only be used as a first hop in chaining)
|
||||||
.br
|
.br
|
||||||
connect+ - parent is HTTP CONNECT proxy with name resolution
|
connect parent is HTTP CONNECT method proxy
|
||||||
.br
|
.br
|
||||||
socks4 - parent is SOCKSv4 proxy
|
connect+ parent is HTTP CONNECT proxy with name resolution (hostname is used instead of IP if available)
|
||||||
.br
|
.br
|
||||||
socks4+ - parent is SOCKSv4 proxy with name resolution (SOCKSv4a)
|
socks4 parent is SOCKSv4 proxy
|
||||||
.br
|
.br
|
||||||
socks5 - parent is SOCKSv5 proxy
|
socks4+ parent is SOCKSv4 proxy with name resolution (SOCKSv4a)
|
||||||
.br
|
.br
|
||||||
socks5+ - parent is SOCKSv5 proxy with name resolution
|
socks5 parent is SOCKSv5 proxy
|
||||||
.br
|
.br
|
||||||
socks4b - parent is SOCKS4b (broken SOCKSv4 implementation with shortened
|
socks5+ parent is SOCKSv5 proxy with name resolution
|
||||||
|
.br
|
||||||
|
socks4b parent is SOCKS4b (broken SOCKSv4 implementation with shortened
|
||||||
server reply. I never saw this kind ofservers byt they say there are).
|
server reply. I never saw this kind ofservers byt they say there are).
|
||||||
Normally you should not use this option. Do not mess this option with
|
Normally you should not use this option. Do not mess this option with
|
||||||
SOCKSv4a (socks4+).
|
SOCKSv4a (socks4+).
|
||||||
.br
|
.br
|
||||||
socks5b - parent is SOCKS5b (broken SOCKSv5 implementation with shortened
|
socks5b parent is SOCKS5b (broken SOCKSv5 implementation with shortened
|
||||||
server reply. I think you will never find it useful). Never use this option
|
server reply. I think you will never find it useful). Never use this option
|
||||||
unless you know exactly you need it.
|
unless you know exactly you need it.
|
||||||
.br
|
.br
|
||||||
admin - redirect request to local 'admin' service (with -s parameter).
|
admin redirect request to local \'admin\' service (with -s parameter).
|
||||||
.br
|
.br
|
||||||
Use "+" proxy only with "fakeresolve" option
|
Use "+" proxy only with "fakeresolve" option
|
||||||
.br
|
.br
|
||||||
|
|
||||||
IP and port are ip addres and port of parent proxy server.
|
IP and port are ip addres and port of parent proxy server.
|
||||||
If IP is zero, ip is taken from original request, only port is changed.
|
If IP is zero, ip is taken from original request, only port is changed.
|
||||||
If port is zero, it's taken from original request, only IP is changed.
|
If port is zero, it\'s taken from original request, only IP is changed.
|
||||||
If both IP and port are zero - it's a special case of local redirection,
|
If both IP and port are zero - it\'s a special case of local redirection,
|
||||||
it works only with
|
it works only with
|
||||||
.B socks
|
.B socks
|
||||||
proxy. In case of local redirection request is redirected to different service,
|
proxy. In case of local redirection request is redirected to different service,
|
||||||
@@ -683,14 +742,14 @@ locally redurects to
|
|||||||
.B proxy
|
.B proxy
|
||||||
.B admin
|
.B admin
|
||||||
locally redirects to admin -s service.
|
locally redirects to admin -s service.
|
||||||
.br
|
|
||||||
|
|
||||||
|
.br
|
||||||
Main purpose of local redirections is to have requested resource
|
Main purpose of local redirections is to have requested resource
|
||||||
(URL or POP3 username) logged and protocol-specific filters to be applied.
|
(URL or POP3 username) logged and protocol-specific filters to be applied.
|
||||||
In case of local redirection ACLs are revied twice: first, by SOCKS proxy up to
|
In case of local redirection ACLs are revied twice: first, by SOCKS proxy up to \'parent\'
|
||||||
'parent' command and then with gateway service connection is
|
command and then with gateway service connection is
|
||||||
redirected (HTTP, FTP or POP3) after 'parent' command. It means,
|
redirected (HTTP, FTP or POP3) after \'parent\' command. It means,
|
||||||
additional 'allow' command is required for redirected requests, for
|
additional \'allow\' command is required for redirected requests, for
|
||||||
example:
|
example:
|
||||||
.br
|
.br
|
||||||
allow * * * 80
|
allow * * * 80
|
||||||
@@ -706,11 +765,10 @@ local HTTP proxy parses requests and allows only GET and POST requests.
|
|||||||
.br
|
.br
|
||||||
parent 1000 http 1.2.3.4 0
|
parent 1000 http 1.2.3.4 0
|
||||||
.br
|
.br
|
||||||
Changes external address for given connection to 1.2.3.4
|
Changes external address for given connection to 1.2.3.4 (an equivalent to -e1.2.3.4)
|
||||||
(an equivalent to -e1.2.3.4)
|
|
||||||
.br
|
.br
|
||||||
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
|
.br
|
||||||
@@ -736,27 +794,42 @@ nolog
|
|||||||
.br
|
.br
|
||||||
Weight may be used for different purposes.
|
Weight may be used for different purposes.
|
||||||
|
|
||||||
|
|
||||||
|
.br
|
||||||
|
.B force
|
||||||
|
.br
|
||||||
|
.B noforce
|
||||||
|
.br
|
||||||
|
If force is specified for service, configuration reload will require all current
|
||||||
|
sessions of this service to be re-authenticated. If ACL is changed or user account
|
||||||
|
is removed, old connections which do not match current are closed.
|
||||||
|
noforce allows to keep previously authenticated connections.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B bandlimin
|
.B bandlimin
|
||||||
<rate> <userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
<rate> <userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
||||||
|
<weekdayslist> <timeperiodslist>
|
||||||
.br
|
.br
|
||||||
.B nobandlimin
|
.B nobandlimin
|
||||||
<userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
<userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
||||||
|
<weekdayslist> <timeperiodslist>
|
||||||
.br
|
.br
|
||||||
.B bandlimout
|
.B bandlimout
|
||||||
<rate> <userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
<rate> <userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
||||||
|
<weekdayslist> <timeperiodslist>
|
||||||
.br
|
.br
|
||||||
.B nobandlimout
|
.B nobandlimout
|
||||||
<userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
<userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
||||||
|
<weekdayslist> <timeperiodslist>
|
||||||
.br
|
.br
|
||||||
bandlim sets bandwith limitation filter to <rate> bps (bits per second)
|
bandlim sets bandwith limitation filter to <rate> bps (bits per second)
|
||||||
(if you want to specife bytes per second - multiply your value to 8).
|
If you want to specife bytes per second - multiply your value to 8.
|
||||||
bandlim rules act in a same manner as allow/deny rules except
|
bandlim rules act in a same manner as allow/deny rules except
|
||||||
one thing: bandwidth limiting is applied to all services, not to some
|
one thing: bandwidth limiting is applied to all services, not to some
|
||||||
specific service.
|
specific service.
|
||||||
bandlimin and nobandlimin applies to incoming traffic
|
bandlimin and nobandlimin applies to incoming traffic
|
||||||
bandlimout and nobandlimout applies to outgoing traffic
|
bandlimout and nobandlimout applies to outgoing traffic
|
||||||
If tou want to ratelimit your clients with ip's 192.168.10.16/30 (4
|
If tou want to ratelimit your clients with IPs 192.168.10.16/30 (4
|
||||||
addresses) to 57600 bps you have to specify 4 rules like
|
addresses) to 57600 bps you have to specify 4 rules like
|
||||||
.br
|
.br
|
||||||
bandlimin 57600 * 192.168.10.16
|
bandlimin 57600 * 192.168.10.16
|
||||||
@@ -778,31 +851,71 @@ if you want, for example, to limit all speed ecept access to POP3 you can use
|
|||||||
.br
|
.br
|
||||||
before the rest of bandlim rules.
|
before the rest of bandlim rules.
|
||||||
|
|
||||||
|
.br
|
||||||
|
.B connlim
|
||||||
|
<rate> <period> <userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
||||||
|
<weekdayslist> <timeperiodslist>
|
||||||
|
.br
|
||||||
|
.B noconnlim
|
||||||
|
<userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
||||||
|
<weekdayslist> <timeperiodslist>
|
||||||
|
.br
|
||||||
|
connlim sets connections rate limit per time period for traffic
|
||||||
|
pattern controlled by ACL. Period is in seconds. If period is 0,
|
||||||
|
connlim limits a number of parallel connections.
|
||||||
|
.br
|
||||||
|
connlim 100 60 * 127.0.0.1
|
||||||
|
.br
|
||||||
|
allows 100 connections per minute for 127.0.0.1.
|
||||||
|
.br
|
||||||
|
connlim 20 0 * 127.0.0.1
|
||||||
|
.br
|
||||||
|
allows 20 simulationeous connections for 127.0.0.1.
|
||||||
|
.br
|
||||||
|
Like with bandlimin, if individual limit is required per client, separate
|
||||||
|
rule mustbe added for every client. Like with nobanlimin, noconnlim adds an
|
||||||
|
exception.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B counter
|
.B counter
|
||||||
<filename> <reporttype> <repotname>
|
<filename> <reporttype> <repotname>
|
||||||
.br
|
.br
|
||||||
.B countin
|
.B countin
|
||||||
<number> <type> <limit> <userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
<number> <type> <limit> <userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
||||||
|
<weekdayslist> <timeperiodslist>
|
||||||
.br
|
.br
|
||||||
.B nocountin
|
.B nocountin
|
||||||
<userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
<userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
||||||
|
<weekdayslist> <timeperiodslist>
|
||||||
.br
|
.br
|
||||||
.B countout
|
.B countout
|
||||||
<number> <type> <limit> <userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
<number> <type> <limit> <userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
||||||
|
<weekdayslist> <timeperiodslist>
|
||||||
.br
|
.br
|
||||||
.B nocountout
|
.B nocountout
|
||||||
<userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
<userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
||||||
|
<weekdayslist> <timeperiodslist>
|
||||||
|
.br
|
||||||
|
.B countall
|
||||||
|
<number> <type> <limit> <userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
||||||
|
<weekdayslist> <timeperiodslist>
|
||||||
|
.br
|
||||||
|
.B nocountall
|
||||||
|
<userlist> <sourcelist> <targetlist> <targetportlist> <operationlist>
|
||||||
|
<weekdayslist> <timeperiodslist>
|
||||||
.br
|
.br
|
||||||
|
|
||||||
counter, countin, nocountin, countout, noucountout commands are
|
counter, countin, nocountin, countout, noucountout, countall,
|
||||||
used to set traffic limit
|
nocountall commands are used to set traffic limit
|
||||||
in MB for period of time (day, week or month). Filename is a path
|
in MB for period of time (day, week or month). Filename is a path
|
||||||
to a special file where traffic information is permanently stored.
|
to a special file where traffic information is permanently stored.
|
||||||
number is sequential number of record in this file. If number is 0
|
number is sequential number of record in this file. If number is 0
|
||||||
no traffic information on this counter is saved in file (that is
|
this counter is not preserved in counter file (that is
|
||||||
if proxy restarted all information is loosed) overwise it should be
|
if proxy restarted all counters with 0 are flushed) overwise it
|
||||||
unique sequential number.
|
should be unique sequential number which points to position of
|
||||||
|
the couter within the file.
|
||||||
Type specifies a type of counter. Type is one of:
|
Type specifies a type of counter. Type is one of:
|
||||||
.br
|
.br
|
||||||
H - counter is resetted hourly
|
H - counter is resetted hourly
|
||||||
@@ -828,13 +941,13 @@ username[:pwtype:password] ...
|
|||||||
.br
|
.br
|
||||||
pwtype is one of:
|
pwtype is one of:
|
||||||
.br
|
.br
|
||||||
none (empty) - use system authentication
|
none (empty) - use system authentication
|
||||||
.br
|
.br
|
||||||
CL - password is cleartext
|
CL - password is cleartext
|
||||||
.br
|
.br
|
||||||
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
|
.br
|
||||||
example:
|
example:
|
||||||
.br
|
.br
|
||||||
@@ -889,35 +1002,36 @@ configuration within one minute. Any number of files may be monitored.
|
|||||||
.B setuid
|
.B setuid
|
||||||
<uid>
|
<uid>
|
||||||
.br
|
.br
|
||||||
calls setuid(uid), uid must be numeric. Unix only. Warning: under some Linux
|
calls setuid(uid), uid can be numeric or since 0.9 username. Unix only. Warning: under some Linux
|
||||||
kernels setuid() works onle for current thread. It makes it impossible to suid
|
kernels setuid() works for current thread only. It makes it impossible to suid
|
||||||
for all threads.
|
for all threads.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B setgid
|
.B setgid
|
||||||
<gid>
|
<gid>
|
||||||
.br
|
.br
|
||||||
calls setgid(gid), gid must be numeric. Unix only.
|
calls setgid(gid), gid can be numeric or since 0.9 groupname. Unix only.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B chroot
|
.B chroot
|
||||||
<path>
|
<path> [<uid>] [<gid>]
|
||||||
.br
|
.br
|
||||||
calls chroot(path). Unix only.
|
calls chroot(path) and sets gid/uid. Unix only. uid/gid supported since 0.9, can be numeric or username/groupname
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.B stacksize
|
.B stacksize
|
||||||
<value_to_add_to_default_stack_size>
|
<value_to_add_to_default_stack_size>
|
||||||
.br
|
.br
|
||||||
Change default size for threads stack. May be required in some situation,
|
Change default size for threads stack. May be required in some situation,
|
||||||
e.g. with non-default plugins, on on some platforms (some FreeBSD version
|
e.g. with non-default plugins, on on some platforms (some FreeBSD version
|
||||||
may require adjusting stack size due to invalid defined value in system
|
may require adjusting stack size due to invalid defined value in system
|
||||||
header files, this value is also oftent reqruied to be changed for ODBC and
|
header files, this value is also oftent reqruied to be changed for ODBC and
|
||||||
PAM support on Linux. If you experience 3proxy
|
PAM support on Linux. If you experience 3proxy
|
||||||
crash on request processing, try to set some positive value. You may start with
|
crash on request processing, try to set some positive value. You may start with
|
||||||
stacksize 65536
|
stacksize 65536
|
||||||
and then find the minimal value for service to work. If you experience
|
and then find the minimal value for service to work. If you experience
|
||||||
memory shortage, you can try to experiment with negative values.
|
memory shortage, you can try to experiment with negative values.
|
||||||
|
|
||||||
.SH PLUGINS
|
.SH PLUGINS
|
||||||
|
|
||||||
.br
|
.br
|
||||||
@@ -945,7 +1059,7 @@ Report all bugs to
|
|||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
3proxy(8), proxy(8), ftppr(8), socks(8), pop3p(8), tcppm(8), udppm(8), syslogd(8),
|
3proxy(8), proxy(8), ftppr(8), socks(8), pop3p(8), tcppm(8), udppm(8), syslogd(8),
|
||||||
.br
|
.br
|
||||||
http://3proxy.ru/
|
https://3proxy.org/
|
||||||
.SH TRIVIA
|
.SH TRIVIA
|
||||||
3APA3A is pronounced as \`\`zaraza\'\'.
|
3APA3A is pronounced as \`\`zaraza\'\'.
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
|
|||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
.TH ftppr "8" "January 2016" "3proxy 0.8" "Universal proxy server"
|
.TH ftppr "8" "January 2019" "3proxy 0.9" "Universal proxy server"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.B ftppr
|
.B ftppr
|
||||||
\- FTP proxy gateway service
|
\- FTP proxy gateway service
|
||||||
@@ -81,7 +81,7 @@ Report all bugs to
|
|||||||
.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
|
||||||
http://3proxy.ru/
|
https://3proxy.org/
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
3proxy is designed by Vladimir 3APA3A Dubrovin
|
3proxy is designed by Vladimir 3APA3A Dubrovin
|
||||||
.RI ( 3proxy@3proxy.ru )
|
.RI ( 3proxy@3proxy.ru )
|
||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
.TH icqpr "8" "January 2016" "3proxy 0.8" "Universal proxy server"
|
.TH icqpr "8" "January 2019" "3proxy 0.9" "Universal proxy server"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.B icqpr
|
.B icqpr
|
||||||
\- ICQ (AOL OSCAR) proxy
|
\- ICQ (AOL OSCAR) proxy
|
||||||
@@ -74,7 +74,7 @@ Report all bugs to
|
|||||||
.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
|
||||||
http://3proxy.ru/
|
https://3proxy.org/
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
3proxy is designed by Vladimir 3APA3A Dubrovin
|
3proxy is designed by Vladimir 3APA3A Dubrovin
|
||||||
.RI ( 3proxy@3proxy.ru )
|
.RI ( 3proxy@3proxy.ru )
|
||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
.TH pop3p "8" "January 2016" "3proxy 0.8" "Universal proxy server"
|
.TH pop3p "8" "January 2019" "3proxy 0.9" "Universal proxy server"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.B pop3p
|
.B pop3p
|
||||||
\- POP3 proxy gateway service
|
\- POP3 proxy gateway service
|
||||||
@@ -77,7 +77,7 @@ Report all bugs to
|
|||||||
.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
|
||||||
http://3proxy.ru/
|
https://3proxy.org/
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
3proxy is designed by Vladimir 3APA3A Dubrovin
|
3proxy is designed by Vladimir 3APA3A Dubrovin
|
||||||
.RI ( 3proxy@3proxy.ru )
|
.RI ( 3proxy@3proxy.ru )
|
||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
.TH proxy "8" "January 2016" "3proxy 0.8" "Universal proxy server"
|
.TH proxy "8" "January 2019" "3proxy 0.9" "Universal proxy server"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.B proxy
|
.B proxy
|
||||||
\- HTTP proxy gateway service
|
\- HTTP proxy gateway service
|
||||||
@@ -72,7 +72,7 @@ Report all bugs to
|
|||||||
.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
|
||||||
http://3proxy.ru/
|
https://3proxy.org/
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
3proxy is designed by Vladimir 3APA3A Dubrovin
|
3proxy is designed by Vladimir 3APA3A Dubrovin
|
||||||
.RI ( 3proxy@3proxy.ru )
|
.RI ( 3proxy@3proxy.ru )
|
||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
.TH smtpp "8" "January 2016" "3proxy 0.8" "Universal proxy server"
|
.TH smtpp "8" "January 2019" "3proxy 0.9" "Universal proxy server"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.B smtpp
|
.B smtpp
|
||||||
\- SMTP proxy gateway service
|
\- SMTP proxy gateway service
|
||||||
@@ -78,7 +78,7 @@ Report all bugs to
|
|||||||
.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
|
||||||
http://3proxy.ru/
|
https://3proxy.org/
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
3proxy is designed by Vladimir 3APA3A Dubrovin
|
3proxy is designed by Vladimir 3APA3A Dubrovin
|
||||||
.RI ( 3proxy@3proxy.ru )
|
.RI ( 3proxy@3proxy.ru )
|
||||||
+7
-2
@@ -1,4 +1,4 @@
|
|||||||
.TH socks "8" "January 2016" "3proxy 0.8" "Universal proxy server"
|
.TH socks "8" "January 2019" "3proxy 0.9" "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,6 +33,11 @@ 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.
|
||||||
@@ -73,7 +78,7 @@ Report all bugs to
|
|||||||
.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
|
||||||
http://3proxy.ru/
|
https://3proxy.org/
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
3proxy is designed by Vladimir 3APA3A Dubrovin
|
3proxy is designed by Vladimir 3APA3A Dubrovin
|
||||||
.RI ( 3proxy@3proxy.ru )
|
.RI ( 3proxy@3proxy.ru )
|
||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
.TH tcppm "8" "January 2016" "3proxy 0.8" "Universal proxy server"
|
.TH tcppm "8" "January 2019" "3proxy 0.9" "Universal proxy server"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.B tcppm
|
.B tcppm
|
||||||
\- TCP port mapper
|
\- TCP port mapper
|
||||||
@@ -67,7 +67,7 @@ Report all bugs to
|
|||||||
.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
|
||||||
http://3proxy.ru/
|
https://3proxy.org/
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
3proxy is designed by Vladimir 3APA3A Dubrovin
|
3proxy is designed by Vladimir 3APA3A Dubrovin
|
||||||
.RI ( 3proxy@3proxy.ru )
|
.RI ( 3proxy@3proxy.ru )
|
||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
.TH udppm "8" "January 2016" "3proxy 0.8" "Universal proxy server"
|
.TH udppm "8" "January 2019" "3proxy 0.9" "Universal proxy server"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.B udppm
|
.B udppm
|
||||||
\- UDP port mapper
|
\- UDP port mapper
|
||||||
@@ -73,7 +73,7 @@ Report all bugs to
|
|||||||
.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
|
||||||
http://3proxy.ru/
|
https://3proxy.org/
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
3proxy is designed by Vladimir 3APA3A Dubrovin
|
3proxy is designed by Vladimir 3APA3A Dubrovin
|
||||||
.RI ( 3proxy@3proxy.ru )
|
.RI ( 3proxy@3proxy.ru )
|
||||||
@@ -112,7 +112,7 @@ value {\n
|
|||||||
[/--admin--]
|
[/--admin--]
|
||||||
[--proxy--]
|
[--proxy--]
|
||||||
HTTP/1.0 400 Bad Request\n
|
HTTP/1.0 400 Bad Request\n
|
||||||
Proxy-Connection: close\n
|
Connection: close\n
|
||||||
Content-type: text/html; charset=utf-8\n
|
Content-type: text/html; charset=utf-8\n
|
||||||
\n
|
\n
|
||||||
<html><head><title>400 Bad Request</title></head>\n
|
<html><head><title>400 Bad Request</title></head>\n
|
||||||
@@ -122,7 +122,7 @@ Content-type: text/html; charset=utf-8\n
|
|||||||
</html>\n
|
</html>\n
|
||||||
[end]
|
[end]
|
||||||
HTTP/1.0 502 Bad Gateway\n
|
HTTP/1.0 502 Bad Gateway\n
|
||||||
Proxy-Connection: close\n
|
Connection: close\n
|
||||||
Content-type: text/html; charset=utf-8\n
|
Content-type: text/html; charset=utf-8\n
|
||||||
\n
|
\n
|
||||||
<html><head><title>502 Bad Gateway</title></head>\n
|
<html><head><title>502 Bad Gateway</title></head>\n
|
||||||
@@ -131,7 +131,7 @@ Content-type: text/html; charset=utf-8\n
|
|||||||
</body></html>\n
|
</body></html>\n
|
||||||
[end]
|
[end]
|
||||||
HTTP/1.0 503 Service Unavailable\n
|
HTTP/1.0 503 Service Unavailable\n
|
||||||
Proxy-Connection: close\n
|
Connection: close\n
|
||||||
Content-type: text/html; charset=utf-8\n
|
Content-type: text/html; charset=utf-8\n
|
||||||
\n
|
\n
|
||||||
<html><head><title>503 Service Unavailable</title></head>\n
|
<html><head><title>503 Service Unavailable</title></head>\n
|
||||||
@@ -140,7 +140,7 @@ Content-type: text/html; charset=utf-8\n
|
|||||||
</h3></body></html>\n
|
</h3></body></html>\n
|
||||||
[end]
|
[end]
|
||||||
HTTP/1.0 503 Service Unavailable\n
|
HTTP/1.0 503 Service Unavailable\n
|
||||||
Proxy-Connection: close\n
|
Connection: close\n
|
||||||
Content-type: text/html; charset=utf-8\n
|
Content-type: text/html; charset=utf-8\n
|
||||||
\n
|
\n
|
||||||
<html><head><title>503 Service Unavailable</title></head>\n
|
<html><head><title>503 Service Unavailable</title></head>\n
|
||||||
@@ -149,7 +149,7 @@ Content-type: text/html; charset=utf-8\n
|
|||||||
</h3></body></html>\n
|
</h3></body></html>\n
|
||||||
[end]
|
[end]
|
||||||
HTTP/1.0 501 Not Implemented\n
|
HTTP/1.0 501 Not Implemented\n
|
||||||
Proxy-Connection: close\n
|
Connection: close\n
|
||||||
Content-type: text/html; charset=utf-8\n
|
Content-type: text/html; charset=utf-8\n
|
||||||
\n
|
\n
|
||||||
<html><head><title>501 Not Implemented</title></head>\n
|
<html><head><title>501 Not Implemented</title></head>\n
|
||||||
@@ -158,7 +158,7 @@ Content-type: text/html; charset=utf-8\n
|
|||||||
</h3></body></html>\n
|
</h3></body></html>\n
|
||||||
[end]
|
[end]
|
||||||
HTTP/1.0 502 Bad Gateway\n
|
HTTP/1.0 502 Bad Gateway\n
|
||||||
Proxy-Connection: close\n
|
Connection: close\n
|
||||||
Content-type: text/html; charset=utf-8\n
|
Content-type: text/html; charset=utf-8\n
|
||||||
\n
|
\n
|
||||||
<html><head><title>502 Bad Gateway</title></head>\n
|
<html><head><title>502 Bad Gateway</title></head>\n
|
||||||
@@ -167,7 +167,7 @@ Content-type: text/html; charset=utf-8\n
|
|||||||
</h3></body></html>\n",
|
</h3></body></html>\n",
|
||||||
[end]
|
[end]
|
||||||
HTTP/1.0 500 Internal Error\n
|
HTTP/1.0 500 Internal Error\n
|
||||||
Proxy-Connection: close\n
|
Connection: close\n
|
||||||
Content-type: text/html; charset=utf-8\n
|
Content-type: text/html; charset=utf-8\n
|
||||||
\n
|
\n
|
||||||
<html><head><title>500 Internal Error</title></head>\n
|
<html><head><title>500 Internal Error</title></head>\n
|
||||||
@@ -177,7 +177,7 @@ Content-type: text/html; charset=utf-8\n
|
|||||||
[end]
|
[end]
|
||||||
HTTP/1.0 407 Proxy Authentication Required\n
|
HTTP/1.0 407 Proxy Authentication Required\n
|
||||||
Proxy-Authenticate: Basic realm="proxy", encoding="utf-8"\n
|
Proxy-Authenticate: Basic realm="proxy", encoding="utf-8"\n
|
||||||
Proxy-Connection: close\n
|
Connection: close\n
|
||||||
Content-type: text/html; charset=utf-8\n
|
Content-type: text/html; charset=utf-8\n
|
||||||
\n
|
\n
|
||||||
<html><head><title>407 Proxy Authentication Required</title></head>\n
|
<html><head><title>407 Proxy Authentication Required</title></head>\n
|
||||||
@@ -191,7 +191,7 @@ HTTP/1.0 200 Connection established\n
|
|||||||
Content-Type: text/html\n\n
|
Content-Type: text/html\n\n
|
||||||
[end]
|
[end]
|
||||||
HTTP/1.0 404 Not Found\n
|
HTTP/1.0 404 Not Found\n
|
||||||
Proxy-Connection: close\n
|
Connection: close\n
|
||||||
Content-type: text/html; charset=utf-8\n
|
Content-type: text/html; charset=utf-8\n
|
||||||
\n
|
\n
|
||||||
<html><head><title>404 Not Found</title></head>\n
|
<html><head><title>404 Not Found</title></head>\n
|
||||||
@@ -200,7 +200,7 @@ Content-type: text/html; charset=utf-8\n
|
|||||||
</h3></body></html>\n
|
</h3></body></html>\n
|
||||||
[end]
|
[end]
|
||||||
HTTP/1.0 403 Forbidden\n
|
HTTP/1.0 403 Forbidden\n
|
||||||
Proxy-Connection: close\n
|
Connection: close\n
|
||||||
Content-type: text/html; charset=utf-8\n
|
Content-type: text/html; charset=utf-8\n
|
||||||
\n
|
\n
|
||||||
<html><head><title>403 Access Denied</title></head>\n
|
<html><head><title>403 Access Denied</title></head>\n
|
||||||
@@ -212,7 +212,7 @@ Content-type: text/html; charset=utf-8\n
|
|||||||
HTTP/1.0 407 Proxy Authentication Required\n
|
HTTP/1.0 407 Proxy Authentication Required\n
|
||||||
Proxy-Authenticate: NTLM\n
|
Proxy-Authenticate: NTLM\n
|
||||||
Proxy-Authenticate: basic realm="proxy", encoding="utf-8"\n
|
Proxy-Authenticate: basic realm="proxy", encoding="utf-8"\n
|
||||||
Proxy-Connection: close\n
|
Connection: close\n
|
||||||
Content-type: text/html; charset=utf-8\n
|
Content-type: text/html; charset=utf-8\n
|
||||||
\n
|
\n
|
||||||
<html><head><title>407 Proxy Authentication Required</title></head>\n
|
<html><head><title>407 Proxy Authentication Required</title></head>\n
|
||||||
@@ -221,18 +221,18 @@ Content-type: text/html; charset=utf-8\n
|
|||||||
</h3></body></html>\n
|
</h3></body></html>\n
|
||||||
[end]
|
[end]
|
||||||
HTTP/1.0 407 Proxy Authentication Required\n
|
HTTP/1.0 407 Proxy Authentication Required\n
|
||||||
Proxy-Connection: keep-alive\n
|
Connection: keep-alive\n
|
||||||
Content-Length: 0\n
|
Content-Length: 0\n
|
||||||
Proxy-Authenticate: NTLM
|
Proxy-Authenticate: NTLM
|
||||||
[end]
|
[end]
|
||||||
HTTP/1.0 403 Forbidden\n
|
HTTP/1.0 403 Forbidden\n
|
||||||
Proxy-Connection: close\n
|
Connection: close\n
|
||||||
Content-type: text/html; charset=us-ascii\n
|
Content-type: text/html; charset=us-ascii\n
|
||||||
\n
|
\n
|
||||||
<pre>
|
<pre>
|
||||||
[end]
|
[end]
|
||||||
HTTP/1.0 503 Service Unavailable\n
|
HTTP/1.0 503 Service Unavailable\n
|
||||||
Proxy-Connection: close\n
|
Connection: close\n
|
||||||
Content-type: text/html; charset=utf-8\n
|
Content-type: text/html; charset=utf-8\n
|
||||||
\n
|
\n
|
||||||
<html><head><title>503 Service Unavailable</title></head>\n
|
<html><head><title>503 Service Unavailable</title></head>\n
|
||||||
@@ -242,7 +242,7 @@ Content-type: text/html; charset=utf-8\n
|
|||||||
[end]
|
[end]
|
||||||
HTTP/1.0 401 Authentication Required\n
|
HTTP/1.0 401 Authentication Required\n
|
||||||
WWW-Authenticate: basic realm="FTP Server", encoding="utf-8"\n
|
WWW-Authenticate: basic realm="FTP Server", encoding="utf-8"\n
|
||||||
Proxy-Connection: close\n
|
Connection: close\n
|
||||||
Content-type: text/html; charset=utf-8\n
|
Content-type: text/html; charset=utf-8\n
|
||||||
\n
|
\n
|
||||||
<html><head><title>401 FTP Server requires authentication</title></head>\n
|
<html><head><title>401 FTP Server requires authentication</title></head>\n
|
||||||
|
|||||||
@@ -0,0 +1,985 @@
|
|||||||
|
#!/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
|
||||||
+9
-16
@@ -1,23 +1,18 @@
|
|||||||
#!/usr/local/etc/3proxy/bin/3proxy
|
|
||||||
daemon
|
|
||||||
pidfile /usr/local/etc/3proxy/3proxy.pid
|
|
||||||
nscache 65536
|
nscache 65536
|
||||||
nserver 127.0.0.1
|
nserver 8.8.8.8
|
||||||
|
nserver 8.8.4.4
|
||||||
|
|
||||||
config /usr/local/etc/3proxy/3proxy.cfg
|
config /conf/3proxy.cfg
|
||||||
monitor /usr/local/etc/3proxy/3proxy.cfg
|
monitor /conf/3proxy.cfg
|
||||||
monitor /usr/local/etc/3proxy/counters
|
|
||||||
monitor /usr/local/etc/3proxy/passwd
|
|
||||||
monitor /usr/local/etc/3proxy/bandlimiters
|
|
||||||
|
|
||||||
log /usr/local/etc/3proxy/log/log D
|
log /logs/3proxy-%y%m%d.log D
|
||||||
rotate 60
|
rotate 60
|
||||||
counter /usr/local/etc/3proxy/3proxy.3cf
|
counter /count/3proxy.3cf
|
||||||
|
|
||||||
users $/usr/local/etc/3proxy/passwd
|
users $/conf/passwd
|
||||||
|
|
||||||
include /usr/local/etc/3proxy/counters
|
include /conf/counters
|
||||||
include /usr/local/etc/3proxy/bandlimiters
|
include /conf/bandlimiters
|
||||||
|
|
||||||
auth strong
|
auth strong
|
||||||
deny * * 127.0.0.1
|
deny * * 127.0.0.1
|
||||||
@@ -28,5 +23,3 @@ flush
|
|||||||
allow admin
|
allow admin
|
||||||
|
|
||||||
admin -p8080
|
admin -p8080
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/3proxy
|
||||||
|
#daemon
|
||||||
|
pidfile /var/run/3proxy/3proxy.pid
|
||||||
|
chroot /usr/local/3proxy proxy proxy
|
||||||
|
include /conf/3proxy.cfg
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=3proxy tiny proxy server
|
||||||
|
Documentation=man:3proxy(1)
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Environment=CONFIGFILE=/etc/3proxy/3proxy.cfg
|
||||||
|
ExecStart=/bin/3proxy ${CONFIGFILE}
|
||||||
|
ExecReload=/bin/kill -SIGUSR1 $MAINPID
|
||||||
|
KillMode=process
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=60s
|
||||||
|
LimitNOFILE=65536
|
||||||
|
LimitNPROC=32768
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
Alias=3proxy.service
|
||||||
@@ -1,10 +1,15 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
if [ $4 ]; then
|
if [ $4 ]; then
|
||||||
echo $1:`/usr/local/etc/3proxy/bin/mycrypt $$ $2` >> /usr/local/etc/3proxy/passwd
|
echo bandlimin $4 $1 >> /etc/3proxy/conf/bandlimiters
|
||||||
echo countin \"`wc -l /usr/local/etc/3proxy/counters|awk '{print $1}'`/$1\" D $3 $1 >> /usr/local/etc/3proxy/counters
|
fi
|
||||||
echo bandlimin $4 $1 >> /usr/local/etc/3proxy/bandlimiters
|
if [ $3 ]; then
|
||||||
|
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
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
man/3proxy.8
|
||||||
|
man/3proxy.cfg.3
|
||||||
|
man/ftppr.8
|
||||||
|
man/icqpr.8
|
||||||
|
man/pop3p.8
|
||||||
|
man/proxy.8
|
||||||
|
man/smtpp.8
|
||||||
|
man/socks.8
|
||||||
|
man/tcppm.8
|
||||||
|
man/udppm.8
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
3proxy (0.9.3-1) buster; urgency=medium
|
||||||
|
|
||||||
|
*3proxy 0.9.3 initial build
|
||||||
|
|
||||||
|
-- z3APA3A <3apa3a@3proxy.org> Thu, 03 Dec 2020 21:13:58 +0300
|
||||||
|
|
||||||
|
3proxy (0.9.2-1) buster; urgency=medium
|
||||||
|
|
||||||
|
*3proxy 0.9.2 initial build
|
||||||
|
|
||||||
|
-- z3APA3A <3apa3a@3proxy.org> Thu, 19 Nov 2020 19:19:19 +0300
|
||||||
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
9
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
/usr/local/3proxy/conf/3proxy.cfg
|
||||||
|
/usr/local/3proxy/conf/add3proxyuser.sh
|
||||||
|
/usr/local/3proxy/conf/bandlimiters
|
||||||
|
/usr/local/3proxy/conf/counters
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
Source: 3proxy
|
||||||
|
Maintainer: z3APA3A <3apa3a@3proxy.org>
|
||||||
|
Section: net
|
||||||
|
Priority: optional
|
||||||
|
Standards-Version: 4.0.0
|
||||||
|
Build-Depends: debhelper (>=10)
|
||||||
|
Homepage: https://3proxy.org/
|
||||||
|
Vcs-Git: https://github.com/z3APA3A/3proxy
|
||||||
|
Vcs-Browser: https://github.com/z3APA3A/3proxy
|
||||||
|
|
||||||
|
Package: 3proxy
|
||||||
|
Architecture: any
|
||||||
|
Depends: ${shlibs:Depends}, ${misc:Depends}
|
||||||
|
Description: tiny free proxy server
|
||||||
|
3Proxy tiny free proxy server is really tiny freeware proxy servers set.
|
||||||
|
It includes HTTP proxy with HTTPS and FTP support, SOCKSv4/SOCKSv4.5/SOCKSv5 proxy (socks/socks.exe), POP3 proxy, SMTP proxy, FTP proxy, caching DNS proxy, TCP and UDP portmappers.
|
||||||
|
You can use every proxy as a standalone program (socks, proxy, tcppm, udppm, pop3p) or use combined program (3proxy). Combined proxy additionally supports features like access control, bandwidth limiting, limiting daily/weekly/monthly traffic amount, proxy chaining, log rotation, syslog and ODBC logging, etc.
|
||||||
|
It's created to be small, simple and yet very functional.
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||||
|
Upstream-Name: 3proxy
|
||||||
|
Upstream-Contact: 3proxy@3proxy.org
|
||||||
|
Source: https://3proxy.org/
|
||||||
|
|
||||||
|
Files: *
|
||||||
|
Copyright: 2000-2020 3APA3A, Vladimir Dubrovin, 3proxy.org
|
||||||
|
License: BSD-3-clause or Apache or GPL-2+ or LGPL-2+
|
||||||
|
|
||||||
|
Files: src/libs/md*.*
|
||||||
|
Copyright: 1990,1991,1992 RSA Data Security, Inc
|
||||||
|
License: public-domain
|
||||||
|
|
||||||
|
Files: src/libs/regex.*
|
||||||
|
Copyright: Henry Spencer
|
||||||
|
License: public-domain
|
||||||
|
|
||||||
|
Files: src/libs/smbdes.c
|
||||||
|
Copyright: Andrew Tridgell 1998
|
||||||
|
License: GPL-2+
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
if [ ! -f /usr/local/3proxy/conf/passwd ]; then \
|
||||||
|
touch /usr/local/3proxy/conf/passwd;\
|
||||||
|
fi
|
||||||
|
chown -R proxy:proxy /usr/local/3proxy
|
||||||
|
chmod 550 /usr/local/3proxy/
|
||||||
|
chmod 550 /usr/local/3proxy/conf/
|
||||||
|
chmod 440 /usr/local/3proxy/conf/*
|
||||||
|
if /bin/systemctl >/dev/null 2>&1; then \
|
||||||
|
/usr/sbin/update-rc.d 3proxy disable || true; \
|
||||||
|
/usr/sbin/chkconfig 3proxy off || true; \
|
||||||
|
/bin/systemctl enable 3proxy.service; \
|
||||||
|
elif [ -x /usr/sbin/update-rc.d ]; then \
|
||||||
|
/usr/sbin/update-rc.d 3proxy defaults; \
|
||||||
|
/usr/sbin/update-rc.d 3proxy enable; \
|
||||||
|
elif [ -x /usr/sbin/chkconfig ]; then \
|
||||||
|
/usr/sbin/chkconfig 3proxy on; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo 3proxy installed.
|
||||||
|
if /bin/systemctl >/dev/null 2>&1; then \
|
||||||
|
/bin/systemctl stop 3proxy.service \
|
||||||
|
/bin/systemctl start 3proxy.service \
|
||||||
|
echo use ;\
|
||||||
|
echo " "systemctl start 3proxy.service ;\
|
||||||
|
echo to start proxy ;\
|
||||||
|
echo " "systemctl stop 3proxy.service ;\
|
||||||
|
echo to stop proxy ;\
|
||||||
|
elif [ -x /usr/sbin/service ]; then \
|
||||||
|
/usr/sbin/service 3proxy stop || true;\
|
||||||
|
/usr/sbin/service 3proxy start || true;\
|
||||||
|
echo " "service 3proxy start ;\
|
||||||
|
echo to start proxy ;\
|
||||||
|
echo " "service 3proxy stop ;\
|
||||||
|
echo to stop proxy ;\
|
||||||
|
fi
|
||||||
|
echo " "/usr/local/3proxy/conf/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 /usr/local/3proxy/conf/3proxy.cfg.
|
||||||
|
echo run \'/usr/local/3proxy/conf/add3proxyuser.sh admin password\' to configure \'admin\' user
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
if [ -x /usr/sbin/useradd ]; then \
|
||||||
|
/usr/bin/getent group proxy >/dev/null || (/usr/sbin/groupadd -f -r proxy || true); \
|
||||||
|
/usr/bin/getent passwd proxy >/dev/null || (/usr/sbin/useradd -Mr -s /bin/false -g proxy -c 3proxy proxy || true); \
|
||||||
|
fi
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/make -f
|
||||||
|
|
||||||
|
%:
|
||||||
|
dh $@
|
||||||
|
|
||||||
|
override_dh_auto_build:
|
||||||
|
ln -s Makefile.Linux Makefile || true
|
||||||
|
dh_auto_build
|
||||||
|
|
||||||
|
override_dh_auto_clean:
|
||||||
|
find src/ -type f -name "*.o" -delete
|
||||||
|
find src/ -type f -name "Makefile.var" -delete
|
||||||
|
find bin/ -type f -executable -delete
|
||||||
|
rm -f Makefile
|
||||||
|
|
||||||
|
override_dh_usrlocal:
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
3.0 (quilt)
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
#!/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 src/3proxy /usr/local/etc/3proxy/bin/3proxy
|
install bin/3proxy /usr/local/bin/3proxy
|
||||||
install src/mycrypt /usr/local/etc/3proxy/bin/mycrypt
|
install bin/mycrypt /usr/local/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,3 +19,4 @@ 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
|
||||||
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
#!/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
|
|
||||||
@@ -0,0 +1,126 @@
|
|||||||
|
Name: 3proxy
|
||||||
|
Version: 0.9.3
|
||||||
|
Release: 1
|
||||||
|
Summary: 3proxy tiny proxy server
|
||||||
|
License: GPL/LGPL/Apache/BSD
|
||||||
|
URL: https://3proxy.org/
|
||||||
|
Vendor: 3proxy.org 3proxy@3proxy.org
|
||||||
|
Prefix: %{_prefix}
|
||||||
|
Packager: z3APA3A
|
||||||
|
Source: https://github.com/%{packager}/%{name}/archive/%{version}.tar.gz
|
||||||
|
|
||||||
|
%description
|
||||||
|
3proxy is lightweight yet powerful proxy server
|
||||||
|
|
||||||
|
%prep
|
||||||
|
%setup -q -n %{name}-%{version}
|
||||||
|
ln -s Makefile.Linux Makefile
|
||||||
|
|
||||||
|
%build
|
||||||
|
make
|
||||||
|
|
||||||
|
%install
|
||||||
|
make DESTDIR=%buildroot install
|
||||||
|
|
||||||
|
%clean
|
||||||
|
make clean
|
||||||
|
|
||||||
|
|
||||||
|
%files
|
||||||
|
/bin/3proxy
|
||||||
|
/bin/ftppr
|
||||||
|
/bin/mycrypt
|
||||||
|
/bin/pop3p
|
||||||
|
/bin/proxy
|
||||||
|
/bin/socks
|
||||||
|
/bin/tcppm
|
||||||
|
/bin/udppm
|
||||||
|
%config(noreplace) /etc/3proxy/3proxy.cfg
|
||||||
|
/etc/3proxy/conf
|
||||||
|
/etc/init.d/3proxy
|
||||||
|
/usr/lib/systemd/system/3proxy.service
|
||||||
|
%config(noreplace) /usr/local/3proxy/conf/3proxy.cfg
|
||||||
|
%config(noreplace) /usr/local/3proxy/conf/add3proxyuser.sh
|
||||||
|
%config(noreplace) /usr/local/3proxy/conf/bandlimiters
|
||||||
|
%config(noreplace) /usr/local/3proxy/conf/counters
|
||||||
|
/usr/local/3proxy/libexec/PCREPlugin.ld.so
|
||||||
|
/usr/local/3proxy/libexec/StringsPlugin.ld.so
|
||||||
|
/usr/local/3proxy/libexec/TrafficPlugin.ld.so
|
||||||
|
/usr/local/3proxy/libexec/TransparentPlugin.ld.so
|
||||||
|
%if "%{_arch}" == "arm"
|
||||||
|
/usr/share/man/man3/3proxy.cfg.3
|
||||||
|
/usr/share/man/man8/3proxy.8
|
||||||
|
/usr/share/man/man8/ftppr.8
|
||||||
|
/usr/share/man/man8/icqpr.8
|
||||||
|
/usr/share/man/man8/pop3p.8
|
||||||
|
/usr/share/man/man8/proxy.8
|
||||||
|
/usr/share/man/man8/smtpp.8
|
||||||
|
/usr/share/man/man8/socks.8
|
||||||
|
/usr/share/man/man8/tcppm.8
|
||||||
|
/usr/share/man/man8/udppm.8
|
||||||
|
%else
|
||||||
|
/usr/share/man/man3/3proxy.cfg.3.gz
|
||||||
|
/usr/share/man/man8/3proxy.8.gz
|
||||||
|
/usr/share/man/man8/ftppr.8.gz
|
||||||
|
/usr/share/man/man8/icqpr.8.gz
|
||||||
|
/usr/share/man/man8/pop3p.8.gz
|
||||||
|
/usr/share/man/man8/proxy.8.gz
|
||||||
|
/usr/share/man/man8/smtpp.8.gz
|
||||||
|
/usr/share/man/man8/socks.8.gz
|
||||||
|
/usr/share/man/man8/tcppm.8.gz
|
||||||
|
/usr/share/man/man8/udppm.8.gz
|
||||||
|
%endif
|
||||||
|
/var/log/3proxy
|
||||||
|
|
||||||
|
%doc doc/*
|
||||||
|
|
||||||
|
%pre
|
||||||
|
if [ -x /usr/sbin/useradd ]; then \
|
||||||
|
/usr/bin/getent group proxy >/dev/null || (/usr/sbin/groupadd -f -r proxy || true); \
|
||||||
|
/usr/bin/getent passwd proxy >/dev/null || (/usr/sbin/useradd -Mr -s /bin/false -g proxy -c 3proxy proxy || true); \
|
||||||
|
fi
|
||||||
|
|
||||||
|
%post
|
||||||
|
if [ ! -f /usr/local/3proxy/conf/passwd ]; then \
|
||||||
|
touch /usr/local/3proxy/conf/passwd;\
|
||||||
|
fi
|
||||||
|
chown -R proxy:proxy /usr/local/3proxy
|
||||||
|
chmod 550 /usr/local/3proxy/
|
||||||
|
chmod 550 /usr/local/3proxy/conf/
|
||||||
|
chmod 440 /usr/local/3proxy/conf/*
|
||||||
|
if /bin/systemctl >/dev/null 2>&1; then \
|
||||||
|
/usr/sbin/update-rc.d 3proxy disable || true; \
|
||||||
|
/usr/sbin/chkconfig 3proxy off || true; \
|
||||||
|
/bin/systemctl enable 3proxy.service; \
|
||||||
|
elif [ -x /usr/sbin/update-rc.d ]; then \
|
||||||
|
/usr/sbin/update-rc.d 3proxy defaults; \
|
||||||
|
/usr/sbin/update-rc.d 3proxy enable; \
|
||||||
|
elif [ -x /usr/sbin/chkconfig ]; then \
|
||||||
|
/usr/sbin/chkconfig 3proxy on; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo 3proxy installed.
|
||||||
|
if /bin/systemctl >/dev/null 2>&1; then \
|
||||||
|
/bin/systemctl stop 3proxy.service \
|
||||||
|
/bin/systemctl start 3proxy.service \
|
||||||
|
echo use ;\
|
||||||
|
echo " "systemctl start 3proxy.service ;\
|
||||||
|
echo to start proxy ;\
|
||||||
|
echo " "systemctl stop 3proxy.service ;\
|
||||||
|
echo to stop proxy ;\
|
||||||
|
elif [ -x /usr/sbin/service ]; then \
|
||||||
|
/usr/sbin/service 3proxy stop || true;\
|
||||||
|
/usr/sbin/service 3proxy start || true;\
|
||||||
|
echo " "service 3proxy start ;\
|
||||||
|
echo to start proxy ;\
|
||||||
|
echo " "service 3proxy stop ;\
|
||||||
|
echo to stop proxy ;\
|
||||||
|
fi
|
||||||
|
echo " "/usr/local/3proxy/conf/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 /usr/local/3proxy/conf/3proxy.cfg.
|
||||||
|
echo run \'/usr/local/3proxy/conf/add3proxyuser.sh admin password\' to configure \'admin\' user
|
||||||
+8
-11
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
3APA3A simpliest proxy server
|
3APA3A simpliest proxy server
|
||||||
(c) 2002-2008 by ZARAZA <3APA3A@security.nnov.ru>
|
(c) 2002-2016 by Vladimir Dubrovin <3proxy@3proxy.ru>
|
||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
@@ -271,16 +271,8 @@ void cyclestep(void){
|
|||||||
}
|
}
|
||||||
if(conf.logname) {
|
if(conf.logname) {
|
||||||
if(timechanged(conf.logtime, conf.time, conf.logtype)) {
|
if(timechanged(conf.logtime, conf.time, conf.logtype)) {
|
||||||
FILE *fp;
|
if(conf.stdlog) conf.stdlog = freopen((char *)dologname (tmpbuf, conf.logname, NULL, conf.logtype, conf.time), "a", conf.stdlog);
|
||||||
fp = fopen((char *)dologname (tmpbuf, conf.logname, NULL, conf.logtype, conf.time), "a");
|
else conf.stdlog = fopen((char *)dologname (tmpbuf, conf.logname, NULL, conf.logtype, conf.time), "a");
|
||||||
if (fp) {
|
|
||||||
pthread_mutex_lock(&log_mutex);
|
|
||||||
fclose(conf.stdlog);
|
|
||||||
conf.stdlog = fp;
|
|
||||||
pthread_mutex_unlock(&log_mutex);
|
|
||||||
}
|
|
||||||
fseek(stdout, 0L, SEEK_END);
|
|
||||||
usleep(SLEEPTIME);
|
|
||||||
conf.logtime = conf.time;
|
conf.logtime = conf.time;
|
||||||
if(conf.logtype != NONE && conf.rotate) {
|
if(conf.logtype != NONE && conf.rotate) {
|
||||||
int t;
|
int t;
|
||||||
@@ -508,6 +500,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
|
|||||||
#else
|
#else
|
||||||
fprintf(stderr, "\n if conffile is missing, configuration is expected from stdin\n");
|
fprintf(stderr, "\n if conffile is missing, configuration is expected from stdin\n");
|
||||||
#endif
|
#endif
|
||||||
|
fprintf(stderr, "available socket options:\n\t%s\n", printopts("\n\t"));
|
||||||
fprintf(stderr, "\n%s %s\n%s\n", conf.stringtable[2], conf.stringtable[3], copyright);
|
fprintf(stderr, "\n%s %s\n%s\n", conf.stringtable[2], conf.stringtable[3], copyright);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@@ -515,10 +508,14 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
|
|||||||
|
|
||||||
pthread_mutex_init(&config_mutex, NULL);
|
pthread_mutex_init(&config_mutex, NULL);
|
||||||
pthread_mutex_init(&bandlim_mutex, NULL);
|
pthread_mutex_init(&bandlim_mutex, NULL);
|
||||||
|
pthread_mutex_init(&connlim_mutex, NULL);
|
||||||
pthread_mutex_init(&hash_mutex, NULL);
|
pthread_mutex_init(&hash_mutex, NULL);
|
||||||
pthread_mutex_init(&tc_mutex, NULL);
|
pthread_mutex_init(&tc_mutex, NULL);
|
||||||
pthread_mutex_init(&pwl_mutex, NULL);
|
pthread_mutex_init(&pwl_mutex, NULL);
|
||||||
pthread_mutex_init(&log_mutex, NULL);
|
pthread_mutex_init(&log_mutex, NULL);
|
||||||
|
#ifndef NORADIUS
|
||||||
|
pthread_mutex_init(&rad_mutex, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
freeconf(&conf);
|
freeconf(&conf);
|
||||||
res = readconfig(fp);
|
res = readconfig(fp);
|
||||||
|
|||||||
File renamed without changes.
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
@@ -1,9 +1,8 @@
|
|||||||
#include "src/version.h"
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
1 VERSIONINFO
|
1 VERSIONINFO
|
||||||
FILEVERSION 0,8,7,0
|
FILEVERSION MAJOR3PROXY,SUBMAJOR3PROXY,MINOR3PROXY,SUBMINOR3PROXY
|
||||||
PRODUCTVERSION 0,8,7,0
|
PRODUCTVERSION MAJOR3PROXY,SUBMAJOR3PROXY,MINOR3PROXY,SUBMINOR3PROXY
|
||||||
FILETYPE 1
|
FILETYPE 1
|
||||||
FILESUBTYPE 0x0L
|
FILESUBTYPE 0x0L
|
||||||
BEGIN
|
BEGIN
|
||||||
@@ -11,15 +10,15 @@ BEGIN
|
|||||||
BEGIN
|
BEGIN
|
||||||
BLOCK "040904E4"
|
BLOCK "040904E4"
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "Comments", "3proxy - tiny proxy server, http://3proxy.ru/\0"
|
VALUE "Comments", "3proxy - tiny proxy server, http://3proxy.org/\0"
|
||||||
VALUE "CompanyName", "Vladimir Dubrovin\0"
|
VALUE "CompanyName", "Vladimir Dubrovin\0"
|
||||||
VALUE "FileDescription", "3proxy - tiny proxy server\0"
|
VALUE "FileDescription", "3proxy - tiny proxy server\0"
|
||||||
VALUE "FileVersion", "0.8.7\0"
|
VALUE "FileVersion", RELEASE3PROXY
|
||||||
VALUE "InternalName", "3proxy\0"
|
VALUE "InternalName", "3proxy\0"
|
||||||
VALUE "LegalCopyright", "Copyright (C) 2002-2016 Vladimir Dubrovin\0"
|
VALUE "LegalCopyright", "Copyright (C) 2002-" YEAR3PROXY " Vladimir Dubrovin\0"
|
||||||
VALUE "OriginalFilename", "3proxy.exe\0"
|
VALUE "OriginalFilename", "3proxy.exe\0"
|
||||||
VALUE "ProductName", "3proxy\0"
|
VALUE "ProductName", "3proxy\0"
|
||||||
VALUE "ProductVersion", "0.8.7\0"
|
VALUE "ProductVersion", RELEASE3PROXY
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
+23
-37
@@ -2,7 +2,7 @@
|
|||||||
# 3 proxy common Makefile
|
# 3 proxy common Makefile
|
||||||
#
|
#
|
||||||
|
|
||||||
all: $(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)udppm$(EXESUFFICS) $(BUILDDIR)socks$(EXESUFFICS) $(BUILDDIR)proxy$(EXESUFFICS) allplugins
|
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
|
||||||
|
|
||||||
|
|
||||||
sockmap$(OBJSUFFICS): sockmap.c proxy.h structures.h
|
sockmap$(OBJSUFFICS): sockmap.c proxy.h structures.h
|
||||||
@@ -11,9 +11,6 @@ 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
|
||||||
|
|
||||||
@@ -44,9 +41,6 @@ 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
|
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
@@ -56,29 +50,26 @@ 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) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) $(COMPATLIBS)
|
$(BUILDDIR)proxy$(EXESUFFICS): sockmap$(OBJSUFFICS) proxy$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) $(COMPATLIBS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)proxy$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) proxy$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)proxy$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) proxy$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) log$(OBJSUFFICS) common$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
||||||
|
|
||||||
$(BUILDDIR)pop3p$(EXESUFFICS): sockmap$(OBJSUFFICS) pop3p$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS)
|
$(BUILDDIR)pop3p$(EXESUFFICS): sockmap$(OBJSUFFICS) pop3p$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS) $(COMPATLIBS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)pop3p$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) pop3p$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)pop3p$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) pop3p$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) log$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
||||||
|
|
||||||
$(BUILDDIR)smtpp$(EXESUFFICS): sockmap$(OBJSUFFICS) smtpp$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) base64$(OBJSUFFICS) $(COMPATLIBS)
|
$(BUILDDIR)smtpp$(EXESUFFICS): sockmap$(OBJSUFFICS) smtpp$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS) base64$(OBJSUFFICS) $(COMPATLIBS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)smtpp$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) smtpp$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) base64$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)smtpp$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) smtpp$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) base64$(OBJSUFFICS) log$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
||||||
|
|
||||||
$(BUILDDIR)ftppr$(EXESUFFICS): sockmap$(OBJSUFFICS) ftppr$(OBJSUFFICS) ftp$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS)
|
$(BUILDDIR)ftppr$(EXESUFFICS): sockmap$(OBJSUFFICS) ftppr$(OBJSUFFICS) ftp$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS) $(COMPATLIBS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)ftppr$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) ftppr$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) ftp$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)ftppr$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) ftppr$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS) ftp$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
|
||||||
|
|
||||||
$(BUILDDIR)socks$(EXESUFFICS): sockmap$(OBJSUFFICS) socks$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS)
|
$(BUILDDIR)socks$(EXESUFFICS): sockmap$(OBJSUFFICS) socks$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)socks$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) socks$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)socks$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) socks$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) log$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
|
||||||
|
|
||||||
$(BUILDDIR)tcppm$(EXESUFFICS): sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) tcppm$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS)
|
$(BUILDDIR)tcppm$(EXESUFFICS): sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) tcppm$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)tcppm$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) tcppm$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)tcppm$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) tcppm$(OBJSUFFICS) log$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
|
||||||
|
|
||||||
$(BUILDDIR)icqpr$(EXESUFFICS): sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) icqpr$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS)
|
$(BUILDDIR)udppm$(EXESUFFICS): sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) udppm$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)icqpr$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) icqpr$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
|
$(LN) $(LNOUT)$(BUILDDIR)udppm$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) udppm$(OBJSUFFICS) log$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
|
||||||
|
|
||||||
$(BUILDDIR)udppm$(EXESUFFICS): sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) udppm$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS)
|
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)udppm$(EXESUFFICS) $(LDFLAGS) 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
|
||||||
@@ -100,9 +91,6 @@ 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
|
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
@@ -118,21 +106,21 @@ 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
|
conf$(OBJSUFFICS): conf.c proxy.h structures.h
|
||||||
$(CC) $(COUT)conf$(OBJSUFFICS) $(CFLAGS) conf.c
|
$(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) dighosts$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(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
|
||||||
|
|
||||||
@@ -155,8 +143,6 @@ 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) srvicqpr$(OBJSUFFICS) srvudppm$(OBJSUFFICS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) myalloc$(OBJSUFFICS) common$(OBJSUFFICS) auth$(OBJSUFFICS) conf$(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) 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) $(VERSIONDEP)
|
||||||
$(LN) $(LNOUT)$(BUILDDIR)3proxy$(EXESUFFICS) $(LDFLAGS) $(VERFILE) 3proxy$(OBJSUFFICS) mainfunc$(OBJSUFFICS) auth$(OBJSUFFICS) conf$(OBJSUFFICS) datatypes$(OBJSUFFICS) srvproxy$(OBJSUFFICS) srvpop3p$(OBJSUFFICS) srvsmtpp$(OBJSUFFICS) srvftppr$(OBJSUFFICS) srvsocks$(OBJSUFFICS) srvtcppm$(OBJSUFFICS) srvicqpr$(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)
|
$(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)
|
||||||
|
|
||||||
clean:
|
|
||||||
@$(REMOVECOMMAND) *$(OBJSUFFICS) $(COMPFILES)
|
|
||||||
+245
-105
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
3APA3A simpliest proxy server
|
3APA3A simpliest proxy server
|
||||||
(c) 2002-2008 by ZARAZA <3APA3A@security.nnov.ru>
|
(c) 2002-2016 by Vladimir Dubrovin <3proxy@3proxy.ru>
|
||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
|
|
||||||
|
|
||||||
int clientnegotiate(struct chain * redir, struct clientparam * param, struct sockaddr * addr){
|
int clientnegotiate(struct chain * redir, struct clientparam * param, struct sockaddr * addr, unsigned char * hostname){
|
||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
unsigned char *username;
|
unsigned char *username;
|
||||||
int res;
|
int res;
|
||||||
@@ -19,10 +19,9 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, struct soc
|
|||||||
|
|
||||||
user = redir->extuser;
|
user = redir->extuser;
|
||||||
pass = redir->extpass;
|
pass = redir->extpass;
|
||||||
if (param->srvinbuf < 4096){
|
if (!param->srvbufsize){
|
||||||
if(param->srvbuf)myfree(param->srvbuf);
|
param->srvbufsize = SRVBUFSIZE;
|
||||||
param->srvbuf = myalloc(4096);
|
param->srvbuf = myalloc(param->srvbufsize);
|
||||||
param->srvbufsize = 4096;
|
|
||||||
}
|
}
|
||||||
buf = param->srvbuf;
|
buf = param->srvbuf;
|
||||||
username = buf + 2048;
|
username = buf + 2048;
|
||||||
@@ -41,11 +40,11 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, struct soc
|
|||||||
case R_CONNECTP:
|
case R_CONNECTP:
|
||||||
{
|
{
|
||||||
len = sprintf((char *)buf, "CONNECT ");
|
len = sprintf((char *)buf, "CONNECT ");
|
||||||
if(redir->type == R_CONNECTP && param->hostname) {
|
if(redir->type == R_CONNECTP && hostname) {
|
||||||
char * needreplace;
|
char * needreplace;
|
||||||
needreplace = strchr((char *)param->hostname, ':');
|
needreplace = strchr((char *)hostname, ':');
|
||||||
if(needreplace) buf[len++] = '[';
|
if(needreplace) buf[len++] = '[';
|
||||||
len += sprintf((char *)buf + len, "%.256s", (char *)param->hostname);
|
len += sprintf((char *)buf + len, "%.256s", (char *)hostname);
|
||||||
if(needreplace) buf[len++] = ']';
|
if(needreplace) buf[len++] = ']';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -54,9 +53,9 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, struct soc
|
|||||||
if(*SAFAMILY(addr) == AF_INET6) buf[len++] = ']';
|
if(*SAFAMILY(addr) == AF_INET6) buf[len++] = ']';
|
||||||
}
|
}
|
||||||
len += sprintf((char *)buf + len,
|
len += sprintf((char *)buf + len,
|
||||||
":%hu HTTP/1.0\r\nProxy-Connection: keep-alive\r\n", ntohs(*SAPORT(addr)));
|
":%hu HTTP/1.0\r\nConnection: keep-alive\r\n", ntohs(*SAPORT(addr)));
|
||||||
if(user){
|
if(user){
|
||||||
len += sprintf((char *)buf + len, "Proxy-authorization: basic ");
|
len += sprintf((char *)buf + len, "Proxy-Authorization: Basic ");
|
||||||
sprintf((char *)username, "%.128s:%.128s", user, pass?pass:(unsigned char *)"");
|
sprintf((char *)username, "%.128s:%.128s", user, pass?pass:(unsigned char *)"");
|
||||||
en64(username, buf+len, (int)strlen((char *)username));
|
en64(username, buf+len, (int)strlen((char *)username));
|
||||||
len = (int)strlen((char *)buf);
|
len = (int)strlen((char *)buf);
|
||||||
@@ -83,7 +82,7 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, struct soc
|
|||||||
buf[0] = 4;
|
buf[0] = 4;
|
||||||
buf[1] = 1;
|
buf[1] = 1;
|
||||||
memcpy(buf+2, SAPORT(addr), 2);
|
memcpy(buf+2, SAPORT(addr), 2);
|
||||||
if(redir->type == R_SOCKS4P && param->hostname) {
|
if(redir->type == R_SOCKS4P && hostname) {
|
||||||
buf[4] = buf[5] = buf[6] = 0;
|
buf[4] = buf[5] = buf[6] = 0;
|
||||||
buf[7] = 3;
|
buf[7] = 3;
|
||||||
}
|
}
|
||||||
@@ -92,12 +91,12 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, struct soc
|
|||||||
len = (int)strlen((char *)user) + 1;
|
len = (int)strlen((char *)user) + 1;
|
||||||
memcpy(buf+8, user, len);
|
memcpy(buf+8, user, len);
|
||||||
len += 8;
|
len += 8;
|
||||||
if(redir->type == R_SOCKS4P && param->hostname) {
|
if(redir->type == R_SOCKS4P && hostname) {
|
||||||
int hostnamelen;
|
int hostnamelen;
|
||||||
|
|
||||||
hostnamelen = (int)strlen((char *)param->hostname) + 1;
|
hostnamelen = (int)strlen((char *)hostname) + 1;
|
||||||
if(hostnamelen > 255) hostnamelen = 255;
|
if(hostnamelen > 255) hostnamelen = 255;
|
||||||
memcpy(buf+len, param->hostname, hostnamelen);
|
memcpy(buf+len, hostname, hostnamelen);
|
||||||
len += hostnamelen;
|
len += hostnamelen;
|
||||||
}
|
}
|
||||||
if(socksend(param->remsock, buf, len, conf.timeouts[CHAIN_TO]) < len){
|
if(socksend(param->remsock, buf, len, conf.timeouts[CHAIN_TO]) < len){
|
||||||
@@ -160,12 +159,12 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, struct soc
|
|||||||
buf[0] = 5;
|
buf[0] = 5;
|
||||||
buf[1] = 1;
|
buf[1] = 1;
|
||||||
buf[2] = 0;
|
buf[2] = 0;
|
||||||
if(redir->type == R_SOCKS5P && param->hostname) {
|
if(redir->type == R_SOCKS5P && hostname) {
|
||||||
buf[3] = 3;
|
buf[3] = 3;
|
||||||
len = (int)strlen((char *)param->hostname);
|
len = (int)strlen((char *)hostname);
|
||||||
if(len > 255) len = 255;
|
if(len > 255) len = 255;
|
||||||
buf[4] = len;
|
buf[4] = len;
|
||||||
memcpy(buf + 5, param->hostname, len);
|
memcpy(buf + 5, hostname, len);
|
||||||
len += 5;
|
len += 5;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -190,11 +189,21 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, struct soc
|
|||||||
if(buf[1] != 0) {
|
if(buf[1] != 0) {
|
||||||
return 60 + (buf[1] % 10);
|
return 60 + (buf[1] % 10);
|
||||||
}
|
}
|
||||||
if(buf[3] != 1) {
|
switch (buf[3]) {
|
||||||
return 58;
|
case 1:
|
||||||
}
|
if (redir->type == R_SOCKS5B || sockgetlinebuf(param, SERVER, buf, 6, EOF, conf.timeouts[CHAIN_TO]) == 6)
|
||||||
if (redir->type != R_SOCKS5B && sockgetlinebuf(param, SERVER, buf, 6, EOF, conf.timeouts[CHAIN_TO]) != 6){
|
break;
|
||||||
return 59;
|
return 59;
|
||||||
|
case 3:
|
||||||
|
if (sockgetlinebuf(param, SERVER, buf, 256, 0, conf.timeouts[CHAIN_TO]) > 1)
|
||||||
|
break;
|
||||||
|
return 59;
|
||||||
|
case 4:
|
||||||
|
if (sockgetlinebuf(param, SERVER, buf, 18, EOF, conf.timeouts[CHAIN_TO]) == 18)
|
||||||
|
break;
|
||||||
|
return 59;
|
||||||
|
default:
|
||||||
|
return 58;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -243,6 +252,7 @@ int handleredirect(struct clientparam * param, struct ace * acentry){
|
|||||||
if(!connected){
|
if(!connected){
|
||||||
if(cur->type == R_EXTIP){
|
if(cur->type == R_EXTIP){
|
||||||
param->sinsl = cur->addr;
|
param->sinsl = cur->addr;
|
||||||
|
if(SAISNULL(¶m->sinsl))param->sinsl = param->sincr;
|
||||||
if(cur->next)continue;
|
if(cur->next)continue;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -268,9 +278,6 @@ int handleredirect(struct clientparam * param, struct ace * acentry){
|
|||||||
case R_ADMIN:
|
case R_ADMIN:
|
||||||
param->redirectfunc = adminchild;
|
param->redirectfunc = adminchild;
|
||||||
break;
|
break;
|
||||||
case R_ICQ:
|
|
||||||
param->redirectfunc = icqprchild;
|
|
||||||
break;
|
|
||||||
case R_SMTP:
|
case R_SMTP:
|
||||||
param->redirectfunc = smtppchild;
|
param->redirectfunc = smtppchild;
|
||||||
break;
|
break;
|
||||||
@@ -295,7 +302,7 @@ int handleredirect(struct clientparam * param, struct ace * acentry){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
res = (redir)?clientnegotiate(redir, param, (struct sockaddr *)&cur->addr):0;
|
res = (redir)?clientnegotiate(redir, param, (struct sockaddr *)&cur->addr, cur->exthost):0;
|
||||||
if(res) return res;
|
if(res) return res;
|
||||||
}
|
}
|
||||||
redir = cur;
|
redir = cur;
|
||||||
@@ -318,7 +325,7 @@ int handleredirect(struct clientparam * param, struct ace * acentry){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!connected || !redir) return 0;
|
if(!connected || !redir) return 0;
|
||||||
return clientnegotiate(redir, param, (struct sockaddr *)¶m->req);
|
return clientnegotiate(redir, param, (struct sockaddr *)¶m->req, param->hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
int IPInentry(struct sockaddr *sa, struct iplist *ipentry){
|
int IPInentry(struct sockaddr *sa, struct iplist *ipentry){
|
||||||
@@ -370,21 +377,34 @@ int ACLmatches(struct ace* acentry, struct clientparam * param){
|
|||||||
}
|
}
|
||||||
while(i > 5 && param->hostname[i-1] == '.') param->hostname[i-1] = 0;
|
while(i > 5 && param->hostname[i-1] == '.') param->hostname[i-1] = 0;
|
||||||
for(hstentry = acentry->dstnames; hstentry; hstentry = hstentry->next){
|
for(hstentry = acentry->dstnames; hstentry; hstentry = hstentry->next){
|
||||||
|
int lname, lhost;
|
||||||
switch(hstentry->matchtype){
|
switch(hstentry->matchtype){
|
||||||
case 0:
|
case 0:
|
||||||
|
#ifndef _WIN32
|
||||||
|
if(strcasestr((char *)param->hostname, (char *)hstentry->name)) match = 1;
|
||||||
|
#else
|
||||||
if(strstr((char *)param->hostname, (char *)hstentry->name)) match = 1;
|
if(strstr((char *)param->hostname, (char *)hstentry->name)) match = 1;
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
if(strstr((char *)param->hostname, (char *)hstentry->name) == (char *)param->hostname) match = 1;
|
if(!strncasecmp((char *)param->hostname, (char *)hstentry->name, strlen((char *)hstentry->name)))
|
||||||
|
match = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
if(strstr((char *)param->hostname, (char *)hstentry->name) == (char *)(param->hostname + i - (strlen((char *)hstentry->name)))) match = 1;
|
lname = strlen((char *)hstentry->name);
|
||||||
|
lhost = strlen((char *)param->hostname);
|
||||||
|
if(lhost > lname){
|
||||||
|
if(!strncasecmp((char *)param->hostname + (lhost - lname),
|
||||||
|
(char *)hstentry->name,
|
||||||
|
lname))
|
||||||
|
match = 1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if(!strcmp((char *)param->hostname, (char *)hstentry->name)) match = 1;
|
if(!strcasecmp((char *)param->hostname, (char *)hstentry->name)) match = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(match) break;
|
if(match) break;
|
||||||
@@ -428,9 +448,68 @@ int ACLmatches(struct ace* acentry, struct clientparam * param){
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int startconnlims (struct clientparam *param){
|
||||||
|
struct connlim * ce;
|
||||||
|
time_t delta;
|
||||||
|
uint64_t rating;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
pthread_mutex_lock(&connlim_mutex);
|
||||||
|
for(ce = conf.connlimiter; ce; ce = ce->next) {
|
||||||
|
if(ACLmatches(ce->ace, param)){
|
||||||
|
if(ce->ace->action == NOCONNLIM)break;
|
||||||
|
if(!ce->period){
|
||||||
|
if(ce->rate <= ce->rating) {
|
||||||
|
ret = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ce->rating++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
delta = conf.time - ce->basetime;
|
||||||
|
if(ce->period <= delta || ce->basetime > conf.time){
|
||||||
|
ce->basetime = conf.time;
|
||||||
|
ce->rating = 0x100000;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
rating = delta? ((ce->rating * (ce->period - delta)) / ce->period) + 0x100000 : ce->rating + 0x100000;
|
||||||
|
if (rating > (ce->rate<<20)) {
|
||||||
|
ret = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ce->rating = rating;
|
||||||
|
ce->basetime = conf.time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&connlim_mutex);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void stopconnlims (struct clientparam *param){
|
||||||
|
struct connlim * ce;
|
||||||
|
|
||||||
|
pthread_mutex_lock(&connlim_mutex);
|
||||||
|
for(ce = conf.connlimiter; ce; ce = ce->next) {
|
||||||
|
if(ACLmatches(ce->ace, param)){
|
||||||
|
if(ce->ace->action == NOCONNLIM)break;
|
||||||
|
if(!ce->period && ce->rating){
|
||||||
|
ce->rating--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&connlim_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
static void initbandlims (struct clientparam *param){
|
static void initbandlims (struct clientparam *param){
|
||||||
struct bandlim * be;
|
struct bandlim * be;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
param->bandlimfunc = NULL;
|
||||||
|
param->bandlims[0] = NULL;
|
||||||
|
param->bandlimsout[0] = NULL;
|
||||||
|
if(!conf.bandlimfunc || (!conf.bandlimiter && !conf.bandlimiterout)) return;
|
||||||
for(i=0, be = conf.bandlimiter; be && i<MAXBANDLIMS; be = be->next) {
|
for(i=0, be = conf.bandlimiter; be && i<MAXBANDLIMS; be = be->next) {
|
||||||
if(ACLmatches(be->ace, param)){
|
if(ACLmatches(be->ace, param)){
|
||||||
if(be->ace->action == NOBANDLIM) {
|
if(be->ace->action == NOBANDLIM) {
|
||||||
@@ -451,11 +530,12 @@ static void initbandlims (struct clientparam *param){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(i<MAXBANDLIMS)param->bandlimsout[i] = NULL;
|
if(i<MAXBANDLIMS)param->bandlimsout[i] = NULL;
|
||||||
|
param->bandlimver = conf.bandlimver;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned bandlimitfunc(struct clientparam *param, unsigned nbytesin, unsigned nbytesout){
|
unsigned bandlimitfunc(struct clientparam *param, unsigned nbytesin, unsigned nbytesout){
|
||||||
unsigned sleeptime = 0, nsleeptime;
|
unsigned sleeptime = 0, nsleeptime;
|
||||||
unsigned long sec;
|
time_t sec;
|
||||||
unsigned msec;
|
unsigned msec;
|
||||||
unsigned now;
|
unsigned now;
|
||||||
int i;
|
int i;
|
||||||
@@ -476,8 +556,9 @@ unsigned bandlimitfunc(struct clientparam *param, unsigned nbytesin, unsigned nb
|
|||||||
|
|
||||||
if(!nbytesin && !nbytesout) return 0;
|
if(!nbytesin && !nbytesout) return 0;
|
||||||
pthread_mutex_lock(&bandlim_mutex);
|
pthread_mutex_lock(&bandlim_mutex);
|
||||||
if(param->paused != conf.paused){
|
if(param->bandlimver != conf.bandlimver){
|
||||||
return (1);
|
initbandlims(param);
|
||||||
|
param->bandlimver = conf.bandlimver;
|
||||||
}
|
}
|
||||||
for(i=0; nbytesin&& i<MAXBANDLIMS && param->bandlims[i]; i++){
|
for(i=0; nbytesin&& i<MAXBANDLIMS && param->bandlims[i]; i++){
|
||||||
if( !param->bandlims[i]->basetime ||
|
if( !param->bandlims[i]->basetime ||
|
||||||
@@ -489,12 +570,12 @@ unsigned bandlimitfunc(struct clientparam *param, unsigned nbytesin, unsigned nb
|
|||||||
param->bandlims[i]->nexttime = 0;
|
param->bandlims[i]->nexttime = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
now = ((sec - param->bandlims[i]->basetime) * 1000000) + msec;
|
now = (unsigned)((sec - param->bandlims[i]->basetime) * 1000000) + msec;
|
||||||
nsleeptime = (param->bandlims[i]->nexttime > now)?
|
nsleeptime = (param->bandlims[i]->nexttime > now)?
|
||||||
param->bandlims[i]->nexttime - now : 0;
|
param->bandlims[i]->nexttime - now : 0;
|
||||||
sleeptime = (nsleeptime > sleeptime)? nsleeptime : sleeptime;
|
sleeptime = (nsleeptime > sleeptime)? nsleeptime : sleeptime;
|
||||||
param->bandlims[i]->basetime = sec;
|
param->bandlims[i]->basetime = sec;
|
||||||
param->bandlims[i]->nexttime = msec + nsleeptime + ((param->bandlims[i]->rate > 1000000)? ((nbytesin/32)*(256000000/param->bandlims[i]->rate)) : (nbytesin * (8000000/param->bandlims[i]->rate)));
|
param->bandlims[i]->nexttime = msec + nsleeptime + ((nbytesin > 512)? ((nbytesin+32)/64)*(((64*8*1000000)/param->bandlims[i]->rate)) : ((nbytesin+1) * (8*1000000))/param->bandlims[i]->rate);
|
||||||
}
|
}
|
||||||
for(i=0; nbytesout && i<MAXBANDLIMS && param->bandlimsout[i]; i++){
|
for(i=0; nbytesout && i<MAXBANDLIMS && param->bandlimsout[i]; i++){
|
||||||
if( !param->bandlimsout[i]->basetime ||
|
if( !param->bandlimsout[i]->basetime ||
|
||||||
@@ -506,12 +587,12 @@ unsigned bandlimitfunc(struct clientparam *param, unsigned nbytesin, unsigned nb
|
|||||||
param->bandlimsout[i]->nexttime = 0;
|
param->bandlimsout[i]->nexttime = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
now = ((sec - param->bandlimsout[i]->basetime) * 1000000) + msec;
|
now = (unsigned)((sec - param->bandlimsout[i]->basetime) * 1000000) + msec;
|
||||||
nsleeptime = (param->bandlimsout[i]->nexttime > now)?
|
nsleeptime = (param->bandlimsout[i]->nexttime > now)?
|
||||||
param->bandlimsout[i]->nexttime - now : 0;
|
param->bandlimsout[i]->nexttime - now : 0;
|
||||||
sleeptime = (nsleeptime > sleeptime)? nsleeptime : sleeptime;
|
sleeptime = (nsleeptime > sleeptime)? nsleeptime : sleeptime;
|
||||||
param->bandlimsout[i]->basetime = sec;
|
param->bandlimsout[i]->basetime = sec;
|
||||||
param->bandlimsout[i]->nexttime = msec + nsleeptime + ((param->bandlimsout[i]->rate > 1000000)? ((nbytesout/32)*(256000000/param->bandlimsout[i]->rate)) : (nbytesout * (8000000/param->bandlimsout[i]->rate)));
|
param->bandlimsout[i]->nexttime = msec + nsleeptime + ((nbytesout > 512)? ((nbytesout+32)/64)*((64*8*1000000)/param->bandlimsout[i]->rate) : ((nbytesout+1)* (8*1000000))/param->bandlimsout[i]->rate);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&bandlim_mutex);
|
pthread_mutex_unlock(&bandlim_mutex);
|
||||||
return sleeptime/1000;
|
return sleeptime/1000;
|
||||||
@@ -525,26 +606,29 @@ void trafcountfunc(struct clientparam *param){
|
|||||||
for(tc = conf.trafcounter; tc; tc = tc->next) {
|
for(tc = conf.trafcounter; tc; tc = tc->next) {
|
||||||
if(ACLmatches(tc->ace, param)){
|
if(ACLmatches(tc->ace, param)){
|
||||||
time_t t;
|
time_t t;
|
||||||
if(tc->ace->action == NOCOUNTIN) break;
|
|
||||||
if(tc->ace->action != COUNTIN) {
|
if(tc->ace->action == NOCOUNTIN) {
|
||||||
|
countout = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(tc->ace->action == NOCOUNTALL) break;
|
||||||
|
if(tc->ace->action != COUNTIN && tc->ace->action != COUNTALL) {
|
||||||
countout = 1;
|
countout = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
tc->traf64 += param->statssrv64;
|
tc->traf64 += param->statssrv64;
|
||||||
time(&t);
|
tc->updated = conf.time;
|
||||||
tc->updated = t;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(countout) for(tc = conf.trafcounter; tc; tc = tc->next) {
|
if(countout) for(tc = conf.trafcounter; tc; tc = tc->next) {
|
||||||
if(ACLmatches(tc->ace, param)){
|
if(ACLmatches(tc->ace, param)){
|
||||||
time_t t;
|
time_t t;
|
||||||
if(tc->ace->action == NOCOUNTOUT) break;
|
if(tc->ace->action == NOCOUNTOUT || tc->ace->action == NOCOUNTALL) break;
|
||||||
if(tc->ace->action != COUNTOUT) {
|
if(tc->ace->action != COUNTOUT && tc->ace->action != COUNTALL ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
tc->traf64 += param->statscli64;
|
tc->traf64 += param->statscli64;
|
||||||
time(&t);
|
tc->updated = conf.time;
|
||||||
tc->updated = t;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -556,37 +640,49 @@ int alwaysauth(struct clientparam * param){
|
|||||||
struct trafcount * tc;
|
struct trafcount * tc;
|
||||||
int countout = 0;
|
int countout = 0;
|
||||||
|
|
||||||
|
|
||||||
|
if(conf.connlimiter && param->remsock == INVALID_SOCKET && startconnlims(param)) return 95;
|
||||||
res = doconnect(param);
|
res = doconnect(param);
|
||||||
if(!res){
|
if(!res){
|
||||||
initbandlims(param);
|
if(conf.bandlimfunc && (conf.bandlimiter||conf.bandlimiterout)){
|
||||||
for(tc = conf.trafcounter; tc; tc = tc->next) {
|
pthread_mutex_lock(&bandlim_mutex);
|
||||||
if(tc->disabled) continue;
|
initbandlims(param);
|
||||||
if(ACLmatches(tc->ace, param)){
|
pthread_mutex_unlock(&bandlim_mutex);
|
||||||
if(tc->ace->action == NOCOUNTIN) break;
|
|
||||||
if(tc->ace->action != COUNTIN) {
|
|
||||||
countout = 1;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(tc->traflim64 <= tc->traf64) return 10;
|
|
||||||
param->trafcountfunc = conf.trafcountfunc;
|
|
||||||
param->maxtrafin64 = tc->traflim64 - tc->traf64;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(countout)for(tc = conf.trafcounter; tc; tc = tc->next) {
|
|
||||||
if(tc->disabled) continue;
|
|
||||||
if(ACLmatches(tc->ace, param)){
|
|
||||||
if(tc->ace->action == NOCOUNTOUT) break;
|
|
||||||
if(tc->ace->action != COUNTOUT) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(tc->traflim64 <= tc->traf64) return 10;
|
|
||||||
param->trafcountfunc = conf.trafcountfunc;
|
|
||||||
param->maxtrafout64 = tc->traflim64 - tc->traf64;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(conf.trafcountfunc && conf.trafcounter) {
|
||||||
|
pthread_mutex_lock(&tc_mutex);
|
||||||
|
for(tc = conf.trafcounter; tc; tc = tc->next) {
|
||||||
|
if(tc->disabled) continue;
|
||||||
|
if(ACLmatches(tc->ace, param)){
|
||||||
|
if(tc->ace->action == NOCOUNTIN) {
|
||||||
|
countout = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(tc->ace->action == NOCOUNTALL) break;
|
||||||
|
if(tc->ace->action != COUNTIN) {
|
||||||
|
countout = 1;
|
||||||
|
if(tc->ace->action != COUNTALL) continue;
|
||||||
|
}
|
||||||
|
if(tc->traflim64 <= tc->traf64) return 10;
|
||||||
|
param->trafcountfunc = conf.trafcountfunc;
|
||||||
|
param->maxtrafin64 = tc->traflim64 - tc->traf64;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(countout)for(tc = conf.trafcounter; tc; tc = tc->next) {
|
||||||
|
if(tc->disabled) continue;
|
||||||
|
if(ACLmatches(tc->ace, param)){
|
||||||
|
if(tc->ace->action == NOCOUNTOUT || tc->ace->action == NOCOUNTALL) break;
|
||||||
|
if(tc->ace->action != COUNTOUT && tc->ace->action != COUNTALL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(tc->traflim64 <= tc->traf64) return 10;
|
||||||
|
param->trafcountfunc = conf.trafcountfunc;
|
||||||
|
param->maxtrafout64 = tc->traflim64 - tc->traf64;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&tc_mutex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -595,7 +691,7 @@ int checkACL(struct clientparam * param){
|
|||||||
struct ace* acentry;
|
struct ace* acentry;
|
||||||
|
|
||||||
if(!param->srv->acl) {
|
if(!param->srv->acl) {
|
||||||
return alwaysauth(param);
|
return 0;
|
||||||
}
|
}
|
||||||
for(acentry = param->srv->acl; acentry; acentry = acentry->next) {
|
for(acentry = param->srv->acl; acentry; acentry = acentry->next) {
|
||||||
if(ACLmatches(acentry, param)) {
|
if(ACLmatches(acentry, param)) {
|
||||||
@@ -624,14 +720,14 @@ struct authcache {
|
|||||||
char * password;
|
char * password;
|
||||||
time_t expires;
|
time_t expires;
|
||||||
#ifndef NOIPV6
|
#ifndef NOIPV6
|
||||||
struct sockaddr_in6 sa;
|
struct sockaddr_in6 sa, sinsl;
|
||||||
#else
|
#else
|
||||||
struct sockaddr_in sa;
|
struct sockaddr_in sa, sinsl;
|
||||||
#endif
|
#endif
|
||||||
|
struct ace *acl;
|
||||||
struct authcache *next;
|
struct authcache *next;
|
||||||
} *authc = NULL;
|
} *authc = NULL;
|
||||||
|
|
||||||
|
|
||||||
int cacheauth(struct clientparam * param){
|
int cacheauth(struct clientparam * param){
|
||||||
struct authcache *ac, *last=NULL;
|
struct authcache *ac, *last=NULL;
|
||||||
|
|
||||||
@@ -653,15 +749,30 @@ int cacheauth(struct clientparam * param){
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
if(((!(conf.authcachetype&2)) || (param->username && ac->username && !strcmp(ac->username, (char *)param->username))) &&
|
if(
|
||||||
((!(conf.authcachetype&1)) || (*SAFAMILY(&ac->sa) == *SAFAMILY(¶m->sincr) && !memcmp(SAADDR(&ac->sa), SAADDR(¶m->sincr), SAADDRLEN(&ac->sa)))) &&
|
(!(conf.authcachetype&2) || (param->username && ac->username && !strcmp(ac->username, (char *)param->username))) &&
|
||||||
(!(conf.authcachetype&4) || (ac->password && param->password && !strcmp(ac->password, (char *)param->password)))) {
|
(!(conf.authcachetype&4) || (ac->password && param->password && !strcmp(ac->password, (char *)param->password))) &&
|
||||||
if(param->username){
|
(!(conf.authcachetype&16) || (ac->acl == param->srv->acl))
|
||||||
myfree(param->username);
|
) {
|
||||||
|
|
||||||
|
if(!(conf.authcachetype&1)
|
||||||
|
|| ((*SAFAMILY(&ac->sa) == *SAFAMILY(¶m->sincr)
|
||||||
|
&& !memcmp(SAADDR(&ac->sa), SAADDR(¶m->sincr), SAADDRLEN(&ac->sa))))){
|
||||||
|
|
||||||
|
if(conf.authcachetype&32) {
|
||||||
|
param->sinsl = ac->sinsl;
|
||||||
|
}
|
||||||
|
if(param->username){
|
||||||
|
myfree(param->username);
|
||||||
|
}
|
||||||
|
param->username = (unsigned char *)mystrdup(ac->username);
|
||||||
|
pthread_mutex_unlock(&hash_mutex);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if ((conf.authcachetype&1) && (conf.authcachetype&8)) {
|
||||||
|
pthread_mutex_unlock(&hash_mutex);
|
||||||
|
return 10;
|
||||||
}
|
}
|
||||||
param->username = (unsigned char *)mystrdup(ac->username);
|
|
||||||
pthread_mutex_unlock(&hash_mutex);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
last = ac;
|
last = ac;
|
||||||
ac = ac->next;
|
ac = ac->next;
|
||||||
@@ -687,9 +798,12 @@ int doauth(struct clientparam * param){
|
|||||||
if(conf.authcachetype && authfuncs->authenticate && authfuncs->authenticate != cacheauth && param->username && (!(conf.authcachetype&4) || (!param->pwtype && param->password))){
|
if(conf.authcachetype && authfuncs->authenticate && authfuncs->authenticate != cacheauth && param->username && (!(conf.authcachetype&4) || (!param->pwtype && param->password))){
|
||||||
pthread_mutex_lock(&hash_mutex);
|
pthread_mutex_lock(&hash_mutex);
|
||||||
for(ac = authc; ac; ac = ac->next){
|
for(ac = authc; ac; ac = ac->next){
|
||||||
if((!(conf.authcachetype&2) || !strcmp(ac->username, (char *)param->username)) &&
|
if(
|
||||||
|
(!(conf.authcachetype&2) || !strcmp(ac->username, (char *)param->username)) &&
|
||||||
(!(conf.authcachetype&1) || (*SAFAMILY(&ac->sa) == *SAFAMILY(¶m->sincr) && !memcmp(SAADDR(&ac->sa), SAADDR(¶m->sincr), SAADDRLEN(&ac->sa)))) &&
|
(!(conf.authcachetype&1) || (*SAFAMILY(&ac->sa) == *SAFAMILY(¶m->sincr) && !memcmp(SAADDR(&ac->sa), SAADDR(¶m->sincr), SAADDRLEN(&ac->sa)))) &&
|
||||||
(!(conf.authcachetype&4) || (ac->password && !strcmp(ac->password, (char *)param->password)))) {
|
(!(conf.authcachetype&4) || (ac->password && !strcmp(ac->password, (char *)param->password))) &&
|
||||||
|
(!(conf.authcachetype&16) || (ac->acl == param->srv->acl))
|
||||||
|
) {
|
||||||
ac->expires = conf.time + conf.authcachetime;
|
ac->expires = conf.time + conf.authcachetime;
|
||||||
if(strcmp(ac->username, (char *)param->username)){
|
if(strcmp(ac->username, (char *)param->username)){
|
||||||
tmp = ac->username;
|
tmp = ac->username;
|
||||||
@@ -702,6 +816,11 @@ int doauth(struct clientparam * param){
|
|||||||
myfree(tmp);
|
myfree(tmp);
|
||||||
}
|
}
|
||||||
ac->sa = param->sincr;
|
ac->sa = param->sincr;
|
||||||
|
if(conf.authcachetype&32) {
|
||||||
|
ac->sinsl = param-> sinsl;
|
||||||
|
*SAPORT(&ac->sinsl) = 0;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -713,6 +832,10 @@ int doauth(struct clientparam * param){
|
|||||||
ac->sa = param->sincr;
|
ac->sa = param->sincr;
|
||||||
ac->password = NULL;
|
ac->password = NULL;
|
||||||
if((conf.authcachetype&4) && param->password) ac->password = mystrdup((char *)param->password);
|
if((conf.authcachetype&4) && param->password) ac->password = mystrdup((char *)param->password);
|
||||||
|
if(conf.authcachetype&32) {
|
||||||
|
ac->sinsl = param->sinsl;
|
||||||
|
*SAPORT(&ac->sinsl) = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ac->next = authc;
|
ac->next = authc;
|
||||||
authc = ac;
|
authc = ac;
|
||||||
@@ -722,6 +845,7 @@ int doauth(struct clientparam * param){
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(res > ret) ret = res;
|
if(res > ret) ret = res;
|
||||||
|
if(ret > 9) return ret;
|
||||||
}
|
}
|
||||||
if(!res){
|
if(!res){
|
||||||
return alwaysauth(param);
|
return alwaysauth(param);
|
||||||
@@ -774,10 +898,14 @@ int dnsauth(struct clientparam * param){
|
|||||||
((u&0xFF000000)>>24));
|
((u&0xFF000000)>>24));
|
||||||
|
|
||||||
}
|
}
|
||||||
if(!udpresolve(*SAFAMILY(¶m->sincr), (unsigned char *)buf, (unsigned char *)addr, NULL, param, 1)) return 6;
|
if(!udpresolve(*SAFAMILY(¶m->sincr), (unsigned char *)buf, (unsigned char *)addr, NULL, param, 1)) {
|
||||||
if(!memcmp(SAADDR(¶m->sincr), addr, SAADDRLEN(¶m->sincr))) return 6;
|
return 3;
|
||||||
|
}
|
||||||
|
if(memcmp(SAADDR(¶m->sincr), addr, SAADDRLEN(¶m->sincr))) {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
return param->username? 0:4;
|
return param->username? 0:3;
|
||||||
}
|
}
|
||||||
|
|
||||||
int strongauth(struct clientparam * param){
|
int strongauth(struct clientparam * param){
|
||||||
@@ -840,6 +968,7 @@ int strongauth(struct clientparam * param){
|
|||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int radauth(struct clientparam * param);
|
||||||
|
|
||||||
struct auth authfuncs[] = {
|
struct auth authfuncs[] = {
|
||||||
{authfuncs+1, NULL, NULL, ""},
|
{authfuncs+1, NULL, NULL, ""},
|
||||||
@@ -848,8 +977,13 @@ struct auth authfuncs[] = {
|
|||||||
{authfuncs+4, dnsauth, checkACL, "dnsname"},
|
{authfuncs+4, dnsauth, checkACL, "dnsname"},
|
||||||
{authfuncs+5, strongauth, checkACL, "strong"},
|
{authfuncs+5, strongauth, checkACL, "strong"},
|
||||||
{authfuncs+6, cacheauth, checkACL, "cache"},
|
{authfuncs+6, cacheauth, checkACL, "cache"},
|
||||||
{authfuncs+7, NULL, NULL, "none"},
|
#ifndef NORADIUS
|
||||||
|
#define AUTHOFFSET 1
|
||||||
|
{authfuncs+7, radauth, checkACL, "radius"},
|
||||||
|
#else
|
||||||
|
#define AUTHOFFSET 0
|
||||||
|
#endif
|
||||||
|
{authfuncs+7+AUTHOFFSET, NULL, NULL, "none"},
|
||||||
{NULL, NULL, NULL, ""}
|
{NULL, NULL, NULL, ""}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1076,11 +1210,17 @@ unsigned long udpresolve(int af, unsigned char * name, unsigned char * value, un
|
|||||||
*sinsr = nservers[i].addr;
|
*sinsr = nservers[i].addr;
|
||||||
}
|
}
|
||||||
if(usetcp){
|
if(usetcp){
|
||||||
if(so._connect(sock,(struct sockaddr *)sinsr,SASIZE(sinsr))) {
|
if(connectwithpoll(sock,(struct sockaddr *)sinsr,SASIZE(sinsr),CONNECT_TO)) {
|
||||||
so._shutdown(sock, SHUT_RDWR);
|
so._shutdown(sock, SHUT_RDWR);
|
||||||
so._closesocket(sock);
|
so._closesocket(sock);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#ifdef TCP_NODELAY
|
||||||
|
{
|
||||||
|
int opt = 1;
|
||||||
|
setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *)&opt, sizeof(opt));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
len = (int)strlen((char *)name);
|
len = (int)strlen((char *)name);
|
||||||
|
|
||||||
@@ -1151,6 +1291,8 @@ unsigned long udpresolve(int af, unsigned char * name, unsigned char * value, un
|
|||||||
k += 4;
|
k += 4;
|
||||||
if(na > 255) na = 255; /* somebody is very evil */
|
if(na > 255) na = 255; /* somebody is very evil */
|
||||||
for (j = 0; j < na; j++) { /* now there should be answers */
|
for (j = 0; j < na; j++) { /* now there should be answers */
|
||||||
|
while(buf[k] < 192 && buf[k] !=0 && (k+buf[k]+14) < len) k+= (buf[k] + 1);
|
||||||
|
if(!buf[k]) k--;
|
||||||
if((k+(af == AF_INET6?28:16)) > len) {
|
if((k+(af == AF_INET6?28:16)) > len) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1166,10 +1308,7 @@ unsigned long udpresolve(int af, unsigned char * name, unsigned char * value, un
|
|||||||
ttl = ntohl(*(unsigned long *)(buf + k + 6));
|
ttl = ntohl(*(unsigned long *)(buf + k + 6));
|
||||||
memcpy(value, buf + k + 12, af == AF_INET6? 16:4);
|
memcpy(value, buf + k + 12, af == AF_INET6? 16:4);
|
||||||
if(ttl < 60 || ttl > (3600*12)) ttl = 300;
|
if(ttl < 60 || ttl > (3600*12)) ttl = 300;
|
||||||
if(ttl){
|
hashadd(af == AF_INET6?&dns6_table:&dns_table, name, value, conf.time+ttl);
|
||||||
hashadd(af == AF_INET6?&dns6_table:&dns_table, name, value, conf.time+ttl);
|
|
||||||
|
|
||||||
}
|
|
||||||
if(retttl) *retttl = ttl;
|
if(retttl) *retttl = ttl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -1316,6 +1455,8 @@ void sqlerr (char *buf){
|
|||||||
pthread_mutex_unlock(&log_mutex);
|
pthread_mutex_unlock(&log_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned char statbuf[8192];
|
||||||
|
|
||||||
void logsql(struct clientparam * param, const unsigned char *s) {
|
void logsql(struct clientparam * param, const unsigned char *s) {
|
||||||
SQLRETURN ret;
|
SQLRETURN ret;
|
||||||
int len;
|
int len;
|
||||||
@@ -1323,35 +1464,35 @@ void logsql(struct clientparam * param, const unsigned char *s) {
|
|||||||
|
|
||||||
if(param->nolog) return;
|
if(param->nolog) return;
|
||||||
pthread_mutex_lock(&log_mutex);
|
pthread_mutex_lock(&log_mutex);
|
||||||
len = dobuf(param, tmpbuf, s, (unsigned char *)"\'");
|
len = dobuf(param, statbuf, s, (unsigned char *)"\'");
|
||||||
|
|
||||||
if(attempt > 5){
|
if(attempt > 5){
|
||||||
time_t t;
|
time_t t;
|
||||||
|
|
||||||
t = time(0);
|
t = time(0);
|
||||||
if (t - attempt_time < 180){
|
if (t - attempt_time < 180){
|
||||||
sqlerr((char *)tmpbuf);
|
sqlerr((char *)statbuf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!hstmt){
|
if(!hstmt){
|
||||||
if(!init_sql(sqlstring)) {
|
if(!init_sql(sqlstring)) {
|
||||||
sqlerr((char *)tmpbuf);
|
sqlerr((char *)statbuf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(hstmt){
|
if(hstmt){
|
||||||
ret = SQLExecDirect(hstmt, (SQLCHAR *)tmpbuf, (SQLINTEGER)len);
|
ret = SQLExecDirect(hstmt, (SQLCHAR *)statbuf, (SQLINTEGER)len);
|
||||||
if(ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO){
|
if(ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO){
|
||||||
close_sql();
|
close_sql();
|
||||||
if(!init_sql(sqlstring)){
|
if(!init_sql(sqlstring)){
|
||||||
sqlerr((char *)tmpbuf);
|
sqlerr((char *)statbuf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(hstmt) {
|
if(hstmt) {
|
||||||
ret = SQLExecDirect(hstmt, (SQLCHAR *)tmpbuf, (SQLINTEGER)len);
|
ret = SQLExecDirect(hstmt, (SQLCHAR *)statbuf, (SQLINTEGER)len);
|
||||||
if(ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO){
|
if(ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO){
|
||||||
sqlerr((char *)tmpbuf);
|
sqlerr((char *)statbuf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
attempt = 0;
|
attempt = 0;
|
||||||
@@ -1363,4 +1504,3 @@ void logsql(struct clientparam * param, const unsigned char *s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -0,0 +1,670 @@
|
|||||||
|
/*
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
+5
-5
@@ -1,9 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000-2008 3APA3A
|
(c) 2002-2016 by Vladimir Dubrovin <3proxy@3proxy.ru>
|
||||||
*
|
|
||||||
* please read License Agreement
|
please read License Agreement
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|||||||
+116
-366
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
3APA3A simpliest proxy server
|
3APA3A simpliest proxy server
|
||||||
(c) 2002-2008 by ZARAZA <3APA3A@security.nnov.ru>
|
(c) 2002-2016 by Vladimir Dubrovin <3proxy@3proxy.ru>
|
||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
@@ -15,6 +15,8 @@ char * copyright = COPYRIGHT;
|
|||||||
|
|
||||||
int randomizer = 1;
|
int randomizer = 1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
pthread_attr_t pa;
|
pthread_attr_t pa;
|
||||||
|
|
||||||
@@ -31,6 +33,35 @@ int randomizer = 1;
|
|||||||
|
|
||||||
unsigned char **stringtable = NULL;
|
unsigned char **stringtable = NULL;
|
||||||
|
|
||||||
|
#ifdef WITH_LINUX_FUTEX
|
||||||
|
int sys_futex(void *addr1, int op, int val1, struct timespec *timeout, void *addr2, int val3)
|
||||||
|
{
|
||||||
|
return syscall(SYS_futex, addr1, op, val1, timeout, addr2, val3);
|
||||||
|
}
|
||||||
|
int mutex_lock(int *val)
|
||||||
|
{
|
||||||
|
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){
|
int myinet_ntop(int af, void *src, char *dst, socklen_t size){
|
||||||
#ifndef NOIPV6
|
#ifndef NOIPV6
|
||||||
if(af != AF_INET6){
|
if(af != AF_INET6){
|
||||||
@@ -62,18 +93,16 @@ char *rotations[] = {
|
|||||||
|
|
||||||
|
|
||||||
struct extparam conf = {
|
struct extparam conf = {
|
||||||
{1, 5, 30, 60, 180, 1800, 15, 60, 0, 0},
|
{1, 5, 30, 60, 180, 1800, 15, 60, 15, 5, 0, 0},
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
#ifdef __FreeBSD__
|
NULL,
|
||||||
8192,
|
|
||||||
#else
|
|
||||||
0,
|
0,
|
||||||
#endif
|
0, -1, 0, 0, 0, 0,
|
||||||
0, -1, 0, 0, 0, 0, 0, 500, 0, 0, 0, 0, 0,
|
0, 500, 0, 0, 0, 0, 0,
|
||||||
6, 600,
|
6, 600,
|
||||||
1048576,
|
1048576,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
@@ -121,6 +150,7 @@ int myrand(void * entropy, int len){
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef WITH_POLL
|
#ifndef WITH_POLL
|
||||||
|
#ifndef WITH_WSAPOLL
|
||||||
int
|
int
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
WINAPI
|
WINAPI
|
||||||
@@ -156,6 +186,7 @@ int
|
|||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
struct sockfuncs so = {
|
struct sockfuncs so = {
|
||||||
socket,
|
socket,
|
||||||
@@ -167,10 +198,14 @@ struct sockfuncs so = {
|
|||||||
getsockname,
|
getsockname,
|
||||||
getsockopt,
|
getsockopt,
|
||||||
setsockopt,
|
setsockopt,
|
||||||
#ifdef WITH_POLL
|
#ifndef WITH_POLL
|
||||||
poll,
|
#ifndef WITH_WSAPOLL
|
||||||
#else
|
|
||||||
mypoll,
|
mypoll,
|
||||||
|
#else
|
||||||
|
WSAPoll,
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
poll,
|
||||||
#endif
|
#endif
|
||||||
(void *)send,
|
(void *)send,
|
||||||
(void *)sendto,
|
(void *)sendto,
|
||||||
@@ -258,7 +293,10 @@ int parsehostname(char *hostname, struct clientparam *param, unsigned short port
|
|||||||
|
|
||||||
if(!hostname || !*hostname)return 2;
|
if(!hostname || !*hostname)return 2;
|
||||||
if(*hostname == '[') se=strchr(hostname, ']');
|
if(*hostname == '[') se=strchr(hostname, ']');
|
||||||
if ( (sp = strchr(se?se:hostname, ':')) && !strchr(sp+1, ':')) *sp = 0;
|
if ((sp = strchr(se?se:hostname, ':'))) {
|
||||||
|
if(strchr(sp+1, ':'))sp = NULL;
|
||||||
|
else *sp = 0;
|
||||||
|
}
|
||||||
if(se){
|
if(se){
|
||||||
*se = 0;
|
*se = 0;
|
||||||
}
|
}
|
||||||
@@ -327,332 +365,34 @@ 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
|
||||||
struct timeb tb;
|
unsigned long ul = 1;
|
||||||
|
ioctlsocket(sock, FIONBIO, &ul);
|
||||||
ftime(&tb);
|
|
||||||
param->time_start = (time_t)tb.time;
|
|
||||||
param->msec_start = (unsigned)tb.millitm;
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
struct timeval tv;
|
fcntl(sock,F_SETFL, O_NONBLOCK | fcntl(sock,F_GETFL));
|
||||||
struct timezone tz;
|
|
||||||
gettimeofday(&tv, &tz);
|
|
||||||
|
|
||||||
param->time_start = (time_t)tv.tv_sec;
|
|
||||||
param->msec_start = (tv.tv_usec / 1000);
|
|
||||||
#endif
|
#endif
|
||||||
param->statscli64 = param->statssrv64 = param->nreads = param->nwrites =
|
if(so._connect(sock,sa,size)) {
|
||||||
param->nconnects = 0;
|
if(errno != EAGAIN && errno != EINPROGRESS) return (13);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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 < 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 {
|
|
||||||
buf[i++] = '[';
|
|
||||||
i += myinet_ntop(*SAFAMILY(¶m->req), SAADDR(¶m->req), (char *)buf + i, 64);
|
|
||||||
buf[i++] = ']';
|
|
||||||
buf[i++] = 0;
|
|
||||||
}
|
|
||||||
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 '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];
|
memset(fds, 0, sizeof(fds));
|
||||||
}
|
fds[0].fd = sock;
|
||||||
buf[i] = 0;
|
fds[0].events = POLLOUT;
|
||||||
return i;
|
if(so._poll(fds, 1, to*1000) <= 0) {
|
||||||
|
return (13);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
unsigned char tmpbuf[8192];
|
|
||||||
|
|
||||||
void logstdout(struct clientparam * param, const unsigned char *s) {
|
|
||||||
FILE *log;
|
|
||||||
|
|
||||||
pthread_mutex_lock(&log_mutex);
|
|
||||||
log = param->srv->stdlog?param->srv->stdlog:conf.stdlog?conf.stdlog:stdout;
|
|
||||||
dobuf(param, tmpbuf, s, NULL);
|
|
||||||
if(!param->nolog)if(fprintf(log, "%s\n", tmpbuf) < 0) {
|
|
||||||
perror("printf()");
|
|
||||||
};
|
|
||||||
if(log != conf.stdlog)fflush(log);
|
|
||||||
pthread_mutex_unlock(&log_mutex);
|
|
||||||
}
|
|
||||||
#ifndef _WIN32
|
|
||||||
void logsyslog(struct clientparam * param, const unsigned char *s) {
|
|
||||||
|
|
||||||
pthread_mutex_lock(&log_mutex);
|
|
||||||
dobuf(param, tmpbuf, s, NULL);
|
|
||||||
if(!param->nolog)syslog(LOG_INFO, "%s", tmpbuf);
|
|
||||||
pthread_mutex_unlock(&log_mutex);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int doconnect(struct clientparam * param){
|
int doconnect(struct clientparam * param){
|
||||||
SASIZETYPE size;
|
SASIZETYPE size;
|
||||||
|
|
||||||
|
|
||||||
if (*SAFAMILY(¶m->sincr) == *SAFAMILY(¶m->req) && !memcmp(SAADDR(¶m->sincr), SAADDR(¶m->req), SAADDRLEN(¶m->req)) &&
|
if (*SAFAMILY(¶m->sincl) == *SAFAMILY(¶m->req) && !memcmp(SAADDR(¶m->sincl), SAADDR(¶m->req), SAADDRLEN(¶m->req)) &&
|
||||||
*SAPORT(¶m->sincr) == *SAPORT(¶m->req)) return 519;
|
*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;
|
||||||
@@ -672,6 +412,8 @@ int doconnect(struct clientparam * param){
|
|||||||
}
|
}
|
||||||
if(!*SAPORT(¶m->sinsr))*SAPORT(¶m->sinsr) = *SAPORT(¶m->req);
|
if(!*SAPORT(¶m->sinsr))*SAPORT(¶m->sinsr) = *SAPORT(¶m->req);
|
||||||
if ((param->remsock=so._socket(SASOCK(¶m->sinsr), SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) {return (11);}
|
if ((param->remsock=so._socket(SASOCK(¶m->sinsr), SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) {return (11);}
|
||||||
|
setopts(param->remsock, param->srv->srvsockopts);
|
||||||
|
|
||||||
so._setsockopt(param->remsock, SOL_SOCKET, SO_LINGER, (char *)&lg, sizeof(lg));
|
so._setsockopt(param->remsock, SOL_SOCKET, SO_LINGER, (char *)&lg, sizeof(lg));
|
||||||
#ifdef REUSE
|
#ifdef REUSE
|
||||||
{
|
{
|
||||||
@@ -687,7 +429,12 @@ int doconnect(struct clientparam * param){
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#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;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if(SAISNULL(¶m->sinsl)){
|
if(SAISNULL(¶m->sinsl)){
|
||||||
#ifndef NOIPV6
|
#ifndef NOIPV6
|
||||||
if(*SAFAMILY(¶m->sinsr) == AF_INET6) param->sinsl = param->srv->extsa6;
|
if(*SAFAMILY(¶m->sinsr) == AF_INET6) param->sinsl = param->srv->extsa6;
|
||||||
@@ -701,18 +448,9 @@ int doconnect(struct clientparam * param){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(param->operation >= 256 || (param->operation & CONNECT)){
|
if(param->operation >= 256 || (param->operation & CONNECT)){
|
||||||
#ifdef _WIN32
|
if(connectwithpoll(param->remsock,(struct sockaddr *)¶m->sinsr,SASIZE(¶m->sinsr),CONNECT_TO)) {
|
||||||
unsigned long ul = 1;
|
return 13;
|
||||||
#endif
|
|
||||||
if(so._connect(param->remsock,(struct sockaddr *)¶m->sinsr,SASIZE(¶m->sinsr))) {
|
|
||||||
return (13);
|
|
||||||
}
|
}
|
||||||
param->nconnects++;
|
|
||||||
#ifdef _WIN32
|
|
||||||
ioctlsocket(param->remsock, FIONBIO, &ul);
|
|
||||||
#else
|
|
||||||
fcntl(param->remsock,F_SETFL,O_NONBLOCK);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
size = sizeof(param->sinsl);
|
size = sizeof(param->sinsl);
|
||||||
if(so._getsockname(param->remsock, (struct sockaddr *)¶m->sinsl, &size)==-1) {return (15);}
|
if(so._getsockname(param->remsock, (struct sockaddr *)¶m->sinsl, &size)==-1) {return (15);}
|
||||||
@@ -807,11 +545,42 @@ unsigned long getip(unsigned char *name){
|
|||||||
}
|
}
|
||||||
#endif
|
#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){
|
unsigned long getip46(int family, unsigned char *name, struct sockaddr *sa){
|
||||||
#ifndef NOIPV6
|
#ifndef NOIPV6
|
||||||
int ndots=0, ncols=0, nhex=0;
|
int detect;
|
||||||
struct addrinfo *ai, hint;
|
struct addrinfo *ai, hint;
|
||||||
int i;
|
|
||||||
RESOLVFUNC tmpresolv;
|
RESOLVFUNC tmpresolv;
|
||||||
|
|
||||||
if(!sa) return 0;
|
if(!sa) return 0;
|
||||||
@@ -823,34 +592,15 @@ unsigned long getip46(int family, unsigned char *name, struct sockaddr *sa){
|
|||||||
#endif
|
#endif
|
||||||
#ifndef NOIPV6
|
#ifndef NOIPV6
|
||||||
}
|
}
|
||||||
for(i=0; name[i]; i++){
|
|
||||||
if(name[i] == '.'){
|
detect = afdetect(name);
|
||||||
if(++ndots > 3) {
|
if(detect != -1){
|
||||||
break;
|
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;
|
||||||
else if(name[i] == ':'){
|
|
||||||
if(++ncols > 7) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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') {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!name[i]){
|
|
||||||
if(ndots == 3 && ncols == 0 && nhex == 0){
|
|
||||||
*SAFAMILY(sa)=(family == 6)?AF_INET6 : AF_INET;
|
|
||||||
return inet_pton(*SAFAMILY(sa), (char *)name, SAADDR(sa))? *SAFAMILY(sa) : 0;
|
|
||||||
}
|
|
||||||
if(ncols >= 2) {
|
|
||||||
*SAFAMILY(sa)=AF_INET6;
|
|
||||||
return inet_pton(AF_INET6, (char *)name, SAADDR(sa))?(family==4? 0:AF_INET6) : 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if((tmpresolv = resolvfunc)){
|
if((tmpresolv = resolvfunc)){
|
||||||
int f = (family == 6 || family == 64)?AF_INET6:AF_INET;
|
int f = (family == 6 || family == 64)?AF_INET6:AF_INET;
|
||||||
*SAFAMILY(sa) = f;
|
*SAFAMILY(sa) = f;
|
||||||
|
|||||||
+281
-106
@@ -1,6 +1,16 @@
|
|||||||
|
/*
|
||||||
|
3APA3A simpliest proxy server
|
||||||
|
(c) 2002-2016 by Vladimir Dubrovin <3proxy@3proxy.ru>
|
||||||
|
|
||||||
|
please read License Agreement
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
|
#include <pwd.h>
|
||||||
|
#include <grp.h>
|
||||||
#ifndef NOPLUGINS
|
#ifndef NOPLUGINS
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -11,6 +21,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
pthread_mutex_t bandlim_mutex;
|
pthread_mutex_t bandlim_mutex;
|
||||||
|
pthread_mutex_t connlim_mutex;
|
||||||
pthread_mutex_t tc_mutex;
|
pthread_mutex_t tc_mutex;
|
||||||
pthread_mutex_t pwl_mutex;
|
pthread_mutex_t pwl_mutex;
|
||||||
pthread_mutex_t hash_mutex;
|
pthread_mutex_t hash_mutex;
|
||||||
@@ -150,13 +161,14 @@ int start_proxy_thread(struct child * chp){
|
|||||||
if(h)CloseHandle(h);
|
if(h)CloseHandle(h);
|
||||||
#else
|
#else
|
||||||
pthread_attr_init(&pa);
|
pthread_attr_init(&pa);
|
||||||
pthread_attr_setstacksize(&pa,PTHREAD_STACK_MIN + (16384+conf.stacksize));
|
pthread_attr_setstacksize(&pa,PTHREAD_STACK_MIN + (32768+conf.stacksize));
|
||||||
pthread_attr_setdetachstate(&pa,PTHREAD_CREATE_DETACHED);
|
pthread_attr_setdetachstate(&pa,PTHREAD_CREATE_DETACHED);
|
||||||
pthread_create(&thread, &pa, startsrv, (void *)chp);
|
pthread_create(&thread, &pa, startsrv, (void *)chp);
|
||||||
|
pthread_attr_destroy(&pa);
|
||||||
#endif
|
#endif
|
||||||
while(conf.threadinit)usleep(SLEEPTIME);
|
while(conf.threadinit)usleep(SLEEPTIME);
|
||||||
if(haveerror) {
|
if(haveerror) {
|
||||||
fprintf(stderr, "Service not started on line: %d\n", linenum);
|
fprintf(stderr, "Service not started on line: %d%s\n", linenum, haveerror == 2? ": insufficient memory":"");
|
||||||
return(40);
|
return(40);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -219,22 +231,6 @@ static int h_proxy(int argc, unsigned char ** argv){
|
|||||||
childdef.service = S_TCPPM;
|
childdef.service = S_TCPPM;
|
||||||
childdef.helpmessage = "";
|
childdef.helpmessage = "";
|
||||||
}
|
}
|
||||||
else if(!strcmp((char *)argv[0], "icqpr")) {
|
|
||||||
childdef.pf = icqprchild;
|
|
||||||
childdef.port = 0;
|
|
||||||
childdef.isudp = 0;
|
|
||||||
childdef.service = S_ICQPR;
|
|
||||||
childdef.helpmessage = "";
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
else if(!strcmp((char *)argv[0], "msnpr")) {
|
|
||||||
childdef.pf = msnprchild;
|
|
||||||
childdef.port = 0;
|
|
||||||
childdef.isudp = 0;
|
|
||||||
childdef.service = S_MSNPR;
|
|
||||||
childdef.helpmessage = "";
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
else if(!strcmp((char *)argv[0], "udppm")) {
|
else if(!strcmp((char *)argv[0], "udppm")) {
|
||||||
childdef.pf = udppmchild;
|
childdef.pf = udppmchild;
|
||||||
childdef.port = 0;
|
childdef.port = 0;
|
||||||
@@ -279,58 +275,71 @@ static int h_external(int argc, unsigned char ** argv){
|
|||||||
else conf.extsa6 = sa6;
|
else conf.extsa6 = sa6;
|
||||||
#else
|
#else
|
||||||
res = getip46(46, argv[1], (struct sockaddr *)&conf.extsa);
|
res = getip46(46, argv[1], (struct sockaddr *)&conf.extsa);
|
||||||
if(!res) return 1;
|
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int h_log(int argc, unsigned char ** argv){
|
static int h_log(int argc, unsigned char ** argv){
|
||||||
unsigned char tmpbuf[8192];
|
unsigned char tmpbuf[8192];
|
||||||
conf.logfunc = logstdout;
|
int notchanged = 0;
|
||||||
if(conf.logtarget){
|
|
||||||
|
|
||||||
|
havelog = 1;
|
||||||
|
if(argc > 1 && conf.logtarget && !strcmp((char *)conf.logtarget, (char *)argv[1])) {
|
||||||
|
notchanged = 1;
|
||||||
|
}
|
||||||
|
if(!notchanged && conf.logtarget){
|
||||||
myfree(conf.logtarget);
|
myfree(conf.logtarget);
|
||||||
conf.logtarget = NULL;
|
conf.logtarget = NULL;
|
||||||
}
|
}
|
||||||
if(argc > 1) {
|
if(argc > 1) {
|
||||||
conf.logtarget = (unsigned char *)mystrdup((char *)argv[1]);
|
if(!strcmp((char *) argv[1], "/dev/null")) {
|
||||||
|
conf.logfunc = lognone;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if(!notchanged) conf.logtarget = (unsigned char *)mystrdup((char *)argv[1]);
|
||||||
if(*argv[1]=='@'){
|
if(*argv[1]=='@'){
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
openlog((char *)conf.logtarget+1, LOG_PID, LOG_DAEMON);
|
|
||||||
conf.logfunc = logsyslog;
|
conf.logfunc = logsyslog;
|
||||||
|
if(notchanged) return 0;
|
||||||
|
openlog((char *)conf.logtarget+1, LOG_PID, LOG_DAEMON);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#ifndef NOODBC
|
#ifndef NOODBC
|
||||||
else if(*argv[1]=='&'){
|
else if(*argv[1]=='&'){
|
||||||
|
if(notchanged) return 0;
|
||||||
|
conf.logfunc = logsql;
|
||||||
pthread_mutex_lock(&log_mutex);
|
pthread_mutex_lock(&log_mutex);
|
||||||
close_sql();
|
close_sql();
|
||||||
init_sql((char *)argv[1]+1);
|
init_sql((char *)argv[1]+1);
|
||||||
pthread_mutex_unlock(&log_mutex);
|
pthread_mutex_unlock(&log_mutex);
|
||||||
conf.logfunc = logsql;
|
}
|
||||||
|
#endif
|
||||||
|
#ifndef NORADIUS
|
||||||
|
else if(!strcmp(argv[1],"radius")){
|
||||||
|
conf.logfunc = logradius;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else {
|
else {
|
||||||
FILE *fp;
|
|
||||||
if(argc > 2) {
|
if(argc > 2) {
|
||||||
conf.logtype = getrotate(*argv[2]);
|
conf.logtype = getrotate(*argv[2]);
|
||||||
}
|
}
|
||||||
|
conf.logfunc = logstdout;
|
||||||
|
if(notchanged) return 0;
|
||||||
conf.logtime = time(0);
|
conf.logtime = time(0);
|
||||||
if(conf.logname)myfree(conf.logname);
|
if(conf.logname)myfree(conf.logname);
|
||||||
conf.logname = (unsigned char *)mystrdup((char *)argv[1]);
|
conf.logname = (unsigned char *)mystrdup((char *)argv[1]);
|
||||||
fp = fopen((char *)dologname (tmpbuf, conf.logname, NULL, conf.logtype, conf.logtime), "a");
|
if(conf.stdlog) conf.stdlog = freopen((char *)dologname (tmpbuf, conf.logname, NULL, conf.logtype, conf.logtime), "a", conf.stdlog);
|
||||||
if(!fp){
|
else conf.stdlog = fopen((char *)dologname (tmpbuf, conf.logname, NULL, conf.logtype, conf.logtime), "a");
|
||||||
|
if(!conf.stdlog){
|
||||||
perror((char *)tmpbuf);
|
perror((char *)tmpbuf);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
if(conf.stdlog)fclose(conf.stdlog);
|
|
||||||
conf.stdlog = fp;
|
|
||||||
#ifdef _WINCE
|
|
||||||
freopen(tmpbuf, "w", stdout);
|
|
||||||
freopen(tmpbuf, "w", stderr);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else conf.logfunc = logstdout;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -363,6 +372,7 @@ static int h_daemon(int argc, unsigned char **argv){
|
|||||||
static int h_config(int argc, unsigned char **argv){
|
static int h_config(int argc, unsigned char **argv){
|
||||||
if(conf.conffile)myfree(conf.conffile);
|
if(conf.conffile)myfree(conf.conffile);
|
||||||
conf.conffile = mystrdup((char *)argv[1]);
|
conf.conffile = mystrdup((char *)argv[1]);
|
||||||
|
if(!conf.conffile) return 21;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -394,7 +404,6 @@ static int h_archiver(int argc, unsigned char **argv){
|
|||||||
static int h_counter(int argc, unsigned char **argv){
|
static int h_counter(int argc, unsigned char **argv){
|
||||||
struct counter_header ch1;
|
struct counter_header ch1;
|
||||||
if(conf.counterd >=0)close(conf.counterd);
|
if(conf.counterd >=0)close(conf.counterd);
|
||||||
if(!conf.trafcountfunc) conf.trafcountfunc = trafcountfunc;
|
|
||||||
conf.counterd = open((char *)argv[1], O_BINARY|O_RDWR|O_CREAT, 0660);
|
conf.counterd = open((char *)argv[1], O_BINARY|O_RDWR|O_CREAT, 0660);
|
||||||
if(conf.counterd<0){
|
if(conf.counterd<0){
|
||||||
fprintf(stderr, "Unable to open counter file %s, line %d\n", argv[1], linenum);
|
fprintf(stderr, "Unable to open counter file %s, line %d\n", argv[1], linenum);
|
||||||
@@ -437,8 +446,9 @@ static int h_rotate(int argc, unsigned char **argv){
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int h_logformat(int argc, unsigned char **argv){
|
static int h_logformat(int argc, unsigned char **argv){
|
||||||
if(conf.logformat) myfree(conf.logformat);
|
unsigned char * old = conf.logformat;
|
||||||
conf.logformat = (unsigned char *)mystrdup((char *)argv[1]);
|
conf.logformat = (unsigned char *)mystrdup((char *)argv[1]);
|
||||||
|
if(old) myfree(old);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -468,6 +478,9 @@ static int h_auth(int argc, unsigned char **argv){
|
|||||||
for(au = authfuncs; au; au=au->next){
|
for(au = authfuncs; au; au=au->next){
|
||||||
if(!strcmp((char *)argv[argc], au->desc)){
|
if(!strcmp((char *)argv[argc], au->desc)){
|
||||||
newau = myalloc(sizeof(struct auth));
|
newau = myalloc(sizeof(struct auth));
|
||||||
|
if(!newau) {
|
||||||
|
return 21;
|
||||||
|
}
|
||||||
newau->next = conf.authfuncs;
|
newau->next = conf.authfuncs;
|
||||||
conf.authfuncs = newau;
|
conf.authfuncs = newau;
|
||||||
conf.authfuncs->desc = au->desc;
|
conf.authfuncs->desc = au->desc;
|
||||||
@@ -489,8 +502,7 @@ static int h_users(int argc, unsigned char **argv){
|
|||||||
|
|
||||||
for (j = 1; j<argc; j++) {
|
for (j = 1; j<argc; j++) {
|
||||||
if(!(pwl = myalloc(sizeof(struct passwords)))) {
|
if(!(pwl = myalloc(sizeof(struct passwords)))) {
|
||||||
fprintf(stderr, "No memory for PWL entry, line %d\n", linenum);
|
return(21);
|
||||||
return(1);
|
|
||||||
}
|
}
|
||||||
memset(pwl, 0, sizeof(struct passwords));
|
memset(pwl, 0, sizeof(struct passwords));
|
||||||
|
|
||||||
@@ -502,6 +514,7 @@ static int h_users(int argc, unsigned char **argv){
|
|||||||
else {
|
else {
|
||||||
*arg = 0;
|
*arg = 0;
|
||||||
pwl->user = (unsigned char *)mystrdup((char *)argv[j]);
|
pwl->user = (unsigned char *)mystrdup((char *)argv[j]);
|
||||||
|
|
||||||
if((arg[1] == 'C' && arg[2] == 'L' && (pwl->pwtype = CL)) ||
|
if((arg[1] == 'C' && arg[2] == 'L' && (pwl->pwtype = CL)) ||
|
||||||
(arg[1] == 'C' && arg[2] == 'R' && (pwl->pwtype = CR)) ||
|
(arg[1] == 'C' && arg[2] == 'R' && (pwl->pwtype = CR)) ||
|
||||||
(arg[1] == 'N' && arg[2] == 'T' && (pwl->pwtype = NT)) ||
|
(arg[1] == 'N' && arg[2] == 'T' && (pwl->pwtype = NT)) ||
|
||||||
@@ -512,7 +525,9 @@ static int h_users(int argc, unsigned char **argv){
|
|||||||
pwl->password = (unsigned char *) mystrdup((char *)arg + 1);
|
pwl->password = (unsigned char *) mystrdup((char *)arg + 1);
|
||||||
pwl->pwtype = UN;
|
pwl->pwtype = UN;
|
||||||
}
|
}
|
||||||
|
if(!pwl->password) return 3;
|
||||||
}
|
}
|
||||||
|
if(!pwl->user) return 21;
|
||||||
pthread_mutex_lock(&pwl_mutex);
|
pthread_mutex_lock(&pwl_mutex);
|
||||||
pwl->next = conf.pwl;
|
pwl->next = conf.pwl;
|
||||||
conf.pwl = pwl;
|
conf.pwl = pwl;
|
||||||
@@ -669,12 +684,14 @@ static int h_monitor(int argc, unsigned char **argv){
|
|||||||
struct filemon * fm;
|
struct filemon * fm;
|
||||||
|
|
||||||
fm = myalloc(sizeof (struct filemon));
|
fm = myalloc(sizeof (struct filemon));
|
||||||
|
if(!fm) return 21;
|
||||||
if(stat((char *)argv[1], &fm->sb)){
|
if(stat((char *)argv[1], &fm->sb)){
|
||||||
myfree(fm);
|
myfree(fm);
|
||||||
fprintf(stderr, "Warning: file %s doesn't exist on line %d\n", argv[1], linenum);
|
fprintf(stderr, "Warning: file %s doesn't exist on line %d\n", argv[1], linenum);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fm->path = mystrdup((char *)argv[1]);
|
fm->path = mystrdup((char *)argv[1]);
|
||||||
|
if(!fm->path) return 21;
|
||||||
fm->next = conf.fmon;
|
fm->next = conf.fmon;
|
||||||
conf.fmon = fm;
|
conf.fmon = fm;
|
||||||
}
|
}
|
||||||
@@ -693,21 +710,11 @@ static int h_parent(int argc, unsigned char **argv){
|
|||||||
}
|
}
|
||||||
acl->action = 2;
|
acl->action = 2;
|
||||||
|
|
||||||
chains = NULL;
|
chains = myalloc(sizeof(struct chain));
|
||||||
if(!acl->chains) {
|
if(!chains){
|
||||||
chains = acl->chains = myalloc(sizeof(struct chain));
|
return(21);
|
||||||
}
|
|
||||||
else {
|
|
||||||
chains = acl->chains;
|
|
||||||
while(chains->next)chains = chains->next;
|
|
||||||
chains->next = myalloc(sizeof(struct chain));
|
|
||||||
chains = chains->next;
|
|
||||||
}
|
}
|
||||||
memset(chains, 0, sizeof(struct chain));
|
memset(chains, 0, sizeof(struct chain));
|
||||||
if(!chains){
|
|
||||||
fprintf(stderr, "Chainig error: unable to allocate memory for chain\n");
|
|
||||||
return(2);
|
|
||||||
}
|
|
||||||
chains->weight = (unsigned)atoi((char *)argv[1]);
|
chains->weight = (unsigned)atoi((char *)argv[1]);
|
||||||
if(chains->weight == 0 || chains->weight >1000) {
|
if(chains->weight == 0 || chains->weight >1000) {
|
||||||
fprintf(stderr, "Chaining error: bad chain weight %u line %d\n", chains->weight, linenum);
|
fprintf(stderr, "Chaining error: bad chain weight %u line %d\n", chains->weight, linenum);
|
||||||
@@ -726,17 +733,31 @@ static int h_parent(int argc, unsigned char **argv){
|
|||||||
else if(!strcmp((char *)argv[2], "pop3"))chains->type = R_POP3;
|
else if(!strcmp((char *)argv[2], "pop3"))chains->type = R_POP3;
|
||||||
else if(!strcmp((char *)argv[2], "ftp"))chains->type = R_FTP;
|
else if(!strcmp((char *)argv[2], "ftp"))chains->type = R_FTP;
|
||||||
else if(!strcmp((char *)argv[2], "admin"))chains->type = R_ADMIN;
|
else if(!strcmp((char *)argv[2], "admin"))chains->type = R_ADMIN;
|
||||||
else if(!strcmp((char *)argv[2], "icq"))chains->type = R_ICQ;
|
|
||||||
else if(!strcmp((char *)argv[2], "extip"))chains->type = R_EXTIP;
|
else if(!strcmp((char *)argv[2], "extip"))chains->type = R_EXTIP;
|
||||||
else if(!strcmp((char *)argv[2], "smtp"))chains->type = R_SMTP;
|
else if(!strcmp((char *)argv[2], "smtp"))chains->type = R_SMTP;
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "Chaining error: bad chain type (%s)\n", argv[2]);
|
fprintf(stderr, "Chaining error: bad chain type (%s)\n", argv[2]);
|
||||||
return(4);
|
return(4);
|
||||||
}
|
}
|
||||||
|
#ifndef NOIPV6
|
||||||
if(!getip46(46, argv[3], (struct sockaddr *)&chains->addr)) return 5;
|
if(!getip46(46, argv[3], (struct sockaddr *)&chains->addr)) return 5;
|
||||||
|
#else
|
||||||
|
getip46(46, argv[3], (struct sockaddr *)&chains->addr);
|
||||||
|
#endif
|
||||||
|
chains->exthost = (unsigned char *)mystrdup((char *)argv[3]);
|
||||||
|
if(!chains->exthost) return 21;
|
||||||
*SAPORT(&chains->addr) = htons((unsigned short)atoi((char *)argv[4]));
|
*SAPORT(&chains->addr) = htons((unsigned short)atoi((char *)argv[4]));
|
||||||
if(argc > 5) chains->extuser = (unsigned char *)mystrdup((char *)argv[5]);
|
if(argc > 5) chains->extuser = (unsigned char *)mystrdup((char *)argv[5]);
|
||||||
if(argc > 6) chains->extpass = (unsigned char *)mystrdup((char *)argv[6]);
|
if(argc > 6) chains->extpass = (unsigned char *)mystrdup((char *)argv[6]);
|
||||||
|
if(!acl->chains) {
|
||||||
|
acl->chains = chains;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
struct chain *tmpchain;
|
||||||
|
|
||||||
|
for(tmpchain = acl->chains; tmpchain->next; tmpchain = tmpchain->next);
|
||||||
|
tmpchain->next = chains;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -750,7 +771,7 @@ static int h_nolog(int argc, unsigned char **argv){
|
|||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
while(acl->next) acl = acl->next;
|
while(acl->next) acl = acl->next;
|
||||||
if(!strcmp((char *)argv[0],"nolog")) acl->nolog = 1;
|
if(argc == 1) acl->nolog = 1;
|
||||||
else acl->weight = atoi((char*)argv[1]);
|
else acl->weight = atoi((char*)argv[1]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -763,13 +784,16 @@ int scanipl(unsigned char *arg, struct iplist *dst){
|
|||||||
#endif
|
#endif
|
||||||
char * slash, *dash;
|
char * slash, *dash;
|
||||||
int masklen, addrlen;
|
int masklen, addrlen;
|
||||||
|
|
||||||
if((slash = strchr((char *)arg, '/'))) *slash = 0;
|
if((slash = strchr((char *)arg, '/'))) *slash = 0;
|
||||||
if((dash = strchr((char *)arg,'-'))) *dash = 0;
|
if((dash = strchr((char *)arg,'-'))) *dash = 0;
|
||||||
|
|
||||||
|
if(afdetect(arg) == -1) return 1;
|
||||||
if(!getip46(46, arg, (struct sockaddr *)&sa)) return 1;
|
if(!getip46(46, arg, (struct sockaddr *)&sa)) return 1;
|
||||||
memcpy(&dst->ip_from, SAADDR(&sa), SAADDRLEN(&sa));
|
memcpy(&dst->ip_from, SAADDR(&sa), SAADDRLEN(&sa));
|
||||||
dst->family = *SAFAMILY(&sa);
|
dst->family = *SAFAMILY(&sa);
|
||||||
if(dash){
|
if(dash){
|
||||||
|
if(afdetect(dash+1) == -1) return 1;
|
||||||
if(!getip46(46, (unsigned char *)dash+1, (struct sockaddr *)&sa)) return 2;
|
if(!getip46(46, (unsigned char *)dash+1, (struct sockaddr *)&sa)) return 2;
|
||||||
memcpy(&dst->ip_to, SAADDR(&sa), SAADDRLEN(&sa));
|
memcpy(&dst->ip_to, SAADDR(&sa), SAADDRLEN(&sa));
|
||||||
if(*SAFAMILY(&sa) != dst->family || memcmp(&dst->ip_to, &dst->ip_from, SAADDRLEN(&sa)) < 0) return 3;
|
if(*SAFAMILY(&sa) != dst->family || memcmp(&dst->ip_to, &dst->ip_from, SAADDRLEN(&sa)) < 0) return 3;
|
||||||
@@ -826,6 +850,7 @@ struct ace * make_ace (int argc, unsigned char ** argv){
|
|||||||
}
|
}
|
||||||
memset(userl, 0, sizeof(struct userlist));
|
memset(userl, 0, sizeof(struct userlist));
|
||||||
userl->user=(unsigned char*)mystrdup((char *)arg);
|
userl->user=(unsigned char*)mystrdup((char *)arg);
|
||||||
|
if(!userl->user) return NULL;
|
||||||
} while((arg = (unsigned char *)strtok((char *)NULL, ",")));
|
} while((arg = (unsigned char *)strtok((char *)NULL, ",")));
|
||||||
}
|
}
|
||||||
if(argc > 1 && strcmp("*", (char *)argv[1])) {
|
if(argc > 1 && strcmp("*", (char *)argv[1])) {
|
||||||
@@ -854,9 +879,11 @@ struct ace * make_ace (int argc, unsigned char ** argv){
|
|||||||
do {
|
do {
|
||||||
int arglen;
|
int arglen;
|
||||||
unsigned char *pattern;
|
unsigned char *pattern;
|
||||||
|
struct iplist tmpip={NULL};
|
||||||
|
|
||||||
arglen = (int)strlen((char *)arg);
|
arglen = (int)strlen((char *)arg);
|
||||||
if(arglen > 0 && (arg[arglen-1] < '0' || arg[arglen-1] > '9')){
|
if(scanipl(arg, &tmpip)){
|
||||||
|
if(!arglen) continue;
|
||||||
if(!acl->dstnames) {
|
if(!acl->dstnames) {
|
||||||
acl->dstnames = hostnamel = myalloc(sizeof(struct hostname));
|
acl->dstnames = hostnamel = myalloc(sizeof(struct hostname));
|
||||||
}
|
}
|
||||||
@@ -900,11 +927,7 @@ struct ace * make_ace (int argc, unsigned char ** argv){
|
|||||||
fprintf(stderr, "No memory for ACL entry, line %d\n", linenum);
|
fprintf(stderr, "No memory for ACL entry, line %d\n", linenum);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ipl, 0, sizeof(struct iplist));
|
*ipl = tmpip;
|
||||||
if (scanipl(arg, ipl)) {
|
|
||||||
fprintf(stderr, "Invalid IP, IP range or CIDR, line %d\n", linenum);
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}while((arg = (unsigned char *)strtok((char *)NULL, ",")));
|
}while((arg = (unsigned char *)strtok((char *)NULL, ",")));
|
||||||
}
|
}
|
||||||
@@ -991,9 +1014,6 @@ struct ace * make_ace (int argc, unsigned char ** argv){
|
|||||||
else if(!strcmp((char *)arg, "DNSRESOLVE")){
|
else if(!strcmp((char *)arg, "DNSRESOLVE")){
|
||||||
acl->operation |= DNSRESOLVE;
|
acl->operation |= DNSRESOLVE;
|
||||||
}
|
}
|
||||||
else if(!strcmp((char *)arg, "ICQ")){
|
|
||||||
acl->operation |= IM_ICQ;
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "Unknown operation type: %s line %d\n", arg, linenum);
|
fprintf(stderr, "Unknown operation type: %s line %d\n", arg, linenum);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
@@ -1068,6 +1088,7 @@ static int h_ace(int argc, unsigned char **argv){
|
|||||||
struct ace *acl = NULL;
|
struct ace *acl = NULL;
|
||||||
struct bandlim * nbl;
|
struct bandlim * nbl;
|
||||||
struct trafcount * tl;
|
struct trafcount * tl;
|
||||||
|
struct connlim * ncl;
|
||||||
|
|
||||||
if(!strcmp((char *)argv[0], "allow")){
|
if(!strcmp((char *)argv[0], "allow")){
|
||||||
res = ALLOW;
|
res = ALLOW;
|
||||||
@@ -1100,6 +1121,20 @@ static int h_ace(int argc, unsigned char **argv){
|
|||||||
else if(!strcmp((char *)argv[0], "nocountout")){
|
else if(!strcmp((char *)argv[0], "nocountout")){
|
||||||
res = NOCOUNTOUT;
|
res = NOCOUNTOUT;
|
||||||
}
|
}
|
||||||
|
else if(!strcmp((char *)argv[0], "countall")){
|
||||||
|
res = COUNTALL;
|
||||||
|
offset = 3;
|
||||||
|
}
|
||||||
|
else if(!strcmp((char *)argv[0], "nocountall")){
|
||||||
|
res = NOCOUNTALL;
|
||||||
|
}
|
||||||
|
else if(!strcmp((char *)argv[0], "connlim")){
|
||||||
|
res = CONNLIM;
|
||||||
|
offset = 2;
|
||||||
|
}
|
||||||
|
else if(!strcmp((char *)argv[0], "noconnlim")){
|
||||||
|
res = NOCONNLIM;
|
||||||
|
}
|
||||||
acl = make_ace(argc - (offset+1), argv + (offset + 1));
|
acl = make_ace(argc - (offset+1), argv + (offset + 1));
|
||||||
if(!acl) {
|
if(!acl) {
|
||||||
fprintf(stderr, "Unable to parse ACL entry, line %d\n", linenum);
|
fprintf(stderr, "Unable to parse ACL entry, line %d\n", linenum);
|
||||||
@@ -1109,18 +1144,14 @@ static int h_ace(int argc, unsigned char **argv){
|
|||||||
switch(acl->action){
|
switch(acl->action){
|
||||||
case REDIRECT:
|
case REDIRECT:
|
||||||
acl->chains = myalloc(sizeof(struct chain));
|
acl->chains = myalloc(sizeof(struct chain));
|
||||||
memset(acl->chains, 0, sizeof(struct chain));
|
|
||||||
if(!acl->chains) {
|
if(!acl->chains) {
|
||||||
fprintf(stderr, "No memory for ACL entry, line %d\n", linenum);
|
return(21);
|
||||||
return(2);
|
|
||||||
}
|
}
|
||||||
|
memset(acl->chains, 0, sizeof(struct chain));
|
||||||
acl->chains->type = R_HTTP;
|
acl->chains->type = R_HTTP;
|
||||||
if(!getip46(46, argv[1], (struct sockaddr *)&acl->chains->addr)) return 5;
|
if(!getip46(46, argv[1], (struct sockaddr *)&acl->chains->addr)) return 5;
|
||||||
*SAPORT(&acl->chains->addr) = htons((unsigned short)atoi((char *)argv[2]));
|
*SAPORT(&acl->chains->addr) = htons((unsigned short)atoi((char *)argv[2]));
|
||||||
acl->chains->weight = 1000;
|
acl->chains->weight = 1000;
|
||||||
acl->chains->extuser = NULL;
|
|
||||||
acl->chains->extpass = NULL;
|
|
||||||
acl->chains->next = NULL;
|
|
||||||
case ALLOW:
|
case ALLOW:
|
||||||
case DENY:
|
case DENY:
|
||||||
if(!conf.acl){
|
if(!conf.acl){
|
||||||
@@ -1133,13 +1164,37 @@ static int h_ace(int argc, unsigned char **argv){
|
|||||||
acei->next = acl;
|
acei->next = acl;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case CONNLIM:
|
||||||
|
case NOCONNLIM:
|
||||||
|
ncl = myalloc(sizeof(struct connlim));
|
||||||
|
if(!ncl) {
|
||||||
|
return(21);
|
||||||
|
}
|
||||||
|
memset(ncl, 0, sizeof(struct connlim));
|
||||||
|
ncl->ace = acl;
|
||||||
|
if(acl->action == CONNLIM) {
|
||||||
|
sscanf((char *)argv[1], "%u", &ncl->rate);
|
||||||
|
sscanf((char *)argv[2], "%u", &ncl->period);
|
||||||
|
}
|
||||||
|
pthread_mutex_lock(&connlim_mutex);
|
||||||
|
if(!conf.connlimiter){
|
||||||
|
conf.connlimiter = ncl;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
struct connlim * cli;
|
||||||
|
|
||||||
|
for(cli = conf.connlimiter; cli->next; cli = cli->next);
|
||||||
|
cli->next = ncl;
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&connlim_mutex);
|
||||||
|
break;
|
||||||
|
|
||||||
case BANDLIM:
|
case BANDLIM:
|
||||||
case NOBANDLIM:
|
case NOBANDLIM:
|
||||||
|
|
||||||
nbl = myalloc(sizeof(struct bandlim));
|
nbl = myalloc(sizeof(struct bandlim));
|
||||||
if(!nbl) {
|
if(!nbl) {
|
||||||
fprintf(stderr, "No memory to create band limit filter\n");
|
return(21);
|
||||||
return(3);
|
|
||||||
}
|
}
|
||||||
memset(nbl, 0, sizeof(struct bandlim));
|
memset(nbl, 0, sizeof(struct bandlim));
|
||||||
nbl->ace = acl;
|
nbl->ace = acl;
|
||||||
@@ -1173,7 +1228,7 @@ static int h_ace(int argc, unsigned char **argv){
|
|||||||
bli->next = nbl;
|
bli->next = nbl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
conf.bandlimver++;
|
||||||
pthread_mutex_unlock(&bandlim_mutex);
|
pthread_mutex_unlock(&bandlim_mutex);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1181,15 +1236,17 @@ static int h_ace(int argc, unsigned char **argv){
|
|||||||
case NOCOUNTIN:
|
case NOCOUNTIN:
|
||||||
case COUNTOUT:
|
case COUNTOUT:
|
||||||
case NOCOUNTOUT:
|
case NOCOUNTOUT:
|
||||||
|
case COUNTALL:
|
||||||
|
case NOCOUNTALL:
|
||||||
|
if(!conf.trafcountfunc) conf.trafcountfunc = trafcountfunc;
|
||||||
tl = myalloc(sizeof(struct trafcount));
|
tl = myalloc(sizeof(struct trafcount));
|
||||||
if(!tl) {
|
if(!tl) {
|
||||||
fprintf(stderr, "No memory to create traffic limit filter\n");
|
return(21);
|
||||||
return(5);
|
|
||||||
}
|
}
|
||||||
memset(tl, 0, sizeof(struct trafcount));
|
memset(tl, 0, sizeof(struct trafcount));
|
||||||
tl->ace = acl;
|
tl->ace = acl;
|
||||||
|
|
||||||
if((acl->action == COUNTIN)||(acl->action == COUNTOUT)) {
|
if((acl->action == COUNTIN)||(acl->action == COUNTOUT)||(acl->action == COUNTALL)) {
|
||||||
unsigned long lim;
|
unsigned long lim;
|
||||||
|
|
||||||
tl->comment = ( char *)argv[1];
|
tl->comment = ( char *)argv[1];
|
||||||
@@ -1253,11 +1310,58 @@ static int h_delimchar(int argc, unsigned char **argv){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NORADIUS
|
||||||
|
static int h_radius(int argc, unsigned char **argv){
|
||||||
|
unsigned short port;
|
||||||
|
|
||||||
|
/*
|
||||||
|
int oldrad;
|
||||||
|
#ifdef NOIPV6
|
||||||
|
struct sockaddr_in bindaddr;
|
||||||
|
#else
|
||||||
|
struct sockaddr_in6 bindaddr;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
oldrad = nradservers;
|
||||||
|
nradservers = 0;
|
||||||
|
for(; oldrad; oldrad--){
|
||||||
|
if(radiuslist[oldrad].logsock >= 0) so._closesocket(radiuslist[oldrad].logsock);
|
||||||
|
radiuslist[oldrad].logsock = -1;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
memset(radiuslist, 0, sizeof(radiuslist));
|
||||||
|
if(strlen(argv[1]) > 63) argv[1][63] = 0;
|
||||||
|
strcpy(radiussecret, argv[1]);
|
||||||
|
for( nradservers=0; nradservers < MAXRADIUS && nradservers < argc -2; nradservers++){
|
||||||
|
char *s = 0;
|
||||||
|
if((s=strchr(argv[nradservers + 2], '/'))){
|
||||||
|
*s = 0;
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
if( !getip46(46, argv[nradservers + 2], (struct sockaddr *)&radiuslist[nradservers].authaddr)) return 1;
|
||||||
|
if( s && !getip46(46, s+1, (struct sockaddr *)&radiuslist[nradservers].localaddr)) return 2;
|
||||||
|
if(!*SAPORT(&radiuslist[nradservers].authaddr))*SAPORT(&radiuslist[nradservers].authaddr) = htons(1812);
|
||||||
|
port = ntohs(*SAPORT(&radiuslist[nradservers].authaddr));
|
||||||
|
radiuslist[nradservers].logaddr = radiuslist[nradservers].authaddr;
|
||||||
|
*SAPORT(&radiuslist[nradservers].logaddr) = htons(port+1);
|
||||||
|
/*
|
||||||
|
bindaddr = radiuslist[nradservers].localaddr;
|
||||||
|
if ((radiuslist[nradservers].logsock = so._socket(SASOCK(&radiuslist[nradservers].logaddr), SOCK_DGRAM, 0)) < 0) return 2;
|
||||||
|
if (so._bind(radiuslist[nradservers].logsock, (struct sockaddr *)&bindaddr, SASIZE(&bindaddr))) return 3;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
static int h_authcache(int argc, unsigned char **argv){
|
static int h_authcache(int argc, unsigned char **argv){
|
||||||
conf.authcachetype = 0;
|
conf.authcachetype = 0;
|
||||||
if(strstr((char *) *(argv + 1), "ip")) conf.authcachetype |= 1;
|
if(strstr((char *) *(argv + 1), "ip")) conf.authcachetype |= 1;
|
||||||
if(strstr((char *) *(argv + 1), "user")) conf.authcachetype |= 2;
|
if(strstr((char *) *(argv + 1), "user")) conf.authcachetype |= 2;
|
||||||
if(strstr((char *) *(argv + 1), "pass")) conf.authcachetype |= 4;
|
if(strstr((char *) *(argv + 1), "pass")) conf.authcachetype |= 4;
|
||||||
|
if(strstr((char *) *(argv + 1), "limit")) conf.authcachetype |= 8;
|
||||||
|
if(strstr((char *) *(argv + 1), "acl")) conf.authcachetype |= 16;
|
||||||
|
if(strstr((char *) *(argv + 1), "ext")) conf.authcachetype |= 32;
|
||||||
if(argc > 2) conf.authcachetime = (unsigned) atoi((char *) *(argv + 2));
|
if(argc > 2) conf.authcachetime = (unsigned) atoi((char *) *(argv + 2));
|
||||||
if(!conf.authcachetype) conf.authcachetype = 6;
|
if(!conf.authcachetype) conf.authcachetype = 6;
|
||||||
if(!conf.authcachetime) conf.authcachetime = 600;
|
if(!conf.authcachetime) conf.authcachetime = 600;
|
||||||
@@ -1303,9 +1407,23 @@ static int h_plugin(int argc, unsigned char **argv){
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
|
||||||
|
uid_t strtouid(unsigned char *str){
|
||||||
|
uid_t res = 0;
|
||||||
|
|
||||||
|
if(!isnumber(*(char *)str)){
|
||||||
|
struct passwd *pw;
|
||||||
|
pw = getpwnam((char *)str);
|
||||||
|
if(pw) res = pw->pw_uid;
|
||||||
|
}
|
||||||
|
else res = atoi((char *)str);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int h_setuid(int argc, unsigned char **argv){
|
static int h_setuid(int argc, unsigned char **argv){
|
||||||
int res;
|
uid_t res = 0;
|
||||||
res = atoi((char *)argv[1]);
|
res = strtouid(argv[1]);
|
||||||
if(!res || setreuid(res,res)) {
|
if(!res || setreuid(res,res)) {
|
||||||
fprintf(stderr, "Unable to set uid %d", res);
|
fprintf(stderr, "Unable to set uid %d", res);
|
||||||
return(1);
|
return(1);
|
||||||
@@ -1313,10 +1431,22 @@ static int h_setuid(int argc, unsigned char **argv){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int h_setgid(int argc, unsigned char **argv){
|
gid_t strtogid(unsigned char *str){
|
||||||
int res;
|
gid_t res = 0;
|
||||||
|
|
||||||
res = atoi((char *)argv[1]);
|
if(!isnumber(*(char *)str)){
|
||||||
|
struct group *gr;
|
||||||
|
gr = getgrnam((char *)str);
|
||||||
|
if(gr) res = gr->gr_gid;
|
||||||
|
}
|
||||||
|
else res = atoi((char *)str);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int h_setgid(int argc, unsigned char **argv){
|
||||||
|
gid_t res = 0;
|
||||||
|
|
||||||
|
res = strtogid(argv[1]);
|
||||||
if(!res || setregid(res,res)) {
|
if(!res || setregid(res,res)) {
|
||||||
fprintf(stderr, "Unable to set gid %d", res);
|
fprintf(stderr, "Unable to set gid %d", res);
|
||||||
return(1);
|
return(1);
|
||||||
@@ -1326,6 +1456,22 @@ static int h_setgid(int argc, unsigned char **argv){
|
|||||||
|
|
||||||
|
|
||||||
static int h_chroot(int argc, unsigned char **argv){
|
static int h_chroot(int argc, unsigned char **argv){
|
||||||
|
uid_t uid = 0;
|
||||||
|
gid_t gid = 0;
|
||||||
|
if(argc > 2) {
|
||||||
|
uid = strtouid(argv[2]);
|
||||||
|
if(!uid){
|
||||||
|
fprintf(stderr, "Unable to resolve uid %s", argv[2]);
|
||||||
|
return(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(argc > 3) {
|
||||||
|
gid = strtogid(argv[3]);
|
||||||
|
if(!gid){
|
||||||
|
fprintf(stderr, "Unable to resolve gid %s", argv[3]);
|
||||||
|
return(3);
|
||||||
|
}
|
||||||
|
}
|
||||||
if(!chrootp){
|
if(!chrootp){
|
||||||
char *p;
|
char *p;
|
||||||
if(chroot((char *)argv[1])) {
|
if(chroot((char *)argv[1])) {
|
||||||
@@ -1338,7 +1484,17 @@ static int h_chroot(int argc, unsigned char **argv){
|
|||||||
*p = 0;
|
*p = 0;
|
||||||
}
|
}
|
||||||
chrootp = mystrdup((char *)argv[1]);
|
chrootp = mystrdup((char *)argv[1]);
|
||||||
|
if(!chrootp) return 21;
|
||||||
}
|
}
|
||||||
|
if (gid && setregid(gid,gid)) {
|
||||||
|
fprintf(stderr, "Unable to set gid %d", (int)gid);
|
||||||
|
return(4);
|
||||||
|
}
|
||||||
|
if (uid && setreuid(uid,uid)) {
|
||||||
|
fprintf(stderr, "Unable to set uid %d", (int)uid);
|
||||||
|
return(5);
|
||||||
|
}
|
||||||
|
chdir("/");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -1348,7 +1504,7 @@ struct commands specificcommands[]={
|
|||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
{specificcommands+1, "setuid", h_setuid, 2, 2},
|
{specificcommands+1, "setuid", h_setuid, 2, 2},
|
||||||
{specificcommands+2, "setgid", h_setgid, 2, 2},
|
{specificcommands+2, "setgid", h_setgid, 2, 2},
|
||||||
{specificcommands+3, "chroot", h_chroot, 2, 2},
|
{specificcommands+3, "chroot", h_chroot, 2, 4},
|
||||||
#endif
|
#endif
|
||||||
{NULL, "", h_noop, 1, 0}
|
{NULL, "", h_noop, 1, 0}
|
||||||
};
|
};
|
||||||
@@ -1376,7 +1532,7 @@ struct commands commandhandlers[]={
|
|||||||
{commandhandlers+20, "logformat", h_logformat, 2, 2},
|
{commandhandlers+20, "logformat", h_logformat, 2, 2},
|
||||||
{commandhandlers+21, "timeouts", h_timeouts, 2, 0},
|
{commandhandlers+21, "timeouts", h_timeouts, 2, 0},
|
||||||
{commandhandlers+22, "auth", h_auth, 2, 0},
|
{commandhandlers+22, "auth", h_auth, 2, 0},
|
||||||
{commandhandlers+23, "users", h_users, 2, 0},
|
{commandhandlers+23, "users", h_users, 1, 0},
|
||||||
{commandhandlers+24, "maxconn", h_maxconn, 2, 2},
|
{commandhandlers+24, "maxconn", h_maxconn, 2, 2},
|
||||||
{commandhandlers+25, "flush", h_flush, 1, 1},
|
{commandhandlers+25, "flush", h_flush, 1, 1},
|
||||||
{commandhandlers+26, "nserver", h_nserver, 2, 2},
|
{commandhandlers+26, "nserver", h_nserver, 2, 2},
|
||||||
@@ -1400,20 +1556,25 @@ struct commands commandhandlers[]={
|
|||||||
{commandhandlers+44, "nocountin", h_ace, 1, 0},
|
{commandhandlers+44, "nocountin", h_ace, 1, 0},
|
||||||
{commandhandlers+45, "countout", h_ace, 4, 0},
|
{commandhandlers+45, "countout", h_ace, 4, 0},
|
||||||
{commandhandlers+46, "nocountout", h_ace, 1, 0},
|
{commandhandlers+46, "nocountout", h_ace, 1, 0},
|
||||||
{commandhandlers+47, "plugin", h_plugin, 3, 0},
|
{commandhandlers+47, "countall", h_ace, 4, 0},
|
||||||
{commandhandlers+48, "logdump", h_logdump, 2, 3},
|
{commandhandlers+48, "nocountall", h_ace, 1, 0},
|
||||||
{commandhandlers+49, "filtermaxsize", h_filtermaxsize, 2, 2},
|
{commandhandlers+49, "connlim", h_ace, 4, 0},
|
||||||
{commandhandlers+50, "nolog", h_nolog, 1, 1},
|
{commandhandlers+50, "noconnlim", h_ace, 1, 0},
|
||||||
{commandhandlers+51, "weight", h_nolog, 2, 2},
|
{commandhandlers+51, "plugin", h_plugin, 3, 0},
|
||||||
{commandhandlers+52, "authcache", h_authcache, 2, 3},
|
{commandhandlers+52, "logdump", h_logdump, 2, 3},
|
||||||
{commandhandlers+53, "smtpp", h_proxy, 1, 0},
|
{commandhandlers+53, "filtermaxsize", h_filtermaxsize, 2, 2},
|
||||||
{commandhandlers+54, "icqpr", h_proxy, 4, 0},
|
{commandhandlers+54, "nolog", h_nolog, 1, 1},
|
||||||
{commandhandlers+55, "msnpr", h_proxy, 4, 0},
|
{commandhandlers+55, "weight", h_nolog, 2, 2},
|
||||||
{commandhandlers+56, "delimchar",h_delimchar, 2, 2},
|
{commandhandlers+56, "authcache", h_authcache, 2, 3},
|
||||||
{commandhandlers+57, "authnserver", h_authnserver, 2, 2},
|
{commandhandlers+57, "smtpp", h_proxy, 1, 0},
|
||||||
{commandhandlers+58, "stacksize", h_stacksize, 2, 2},
|
{commandhandlers+58, "delimchar",h_delimchar, 2, 2},
|
||||||
{commandhandlers+59, "force", h_force, 1, 1},
|
{commandhandlers+59, "authnserver", h_authnserver, 2, 2},
|
||||||
{commandhandlers+60, "noforce", h_noforce, 1, 1},
|
{commandhandlers+60, "stacksize", h_stacksize, 2, 2},
|
||||||
|
{commandhandlers+61, "force", h_force, 1, 1},
|
||||||
|
{commandhandlers+62, "noforce", h_noforce, 1, 1},
|
||||||
|
#ifndef NORADIUS
|
||||||
|
{commandhandlers+63, "radius", h_radius, 3, 0},
|
||||||
|
#endif
|
||||||
{specificcommands, "", h_noop, 1, 0}
|
{specificcommands, "", h_noop, 1, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1425,7 +1586,6 @@ int parsestr (unsigned char *str, unsigned char **argm, int nitems, unsigned cha
|
|||||||
unsigned char * incbegin = 0;
|
unsigned char * incbegin = 0;
|
||||||
int fd;
|
int fd;
|
||||||
int res, len;
|
int res, len;
|
||||||
int i = 1;
|
|
||||||
unsigned char *str1;
|
unsigned char *str1;
|
||||||
|
|
||||||
for(;;str++){
|
for(;;str++){
|
||||||
@@ -1444,7 +1604,14 @@ int parsestr (unsigned char *str, unsigned char **argm, int nitems, unsigned cha
|
|||||||
argm[argc] = 0;
|
argm[argc] = 0;
|
||||||
return argc;
|
return argc;
|
||||||
case '$':
|
case '$':
|
||||||
if(!comment && !included){
|
if(comment){
|
||||||
|
if(space){
|
||||||
|
argm[argc++] = str;
|
||||||
|
if(argc >= nitems) return argc;
|
||||||
|
space = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(!included){
|
||||||
incbegin = str;
|
incbegin = str;
|
||||||
*str = 0;
|
*str = 0;
|
||||||
}
|
}
|
||||||
@@ -1456,7 +1623,6 @@ int parsestr (unsigned char *str, unsigned char **argm, int nitems, unsigned cha
|
|||||||
if(!comment){
|
if(!comment){
|
||||||
*str = 0;
|
*str = 0;
|
||||||
space = 1;
|
space = 1;
|
||||||
i = 0;
|
|
||||||
if(incbegin){
|
if(incbegin){
|
||||||
argc--;
|
argc--;
|
||||||
if((fd = open((char *)incbegin+1, O_RDONLY)) <= 0){
|
if((fd = open((char *)incbegin+1, O_RDONLY)) <= 0){
|
||||||
@@ -1494,7 +1660,6 @@ int parsestr (unsigned char *str, unsigned char **argm, int nitems, unsigned cha
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
i++;
|
|
||||||
if(space) {
|
if(space) {
|
||||||
if(comment && *str == '\"' && str[1] != '\"'){
|
if(comment && *str == '\"' && str[1] != '\"'){
|
||||||
str++;
|
str++;
|
||||||
@@ -1530,7 +1695,7 @@ int readconfig(FILE * fp){
|
|||||||
argc = parsestr (buf, argv, NPARAMS-1, &buf, &inbuf, &bufsize);
|
argc = parsestr (buf, argv, NPARAMS-1, &buf, &inbuf, &bufsize);
|
||||||
if(argc < 1) {
|
if(argc < 1) {
|
||||||
fprintf(stderr, "Parse error line %d\n", linenum);
|
fprintf(stderr, "Parse error line %d\n", linenum);
|
||||||
return(21);
|
return(11);
|
||||||
}
|
}
|
||||||
argv[argc] = NULL;
|
argv[argc] = NULL;
|
||||||
if(!strcmp((char *)argv[0], "end") && argc == 1) {
|
if(!strcmp((char *)argv[0], "end") && argc == 1) {
|
||||||
@@ -1581,6 +1746,7 @@ void freepwl(struct passwords *pwl){
|
|||||||
void freeconf(struct extparam *confp){
|
void freeconf(struct extparam *confp){
|
||||||
struct bandlim * bl;
|
struct bandlim * bl;
|
||||||
struct bandlim * blout;
|
struct bandlim * blout;
|
||||||
|
struct connlim * cl;
|
||||||
struct trafcount * tc;
|
struct trafcount * tc;
|
||||||
struct passwords *pw;
|
struct passwords *pw;
|
||||||
struct ace *acl;
|
struct ace *acl;
|
||||||
@@ -1611,6 +1777,10 @@ void freeconf(struct extparam *confp){
|
|||||||
confp->bandlimiterout = NULL;
|
confp->bandlimiterout = NULL;
|
||||||
confp->bandlimfunc = NULL;
|
confp->bandlimfunc = NULL;
|
||||||
pthread_mutex_unlock(&bandlim_mutex);
|
pthread_mutex_unlock(&bandlim_mutex);
|
||||||
|
pthread_mutex_lock(&connlim_mutex);
|
||||||
|
cl = confp->connlimiter;
|
||||||
|
confp->connlimiter = NULL;
|
||||||
|
pthread_mutex_unlock(&connlim_mutex);
|
||||||
|
|
||||||
pthread_mutex_lock(&pwl_mutex);
|
pthread_mutex_lock(&pwl_mutex);
|
||||||
pw = confp->pwl;
|
pw = confp->pwl;
|
||||||
@@ -1618,14 +1788,18 @@ void freeconf(struct extparam *confp){
|
|||||||
pthread_mutex_unlock(&pwl_mutex);
|
pthread_mutex_unlock(&pwl_mutex);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
logtarget = confp->logtarget;
|
logtarget = confp->logtarget;
|
||||||
confp->logtarget = NULL;
|
confp->logtarget = NULL;
|
||||||
logformat = confp->logformat;
|
|
||||||
confp->logformat = NULL;
|
|
||||||
logname = confp->logname;
|
logname = confp->logname;
|
||||||
confp->logname = NULL;
|
confp->logname = NULL;
|
||||||
|
*/
|
||||||
|
confp->logfunc = lognone;
|
||||||
|
logformat = confp->logformat;
|
||||||
|
confp->logformat = NULL;
|
||||||
confp->rotate = 0;
|
confp->rotate = 0;
|
||||||
confp->logtype = NONE;
|
confp->logtype = NONE;
|
||||||
|
confp->logtime = confp->time = 0;
|
||||||
|
|
||||||
archiverc = confp->archiverc;
|
archiverc = confp->archiverc;
|
||||||
confp->archiverc = 0;
|
confp->archiverc = 0;
|
||||||
@@ -1642,13 +1816,11 @@ void freeconf(struct extparam *confp){
|
|||||||
#endif
|
#endif
|
||||||
*SAFAMILY(&confp->intsa) = AF_INET;
|
*SAFAMILY(&confp->intsa) = AF_INET;
|
||||||
*SAFAMILY(&confp->extsa) = AF_INET;
|
*SAFAMILY(&confp->extsa) = AF_INET;
|
||||||
confp->singlepacket = 0;
|
|
||||||
confp->maxchild = 100;
|
confp->maxchild = 100;
|
||||||
resolvfunc = NULL;
|
resolvfunc = NULL;
|
||||||
numservers = 0;
|
numservers = 0;
|
||||||
acl = confp->acl;
|
acl = confp->acl;
|
||||||
confp->acl = NULL;
|
confp->acl = NULL;
|
||||||
confp->logtime = confp->time = 0;
|
|
||||||
|
|
||||||
usleep(SLEEPTIME);
|
usleep(SLEEPTIME);
|
||||||
|
|
||||||
@@ -1667,6 +1839,7 @@ void freeconf(struct extparam *confp){
|
|||||||
freepwl(pw);
|
freepwl(pw);
|
||||||
for(; bl; bl = (struct bandlim *) itfree(bl, bl->next)) freeacl(bl->ace);
|
for(; bl; bl = (struct bandlim *) itfree(bl, bl->next)) freeacl(bl->ace);
|
||||||
for(; blout; blout = (struct bandlim *) itfree(blout, blout->next))freeacl(blout->ace);
|
for(; blout; blout = (struct bandlim *) itfree(blout, blout->next))freeacl(blout->ace);
|
||||||
|
for(; cl; cl = (struct connlim *) itfree(cl, cl->next)) freeacl(cl->ace);
|
||||||
|
|
||||||
if(counterd != -1) {
|
if(counterd != -1) {
|
||||||
close(counterd);
|
close(counterd);
|
||||||
@@ -1674,12 +1847,14 @@ void freeconf(struct extparam *confp){
|
|||||||
for(; fm; fm = (struct filemon *)itfree(fm, fm->next)){
|
for(; fm; fm = (struct filemon *)itfree(fm, fm->next)){
|
||||||
if(fm->path) myfree(fm->path);
|
if(fm->path) myfree(fm->path);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
if(logtarget) {
|
if(logtarget) {
|
||||||
myfree(logtarget);
|
myfree(logtarget);
|
||||||
}
|
}
|
||||||
if(logname) {
|
if(logname) {
|
||||||
myfree(logname);
|
myfree(logname);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
if(logformat) {
|
if(logformat) {
|
||||||
myfree(logformat);
|
myfree(logformat);
|
||||||
}
|
}
|
||||||
@@ -1687,7 +1862,7 @@ void freeconf(struct extparam *confp){
|
|||||||
for(i = 0; i < archiverc; i++) myfree(archiver[i]);
|
for(i = 0; i < archiverc; i++) myfree(archiver[i]);
|
||||||
myfree(archiver);
|
myfree(archiver);
|
||||||
}
|
}
|
||||||
|
havelog = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int reload (void){
|
int reload (void){
|
||||||
|
|||||||
+41
-43
@@ -1,9 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000-2008 3APA3A
|
(c) 2002-2016 by Vladimir Dubrovin <3proxy@3proxy.ru>
|
||||||
*
|
|
||||||
* please read License Agreement
|
please read License Agreement
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ static void pr_sa(struct node *node, CBFUNC cbf, void*cb){
|
|||||||
char buf[64];
|
char buf[64];
|
||||||
buf[0] = '[';
|
buf[0] = '[';
|
||||||
buf[1] = 0;
|
buf[1] = 0;
|
||||||
inet_ntop(*SAFAMILY(node->value), node->value, buf+1, sizeof(buf)-10);
|
inet_ntop(*SAFAMILY(node->value), SAADDR(node->value), buf+1, sizeof(buf)-10);
|
||||||
sprintf(buf + strlen(buf), "]:%hu", (unsigned short)*SAPORT(node->value));
|
sprintf(buf + strlen(buf), "]:%hu", (unsigned short)*SAPORT(node->value));
|
||||||
if(node->value)(*cbf)(cb, buf, strlen(buf));
|
if(node->value)(*cbf)(cb, buf, strlen(buf));
|
||||||
#endif
|
#endif
|
||||||
@@ -365,28 +365,11 @@ static void * ef_ace_next(struct node * node){
|
|||||||
return ((struct ace *)node->value) -> next;
|
return ((struct ace *)node->value) -> next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char * aceaction (int action);
|
||||||
|
|
||||||
static void * ef_ace_type(struct node * node){
|
static void * ef_ace_type(struct node * node){
|
||||||
switch (((struct ace *)node->value) -> action) {
|
return aceaction(((struct ace *)node->value) -> action);
|
||||||
case ALLOW:
|
|
||||||
case REDIRECT:
|
|
||||||
return "allow";
|
|
||||||
case DENY:
|
|
||||||
return "deny";
|
|
||||||
case BANDLIM:
|
|
||||||
return "bandlim";
|
|
||||||
case NOBANDLIM:
|
|
||||||
return "nobandlim";
|
|
||||||
case COUNTIN:
|
|
||||||
return "countin";
|
|
||||||
case NOCOUNTIN:
|
|
||||||
return "nocountin";
|
|
||||||
case COUNTOUT:
|
|
||||||
return "countout";
|
|
||||||
case NOCOUNTOUT:
|
|
||||||
return "nocountout";
|
|
||||||
default:
|
|
||||||
return "unknown";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -520,6 +503,9 @@ 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
|
||||||
@@ -648,6 +634,14 @@ 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;
|
||||||
}
|
}
|
||||||
@@ -743,21 +737,23 @@ static struct property prop_server[] = {
|
|||||||
{prop_server + 2, "target", ef_server_target, TYPE_STRING, "portmapper target ip"},
|
{prop_server + 2, "target", ef_server_target, TYPE_STRING, "portmapper target ip"},
|
||||||
{prop_server + 3, "targetport", ef_server_targetport, TYPE_PORT, "portmapper target port"},
|
{prop_server + 3, "targetport", ef_server_targetport, TYPE_PORT, "portmapper target port"},
|
||||||
{prop_server + 4, "starttime", ef_server_starttime, TYPE_DATETIME, "service started seconds"},
|
{prop_server + 4, "starttime", ef_server_starttime, TYPE_DATETIME, "service started seconds"},
|
||||||
{prop_server + 5, "intsa", ef_server_intsa, TYPE_SA, "ip address of internal interface"},
|
{prop_server + 5, "auth", ef_server_auth, TYPE_STRING, "service authentication type"},
|
||||||
{prop_server + 6, "extsa", ef_server_extsa, TYPE_SA, "ip address of external interface"},
|
{prop_server + 6, "acl", ef_server_acl, TYPE_ACE, "access control list"},
|
||||||
{prop_server + 7, "auth", ef_server_auth, TYPE_STRING, "service authentication type"},
|
{prop_server + 7, "singlepacket", ef_server_singlepacket, TYPE_INTEGER, "is single packet redirection"},
|
||||||
{prop_server + 8, "acl", ef_server_acl, TYPE_ACE, "access control list"},
|
{prop_server + 8, "usentlm", ef_server_usentlm, TYPE_INTEGER, "allow NTLM authentication"},
|
||||||
{prop_server + 9, "singlepacket", ef_server_singlepacket, TYPE_INTEGER, "is single packet redirection"},
|
{prop_server + 9, "log", ef_server_log, TYPE_STRING, "type of logging"},
|
||||||
{prop_server + 10, "usentlm", ef_server_usentlm, TYPE_INTEGER, "allow NTLM authentication"},
|
{prop_server + 10, "logtarget", ef_server_logtarget, TYPE_STRING, "log target options"},
|
||||||
{prop_server + 11, "log", ef_server_log, TYPE_STRING, "type of logging"},
|
{prop_server + 11, "logformat", ef_server_logformat, TYPE_STRING, "logging format string"},
|
||||||
{prop_server + 12, "logtarget", ef_server_logtarget, TYPE_STRING, "log target options"},
|
{prop_server + 12, "nonprintable", ef_server_nonprintable, TYPE_STRING, "non printable characters"},
|
||||||
{prop_server + 13, "logformat", ef_server_logformat, TYPE_STRING, "logging format string"},
|
{prop_server + 13, "replacement", ef_server_replacement, TYPE_CHAR, "replacement character"},
|
||||||
{prop_server + 14, "nonprintable", ef_server_nonprintable, TYPE_STRING, "non printable characters"},
|
{prop_server + 14, "childcount", ef_server_childcount, TYPE_INTEGER, "number of servers connected"},
|
||||||
{prop_server + 15, "replacement", ef_server_replacement, TYPE_CHAR, "replacement character"},
|
{prop_server + 15, "intsa", ef_server_intsa, TYPE_SA, "ip address of internal interface"},
|
||||||
{prop_server + 16, "childcount", ef_server_childcount, TYPE_INTEGER, "number of servers connected"},
|
{prop_server + 16, "extsa", ef_server_extsa, TYPE_SA, "ip address of external interface"},
|
||||||
{prop_server + 17, "child", ef_server_child, TYPE_CLIENT, "connected clients"},
|
|
||||||
#ifndef NOIPV6
|
#ifndef NOIPV6
|
||||||
{prop_server + 18, "extsa6", ef_server_extsa6, TYPE_SA, "ipv6 address of external interface"},
|
{prop_server + 17, "extsa6", ef_server_extsa6, TYPE_SA, "ipv6 address of external interface"},
|
||||||
|
{prop_server + 18, "child", ef_server_child, TYPE_CLIENT, "connected clients"},
|
||||||
|
#else
|
||||||
|
{prop_server + 17, "child", ef_server_child, TYPE_CLIENT, "connected clients"},
|
||||||
#endif
|
#endif
|
||||||
{NULL, "next", ef_server_next, TYPE_SERVER, "next"}
|
{NULL, "next", ef_server_next, TYPE_SERVER, "next"}
|
||||||
};
|
};
|
||||||
@@ -776,13 +772,15 @@ static struct property prop_client[] = {
|
|||||||
{prop_client + 10, "username", ef_client_username, TYPE_STRING, "client username"},
|
{prop_client + 10, "username", ef_client_username, TYPE_STRING, "client username"},
|
||||||
{prop_client + 11, "password", ef_client_password, TYPE_STRING, "client password"},
|
{prop_client + 11, "password", ef_client_password, TYPE_STRING, "client password"},
|
||||||
{prop_client + 12, "clisa", ef_client_clisa, TYPE_SA, "client sa"},
|
{prop_client + 12, "clisa", ef_client_clisa, TYPE_SA, "client sa"},
|
||||||
{prop_client + 13, "srvsa", ef_client_srvsa, TYPE_IP, "target server sa"},
|
{prop_client + 13, "srvsa", ef_client_srvsa, TYPE_SA, "target server sa"},
|
||||||
{prop_client + 14, "reqsa", ef_client_reqsa, TYPE_IP, "requested server sa"},
|
{prop_client + 14, "reqsa", ef_client_reqsa, TYPE_SA, "requested server sa"},
|
||||||
{prop_client + 15, "bytesin", ef_client_bytesin64, TYPE_UNSIGNED64, "bytes from server to client"},
|
{prop_client + 15, "bytesin", ef_client_bytesin64, TYPE_UNSIGNED64, "bytes from server to client"},
|
||||||
{prop_client + 16, "bytesout", ef_client_bytesout64, TYPE_UNSIGNED64, "bytes from client to server"},
|
{prop_client + 16, "bytesout", ef_client_bytesout64, TYPE_UNSIGNED64, "bytes from client to server"},
|
||||||
{prop_client + 17, "maxtrafin", ef_client_maxtrafin64, TYPE_UNSIGNED64, "maximum traffic allowed for download"},
|
{prop_client + 17, "maxtrafin", ef_client_maxtrafin64, TYPE_UNSIGNED64, "maximum traffic allowed for download"},
|
||||||
{prop_client + 18, "maxtrafout", ef_client_maxtrafout64, TYPE_UNSIGNED64, "maximum traffic allowed for upload"},
|
{prop_client + 18, "maxtrafout", ef_client_maxtrafout64, TYPE_UNSIGNED64, "maximum traffic allowed for upload"},
|
||||||
{prop_client + 19, "pwtype", ef_client_pwtype, TYPE_INTEGER, "type of client password"},
|
{prop_client + 19, "pwtype", ef_client_pwtype, TYPE_INTEGER, "type of client password"},
|
||||||
|
{prop_client + 20, "clisock", ef_client_clisock, TYPE_INTEGER, "client socket"},
|
||||||
|
{prop_client + 21, "remsock", ef_client_remsock, TYPE_INTEGER, "remote socket"},
|
||||||
{NULL, "next", ef_client_next, TYPE_CLIENT, "next"}
|
{NULL, "next", ef_client_next, TYPE_CLIENT, "next"}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
-141
@@ -1,141 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2000-2008 3APA3A
|
|
||||||
*
|
|
||||||
* please read License Agreement
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "proxy.h"
|
|
||||||
pthread_mutex_t log_mutex;
|
|
||||||
|
|
||||||
|
|
||||||
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, (char *)&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(!getip46(4, host, (struct sockaddr *)&sa)) {
|
|
||||||
fprintf(stderr, "Unable to resolve %s\n", host);
|
|
||||||
return 5;
|
|
||||||
}
|
|
||||||
sa.sin_port = htons(80);
|
|
||||||
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, (char *)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;
|
|
||||||
}
|
|
||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
3APA3A simpliest proxy server
|
3APA3A simpliest proxy server
|
||||||
(c) 2002-2008 by ZARAZA <3APA3A@security.nnov.ru>
|
(c) 2002-2016 by Vladimir Dubrovin <3proxy@3proxy.ru>
|
||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ void * dnsprchild(struct clientparam* param) {
|
|||||||
}
|
}
|
||||||
param->sinsr = nservers[0].addr;
|
param->sinsr = nservers[0].addr;
|
||||||
if(nservers[0].usetcp) {
|
if(nservers[0].usetcp) {
|
||||||
if(so._connect(param->remsock,(struct sockaddr *)¶m->sinsr,SASIZE(¶m->sinsr))) RETURN(830);
|
if(connectwithpoll(param->remsock,(struct sockaddr *)¶m->sinsr,SASIZE(¶m->sinsr),CONNECT_TO)) RETURN(830);
|
||||||
buf-=2;
|
buf-=2;
|
||||||
*(unsigned short*)buf = htons(i);
|
*(unsigned short*)buf = htons(i);
|
||||||
i+=2;
|
i+=2;
|
||||||
@@ -198,7 +198,7 @@ CLEANRET:
|
|||||||
if((ip && type == 0x01) || type == 0x1c){
|
if((ip && type == 0x01) || type == 0x1c){
|
||||||
myinet_ntop(type == 0x01? AF_INET:AF_INET6, addr, (char *)buf+strlen((char *)buf), 64);
|
myinet_ntop(type == 0x01? AF_INET:AF_INET6, addr, (char *)buf+strlen((char *)buf), 64);
|
||||||
}
|
}
|
||||||
(*param->srv->logfunc)(param, buf);
|
dolog(param, buf);
|
||||||
}
|
}
|
||||||
if(bbuf)myfree(bbuf);
|
if(bbuf)myfree(bbuf);
|
||||||
if(host)myfree(host);
|
if(host)myfree(host);
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002-2008 3APA3A
|
(c) 2002-2016 by Vladimir Dubrovin <3proxy@3proxy.ru>
|
||||||
*
|
|
||||||
* please read License Agreement
|
please read License Agreement
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
|
|||||||
+16
-8
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
3APA3A simpliest proxy server
|
3APA3A simpliest proxy server
|
||||||
(c) 2002-2008 by ZARAZA <3APA3A@security.nnov.ru>
|
(c) 2002-2016 by Vladimir Dubrovin <3proxy@3proxy.ru>
|
||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
@@ -88,6 +88,7 @@ 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
|
||||||
@@ -125,8 +126,9 @@ void * ftpprchild(struct clientparam* param) {
|
|||||||
if(so._listen(clidatasock, 1)) {RETURN(823);}
|
if(so._listen(clidatasock, 1)) {RETURN(823);}
|
||||||
sasize = sizeof(param->sincl);
|
sasize = sizeof(param->sincl);
|
||||||
if(so._getsockname(clidatasock, (struct sockaddr *)¶m->sincl, &sasize)){RETURN(824);}
|
if(so._getsockname(clidatasock, (struct sockaddr *)¶m->sincl, &sasize)){RETURN(824);}
|
||||||
if(*SAFAMILY(¶m->sincl) == AF_INET)
|
if(pasv == 1){
|
||||||
sprintf((char *)buf, "227 OK (%u,%u,%u,%u,%u,%u)\r\n",
|
if(*SAFAMILY(¶m->sincl) == AF_INET)
|
||||||
|
sprintf((char *)buf, "227 OK (%u,%u,%u,%u,%u,%u)\r\n",
|
||||||
(unsigned)(((unsigned char *)(SAADDR(¶m->sincl)))[0]),
|
(unsigned)(((unsigned char *)(SAADDR(¶m->sincl)))[0]),
|
||||||
(unsigned)(((unsigned char *)(SAADDR(¶m->sincl)))[1]),
|
(unsigned)(((unsigned char *)(SAADDR(¶m->sincl)))[1]),
|
||||||
(unsigned)(((unsigned char *)(SAADDR(¶m->sincl)))[2]),
|
(unsigned)(((unsigned char *)(SAADDR(¶m->sincl)))[2]),
|
||||||
@@ -134,10 +136,16 @@ void * ftpprchild(struct clientparam* param) {
|
|||||||
(unsigned)(((unsigned char *)(SAPORT(¶m->sincl)))[0]),
|
(unsigned)(((unsigned char *)(SAPORT(¶m->sincl)))[0]),
|
||||||
(unsigned)(((unsigned char *)(SAPORT(¶m->sincl)))[1])
|
(unsigned)(((unsigned char *)(SAPORT(¶m->sincl)))[1])
|
||||||
);
|
);
|
||||||
else sprintf((char *)buf, "227 OK (127,0,0,1,%u,%u)\r\n",
|
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)))[0]),
|
||||||
(unsigned)(((unsigned char *)(SAPORT(¶m->sincl)))[1])
|
(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;
|
||||||
@@ -145,7 +153,7 @@ void * ftpprchild(struct clientparam* param) {
|
|||||||
|
|
||||||
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));
|
*SAPORT(¶m->sincr) = htons((unsigned short)((b5<<8)^b6));
|
||||||
if(so._connect(clidatasock, (struct sockaddr *)¶m->sincr, SASIZE(¶m->sincr))) {
|
if(connectwithpoll(clidatasock, (struct sockaddr *)¶m->sincr, SASIZE(¶m->sincr),CONNECT_TO)) {
|
||||||
so._closesocket(clidatasock);
|
so._closesocket(clidatasock);
|
||||||
clidatasock = INVALID_SOCKET;
|
clidatasock = INVALID_SOCKET;
|
||||||
RETURN(826);
|
RETURN(826);
|
||||||
@@ -242,7 +250,7 @@ void * ftpprchild(struct clientparam* param) {
|
|||||||
so._setsockopt(param->remsock, SOL_SOCKET, SO_LINGER, (char *)&lg, sizeof(lg));
|
so._setsockopt(param->remsock, SOL_SOCKET, SO_LINGER, (char *)&lg, sizeof(lg));
|
||||||
so._setsockopt(clidatasock, SOL_SOCKET, SO_LINGER, (char *)&lg, sizeof(lg));
|
so._setsockopt(clidatasock, SOL_SOCKET, SO_LINGER, (char *)&lg, sizeof(lg));
|
||||||
param->clisock = clidatasock;
|
param->clisock = clidatasock;
|
||||||
res = sockmap(param, conf.timeouts[CONNECTION_S]);
|
res = mapsocket(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);
|
||||||
@@ -287,7 +295,7 @@ void * ftpprchild(struct clientparam* param) {
|
|||||||
sasize = sizeof(param->sincr);
|
sasize = sizeof(param->sincr);
|
||||||
if(so._getpeername(param->ctrlsock, (struct sockaddr *)¶m->sincr, &sasize)){RETURN(819);}
|
if(so._getpeername(param->ctrlsock, (struct sockaddr *)¶m->sincr, &sasize)){RETURN(819);}
|
||||||
if(req && (param->statscli64 || param->statssrv64)){
|
if(req && (param->statscli64 || param->statssrv64)){
|
||||||
(*param->srv->logfunc)(param, (unsigned char *)req);
|
dolog(param, (unsigned char *)req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,7 +316,7 @@ CLEANRET:
|
|||||||
sasize = sizeof(param->sincr);
|
sasize = sizeof(param->sincr);
|
||||||
so._getpeername(param->ctrlsock, (struct sockaddr *)¶m->sincr, &sasize);
|
so._getpeername(param->ctrlsock, (struct sockaddr *)¶m->sincr, &sasize);
|
||||||
if(param->res != 0 || param->statscli64 || param->statssrv64 ){
|
if(param->res != 0 || param->statscli64 || param->statssrv64 ){
|
||||||
(*param->srv->logfunc)(param, (unsigned char *)((req && (param->res > 802))? req:NULL));
|
dolog(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);
|
||||||
|
|||||||
-529
@@ -1,529 +0,0 @@
|
|||||||
/*
|
|
||||||
3APA3A simpliest proxy server
|
|
||||||
(c) 2002-2008 by ZARAZA <3APA3A@security.nnov.ru>
|
|
||||||
|
|
||||||
please read License Agreement
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#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[1];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct snack_header {
|
|
||||||
unsigned family;
|
|
||||||
unsigned short flags;
|
|
||||||
unsigned id;
|
|
||||||
char data[1];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct tlv_header {
|
|
||||||
unsigned short type;
|
|
||||||
unsigned short size;
|
|
||||||
char data[1];
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
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, (struct sockaddr *)¶m->sinsr, *buf_p + *length_p, increment, conf.timeouts[STRING_S]*1000);
|
|
||||||
if(len > 0) {
|
|
||||||
*length_p += len;
|
|
||||||
param->nreads++;
|
|
||||||
param->statssrv64 += 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[64];
|
|
||||||
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((char *)param->username, ic->id))break;
|
|
||||||
if(!ic){
|
|
||||||
ic = myalloc(sizeof(struct icq_cookie));
|
|
||||||
memset(ic, 0, sizeof(struct icq_cookie));
|
|
||||||
ic->id = mystrdup((char *)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_ntop(*SAFAMILY(&sa),SAADDR(&sa), smallbuf, 64);
|
|
||||||
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, (unsigned char *)"Warning: need resync");
|
|
||||||
state->leftinstate++;
|
|
||||||
if(state->leftinstate > 65535){
|
|
||||||
param->srv->logfunc(param, (unsigned char *)"Out of Sync");
|
|
||||||
return REJECT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
start++;
|
|
||||||
len--;
|
|
||||||
break;
|
|
||||||
case ONCHAN:
|
|
||||||
if (*start >= 10){
|
|
||||||
param->srv->logfunc(param, (unsigned char *)"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){
|
|
||||||
unsigned char smallbuf[64];
|
|
||||||
if(((state->gotseq < state->srvseq) || ((state->gotseq - state->srvseq) > 10 )) && (!state->resyncseq || state->gotseq != state->resyncseq)){
|
|
||||||
sprintf((char *)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((char *)smallbuf, "Warning: %d 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, (unsigned char *)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 = (unsigned char *)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->statscli64 += 10;
|
|
||||||
}
|
|
||||||
if(readflap(param, SERVER, tmpsend, 1024)) {RETURN (1111);}
|
|
||||||
param->statssrv64 += (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->statscli64 += 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->statscli64 += 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
|
|
||||||
@@ -0,0 +1,354 @@
|
|||||||
|
/*
|
||||||
|
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 < 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 {
|
||||||
|
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
|
||||||
|
|
||||||
-366
@@ -1,366 +0,0 @@
|
|||||||
/*
|
|
||||||
3APA3A simpliest proxy server
|
|
||||||
(c) 2002-2008 by ZARAZA <3APA3A@security.nnov.ru>
|
|
||||||
|
|
||||||
please read License Agreement
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#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){
|
|
||||||
memmove(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
|
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
3APA3A simpliest proxy server
|
3APA3A simpliest proxy server
|
||||||
(c) 2002-2008 by ZARAZA <3APA3A@security.nnov.ru>
|
(c) 2002-2016 by Vladimir Dubrovin <3proxy@3proxy.ru>
|
||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
3APA3A simpliest proxy server
|
3APA3A simpliest proxy server
|
||||||
(c) 2002-2008 by ZARAZA <3APA3A@security.nnov.ru>
|
(c) 2002-2016 by Vladimir Dubrovin <3proxy@3proxy.ru>
|
||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
|
|||||||
+7
-11
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
3APA3A simpliest proxy server
|
3APA3A simpliest proxy server
|
||||||
(c) 2002-2008 by ZARAZA <3APA3A@security.nnov.ru>
|
(c) 2002-2016 by Vladimir Dubrovin <3proxy@3proxy.ru>
|
||||||
|
|
||||||
please read License Agreement
|
please read License Agreement
|
||||||
|
|
||||||
@@ -68,16 +68,12 @@ struct symbol symbols[] = {
|
|||||||
{symbols+41, "admin", (void *) adminchild},
|
{symbols+41, "admin", (void *) adminchild},
|
||||||
{symbols+42, "ftppr", (void *) ftpprchild},
|
{symbols+42, "ftppr", (void *) ftpprchild},
|
||||||
{symbols+43, "smtpp", (void *) smtppchild},
|
{symbols+43, "smtpp", (void *) smtppchild},
|
||||||
{symbols+44, "icqpr", (void *) icqprchild},
|
{symbols+44, "authfuncs", (void *) &authfuncs},
|
||||||
/*
|
{symbols+45, "commandhandlers", (void *) &commandhandlers},
|
||||||
{symbols+45, "msnpr", (void *) msnprchild},
|
{symbols+46, "decodeurl", (void *) decodeurl},
|
||||||
*/
|
{symbols+47, "parsestr", (void *) parsestr},
|
||||||
{symbols+45, "authfuncs", (void *) &authfuncs},
|
{symbols+48, "make_ace", (void *) make_ace},
|
||||||
{symbols+46, "commandhandlers", (void *) &commandhandlers},
|
{symbols+49, "freeacl", (void *) freeacl},
|
||||||
{symbols+47, "decodeurl", (void *) decodeurl},
|
|
||||||
{symbols+48, "parsestr", (void *) parsestr},
|
|
||||||
{symbols+49, "make_ace", (void *) make_ace},
|
|
||||||
{symbols+50, "freeacl", (void *) freeacl},
|
|
||||||
{NULL, "", NULL}
|
{NULL, "", NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -577,7 +577,7 @@ static int WINAPI fp_sendto(SOCKET s, const void *msg, int len, int flags, const
|
|||||||
case GOT_FTP_CLIDATA:
|
case GOT_FTP_CLIDATA:
|
||||||
case GOT_FTP_SRVDATA:
|
case GOT_FTP_SRVDATA:
|
||||||
case GOT_HTTP_CLIDATA:
|
case GOT_HTTP_CLIDATA:
|
||||||
if((!fps->what & FP_CLIDATA)) break;
|
if(!(fps->what & FP_CLIDATA)) break;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if(SetFilePointer(fps->fpd.h_cli, fps->clientwritten + fps->clihdrwritten, 0, FILE_BEGIN) != (fps->clientwritten + fps->clihdrwritten)){
|
if(SetFilePointer(fps->fpd.h_cli, fps->clientwritten + fps->clihdrwritten, 0, FILE_BEGIN) != (fps->clientwritten + fps->clihdrwritten)){
|
||||||
return -1;
|
return -1;
|
||||||
@@ -878,13 +878,13 @@ static struct commands file_commandhandlers[] = {
|
|||||||
|
|
||||||
static int file_loaded=0;
|
static int file_loaded=0;
|
||||||
|
|
||||||
|
#ifdef WATCOM
|
||||||
#ifdef _WIN32
|
#pragma aux file_plugin "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
|
||||||
__declspec(dllexport)
|
#undef PLUGINCALL
|
||||||
|
#define PLUGINCALL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
PLUGINAPI int PLUGINCALL file_plugin (struct pluginlink * pluginlink,
|
||||||
int file_plugin (struct pluginlink * pluginlink,
|
|
||||||
int argc, char** argv){
|
int argc, char** argv){
|
||||||
|
|
||||||
if(!file_loaded){
|
if(!file_loaded){
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
include Makefile.var
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
all: $(BUILDDIR)lastFripper$(DLSUFFICS)
|
|
||||||
|
|
||||||
lastFripper$(OBJSUFFICS): lastFripper.c
|
|
||||||
$(CC) $(DCFLAGS) $(CFLAGS) lastFripper.c
|
|
||||||
|
|
||||||
$(BUILDDIR)lastFripper$(DLSUFFICS): lastFripper$(OBJSUFFICS)
|
|
||||||
$(LN) $(LNOUT)../../$(BUILDDIR)lastFripper$(DLSUFFICS) $(LDFLAGS) $(DLFLAGS) lastFripper$(OBJSUFFICS)
|
|
||||||
@@ -1,704 +0,0 @@
|
|||||||
/*
|
|
||||||
released as a public domain
|
|
||||||
std.denis, 2009
|
|
||||||
*/
|
|
||||||
#include "../../structures.h"
|
|
||||||
#include "lastFripper.h"
|
|
||||||
|
|
||||||
#define strdup _strdup
|
|
||||||
#define strnicmp _strnicmp
|
|
||||||
#define ltoa _ltoa
|
|
||||||
|
|
||||||
#define mkdir _mkdir
|
|
||||||
|
|
||||||
#define PART_SUFFIX "_partial"
|
|
||||||
|
|
||||||
void my_mkdir( char* name )
|
|
||||||
{
|
|
||||||
char* pdir = name;
|
|
||||||
|
|
||||||
while( 1 ) {
|
|
||||||
char ch;
|
|
||||||
char* pnext = pdir;
|
|
||||||
while( *pnext && *pnext != '\\' && *pnext != '/' )
|
|
||||||
pnext++;
|
|
||||||
if( *pnext == 0 )
|
|
||||||
break;
|
|
||||||
|
|
||||||
ch = *pnext;
|
|
||||||
*pnext = 0;
|
|
||||||
mkdir( name );
|
|
||||||
*pnext = ch;
|
|
||||||
|
|
||||||
pdir = pnext + 1;
|
|
||||||
}
|
|
||||||
mkdir( name );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
__inline void myOutputDebugStringA1( char* str )
|
|
||||||
{
|
|
||||||
/* char fname[128];
|
|
||||||
ltoa( GetCurrentThreadId(), fname, 10 );
|
|
||||||
FILE* fp = fopen( fname, "ab" );
|
|
||||||
fputs( str, fp );
|
|
||||||
fputs( "\r\n", fp );
|
|
||||||
fflush( fp );
|
|
||||||
fclose( fp );
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
__inline void myOutputDebugStringA( void* buf, int len )
|
|
||||||
{
|
|
||||||
/* char fname[128];
|
|
||||||
ltoa( GetCurrentThreadId(), fname, 10 );
|
|
||||||
FILE* fp = fopen( fname, "ab" );
|
|
||||||
fwrite( buf, len, 1, fp );
|
|
||||||
fputs( "\r\n", fp );
|
|
||||||
fflush( fp );
|
|
||||||
fclose( fp ); */
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef isnumber
|
|
||||||
#define isnumber(i_n_arg) ((i_n_arg>='0')&&(i_n_arg<='9'))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define sizearr(x) (sizeof(x)/sizeof(x[0]))
|
|
||||||
#define xmalloc( type, len ) ((type*)malloc( (len) * sizeof(type) ) )
|
|
||||||
#define xcalloc( type, len ) ((type*)calloc( (len), sizeof(type) ) )
|
|
||||||
|
|
||||||
int clean_filename( char* filename )
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for( i = 0; filename[i]; i++ )
|
|
||||||
switch( filename[i] ) {
|
|
||||||
case '*':
|
|
||||||
case '?':
|
|
||||||
case '<':
|
|
||||||
case '>':
|
|
||||||
case '\\':
|
|
||||||
case '/':
|
|
||||||
case ':':
|
|
||||||
case '"':
|
|
||||||
filename[i] = '_';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static struct pluginlink * pl;
|
|
||||||
static int lfm_loaded = 0;
|
|
||||||
static char* g_folder = 0;
|
|
||||||
static char* g_format = 0;
|
|
||||||
|
|
||||||
static int lfm_format_filename( struct playlist_item* p_item, char* p_filename, int n_filename )
|
|
||||||
{
|
|
||||||
int i = 0, j;
|
|
||||||
char ch;
|
|
||||||
char* fmt;
|
|
||||||
char *ff = NULL;
|
|
||||||
|
|
||||||
if( g_folder && *g_folder ) {
|
|
||||||
strncpy( p_filename, g_folder, n_filename );
|
|
||||||
i = strlen( p_filename );
|
|
||||||
if( i < n_filename-1 && p_filename[i-1] != '\\' )
|
|
||||||
p_filename[i++] = '\\';
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt = g_format;
|
|
||||||
if( fmt == NULL ) fmt = "%a\\%t.mp3";
|
|
||||||
while( ( ch = *fmt++ ) != 0 ) {
|
|
||||||
if( ch == '%' ) {
|
|
||||||
char* p_sz = NULL;
|
|
||||||
char a_sz[32];
|
|
||||||
ch = *fmt++;
|
|
||||||
switch( ch ) {
|
|
||||||
case 0:
|
|
||||||
fmt--; break;
|
|
||||||
case '%':
|
|
||||||
p_sz = "%";
|
|
||||||
break;
|
|
||||||
case 'n': {
|
|
||||||
static unsigned ndx = 0;
|
|
||||||
ltoa( ndx++, a_sz, 10 );
|
|
||||||
p_sz = a_sz;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'a':
|
|
||||||
p_sz = p_item->artist;
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
p_sz = p_item->title;
|
|
||||||
break;
|
|
||||||
case 'l':
|
|
||||||
p_sz = p_item->album;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if( p_sz ) {
|
|
||||||
strncpy( p_filename+i, p_sz, n_filename-i );
|
|
||||||
p_filename[n_filename-1] = 0;
|
|
||||||
i += clean_filename( p_filename+i );
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
if( i < n_filename ) p_filename[i++] = ch;
|
|
||||||
}
|
|
||||||
|
|
||||||
for( j = i-1; j >= 0; j-- )
|
|
||||||
if( p_filename[j] == '\\' || p_filename[j] == '/' ) {
|
|
||||||
ff = p_filename + j;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if( ff ) {
|
|
||||||
char ch = *ff;
|
|
||||||
*ff = 0;
|
|
||||||
my_mkdir( p_filename );
|
|
||||||
*ff = ch;
|
|
||||||
}
|
|
||||||
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void lfm_close_request( struct lfm_client_data* p_client )
|
|
||||||
{
|
|
||||||
struct lfm_filter_data* p_data;
|
|
||||||
if( p_client == NULL ) return;
|
|
||||||
p_data = p_client->p_data;
|
|
||||||
if( p_data == NULL ) return;
|
|
||||||
|
|
||||||
if( p_client->req_type == LFM_PLAYLIST ) {
|
|
||||||
free( p_client->pl_xml );
|
|
||||||
} else if( p_client->req_type == LFM_GET && p_client->fp ) {
|
|
||||||
struct playlist_item* p_item = p_client->pl_item;
|
|
||||||
if( p_item ) {
|
|
||||||
char id3v1[128];
|
|
||||||
memset( id3v1, 0, 128 );
|
|
||||||
strcpy( id3v1, "TAG" );
|
|
||||||
strncpy( id3v1+3, p_item->title, 30 );
|
|
||||||
strncpy( id3v1+33, p_item->artist, 30 );
|
|
||||||
strncpy( id3v1+63, p_item->album, 30 );
|
|
||||||
id3v1[127] = -1;
|
|
||||||
fwrite( id3v1, 128, 1, p_client->fp );
|
|
||||||
}
|
|
||||||
fclose( p_client->fp );
|
|
||||||
/*
|
|
||||||
if( p_item ) {
|
|
||||||
char filename_part[512], filename[512];
|
|
||||||
int i = lfm_format_filename( p_item, filename_part, sizearr(filename_part) );
|
|
||||||
memcpy( filename, filename_part, sizeof(filename) );
|
|
||||||
strncpy( filename_part+i, PART_SUFFIX, sizearr(filename_part)-i );
|
|
||||||
rename( filename_part, filename );
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
pthread_mutex_lock( &p_data->mutex );
|
|
||||||
if( p_data->playlist != NULL && p_item != NULL ) {
|
|
||||||
if( p_data->playlist == p_item )
|
|
||||||
p_data->playlist = p_item->next;
|
|
||||||
else {
|
|
||||||
struct playlist_item *p_last = p_data->playlist;
|
|
||||||
|
|
||||||
while( p_last->next != NULL && p_last->next != p_item )
|
|
||||||
p_last = p_last->next;
|
|
||||||
|
|
||||||
if( p_last->next )
|
|
||||||
p_last->next = p_item->next;
|
|
||||||
}
|
|
||||||
if( p_item->artist ) free( p_item->artist );
|
|
||||||
if( p_item->title ) free( p_item->title );
|
|
||||||
if( p_item->album ) free( p_item->album );
|
|
||||||
if( p_item->url ) free( p_item->url );
|
|
||||||
free( p_item );
|
|
||||||
}
|
|
||||||
pthread_mutex_unlock( &p_data->mutex );
|
|
||||||
}
|
|
||||||
p_client->req_type = LFM_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void* lfm_filter_open( void * idata, struct srvparam * param ){
|
|
||||||
struct lfm_filter_data* pdata = (struct lfm_filter_data*)idata;
|
|
||||||
if( pdata ){
|
|
||||||
pthread_mutex_lock( &pdata->mutex );
|
|
||||||
pdata->refs++;
|
|
||||||
pthread_mutex_unlock( &pdata->mutex );
|
|
||||||
} else {
|
|
||||||
if( ( pdata = xcalloc( struct lfm_filter_data, 1 ) ) != NULL ) {
|
|
||||||
pthread_mutex_init( &pdata->mutex, NULL );
|
|
||||||
pdata->playlist = NULL;
|
|
||||||
pdata->refs++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return pdata;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FILTER_ACTION lfm_filter_client( void *fo, struct clientparam* param, void** fc )
|
|
||||||
{
|
|
||||||
struct lfm_filter_data* p_data;
|
|
||||||
struct lfm_client_data* p_client;
|
|
||||||
*fc = NULL;
|
|
||||||
if( fo == NULL ) return PASS;
|
|
||||||
|
|
||||||
p_data = (struct lfm_filter_data*)fo;
|
|
||||||
p_client = xcalloc( struct lfm_client_data, 1 );
|
|
||||||
if( p_client == NULL ) return PASS;
|
|
||||||
|
|
||||||
p_client->p_data = p_data;
|
|
||||||
p_client->req_type = LFM_NONE;
|
|
||||||
|
|
||||||
*fc = p_client;
|
|
||||||
return CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void lfm_filter_clear( void *fc )
|
|
||||||
{
|
|
||||||
struct lfm_client_data* p_client;
|
|
||||||
|
|
||||||
p_client = (struct lfm_client_data*)fc;
|
|
||||||
if( p_client == NULL ) return;
|
|
||||||
|
|
||||||
lfm_close_request( p_client );
|
|
||||||
|
|
||||||
free( p_client );
|
|
||||||
}
|
|
||||||
|
|
||||||
static void lfm_filter_close(void *fo){
|
|
||||||
struct lfm_filter_data* p_data;
|
|
||||||
struct playlist_item* p_item;
|
|
||||||
|
|
||||||
p_data = (struct lfm_filter_data*)fo;
|
|
||||||
if( p_data == NULL ) return;
|
|
||||||
|
|
||||||
if( --p_data->refs > 0 ) return;
|
|
||||||
|
|
||||||
pthread_mutex_destroy( &p_data->mutex );
|
|
||||||
p_item = p_data->playlist;
|
|
||||||
while( p_item ) {
|
|
||||||
struct playlist_item* p_old = p_item;
|
|
||||||
p_item = p_item->next;
|
|
||||||
|
|
||||||
if( p_old->artist ) free( p_old->artist );
|
|
||||||
if( p_old->title ) free( p_old->title );
|
|
||||||
if( p_old->album ) free( p_old->album );
|
|
||||||
if( p_old->url ) free( p_old->url );
|
|
||||||
free( p_old );
|
|
||||||
}
|
|
||||||
|
|
||||||
free( p_data );
|
|
||||||
}
|
|
||||||
|
|
||||||
static FILTER_ACTION lfm_filter_request( void *fc, struct clientparam *param, unsigned char** buf_p, int* bufsize_p, int offset, int* length_p )
|
|
||||||
{
|
|
||||||
char* p_buf = (char*)( *buf_p + offset );
|
|
||||||
int n_buf = *length_p - offset;
|
|
||||||
struct lfm_client_data* p_client;
|
|
||||||
struct lfm_filter_data* p_data;
|
|
||||||
|
|
||||||
if( p_buf == NULL || n_buf < 5 ) return CONTINUE;
|
|
||||||
|
|
||||||
p_client = (struct lfm_client_data*)fc;
|
|
||||||
if( p_client == NULL ) return CONTINUE;
|
|
||||||
p_data = p_client->p_data;
|
|
||||||
if( p_data == NULL ) return CONTINUE;
|
|
||||||
|
|
||||||
pl->conf->filtermaxsize = 0;
|
|
||||||
|
|
||||||
lfm_close_request( p_client );
|
|
||||||
|
|
||||||
p_client->req_type = LFM_NONE;
|
|
||||||
p_client->fp = NULL;
|
|
||||||
|
|
||||||
if( strncasecmp( p_buf, "GET ", 4 ) != 0 ) return CONTINUE;
|
|
||||||
|
|
||||||
p_buf += 4;
|
|
||||||
|
|
||||||
if( strncasecmp( p_buf, "http://ws.audioscrobbler.com/radio/xspf.php?", 44 ) == 0 ) {
|
|
||||||
myOutputDebugStringA1( "getting a playlist" );
|
|
||||||
p_client->req_type = LFM_PLAYLIST;
|
|
||||||
} else {
|
|
||||||
char zzz[256];
|
|
||||||
int i;
|
|
||||||
struct playlist_item* p_item;
|
|
||||||
for( i = 0; i < n_buf && i < 256; i++ ) {
|
|
||||||
if( p_buf[i] == '\r' ) break;
|
|
||||||
zzz[i] = p_buf[i];
|
|
||||||
}
|
|
||||||
zzz[i] = 0;
|
|
||||||
myOutputDebugStringA1( zzz );
|
|
||||||
pthread_mutex_lock( &p_data->mutex );
|
|
||||||
p_item = p_data->playlist;
|
|
||||||
while( p_item ) {
|
|
||||||
if( strncasecmp( p_buf, p_item->url, p_item->url_len ) == 0 )
|
|
||||||
break;
|
|
||||||
p_item = p_item->next;
|
|
||||||
}
|
|
||||||
pthread_mutex_unlock( &p_data->mutex );
|
|
||||||
if( p_item ) {
|
|
||||||
myOutputDebugStringA1( "getting a known url: " );
|
|
||||||
myOutputDebugStringA1( p_item->title );
|
|
||||||
p_client->req_type = LFM_GET;
|
|
||||||
p_client->pl_item = p_item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FILTER_ACTION lfm_filter_header_srv( void *fc, struct clientparam *param, unsigned char** buf_p, int* bufsize_p, int offset, int* length_p )
|
|
||||||
{
|
|
||||||
char* p_buf = (char*)( *buf_p + offset );
|
|
||||||
struct lfm_client_data* p_client;
|
|
||||||
int n_buf = *length_p - offset;
|
|
||||||
struct lfm_filter_data* p_data;
|
|
||||||
char zzz[100];
|
|
||||||
int code;
|
|
||||||
|
|
||||||
if( p_buf == NULL || n_buf < 9 ) return CONTINUE;
|
|
||||||
|
|
||||||
p_client = (struct lfm_client_data*)fc;
|
|
||||||
if( p_client == NULL ) return CONTINUE;
|
|
||||||
p_data = p_client->p_data;
|
|
||||||
if( p_data == NULL ) return CONTINUE;
|
|
||||||
|
|
||||||
code = atoi( p_buf + 9 );
|
|
||||||
sprintf( zzz, "http code: %d", code );
|
|
||||||
myOutputDebugStringA1( zzz );
|
|
||||||
myOutputDebugStringA( p_buf, n_buf );
|
|
||||||
if( p_client->req_type == LFM_GET && ( code > 300 && code < 304 || code == 307 ) ) {
|
|
||||||
p_client->req_type = LFM_REDIR;
|
|
||||||
do {
|
|
||||||
char* p_line = p_buf;
|
|
||||||
int n_line;
|
|
||||||
|
|
||||||
for(; n_buf > 0 && *p_buf != '\r'; p_buf++, n_buf-- ) {};
|
|
||||||
n_line = p_buf - p_line;
|
|
||||||
if( n_line <= 0 ) break;
|
|
||||||
if( n_line > 10 && strncasecmp( p_line, "location: ", 10 ) == 0 ) {
|
|
||||||
myOutputDebugStringA1( "redir/location: " );
|
|
||||||
myOutputDebugStringA( p_line + 10, n_line - 10 );
|
|
||||||
if( p_client->pl_item ) {
|
|
||||||
char* p_url = p_line + 10;
|
|
||||||
int n_url = n_line - 10;
|
|
||||||
pthread_mutex_lock( &p_data->mutex );
|
|
||||||
if( p_client->pl_item->url ) free( p_client->pl_item->url );
|
|
||||||
p_client->pl_item->url = xmalloc( char, n_url + 1 + 1 );
|
|
||||||
memcpy( p_client->pl_item->url, p_url, n_url );
|
|
||||||
p_client->pl_item->url[n_url] = ' ';
|
|
||||||
p_client->pl_item->url[n_url+1] = 0;
|
|
||||||
p_client->pl_item->url_len = n_url + 1;
|
|
||||||
myOutputDebugStringA1( "got a url: " );
|
|
||||||
myOutputDebugStringA1( p_client->pl_item->url );
|
|
||||||
pthread_mutex_unlock( &p_data->mutex );
|
|
||||||
}
|
|
||||||
p_client->req_type = LFM_NONE;
|
|
||||||
}
|
|
||||||
for(; n_buf > 0 && ( *p_buf == '\n' || *p_buf == '\r' ); p_buf++, n_buf-- ) {};
|
|
||||||
} while( n_buf > 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( code == 200 && p_client->req_type == LFM_GET ) {
|
|
||||||
struct playlist_item* p_item = p_client->pl_item;
|
|
||||||
char filename[512];
|
|
||||||
int i = lfm_format_filename( p_item, filename, sizearr(filename) );
|
|
||||||
/*
|
|
||||||
strncpy( filename + i, PART_SUFFIX, sizearr(filename)-i );
|
|
||||||
*/
|
|
||||||
p_client->fp = fopen( filename, "wb" );
|
|
||||||
}
|
|
||||||
else if( code == 200 && p_client->req_type == LFM_PLAYLIST ) {
|
|
||||||
p_client->pl_xml = xcalloc( struct xml_state, 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
return CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void playlist_analyze( struct lfm_client_data* p_client, const char* p_buf, int len );
|
|
||||||
static FILTER_ACTION lfm_filter_data_srv( void *fc, struct clientparam *param, unsigned char** buf_p, int* bufsize_p, int offset, int* length_p )
|
|
||||||
{
|
|
||||||
char* p_buf = (char*)( *buf_p + offset );
|
|
||||||
int n_buf = *length_p - offset;
|
|
||||||
struct lfm_client_data* p_client;
|
|
||||||
struct lfm_filter_data* p_data;
|
|
||||||
|
|
||||||
|
|
||||||
myOutputDebugStringA1( "filter_data_srv" );
|
|
||||||
myOutputDebugStringA( p_buf, n_buf );
|
|
||||||
|
|
||||||
if( p_buf == NULL || n_buf < 1 ) return CONTINUE;
|
|
||||||
|
|
||||||
p_client = (struct lfm_client_data*)fc;
|
|
||||||
if( p_client == NULL ) return CONTINUE;
|
|
||||||
p_data = p_client->p_data;
|
|
||||||
if( p_data == NULL ) return CONTINUE;
|
|
||||||
|
|
||||||
if( p_client->req_type == LFM_PLAYLIST )
|
|
||||||
myOutputDebugStringA1( "filter_data_srv: playlist" );
|
|
||||||
else if( p_client->req_type == LFM_GET ) {
|
|
||||||
myOutputDebugStringA1( "filter_data_srv: retrieving" );
|
|
||||||
if( p_client->fp == NULL )
|
|
||||||
myOutputDebugStringA1( "but no file allocated" );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( p_client->req_type == LFM_PLAYLIST )
|
|
||||||
playlist_analyze( p_client, p_buf, n_buf );
|
|
||||||
if( p_client->fp )
|
|
||||||
fwrite( p_buf, n_buf, 1, p_client->fp );
|
|
||||||
|
|
||||||
return CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
enum XmlState
|
|
||||||
{
|
|
||||||
XML_TEXT,
|
|
||||||
XML_TAGNAME,
|
|
||||||
XML_ATTRNAME_W,
|
|
||||||
XML_ATTRNAME,
|
|
||||||
XML_ATTRVALUE_W,
|
|
||||||
XML_ATTRVALUE,
|
|
||||||
XML_TAGCLOSE,
|
|
||||||
XML_TAGOPENCLOSE,
|
|
||||||
};
|
|
||||||
|
|
||||||
int xml_get_token_id( char** table, char* token )
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
char* psz;
|
|
||||||
for( psz = token; *psz; psz++ )
|
|
||||||
*psz = tolower( *psz );
|
|
||||||
for( i = 0; *table; i++, table++ )
|
|
||||||
if( strcmp( *table, token ) == 0 ) return i;
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
enum {
|
|
||||||
XT_PLAYLIST,
|
|
||||||
XT_TRACK_LIST,
|
|
||||||
XT_TRACK,
|
|
||||||
XT_LOCATION,
|
|
||||||
XT_CREATOR,
|
|
||||||
XT_ALBUM,
|
|
||||||
XT_TITLE
|
|
||||||
};
|
|
||||||
|
|
||||||
char* xt_list[] = {
|
|
||||||
"playlist",
|
|
||||||
"tracklist",
|
|
||||||
"track",
|
|
||||||
"location",
|
|
||||||
"creator",
|
|
||||||
"album",
|
|
||||||
"title",
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
void playlist_analyze( struct lfm_client_data* p_client, const char* p_buf, int len )
|
|
||||||
{
|
|
||||||
struct xml_state* xs = p_client->pl_xml;
|
|
||||||
int n_buf = len;
|
|
||||||
|
|
||||||
if( xs == NULL ) return;
|
|
||||||
|
|
||||||
while( n_buf > 0 ) {
|
|
||||||
enum {
|
|
||||||
XMS_NONE,
|
|
||||||
XMS_TAG,
|
|
||||||
XMS_ATTR_NAME,
|
|
||||||
XMS_ATTR_VALUE,
|
|
||||||
XMS_TEXT
|
|
||||||
} gotta = XMS_NONE;
|
|
||||||
char ch = *p_buf++;
|
|
||||||
n_buf--;
|
|
||||||
lbl_retry:
|
|
||||||
switch( xs->state ) {
|
|
||||||
case XML_TAGNAME:
|
|
||||||
if( ch == '>' ) {
|
|
||||||
xs->state = XML_TEXT;
|
|
||||||
gotta = XMS_TAG;
|
|
||||||
break;
|
|
||||||
} else if( ch == '/' ) {
|
|
||||||
if( xs->n_token == 0 )
|
|
||||||
xs->closing = 1;
|
|
||||||
else {
|
|
||||||
xs->state = XML_ATTRNAME_W;
|
|
||||||
gotta = XMS_TAG;
|
|
||||||
xs->n_token--;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
} else if( isspace( ch ) ) {
|
|
||||||
xs->state = XML_ATTRNAME_W;
|
|
||||||
gotta = XMS_TAG;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if( xs->n_token < TOKEN_MAXLEN ) xs->p_token[xs->n_token++] = ch;
|
|
||||||
break;
|
|
||||||
case XML_ATTRNAME_W:
|
|
||||||
if( ch == '>' ) {
|
|
||||||
xs->state = XML_TEXT;
|
|
||||||
break;
|
|
||||||
} else if( ch == '/' ) {
|
|
||||||
xs->closing = 1;
|
|
||||||
xs->state = XML_TEXT;
|
|
||||||
gotta = XMS_TAG;
|
|
||||||
break;
|
|
||||||
} else if( !isspace( ch ) ) {
|
|
||||||
xs->state = XML_ATTRNAME;
|
|
||||||
goto lbl_retry;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case XML_ATTRNAME:
|
|
||||||
if( ch == '=' ) {
|
|
||||||
xs->state = XML_ATTRVALUE_W;
|
|
||||||
gotta = XMS_ATTR_NAME;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if( xs->n_token < TOKEN_MAXLEN ) xs->p_token[xs->n_token++] = ch;
|
|
||||||
break;
|
|
||||||
case XML_ATTRVALUE_W:
|
|
||||||
if( ch == '"' || ch == '\'' ) {
|
|
||||||
xs->sep = ch;
|
|
||||||
xs->state = XML_ATTRVALUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case XML_ATTRVALUE:
|
|
||||||
if( ch == xs->sep ) {
|
|
||||||
xs->state = XML_ATTRNAME_W;
|
|
||||||
gotta = XMS_ATTR_VALUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if( xs->n_token < TOKEN_MAXLEN ) xs->p_token[xs->n_token++] = ch;
|
|
||||||
break;
|
|
||||||
case XML_TEXT:
|
|
||||||
if( ch == '<' ) {
|
|
||||||
xs->state = XML_TAGNAME;
|
|
||||||
gotta = XMS_TEXT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if( xs->n_token < TOKEN_MAXLEN ) xs->p_token[xs->n_token++] = ch;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( gotta != XMS_NONE ) {
|
|
||||||
xs->p_token[xs->n_token] = 0;
|
|
||||||
|
|
||||||
switch( gotta ) {
|
|
||||||
case XMS_TAG: {
|
|
||||||
int id = xml_get_token_id( xt_list, xs->p_token );
|
|
||||||
if( !xs->closing ) {
|
|
||||||
if( xs->level < sizeof(xs->tree) ) xs->tree[xs->level] = id;
|
|
||||||
xs->level++;
|
|
||||||
|
|
||||||
if( id == XT_TRACK && xs->level == 3 && xs->tree[1] == XT_TRACK_LIST )
|
|
||||||
xs->p_item = xcalloc( struct playlist_item, 1 );
|
|
||||||
} else {
|
|
||||||
if( xs->level > 0 ) xs->level--;
|
|
||||||
if( id == XT_TRACK && xs->level == 2 && xs->tree[1] == XT_TRACK_LIST ) {
|
|
||||||
char zzz[1024];
|
|
||||||
_snprintf( zzz, 1024, "artist: <%s>, title: <%s>, url: <%s>",
|
|
||||||
xs->p_item->artist, xs->p_item->title, xs->p_item->url );
|
|
||||||
myOutputDebugStringA1( zzz );
|
|
||||||
pthread_mutex_lock( &p_client->p_data->mutex );
|
|
||||||
xs->p_item->next = p_client->p_data->playlist;
|
|
||||||
p_client->p_data->playlist = xs->p_item;
|
|
||||||
pthread_mutex_unlock( &p_client->p_data->mutex );
|
|
||||||
}
|
|
||||||
xs->closing = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case XMS_ATTR_NAME:
|
|
||||||
break;
|
|
||||||
case XMS_ATTR_VALUE:
|
|
||||||
break;
|
|
||||||
case XMS_TEXT:
|
|
||||||
if( xs->level == 4 && xs->tree[1] == XT_TRACK_LIST && xs->tree[2] == XT_TRACK ) {
|
|
||||||
struct playlist_item* item = xs->p_item;
|
|
||||||
if( item )
|
|
||||||
switch( xs->tree[3] ) {
|
|
||||||
case XT_LOCATION:
|
|
||||||
item->url_len = xs->n_token;
|
|
||||||
item->url = xmalloc( char, item->url_len + 1 + 1);
|
|
||||||
memcpy( item->url, xs->p_token, item->url_len );
|
|
||||||
item->url[item->url_len++] = ' ';
|
|
||||||
item->url[item->url_len] = 0;
|
|
||||||
break;
|
|
||||||
case XT_CREATOR:
|
|
||||||
item->artist = strdup( xs->p_token );
|
|
||||||
break;
|
|
||||||
case XT_ALBUM:
|
|
||||||
item->album = strdup( xs->p_token );
|
|
||||||
break;
|
|
||||||
case XT_TITLE:
|
|
||||||
item->title = strdup( xs->p_token );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
xs->n_token = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static struct filter lfm_filter = {
|
|
||||||
NULL,
|
|
||||||
"last.fm spy",
|
|
||||||
NULL,
|
|
||||||
|
|
||||||
lfm_filter_open,
|
|
||||||
lfm_filter_client,
|
|
||||||
lfm_filter_request,
|
|
||||||
NULL,
|
|
||||||
lfm_filter_header_srv,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
lfm_filter_data_srv,
|
|
||||||
lfm_filter_clear,
|
|
||||||
lfm_filter_close
|
|
||||||
};
|
|
||||||
|
|
||||||
static int h_lfm_folder( int argc, unsigned char **argv )
|
|
||||||
{
|
|
||||||
if( g_folder ) free( g_folder );
|
|
||||||
g_folder = strdup( (char*)argv[1] );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int h_lfm_format( int argc, unsigned char **argv )
|
|
||||||
{
|
|
||||||
if( g_format ) free( g_format );
|
|
||||||
g_format = strdup( (char*)argv[1] );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct commands lfm_commandhandlers[] = {
|
|
||||||
{lfm_commandhandlers+1, "lfm_folder", h_lfm_folder, 2, 2},
|
|
||||||
{NULL, "lfm_format", h_lfm_format, 2, 2}
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
#ifdef _WIN32
|
|
||||||
__declspec(dllexport)
|
|
||||||
#endif
|
|
||||||
int lfm_plugin( struct pluginlink * pluginlink, int argc, char** argv )
|
|
||||||
{
|
|
||||||
pl = pluginlink;
|
|
||||||
myOutputDebugStringA1( "lfm_plugin" );
|
|
||||||
if( !lfm_loaded ) {
|
|
||||||
lfm_loaded = 1;
|
|
||||||
|
|
||||||
lfm_filter.next = pl->conf->filters;
|
|
||||||
pl->conf->filters = &lfm_filter;
|
|
||||||
|
|
||||||
lfm_commandhandlers[1].next = pl->commandhandlers->next;
|
|
||||||
pl->commandhandlers->next = lfm_commandhandlers;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
//
|
|
||||||
// released as a public domain
|
|
||||||
// std.denis, 2009
|
|
||||||
//
|
|
||||||
/*
|
|
||||||
#include "direct.h"
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#define strcasecmp stricmp
|
|
||||||
#define strncasecmp strnicmp
|
|
||||||
#else
|
|
||||||
#define closesocket close
|
|
||||||
extern pthread_attr_t pa;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef SOCKET_ERROR
|
|
||||||
#define SOCKET_ERROR -1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
LFM_NONE,
|
|
||||||
LFM_PLAYLIST, // GET http://ws.audioscrobbler.com/radio/adjust.php(...)
|
|
||||||
LFM_REDIR, // GET http://play.last.fm/user/(...)
|
|
||||||
LFM_GET
|
|
||||||
} LFM_CLASS;
|
|
||||||
|
|
||||||
struct playlist_item {
|
|
||||||
struct playlist_item* next;
|
|
||||||
|
|
||||||
char* artist;
|
|
||||||
char* title;
|
|
||||||
char* album;
|
|
||||||
char* url;
|
|
||||||
int url_len;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define TOKEN_MAXLEN 1024
|
|
||||||
struct xml_state {
|
|
||||||
int state;
|
|
||||||
int closing;
|
|
||||||
char sep;
|
|
||||||
|
|
||||||
int level;
|
|
||||||
char tree[128]; // 128 levels nesting
|
|
||||||
|
|
||||||
int n_token;
|
|
||||||
char p_token[TOKEN_MAXLEN];
|
|
||||||
|
|
||||||
struct playlist_item* p_item;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct lfm_filter_data {
|
|
||||||
pthread_mutex_t mutex;
|
|
||||||
struct playlist_item* playlist;
|
|
||||||
int refs;
|
|
||||||
};
|
|
||||||
struct lfm_client_data {
|
|
||||||
struct lfm_filter_data* p_data;
|
|
||||||
|
|
||||||
int req_type;
|
|
||||||
struct xml_state* pl_xml;
|
|
||||||
struct playlist_item* pl_item;
|
|
||||||
FILE* fp;
|
|
||||||
};
|
|
||||||
@@ -4,4 +4,4 @@ ldapauth$(OBJSUFFICS): ldapauth.c
|
|||||||
$(CC) $(DCFLAGS) $(CFLAGS) ldapauth.c
|
$(CC) $(DCFLAGS) $(CFLAGS) ldapauth.c
|
||||||
|
|
||||||
$(BUILDDIR)ldapauth$(DLSUFFICS): ldapauth$(OBJSUFFICS)
|
$(BUILDDIR)ldapauth$(DLSUFFICS): ldapauth$(OBJSUFFICS)
|
||||||
$(LN) $(LNOUT)../../$(BUILDDIR)ldapauth$(DLSUFFICS) $(LDFLAGS) $(DLFLAGS) $(LIBSPREFIX)ladp$(LIBSSUFFIX) ldapauth$(OBJSUFFICS)
|
$(LN) $(LNOUT)../../$(BUILDDIR)ldapauth$(DLSUFFICS) $(LDFLAGS) $(DLFLAGS) $(LIBSPREFIX)ldap$(LIBSSUFFIX) ldapauth$(OBJSUFFICS)
|
||||||
@@ -1,25 +1,15 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <ldap.h>
|
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../../proxy.h"
|
|
||||||
#include "../../structures.h"
|
#include "../../structures.h"
|
||||||
|
#define LDAP_DEPRECATED 1
|
||||||
struct counter_record
|
#include <ldap.h>
|
||||||
{
|
|
||||||
unsigned long traf;
|
|
||||||
unsigned long trafgb;
|
|
||||||
time_t cleared;
|
|
||||||
time_t updated;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
int already_loaded = 0;
|
int already_loaded = 0;
|
||||||
|
|
||||||
@@ -62,7 +52,7 @@ void lower (char *string)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
int savecouters(void)
|
int savecounters(void)
|
||||||
{
|
{
|
||||||
struct trafcount *tc=mypluginlink->conf->trafcounter;
|
struct trafcount *tc=mypluginlink->conf->trafcounter;
|
||||||
struct trafcount *tcd;
|
struct trafcount *tcd;
|
||||||
@@ -78,15 +68,15 @@ int savecouters(void)
|
|||||||
tc = tc->next;
|
tc = tc->next;
|
||||||
f=NULL;
|
f=NULL;
|
||||||
if(strcmp(tcd->comment,"ldapcounters")==0) {
|
if(strcmp(tcd->comment,"ldapcounters")==0) {
|
||||||
tmpbuf=mypluginlink->myalloc(strlen(pat_file)+strlen(ldap_dircount)+strlen(tcd->ace->users->user));
|
tmpbuf=malloc(strlen(pat_file)+strlen(ldap_dircount)+strlen(tcd->ace->users->user));
|
||||||
sprintf(tmpbuf,pat_file,ldap_dircount,tcd->ace->users->user);
|
sprintf(tmpbuf,pat_file,ldap_dircount,tcd->ace->users->user);
|
||||||
f=fopen(tmpbuf,"w+b");
|
f=fopen(tmpbuf,"w+b");
|
||||||
fseek(f,0,SEEK_SET);
|
fseek(f,0,SEEK_SET);
|
||||||
fprintf(f,"%10lu %10lu %lu %lu\n",tcd->trafgb,tcd->traf,
|
fprintf(f,"%"PRINTF_INT64_MODIFIER"u %lu %lu\n",tcd->traf64,
|
||||||
tcd->cleared,tcd->updated);
|
(unsigned long)tcd->cleared,(unsigned long)tcd->updated);
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
mypluginlink->myfree(tmpbuf);
|
free(tmpbuf);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -100,17 +90,7 @@ int savecouters(void)
|
|||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
__declspec(dllexport) int start(struct pluginlink * pluginlink,
|
|
||||||
int argc, char** argv);
|
|
||||||
#else
|
|
||||||
|
|
||||||
int start(struct pluginlink * pluginlink,
|
|
||||||
int argc, char** argv);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------*/
|
/* --------------------------------------------------------------------------*/
|
||||||
static int ldapfunc(struct clientparam *param)
|
static int ldapfunc(struct clientparam *param)
|
||||||
@@ -214,15 +194,15 @@ int h_ldapconnect(int argc, unsigned char ** argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ldap_serv=mypluginlink->mystrdup(argv[1]);
|
ldap_serv=strdup(argv[1]);
|
||||||
ldap_user=mypluginlink->mystrdup(argv[2]);
|
ldap_user=strdup(argv[2]);
|
||||||
|
|
||||||
ld = ldap_init( ldap_serv, 389 );
|
ld = ldap_init( ldap_serv, 389 );
|
||||||
ldap_unbind_s(ld);
|
ldap_unbind_s(ld);
|
||||||
|
|
||||||
if (argc == 4)
|
if (argc == 4)
|
||||||
{
|
{
|
||||||
ldap_pass= mypluginlink->mystrdup(argv[3]);
|
ldap_pass= strdup(argv[3]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -240,7 +220,7 @@ int h_access(int argc, unsigned char ** argv)
|
|||||||
fprintf(stderr, "Error in ldapaccess: See documentation of ldapauth plugin.\n");
|
fprintf(stderr, "Error in ldapaccess: See documentation of ldapauth plugin.\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
ldap_access=mypluginlink->mystrdup(argv[1]);
|
ldap_access=strdup(argv[1]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------
|
||||||
@@ -253,7 +233,7 @@ int h_sbase(int argc, unsigned char ** argv)
|
|||||||
fprintf(stderr, "Error in ldapsbase: See documentation of ldapauth plugin.\n");
|
fprintf(stderr, "Error in ldapsbase: See documentation of ldapauth plugin.\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
ldap_sbase=mypluginlink->mystrdup(argv[1]);
|
ldap_sbase=strdup(argv[1]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------
|
||||||
@@ -265,7 +245,7 @@ int h_userenv(int argc, unsigned char ** argv)
|
|||||||
fprintf(stderr, "Error in ldapsbase: See documentation of ldapauth plugin.\n");
|
fprintf(stderr, "Error in ldapsbase: See documentation of ldapauth plugin.\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
ldap_userenv=mypluginlink->mystrdup(argv[1]);
|
ldap_userenv=strdup(argv[1]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------
|
||||||
@@ -329,11 +309,11 @@ int h_trafgroup(int argc, unsigned char ** argv)
|
|||||||
bandwidth = atoi((char *)argv[4]);
|
bandwidth = atoi((char *)argv[4]);
|
||||||
|
|
||||||
/* name ldap group */
|
/* name ldap group */
|
||||||
tmpbuf=mypluginlink->myalloc(strlen(pat_group)+strlen(ldap_group_attr)+strlen(argv[1]));
|
tmpbuf=malloc(strlen(pat_group)+strlen(ldap_group_attr)+strlen(argv[1]));
|
||||||
sprintf(tmpbuf,pat_group,ldap_group_attr,argv[1]);
|
sprintf(tmpbuf,pat_group,ldap_group_attr,argv[1]);
|
||||||
rc = ldap_search_s( ld, ldap_sbase, LDAP_SCOPE_SUBTREE,
|
rc = ldap_search_s( ld, ldap_sbase, LDAP_SCOPE_SUBTREE,
|
||||||
tmpbuf, attrs, 0, &res );
|
tmpbuf, attrs, 0, &res );
|
||||||
mypluginlink->myfree(tmpbuf);
|
free(tmpbuf);
|
||||||
|
|
||||||
rc=ldap_count_entries(ld,res);
|
rc=ldap_count_entries(ld,res);
|
||||||
|
|
||||||
@@ -351,7 +331,7 @@ int h_trafgroup(int argc, unsigned char ** argv)
|
|||||||
|
|
||||||
/* -------------bandlim----------
|
/* -------------bandlim----------
|
||||||
create user list */
|
create user list */
|
||||||
newuserlist = (*mypluginlink->myalloc)(sizeof (struct userlist));
|
newuserlist = (*mypluginlink->mallocfunc)(sizeof (struct userlist));
|
||||||
if (usercaselow > 0)
|
if (usercaselow > 0)
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
{ CharLower(vals[0]); }
|
{ CharLower(vals[0]); }
|
||||||
@@ -359,15 +339,15 @@ int h_trafgroup(int argc, unsigned char ** argv)
|
|||||||
{ lower(vals[0]); }
|
{ lower(vals[0]); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
newuserlist->user = (*mypluginlink->mystrdup)(vals[0]);
|
newuserlist->user = (*mypluginlink->strdupfunc)(vals[0]);
|
||||||
newuserlist->next = NULL;
|
newuserlist->next = NULL;
|
||||||
/*create user rule */
|
/*create user rule */
|
||||||
newace = (*mypluginlink->myalloc)(sizeof (struct ace));
|
newace = (*mypluginlink->mallocfunc)(sizeof (struct ace));
|
||||||
memset(newace, 0, sizeof(struct ace));
|
memset(newace, 0, sizeof(struct ace));
|
||||||
newace->users = newuserlist;
|
newace->users = newuserlist;
|
||||||
newace->action = BANDLIM;
|
newace->action = BANDLIM;
|
||||||
/*create user bandlim */
|
/*create user bandlim */
|
||||||
newbandlim =(*mypluginlink->myalloc)(sizeof (struct bandlim));
|
newbandlim =(*mypluginlink->mallocfunc)(sizeof (struct bandlim));
|
||||||
memset(newbandlim, 0, sizeof(struct bandlim));
|
memset(newbandlim, 0, sizeof(struct bandlim));
|
||||||
newbandlim->rate = bandwidth;
|
newbandlim->rate = bandwidth;
|
||||||
newbandlim->ace = newace;
|
newbandlim->ace = newace;
|
||||||
@@ -376,30 +356,29 @@ int h_trafgroup(int argc, unsigned char ** argv)
|
|||||||
|
|
||||||
/* -------------counters----------
|
/* -------------counters----------
|
||||||
create user list */
|
create user list */
|
||||||
newuserlist = (*mypluginlink->myalloc)(sizeof (struct userlist));
|
newuserlist = (*mypluginlink->mallocfunc)(sizeof (struct userlist));
|
||||||
if (usercaselow > 0)
|
if (usercaselow > 0)
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
{ CharLower(vals[0]); }
|
{ CharLower(vals[0]); }
|
||||||
#else
|
#else
|
||||||
{ lower(vals[0]); }
|
{ lower(vals[0]); }
|
||||||
#endif
|
#endif
|
||||||
newuserlist->user = (*mypluginlink->mystrdup)(vals[0]);
|
newuserlist->user = (*mypluginlink->strdupfunc)(vals[0]);
|
||||||
newuserlist->next = NULL;
|
newuserlist->next = NULL;
|
||||||
/*create user rule */
|
/*create user rule */
|
||||||
newace = (*mypluginlink->myalloc)(sizeof (struct ace));
|
newace = (*mypluginlink->mallocfunc)(sizeof (struct ace));
|
||||||
memset(newace, 0, sizeof(struct ace));
|
memset(newace, 0, sizeof(struct ace));
|
||||||
newace->users = newuserlist;
|
newace->users = newuserlist;
|
||||||
newace->action = COUNTIN;
|
newace->action = COUNTIN;
|
||||||
/*create user counter */
|
/*create user counter */
|
||||||
newtrafcount =(*mypluginlink->myalloc)(sizeof (struct trafcount));
|
newtrafcount =(*mypluginlink->mallocfunc)(sizeof (struct trafcount));
|
||||||
memset(newtrafcount, 0, sizeof(struct trafcount));
|
memset(newtrafcount, 0, sizeof(struct trafcount));
|
||||||
newtrafcount->ace = newace;
|
newtrafcount->ace = newace;
|
||||||
newtrafcount->type=rtype;
|
newtrafcount->type=rtype;
|
||||||
newtrafcount->traflimgb =(traflimit/(1024*4));
|
newtrafcount->traflim64 = traflimit;
|
||||||
newtrafcount->traflim = ((traflimit - (newtrafcount->traflimgb*(1024*4)))*(1024*1024));
|
newtrafcount->comment=(*mypluginlink->strdupfunc)("ldapcounters");
|
||||||
newtrafcount->comment=(*mypluginlink->mystrdup)("ldapcounters");
|
|
||||||
newtrafcount->number=0;
|
newtrafcount->number=0;
|
||||||
tmpbuf=(*mypluginlink->myalloc)(strlen(pat_file)+strlen(ldap_dircount)+strlen(vals[0]));
|
tmpbuf=malloc(strlen(pat_file)+strlen(ldap_dircount)+strlen(vals[0]));
|
||||||
sprintf(tmpbuf,pat_file,ldap_dircount,vals[0]);
|
sprintf(tmpbuf,pat_file,ldap_dircount,vals[0]);
|
||||||
f=NULL;
|
f=NULL;
|
||||||
f=fopen(tmpbuf,"rb");
|
f=fopen(tmpbuf,"rb");
|
||||||
@@ -408,17 +387,16 @@ int h_trafgroup(int argc, unsigned char ** argv)
|
|||||||
|
|
||||||
fseek(f,0,SEEK_SET);
|
fseek(f,0,SEEK_SET);
|
||||||
fgets(buf, 256, f);
|
fgets(buf, 256, f);
|
||||||
sscanf(buf,"%10lu %10lu %lu %lu\n",&rcounter.trafgb, &rcounter.traf,
|
sscanf(buf,"%"PRINTF_INT64_MODIFIER"u %lu %lu\n",&rcounter.traf64,
|
||||||
&rcounter.cleared, &rcounter.updated);
|
&rcounter.cleared, &rcounter.updated);
|
||||||
|
|
||||||
|
|
||||||
newtrafcount->trafgb=rcounter.trafgb;
|
newtrafcount->traf64=rcounter.traf64;
|
||||||
newtrafcount->traf=rcounter.traf;
|
|
||||||
newtrafcount->cleared=rcounter.cleared;
|
newtrafcount->cleared=rcounter.cleared;
|
||||||
newtrafcount->updated=rcounter.updated;
|
newtrafcount->updated=rcounter.updated;
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
mypluginlink->myfree(tmpbuf);
|
free(tmpbuf);
|
||||||
|
|
||||||
newtrafcount->next = mypluginlink->conf->trafcounter;
|
newtrafcount->next = mypluginlink->conf->trafcounter;
|
||||||
mypluginlink->conf->trafcounter = newtrafcount;
|
mypluginlink->conf->trafcounter = newtrafcount;
|
||||||
@@ -444,8 +422,8 @@ int h_attrsgroup(int argc, unsigned char ** argv)
|
|||||||
fprintf(stderr, "Error in ldapattr: See documentation of ldapauth plugin.\n");
|
fprintf(stderr, "Error in ldapattr: See documentation of ldapauth plugin.\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
attrs[0]=mypluginlink->mystrdup(argv[1]);
|
attrs[0]=strdup(argv[1]);
|
||||||
ldap_group_attr=mypluginlink->mystrdup(argv[2]);
|
ldap_group_attr=strdup(argv[2]);
|
||||||
|
|
||||||
if(argc == 4)
|
if(argc == 4)
|
||||||
{ usercaselow=atoi(argv[3]); }
|
{ usercaselow=atoi(argv[3]); }
|
||||||
@@ -461,27 +439,36 @@ int h_dircount(int argc, unsigned char ** argv)
|
|||||||
fprintf(stderr, "Error in ldapdircount: See documentation of ldapauth plugin.\n");
|
fprintf(stderr, "Error in ldapdircount: See documentation of ldapauth plugin.\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
ldap_dircount=mypluginlink->mystrdup(argv[1]);
|
ldap_dircount=strdup(argv[1]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------- MAIN --------------------------------------
|
/*------------------------------- MAIN --------------------------------------
|
||||||
start plugin init */
|
start plugin init */
|
||||||
int start(struct pluginlink * pluginlink, int argc, char** argv)
|
|
||||||
|
#ifdef WATCOM
|
||||||
|
#pragma aux start "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
|
||||||
|
#undef PLUGINCALL
|
||||||
|
#define PLUGINCALL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
PLUGINAPI int PLUGINCALL start(struct pluginlink * pluginlink,
|
||||||
|
int argc, char** argv)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if (already_loaded != 0)
|
if (already_loaded != 0)
|
||||||
{
|
{
|
||||||
pluginlink->myfree(ldap_access);
|
free(ldap_access);
|
||||||
pluginlink->myfree(ldap_sbase);
|
free(ldap_sbase);
|
||||||
pluginlink->myfree(ldap_serv);
|
free(ldap_serv);
|
||||||
pluginlink->myfree(ldap_user);
|
free(ldap_user);
|
||||||
pluginlink->myfree(ldap_pass);
|
free(ldap_pass);
|
||||||
pluginlink->myfree(ldap_userenv);
|
free(ldap_userenv);
|
||||||
pluginlink->myfree(ldap_dircount);
|
free(ldap_dircount);
|
||||||
pluginlink->myfree(ldap_group_attr);
|
free(ldap_group_attr);
|
||||||
pluginlink->myfree(attrs[0]);
|
free(attrs[0]);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -566,7 +553,7 @@ int start(struct pluginlink * pluginlink, int argc, char** argv)
|
|||||||
/*create job shedule for processing reload, save counters to file */
|
/*create job shedule for processing reload, save counters to file */
|
||||||
memset(&myschedule,0,sizeof(struct schedule));
|
memset(&myschedule,0,sizeof(struct schedule));
|
||||||
myschedule.type=MINUTELY;
|
myschedule.type=MINUTELY;
|
||||||
myschedule.function=savecouters;
|
myschedule.function=savecounters;
|
||||||
myschedule.next = *pluginlink->schedule;
|
myschedule.next = *pluginlink->schedule;
|
||||||
*pluginlink->schedule=&myschedule;
|
*pluginlink->schedule=&myschedule;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
all: $(BUILDDIR)PCREPlugin$(DLSUFFICS)
|
all: $(BUILDDIR)PCREPlugin$(DLSUFFICS)
|
||||||
|
|
||||||
|
pcre_maketables$(OBJSUFFICS): pcre_maketables.c
|
||||||
|
$(CC) $(DCFLAGS) $(CFLAGS) pcre_maketables.c
|
||||||
|
|
||||||
|
pcre_table$(OBJSUFFICS): pcre_table.c
|
||||||
|
$(CC) $(DCFLAGS) $(CFLAGS) pcre_table.c
|
||||||
|
|
||||||
|
pcre_ucd$(OBJSUFFICS): pcre_ucd.c
|
||||||
|
$(CC) $(DCFLAGS) $(CFLAGS) pcre_ucd.c
|
||||||
|
|
||||||
pcre_compile$(OBJSUFFICS): pcre_compile.c
|
pcre_compile$(OBJSUFFICS): pcre_compile.c
|
||||||
$(CC) $(DCFLAGS) $(CFLAGS) pcre_compile.c
|
$(CC) $(DCFLAGS) $(CFLAGS) pcre_compile.c
|
||||||
@@ -22,12 +30,6 @@ pcre_get$(OBJSUFFICS): pcre_get.c
|
|||||||
pcre_globals$(OBJSUFFICS): pcre_globals.c
|
pcre_globals$(OBJSUFFICS): pcre_globals.c
|
||||||
$(CC) $(DCFLAGS) $(CFLAGS) pcre_globals.c
|
$(CC) $(DCFLAGS) $(CFLAGS) pcre_globals.c
|
||||||
|
|
||||||
pcre_info$(OBJSUFFICS): pcre_info.c
|
|
||||||
$(CC) $(DCFLAGS) $(CFLAGS) pcre_info.c
|
|
||||||
|
|
||||||
pcre_maketables$(OBJSUFFICS): pcre_maketables.c
|
|
||||||
$(CC) $(DCFLAGS) $(CFLAGS) pcre_maketables.c
|
|
||||||
|
|
||||||
pcre_newline$(OBJSUFFICS): pcre_newline.c
|
pcre_newline$(OBJSUFFICS): pcre_newline.c
|
||||||
$(CC) $(DCFLAGS) $(CFLAGS) pcre_newline.c
|
$(CC) $(DCFLAGS) $(CFLAGS) pcre_newline.c
|
||||||
|
|
||||||
@@ -43,12 +45,6 @@ pcre_study$(OBJSUFFICS): pcre_study.c
|
|||||||
pcre_tables$(OBJSUFFICS): pcre_tables.c
|
pcre_tables$(OBJSUFFICS): pcre_tables.c
|
||||||
$(CC) $(DCFLAGS) $(CFLAGS) pcre_tables.c
|
$(CC) $(DCFLAGS) $(CFLAGS) pcre_tables.c
|
||||||
|
|
||||||
pcre_try_flipped$(OBJSUFFICS): pcre_try_flipped.c
|
|
||||||
$(CC) $(DCFLAGS) $(CFLAGS) pcre_try_flipped.c
|
|
||||||
|
|
||||||
pcre_ucp_searchfuncs$(OBJSUFFICS): pcre_ucp_searchfuncs.c
|
|
||||||
$(CC) $(DCFLAGS) $(CFLAGS) pcre_ucp_searchfuncs.c
|
|
||||||
|
|
||||||
pcre_valid_utf8$(OBJSUFFICS): pcre_valid_utf8.c
|
pcre_valid_utf8$(OBJSUFFICS): pcre_valid_utf8.c
|
||||||
$(CC) $(DCFLAGS) $(CFLAGS) pcre_valid_utf8.c
|
$(CC) $(DCFLAGS) $(CFLAGS) pcre_valid_utf8.c
|
||||||
|
|
||||||
@@ -58,14 +54,9 @@ pcre_version$(OBJSUFFICS): pcre_version.c
|
|||||||
pcre_xclass$(OBJSUFFICS): pcre_xclass.c
|
pcre_xclass$(OBJSUFFICS): pcre_xclass.c
|
||||||
$(CC) $(DCFLAGS) $(CFLAGS) pcre_xclass.c
|
$(CC) $(DCFLAGS) $(CFLAGS) pcre_xclass.c
|
||||||
|
|
||||||
pcre_dftables$(OBJSUFFICS): pcre_dftables.c
|
|
||||||
$(CC) $(DCFLAGS) $(CFLAGS) pcre_dftables.c
|
|
||||||
|
|
||||||
pcre_plugin$(OBJSUFFICS): pcre_plugin.c
|
pcre_plugin$(OBJSUFFICS): pcre_plugin.c
|
||||||
$(CC) $(DCFLAGS) $(CFLAGS) pcre_plugin.c
|
$(CC) $(DCFLAGS) $(CFLAGS) pcre_plugin.c
|
||||||
|
|
||||||
pcreposix$(OBJSUFFICS): pcreposix.c
|
$(BUILDDIR)PCREPlugin$(DLSUFFICS): pcre_compile$(OBJSUFFICS) pcre_config$(OBJSUFFICS) pcre_dfa_exec$(OBJSUFFICS) pcre_exec$(OBJSUFFICS) pcre_fullinfo$(OBJSUFFICS) pcre_get$(OBJSUFFICS) pcre_globals$(OBJSUFFICS) pcre_newline$(OBJSUFFICS) pcre_ord2utf8$(OBJSUFFICS) pcre_refcount$(OBJSUFFICS) pcre_study$(OBJSUFFICS) pcre_tables$(OBJSUFFICS) pcre_valid_utf8$(OBJSUFFICS) pcre_version$(OBJSUFFICS) pcre_xclass$(OBJSUFFICS) pcre_plugin$(OBJSUFFICS) pcre_maketables$(OBJSUFFICS) pcre_ucd$(OBJSUFFICS) pcre_table$(OBJSUFFICS)
|
||||||
$(CC) $(DCFLAGS) $(CFLAGS) pcreposix.c
|
$(LN) $(LNOUT)../../$(BUILDDIR)PCREPlugin$(DLSUFFICS) $(LDFLAGS) $(DLFLAGS) pcre_compile$(OBJSUFFICS) pcre_config$(OBJSUFFICS) pcre_dfa_exec$(OBJSUFFICS) pcre_exec$(OBJSUFFICS) pcre_fullinfo$(OBJSUFFICS) pcre_get$(OBJSUFFICS) pcre_globals$(OBJSUFFICS) pcre_newline$(OBJSUFFICS) pcre_ord2utf8$(OBJSUFFICS) pcre_refcount$(OBJSUFFICS) pcre_study$(OBJSUFFICS) pcre_tables$(OBJSUFFICS) pcre_valid_utf8$(OBJSUFFICS) pcre_version$(OBJSUFFICS) pcre_xclass$(OBJSUFFICS) pcre_plugin$(OBJSUFFICS) pcre_maketables$(OBJSUFFICS) pcre_ucd$(OBJSUFFICS) pcre_table$(OBJSUFFICS)
|
||||||
|
|
||||||
$(BUILDDIR)PCREPlugin$(DLSUFFICS): pcre_compile$(OBJSUFFICS) pcre_config$(OBJSUFFICS) pcre_dfa_exec$(OBJSUFFICS) pcre_exec$(OBJSUFFICS) pcre_fullinfo$(OBJSUFFICS) pcre_get$(OBJSUFFICS) pcre_globals$(OBJSUFFICS) pcre_info$(OBJSUFFICS) pcre_maketables$(OBJSUFFICS) pcre_newline$(OBJSUFFICS) pcre_ord2utf8$(OBJSUFFICS) pcre_refcount$(OBJSUFFICS) pcre_study$(OBJSUFFICS) pcre_tables$(OBJSUFFICS) pcre_try_flipped$(OBJSUFFICS) pcre_ucp_searchfuncs$(OBJSUFFICS) pcre_valid_utf8$(OBJSUFFICS) pcre_version$(OBJSUFFICS) pcre_xclass$(OBJSUFFICS) pcre_dftables$(OBJSUFFICS) pcre_plugin$(OBJSUFFICS) pcreposix$(OBJSUFFICS)
|
|
||||||
$(LN) $(LNOUT)../../$(BUILDDIR)PCREPlugin$(DLSUFFICS) $(LDFLAGS) $(DLFLAGS) pcre_compile$(OBJSUFFICS) pcre_config$(OBJSUFFICS) pcre_dfa_exec$(OBJSUFFICS) pcre_exec$(OBJSUFFICS) pcre_fullinfo$(OBJSUFFICS) pcre_get$(OBJSUFFICS) pcre_globals$(OBJSUFFICS) pcre_info$(OBJSUFFICS) pcre_maketables$(OBJSUFFICS) pcre_newline$(OBJSUFFICS) pcre_ord2utf8$(OBJSUFFICS) pcre_refcount$(OBJSUFFICS) pcre_study$(OBJSUFFICS) pcre_tables$(OBJSUFFICS) pcre_try_flipped$(OBJSUFFICS) pcre_ucp_searchfuncs$(OBJSUFFICS) pcre_valid_utf8$(OBJSUFFICS) pcre_version$(OBJSUFFICS) pcre_xclass$(OBJSUFFICS) pcre_dftables$(OBJSUFFICS) pcre_plugin$(OBJSUFFICS) pcreposix$(OBJSUFFICS)
|
|
||||||
+312
-105
@@ -1,145 +1,352 @@
|
|||||||
|
#define PCRE_STATIC
|
||||||
|
/* config.h. Generated from config.h.in by configure. */
|
||||||
|
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||||
|
|
||||||
/* On Unix-like systems config.in is converted by "configure" into config.h.
|
/* PCRE is written in Standard C, but there are a few non-standard things it
|
||||||
Some other environments also support the use of "configure". PCRE is written in
|
can cope with, allowing it to run on SunOS4 and other "close to standard"
|
||||||
Standard C, but there are a few non-standard things it can cope with, allowing
|
systems.
|
||||||
it to run on SunOS4 and other "close to standard" systems.
|
|
||||||
|
|
||||||
On a non-Unix-like system you should just copy this file into config.h, and set
|
In environments that support the GNU autotools, config.h.in is converted into
|
||||||
up the macros the way you need them. You should normally change the definitions
|
config.h by the "configure" script. In environments that use CMake,
|
||||||
of HAVE_STRERROR and HAVE_MEMMOVE to 1. Unfortunately, because of the way
|
config-cmake.in is converted into config.h. If you are going to build PCRE "by
|
||||||
autoconf works, these cannot be made the defaults. If your system has bcopy()
|
hand" without using "configure" or CMake, you should copy the distributed
|
||||||
and not memmove(), change the definition of HAVE_BCOPY instead of HAVE_MEMMOVE.
|
config.h.generic to config.h, and edit the macro definitions to be the way you
|
||||||
If your system has neither bcopy() nor memmove(), leave them both as 0; an
|
need them. You must then add -DHAVE_CONFIG_H to all of your compile commands,
|
||||||
emulation function will be used. */
|
so that config.h is included at the start of every source.
|
||||||
|
|
||||||
|
Alternatively, you can avoid editing by using -D on the compiler command line
|
||||||
|
to set the macro values. In this case, you do not have to set -DHAVE_CONFIG_H,
|
||||||
|
but if you do, default values will be taken from config.h for non-boolean
|
||||||
|
macros that are not defined on the command line.
|
||||||
|
|
||||||
|
Boolean macros such as HAVE_STDLIB_H and SUPPORT_PCRE8 should either be defined
|
||||||
|
(conventionally to 1) for TRUE, and not defined at all for FALSE. All such
|
||||||
|
macros are listed as a commented #undef in config.h.generic. Macros such as
|
||||||
|
MATCH_LIMIT, whose actual value is relevant, have defaults defined, but are
|
||||||
|
surrounded by #ifndef/#endif lines so that the value can be overridden by -D.
|
||||||
|
|
||||||
|
PCRE uses memmove() if HAVE_MEMMOVE is defined; otherwise it uses bcopy() if
|
||||||
|
HAVE_BCOPY is defined. If your system has neither bcopy() nor memmove(), make
|
||||||
|
sure both macros are undefined; an emulation function will then be used. */
|
||||||
|
|
||||||
|
/* By default, the \R escape sequence matches any Unicode line ending
|
||||||
|
character or sequence of characters. If BSR_ANYCRLF is defined (to any
|
||||||
|
value), this is changed so that backslash-R matches only CR, LF, or CRLF.
|
||||||
|
The build-time default can be overridden by the user of PCRE at runtime. */
|
||||||
|
/* #undef BSR_ANYCRLF */
|
||||||
|
|
||||||
/* If you are compiling for a system that uses EBCDIC instead of ASCII
|
/* If you are compiling for a system that uses EBCDIC instead of ASCII
|
||||||
character codes, define this macro as 1. On systems that can use "configure",
|
character codes, define this macro to any value. You must also edit the
|
||||||
this can be done via --enable-ebcdic. */
|
NEWLINE macro below to set a suitable EBCDIC newline, commonly 21 (0x15).
|
||||||
|
On systems that can use "configure" or CMake to set EBCDIC, NEWLINE is
|
||||||
|
automatically adjusted. When EBCDIC is set, PCRE assumes that all input
|
||||||
|
strings are in EBCDIC. If you do not define this macro, PCRE will assume
|
||||||
|
input strings are ASCII or UTF-8/16/32 Unicode. It is not possible to build
|
||||||
|
a version of PCRE that supports both EBCDIC and UTF-8/16/32. */
|
||||||
|
/* #undef EBCDIC */
|
||||||
|
|
||||||
#ifndef EBCDIC
|
/* In an EBCDIC environment, define this macro to any value to arrange for the
|
||||||
#define EBCDIC 0
|
NL character to be 0x25 instead of the default 0x15. NL plays the role that
|
||||||
#endif
|
LF does in an ASCII/Unicode environment. The value must also be set in the
|
||||||
|
NEWLINE macro below. On systems that can use "configure" or CMake to set
|
||||||
|
EBCDIC_NL25, the adjustment of NEWLINE is automatic. */
|
||||||
|
/* #undef EBCDIC_NL25 */
|
||||||
|
|
||||||
#define PCRE_STATIC
|
/* Define to 1 if you have the `bcopy' function. */
|
||||||
|
/* #undef HAVE_BCOPY */
|
||||||
|
|
||||||
/* If you are compiling for a system other than a Unix-like system or Win32,
|
/* Define to 1 if you have the <bits/type_traits.h> header file. */
|
||||||
and it needs some magic to be inserted before the definition of a function that
|
/* #undef HAVE_BITS_TYPE_TRAITS_H */
|
||||||
is exported by the library, define this macro to contain the relevant magic. If
|
|
||||||
you do not define this macro, it defaults to "extern" for a C compiler and
|
|
||||||
"extern C" for a C++ compiler on non-Win32 systems. This macro apears at the
|
|
||||||
start of every exported function that is part of the external API. It does not
|
|
||||||
appear on functions that are "external" in the C sense, but which are internal
|
|
||||||
to the library. */
|
|
||||||
|
|
||||||
/* #define PCRE_DATA_SCOPE */
|
/* Define to 1 if you have the <bzlib.h> header file. */
|
||||||
|
/* #undef HAVE_BZLIB_H */
|
||||||
|
|
||||||
/* Define the following macro to empty if the "const" keyword does not work. */
|
/* Define to 1 if you have the <dirent.h> header file. */
|
||||||
|
/* #undef HAVE_DIRENT_H */
|
||||||
|
|
||||||
#undef const
|
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||||
|
/* #undef HAVE_DLFCN_H */
|
||||||
|
|
||||||
/* Define the following macro to "unsigned" if <stddef.h> does not define
|
/* Define to 1 if you have the <editline/readline.h> header file. */
|
||||||
size_t. */
|
/* #undef HAVE_EDITLINE_READLINE_H */
|
||||||
|
|
||||||
#undef size_t
|
/* Define to 1 if you have the <edit/readline/readline.h> header file. */
|
||||||
|
/* #undef HAVE_EDIT_READLINE_READLINE_H */
|
||||||
|
|
||||||
/* The following two definitions are mainly for the benefit of SunOS4, which
|
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||||
does not have the strerror() or memmove() functions that should be present in
|
/* #undef HAVE_INTTYPES_H */
|
||||||
all Standard C libraries. The macros HAVE_STRERROR and HAVE_MEMMOVE should
|
|
||||||
normally be defined with the value 1 for other systems, but unfortunately we
|
|
||||||
cannot make this the default because "configure" files generated by autoconf
|
|
||||||
will only change 0 to 1; they won't change 1 to 0 if the functions are not
|
|
||||||
found. */
|
|
||||||
|
|
||||||
#define HAVE_STRERROR 0
|
/* Define to 1 if you have the <limits.h> header file. */
|
||||||
#define HAVE_MEMMOVE 0
|
/* #undef HAVE_LIMITS_H */
|
||||||
|
|
||||||
/* There are some non-Unix-like systems that don't even have bcopy(). If this
|
/* Define to 1 if the system has the type `long long'. */
|
||||||
macro is false, an emulation is used. If HAVE_MEMMOVE is set to 1, the value of
|
/* #undef HAVE_LONG_LONG */
|
||||||
HAVE_BCOPY is not relevant. */
|
|
||||||
|
|
||||||
#define HAVE_BCOPY 0
|
/* Define to 1 if you have the `memmove' function. */
|
||||||
|
/* #undef HAVE_MEMMOVE */
|
||||||
|
|
||||||
/* The value of NEWLINE determines the newline character. The default is to
|
/* Define to 1 if you have the <memory.h> header file. */
|
||||||
leave it up to the compiler, but some sites want to force a particular value.
|
/* #undef HAVE_MEMORY_H */
|
||||||
On Unix-like systems, "configure" can be used to override this default. */
|
|
||||||
|
|
||||||
#ifndef NEWLINE
|
/* Define if you have POSIX threads libraries and header files. */
|
||||||
#define NEWLINE '\n'
|
/* #undef HAVE_PTHREAD */
|
||||||
#endif
|
|
||||||
|
|
||||||
/* The value of LINK_SIZE determines the number of bytes used to store links as
|
/* Have PTHREAD_PRIO_INHERIT. */
|
||||||
offsets within the compiled regex. The default is 2, which allows for compiled
|
/* #undef HAVE_PTHREAD_PRIO_INHERIT */
|
||||||
patterns up to 64K long. This covers the vast majority of cases. However, PCRE
|
|
||||||
can also be compiled to use 3 or 4 bytes instead. This allows for longer
|
|
||||||
patterns in extreme cases. On systems that support it, "configure" can be used
|
|
||||||
to override this default. */
|
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <readline/history.h> header file. */
|
||||||
|
/* #undef HAVE_READLINE_HISTORY_H */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <readline/readline.h> header file. */
|
||||||
|
/* #undef HAVE_READLINE_READLINE_H */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdint.h> header file. */
|
||||||
|
/* #undef HAVE_STDINT_H */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||||
|
/* #undef HAVE_STDLIB_H */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strerror' function. */
|
||||||
|
/* #undef HAVE_STRERROR */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <string> header file. */
|
||||||
|
/* #undef HAVE_STRING */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <strings.h> header file. */
|
||||||
|
/* #undef HAVE_STRINGS_H */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <string.h> header file. */
|
||||||
|
/* #undef HAVE_STRING_H */
|
||||||
|
|
||||||
|
/* Define to 1 if you have `strtoimax'. */
|
||||||
|
/* #undef HAVE_STRTOIMAX */
|
||||||
|
|
||||||
|
/* Define to 1 if you have `strtoll'. */
|
||||||
|
/* #undef HAVE_STRTOLL */
|
||||||
|
|
||||||
|
/* Define to 1 if you have `strtoq'. */
|
||||||
|
/* #undef HAVE_STRTOQ */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||||
|
/* #undef HAVE_SYS_STAT_H */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||||
|
/* #undef HAVE_SYS_TYPES_H */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <type_traits.h> header file. */
|
||||||
|
/* #undef HAVE_TYPE_TRAITS_H */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <unistd.h> header file. */
|
||||||
|
/* #undef HAVE_UNISTD_H */
|
||||||
|
|
||||||
|
/* Define to 1 if the system has the type `unsigned long long'. */
|
||||||
|
/* #undef HAVE_UNSIGNED_LONG_LONG */
|
||||||
|
|
||||||
|
/* Define to 1 if the compiler supports simple visibility declarations. */
|
||||||
|
/* #undef HAVE_VISIBILITY */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <windows.h> header file. */
|
||||||
|
/* #undef HAVE_WINDOWS_H */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <zlib.h> header file. */
|
||||||
|
/* #undef HAVE_ZLIB_H */
|
||||||
|
|
||||||
|
/* Define to 1 if you have `_strtoi64'. */
|
||||||
|
/* #undef HAVE__STRTOI64 */
|
||||||
|
|
||||||
|
/* The value of LINK_SIZE determines the number of bytes used to store links
|
||||||
|
as offsets within the compiled regex. The default is 2, which allows for
|
||||||
|
compiled patterns up to 64K long. This covers the vast majority of cases.
|
||||||
|
However, PCRE can also be compiled to use 3 or 4 bytes instead. This allows
|
||||||
|
for longer patterns in extreme cases. */
|
||||||
#ifndef LINK_SIZE
|
#ifndef LINK_SIZE
|
||||||
#define LINK_SIZE 2
|
#define LINK_SIZE 2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* When calling PCRE via the POSIX interface, additional working storage is
|
/* Define to the sub-directory where libtool stores uninstalled libraries. */
|
||||||
required for holding the pointers to capturing substrings because PCRE requires
|
/* This is ignored unless you are using libtool. */
|
||||||
three integers per substring, whereas the POSIX interface provides only two. If
|
#ifndef LT_OBJDIR
|
||||||
the number of expected substrings is small, the wrapper function uses space on
|
#define LT_OBJDIR ".libs/"
|
||||||
the stack, because this is faster than using malloc() for each call. The
|
|
||||||
threshold above which the stack is no longer used is defined by POSIX_MALLOC_
|
|
||||||
THRESHOLD. On systems that support it, "configure" can be used to override this
|
|
||||||
default. */
|
|
||||||
|
|
||||||
#ifndef POSIX_MALLOC_THRESHOLD
|
|
||||||
#define POSIX_MALLOC_THRESHOLD 10
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* PCRE uses recursive function calls to handle backtracking while matching.
|
/* The value of MATCH_LIMIT determines the default number of times the
|
||||||
This can sometimes be a problem on systems that have stacks of limited size.
|
internal match() function can be called during a single execution of
|
||||||
Define NO_RECURSE to get a version that doesn't use recursion in the match()
|
pcre_exec(). There is a runtime interface for setting a different limit.
|
||||||
function; instead it creates its own stack by steam using pcre_recurse_malloc()
|
The limit exists in order to catch runaway regular expressions that take
|
||||||
to obtain memory from the heap. For more detail, see the comments and other
|
for ever to determine that they do not match. The default is set very large
|
||||||
stuff just above the match() function. On systems that support it, "configure"
|
so that it does not accidentally catch legitimate cases. */
|
||||||
can be used to set this in the Makefile (use --disable-stack-for-recursion). */
|
|
||||||
|
|
||||||
/* #define NO_RECURSE */
|
|
||||||
|
|
||||||
/* The value of MATCH_LIMIT determines the default number of times the internal
|
|
||||||
match() function can be called during a single execution of pcre_exec(). There
|
|
||||||
is a runtime interface for setting a different limit. The limit exists in order
|
|
||||||
to catch runaway regular expressions that take for ever to determine that they
|
|
||||||
do not match. The default is set very large so that it does not accidentally
|
|
||||||
catch legitimate cases. On systems that support it, "configure" can be used to
|
|
||||||
override this default default. */
|
|
||||||
|
|
||||||
#ifndef MATCH_LIMIT
|
#ifndef MATCH_LIMIT
|
||||||
#define MATCH_LIMIT 10000000
|
#define MATCH_LIMIT 10000000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The above limit applies to all calls of match(), whether or not they
|
/* The above limit applies to all calls of match(), whether or not they
|
||||||
increase the recursion depth. In some environments it is desirable to limit the
|
increase the recursion depth. In some environments it is desirable to limit
|
||||||
depth of recursive calls of match() more strictly, in order to restrict the
|
the depth of recursive calls of match() more strictly, in order to restrict
|
||||||
maximum amount of stack (or heap, if NO_RECURSE is defined) that is used. The
|
the maximum amount of stack (or heap, if NO_RECURSE is defined) that is
|
||||||
value of MATCH_LIMIT_RECURSION applies only to recursive calls of match(). To
|
used. The value of MATCH_LIMIT_RECURSION applies only to recursive calls of
|
||||||
have any useful effect, it must be less than the value of MATCH_LIMIT. There is
|
match(). To have any useful effect, it must be less than the value of
|
||||||
a runtime method for setting a different limit. On systems that support it,
|
MATCH_LIMIT. The default is to use the same value as MATCH_LIMIT. There is
|
||||||
"configure" can be used to override this default default. */
|
a runtime method for setting a different limit. */
|
||||||
|
|
||||||
#ifndef MATCH_LIMIT_RECURSION
|
#ifndef MATCH_LIMIT_RECURSION
|
||||||
#define MATCH_LIMIT_RECURSION MATCH_LIMIT
|
#define MATCH_LIMIT_RECURSION MATCH_LIMIT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* These three limits are parameterized just in case anybody ever wants to
|
/* This limit is parameterized just in case anybody ever wants to change it.
|
||||||
change them. Care must be taken if they are increased, because they guard
|
Care must be taken if it is increased, because it guards against integer
|
||||||
against integer overflow caused by enormously large patterns. */
|
overflow caused by enormously large patterns. */
|
||||||
|
|
||||||
#ifndef MAX_NAME_SIZE
|
|
||||||
#define MAX_NAME_SIZE 32
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef MAX_NAME_COUNT
|
#ifndef MAX_NAME_COUNT
|
||||||
#define MAX_NAME_COUNT 10000
|
#define MAX_NAME_COUNT 10000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MAX_DUPLENGTH
|
/* This limit is parameterized just in case anybody ever wants to change it.
|
||||||
#define MAX_DUPLENGTH 30000
|
Care must be taken if it is increased, because it guards against integer
|
||||||
|
overflow caused by enormously large patterns. */
|
||||||
|
#ifndef MAX_NAME_SIZE
|
||||||
|
#define MAX_NAME_SIZE 32
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* End */
|
/* The value of NEWLINE determines the default newline character sequence.
|
||||||
|
PCRE client programs can override this by selecting other values at run
|
||||||
|
time. In ASCII environments, the value can be 10 (LF), 13 (CR), or 3338
|
||||||
|
(CRLF); in EBCDIC environments the value can be 21 or 37 (LF), 13 (CR), or
|
||||||
|
3349 or 3365 (CRLF) because there are two alternative codepoints (0x15 and
|
||||||
|
0x25) that are used as the NL line terminator that is equivalent to ASCII
|
||||||
|
LF. In both ASCII and EBCDIC environments the value can also be -1 (ANY),
|
||||||
|
or -2 (ANYCRLF). */
|
||||||
|
#ifndef NEWLINE
|
||||||
|
#define NEWLINE 10
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* PCRE uses recursive function calls to handle backtracking while matching.
|
||||||
|
This can sometimes be a problem on systems that have stacks of limited
|
||||||
|
size. Define NO_RECURSE to any value to get a version that doesn't use
|
||||||
|
recursion in the match() function; instead it creates its own stack by
|
||||||
|
steam using pcre_recurse_malloc() to obtain memory from the heap. For more
|
||||||
|
detail, see the comments and other stuff just above the match() function.
|
||||||
|
*/
|
||||||
|
/* #undef NO_RECURSE */
|
||||||
|
|
||||||
|
/* Name of package */
|
||||||
|
#define PACKAGE "pcre"
|
||||||
|
|
||||||
|
/* Define to the address where bug reports for this package should be sent. */
|
||||||
|
#define PACKAGE_BUGREPORT ""
|
||||||
|
|
||||||
|
/* Define to the full name of this package. */
|
||||||
|
#define PACKAGE_NAME "PCRE"
|
||||||
|
|
||||||
|
/* Define to the full name and version of this package. */
|
||||||
|
#define PACKAGE_STRING "PCRE 8.39"
|
||||||
|
|
||||||
|
/* Define to the one symbol short name of this package. */
|
||||||
|
#define PACKAGE_TARNAME "pcre"
|
||||||
|
|
||||||
|
/* Define to the home page for this package. */
|
||||||
|
#define PACKAGE_URL ""
|
||||||
|
|
||||||
|
/* Define to the version of this package. */
|
||||||
|
#define PACKAGE_VERSION "8.39"
|
||||||
|
|
||||||
|
/* The value of PARENS_NEST_LIMIT specifies the maximum depth of nested
|
||||||
|
parentheses (of any kind) in a pattern. This limits the amount of system
|
||||||
|
stack that is used while compiling a pattern. */
|
||||||
|
#ifndef PARENS_NEST_LIMIT
|
||||||
|
#define PARENS_NEST_LIMIT 250
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* The value of PCREGREP_BUFSIZE determines the size of buffer used by
|
||||||
|
pcregrep to hold parts of the file it is searching. This is also the
|
||||||
|
minimum value. The actual amount of memory used by pcregrep is three times
|
||||||
|
this number, because it allows for the buffering of "before" and "after"
|
||||||
|
lines. */
|
||||||
|
#ifndef PCREGREP_BUFSIZE
|
||||||
|
#define PCREGREP_BUFSIZE 20480
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* If you are compiling for a system other than a Unix-like system or
|
||||||
|
Win32, and it needs some magic to be inserted before the definition
|
||||||
|
of a function that is exported by the library, define this macro to
|
||||||
|
contain the relevant magic. If you do not define this macro, a suitable
|
||||||
|
__declspec value is used for Windows systems; in other environments
|
||||||
|
"extern" is used for a C compiler and "extern C" for a C++ compiler.
|
||||||
|
This macro apears at the start of every exported function that is part
|
||||||
|
of the external API. It does not appear on functions that are "external"
|
||||||
|
in the C sense, but which are internal to the library. */
|
||||||
|
/* #undef PCRE_EXP_DEFN */
|
||||||
|
|
||||||
|
/* Define to any value if linking statically (TODO: make nice with Libtool) */
|
||||||
|
/* #undef PCRE_STATIC */
|
||||||
|
|
||||||
|
/* When calling PCRE via the POSIX interface, additional working storage is
|
||||||
|
required for holding the pointers to capturing substrings because PCRE
|
||||||
|
requires three integers per substring, whereas the POSIX interface provides
|
||||||
|
only two. If the number of expected substrings is small, the wrapper
|
||||||
|
function uses space on the stack, because this is faster than using
|
||||||
|
malloc() for each call. The threshold above which the stack is no longer
|
||||||
|
used is defined by POSIX_MALLOC_THRESHOLD. */
|
||||||
|
#ifndef POSIX_MALLOC_THRESHOLD
|
||||||
|
#define POSIX_MALLOC_THRESHOLD 10
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Define to necessary symbol if this constant uses a non-standard name on
|
||||||
|
your system. */
|
||||||
|
/* #undef PTHREAD_CREATE_JOINABLE */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the ANSI C header files. */
|
||||||
|
/* #undef STDC_HEADERS */
|
||||||
|
|
||||||
|
/* Define to any value to enable support for Just-In-Time compiling. */
|
||||||
|
/* #undef SUPPORT_JIT */
|
||||||
|
|
||||||
|
/* Define to any value to allow pcregrep to be linked with libbz2, so that it
|
||||||
|
is able to handle .bz2 files. */
|
||||||
|
/* #undef SUPPORT_LIBBZ2 */
|
||||||
|
|
||||||
|
/* Define to any value to allow pcretest to be linked with libedit. */
|
||||||
|
/* #undef SUPPORT_LIBEDIT */
|
||||||
|
|
||||||
|
/* Define to any value to allow pcretest to be linked with libreadline. */
|
||||||
|
/* #undef SUPPORT_LIBREADLINE */
|
||||||
|
|
||||||
|
/* Define to any value to allow pcregrep to be linked with libz, so that it is
|
||||||
|
able to handle .gz files. */
|
||||||
|
/* #undef SUPPORT_LIBZ */
|
||||||
|
|
||||||
|
/* Define to any value to enable the 16 bit PCRE library. */
|
||||||
|
/* #undef SUPPORT_PCRE16 */
|
||||||
|
|
||||||
|
/* Define to any value to enable the 32 bit PCRE library. */
|
||||||
|
/* #undef SUPPORT_PCRE32 */
|
||||||
|
|
||||||
|
/* Define to any value to enable the 8 bit PCRE library. */
|
||||||
|
/* #undef SUPPORT_PCRE8 */
|
||||||
|
|
||||||
|
/* Define to any value to enable JIT support in pcregrep. */
|
||||||
|
/* #undef SUPPORT_PCREGREP_JIT */
|
||||||
|
|
||||||
|
/* Define to any value to enable support for Unicode properties. */
|
||||||
|
/* #undef SUPPORT_UCP */
|
||||||
|
|
||||||
|
/* Define to any value to enable support for the UTF-8/16/32 Unicode encoding.
|
||||||
|
This will work even in an EBCDIC environment, but it is incompatible with
|
||||||
|
the EBCDIC macro. That is, PCRE can support *either* EBCDIC code *or*
|
||||||
|
ASCII/UTF-8/16/32, but not both at once. */
|
||||||
|
/* #undef SUPPORT_UTF */
|
||||||
|
|
||||||
|
/* Define to any value for valgrind support to find invalid memory reads. */
|
||||||
|
/* #undef SUPPORT_VALGRIND */
|
||||||
|
|
||||||
|
/* Version number of package */
|
||||||
|
#ifndef VERSION
|
||||||
|
#define VERSION "8.39"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Define to empty if `const' does not conform to ANSI C. */
|
||||||
|
/* #undef const */
|
||||||
|
|
||||||
|
/* Define to the type of a signed integer type of width exactly 64 bits if
|
||||||
|
such a type exists and the standard includes do not define it. */
|
||||||
|
/* #undef int64_t */
|
||||||
|
|
||||||
|
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||||
|
/* #undef size_t */
|
||||||
+434
-61
@@ -1,4 +1,3 @@
|
|||||||
#include "config.h"
|
|
||||||
/*************************************************
|
/*************************************************
|
||||||
* Perl-Compatible Regular Expressions *
|
* Perl-Compatible Regular Expressions *
|
||||||
*************************************************/
|
*************************************************/
|
||||||
@@ -6,7 +5,7 @@
|
|||||||
/* This is the public header file for the PCRE library, to be #included by
|
/* This is the public header file for the PCRE library, to be #included by
|
||||||
applications that call the PCRE functions.
|
applications that call the PCRE functions.
|
||||||
|
|
||||||
Copyright (c) 1997-2007 University of Cambridge
|
Copyright (c) 1997-2014 University of Cambridge
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
@@ -42,10 +41,10 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
/* The current PCRE version information. */
|
/* The current PCRE version information. */
|
||||||
|
|
||||||
#define PCRE_MAJOR 7
|
#define PCRE_MAJOR 8
|
||||||
#define PCRE_MINOR 4
|
#define PCRE_MINOR 39
|
||||||
#define PCRE_PRERELEASE
|
#define PCRE_PRERELEASE
|
||||||
#define PCRE_DATE 2007-09-21
|
#define PCRE_DATE 2016-06-14
|
||||||
|
|
||||||
/* When an application links to a PCRE DLL in Windows, the symbols that are
|
/* When an application links to a PCRE DLL in Windows, the symbols that are
|
||||||
imported have to be identified as such. When building PCRE, the appropriate
|
imported have to be identified as such. When building PCRE, the appropriate
|
||||||
@@ -96,62 +95,162 @@ it is needed here for malloc. */
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Options */
|
/* Public options. Some are compile-time only, some are run-time only, and some
|
||||||
|
are both. Most of the compile-time options are saved with the compiled regex so
|
||||||
|
that they can be inspected during studying (and therefore JIT compiling). Note
|
||||||
|
that pcre_study() has its own set of options. Originally, all the options
|
||||||
|
defined here used distinct bits. However, almost all the bits in a 32-bit word
|
||||||
|
are now used, so in order to conserve them, option bits that were previously
|
||||||
|
only recognized at matching time (i.e. by pcre_exec() or pcre_dfa_exec()) may
|
||||||
|
also be used for compile-time options that affect only compiling and are not
|
||||||
|
relevant for studying or JIT compiling.
|
||||||
|
|
||||||
#define PCRE_CASELESS 0x00000001
|
Some options for pcre_compile() change its behaviour but do not affect the
|
||||||
#define PCRE_MULTILINE 0x00000002
|
behaviour of the execution functions. Other options are passed through to the
|
||||||
#define PCRE_DOTALL 0x00000004
|
execution functions and affect their behaviour, with or without affecting the
|
||||||
#define PCRE_EXTENDED 0x00000008
|
behaviour of pcre_compile().
|
||||||
#define PCRE_ANCHORED 0x00000010
|
|
||||||
#define PCRE_DOLLAR_ENDONLY 0x00000020
|
Options that can be passed to pcre_compile() are tagged Cx below, with these
|
||||||
#define PCRE_EXTRA 0x00000040
|
variants:
|
||||||
#define PCRE_NOTBOL 0x00000080
|
|
||||||
#define PCRE_NOTEOL 0x00000100
|
C1 Affects compile only
|
||||||
#define PCRE_UNGREEDY 0x00000200
|
C2 Does not affect compile; affects exec, dfa_exec
|
||||||
#define PCRE_NOTEMPTY 0x00000400
|
C3 Affects compile, exec, dfa_exec
|
||||||
#define PCRE_UTF8 0x00000800
|
C4 Affects compile, exec, dfa_exec, study
|
||||||
#define PCRE_NO_AUTO_CAPTURE 0x00001000
|
C5 Affects compile, exec, study
|
||||||
#define PCRE_NO_UTF8_CHECK 0x00002000
|
|
||||||
#define PCRE_AUTO_CALLOUT 0x00004000
|
Options that can be set for pcre_exec() and/or pcre_dfa_exec() are flagged with
|
||||||
#define PCRE_PARTIAL 0x00008000
|
E and D, respectively. They take precedence over C3, C4, and C5 settings passed
|
||||||
#define PCRE_DFA_SHORTEST 0x00010000
|
from pcre_compile(). Those that are compatible with JIT execution are flagged
|
||||||
#define PCRE_DFA_RESTART 0x00020000
|
with J. */
|
||||||
#define PCRE_FIRSTLINE 0x00040000
|
|
||||||
#define PCRE_DUPNAMES 0x00080000
|
#define PCRE_CASELESS 0x00000001 /* C1 */
|
||||||
#define PCRE_NEWLINE_CR 0x00100000
|
#define PCRE_MULTILINE 0x00000002 /* C1 */
|
||||||
#define PCRE_NEWLINE_LF 0x00200000
|
#define PCRE_DOTALL 0x00000004 /* C1 */
|
||||||
#define PCRE_NEWLINE_CRLF 0x00300000
|
#define PCRE_EXTENDED 0x00000008 /* C1 */
|
||||||
#define PCRE_NEWLINE_ANY 0x00400000
|
#define PCRE_ANCHORED 0x00000010 /* C4 E D */
|
||||||
#define PCRE_NEWLINE_ANYCRLF 0x00500000
|
#define PCRE_DOLLAR_ENDONLY 0x00000020 /* C2 */
|
||||||
#define PCRE_BSR_ANYCRLF 0x00800000
|
#define PCRE_EXTRA 0x00000040 /* C1 */
|
||||||
#define PCRE_BSR_UNICODE 0x01000000
|
#define PCRE_NOTBOL 0x00000080 /* E D J */
|
||||||
|
#define PCRE_NOTEOL 0x00000100 /* E D J */
|
||||||
|
#define PCRE_UNGREEDY 0x00000200 /* C1 */
|
||||||
|
#define PCRE_NOTEMPTY 0x00000400 /* E D J */
|
||||||
|
#define PCRE_UTF8 0x00000800 /* C4 ) */
|
||||||
|
#define PCRE_UTF16 0x00000800 /* C4 ) Synonyms */
|
||||||
|
#define PCRE_UTF32 0x00000800 /* C4 ) */
|
||||||
|
#define PCRE_NO_AUTO_CAPTURE 0x00001000 /* C1 */
|
||||||
|
#define PCRE_NO_UTF8_CHECK 0x00002000 /* C1 E D J ) */
|
||||||
|
#define PCRE_NO_UTF16_CHECK 0x00002000 /* C1 E D J ) Synonyms */
|
||||||
|
#define PCRE_NO_UTF32_CHECK 0x00002000 /* C1 E D J ) */
|
||||||
|
#define PCRE_AUTO_CALLOUT 0x00004000 /* C1 */
|
||||||
|
#define PCRE_PARTIAL_SOFT 0x00008000 /* E D J ) Synonyms */
|
||||||
|
#define PCRE_PARTIAL 0x00008000 /* E D J ) */
|
||||||
|
|
||||||
|
/* This pair use the same bit. */
|
||||||
|
#define PCRE_NEVER_UTF 0x00010000 /* C1 ) Overlaid */
|
||||||
|
#define PCRE_DFA_SHORTEST 0x00010000 /* D ) Overlaid */
|
||||||
|
|
||||||
|
/* This pair use the same bit. */
|
||||||
|
#define PCRE_NO_AUTO_POSSESS 0x00020000 /* C1 ) Overlaid */
|
||||||
|
#define PCRE_DFA_RESTART 0x00020000 /* D ) Overlaid */
|
||||||
|
|
||||||
|
#define PCRE_FIRSTLINE 0x00040000 /* C3 */
|
||||||
|
#define PCRE_DUPNAMES 0x00080000 /* C1 */
|
||||||
|
#define PCRE_NEWLINE_CR 0x00100000 /* C3 E D */
|
||||||
|
#define PCRE_NEWLINE_LF 0x00200000 /* C3 E D */
|
||||||
|
#define PCRE_NEWLINE_CRLF 0x00300000 /* C3 E D */
|
||||||
|
#define PCRE_NEWLINE_ANY 0x00400000 /* C3 E D */
|
||||||
|
#define PCRE_NEWLINE_ANYCRLF 0x00500000 /* C3 E D */
|
||||||
|
#define PCRE_BSR_ANYCRLF 0x00800000 /* C3 E D */
|
||||||
|
#define PCRE_BSR_UNICODE 0x01000000 /* C3 E D */
|
||||||
|
#define PCRE_JAVASCRIPT_COMPAT 0x02000000 /* C5 */
|
||||||
|
#define PCRE_NO_START_OPTIMIZE 0x04000000 /* C2 E D ) Synonyms */
|
||||||
|
#define PCRE_NO_START_OPTIMISE 0x04000000 /* C2 E D ) */
|
||||||
|
#define PCRE_PARTIAL_HARD 0x08000000 /* E D J */
|
||||||
|
#define PCRE_NOTEMPTY_ATSTART 0x10000000 /* E D J */
|
||||||
|
#define PCRE_UCP 0x20000000 /* C3 */
|
||||||
|
|
||||||
/* Exec-time and get/set-time error codes */
|
/* Exec-time and get/set-time error codes */
|
||||||
|
|
||||||
#define PCRE_ERROR_NOMATCH (-1)
|
#define PCRE_ERROR_NOMATCH (-1)
|
||||||
#define PCRE_ERROR_NULL (-2)
|
#define PCRE_ERROR_NULL (-2)
|
||||||
#define PCRE_ERROR_BADOPTION (-3)
|
#define PCRE_ERROR_BADOPTION (-3)
|
||||||
#define PCRE_ERROR_BADMAGIC (-4)
|
#define PCRE_ERROR_BADMAGIC (-4)
|
||||||
#define PCRE_ERROR_UNKNOWN_OPCODE (-5)
|
#define PCRE_ERROR_UNKNOWN_OPCODE (-5)
|
||||||
#define PCRE_ERROR_UNKNOWN_NODE (-5) /* For backward compatibility */
|
#define PCRE_ERROR_UNKNOWN_NODE (-5) /* For backward compatibility */
|
||||||
#define PCRE_ERROR_NOMEMORY (-6)
|
#define PCRE_ERROR_NOMEMORY (-6)
|
||||||
#define PCRE_ERROR_NOSUBSTRING (-7)
|
#define PCRE_ERROR_NOSUBSTRING (-7)
|
||||||
#define PCRE_ERROR_MATCHLIMIT (-8)
|
#define PCRE_ERROR_MATCHLIMIT (-8)
|
||||||
#define PCRE_ERROR_CALLOUT (-9) /* Never used by PCRE itself */
|
#define PCRE_ERROR_CALLOUT (-9) /* Never used by PCRE itself */
|
||||||
#define PCRE_ERROR_BADUTF8 (-10)
|
#define PCRE_ERROR_BADUTF8 (-10) /* Same for 8/16/32 */
|
||||||
#define PCRE_ERROR_BADUTF8_OFFSET (-11)
|
#define PCRE_ERROR_BADUTF16 (-10) /* Same for 8/16/32 */
|
||||||
#define PCRE_ERROR_PARTIAL (-12)
|
#define PCRE_ERROR_BADUTF32 (-10) /* Same for 8/16/32 */
|
||||||
#define PCRE_ERROR_BADPARTIAL (-13)
|
#define PCRE_ERROR_BADUTF8_OFFSET (-11) /* Same for 8/16 */
|
||||||
#define PCRE_ERROR_INTERNAL (-14)
|
#define PCRE_ERROR_BADUTF16_OFFSET (-11) /* Same for 8/16 */
|
||||||
#define PCRE_ERROR_BADCOUNT (-15)
|
#define PCRE_ERROR_PARTIAL (-12)
|
||||||
#define PCRE_ERROR_DFA_UITEM (-16)
|
#define PCRE_ERROR_BADPARTIAL (-13)
|
||||||
#define PCRE_ERROR_DFA_UCOND (-17)
|
#define PCRE_ERROR_INTERNAL (-14)
|
||||||
#define PCRE_ERROR_DFA_UMLIMIT (-18)
|
#define PCRE_ERROR_BADCOUNT (-15)
|
||||||
#define PCRE_ERROR_DFA_WSSIZE (-19)
|
#define PCRE_ERROR_DFA_UITEM (-16)
|
||||||
#define PCRE_ERROR_DFA_RECURSE (-20)
|
#define PCRE_ERROR_DFA_UCOND (-17)
|
||||||
#define PCRE_ERROR_RECURSIONLIMIT (-21)
|
#define PCRE_ERROR_DFA_UMLIMIT (-18)
|
||||||
#define PCRE_ERROR_NULLWSLIMIT (-22) /* No longer actually used */
|
#define PCRE_ERROR_DFA_WSSIZE (-19)
|
||||||
#define PCRE_ERROR_BADNEWLINE (-23)
|
#define PCRE_ERROR_DFA_RECURSE (-20)
|
||||||
|
#define PCRE_ERROR_RECURSIONLIMIT (-21)
|
||||||
|
#define PCRE_ERROR_NULLWSLIMIT (-22) /* No longer actually used */
|
||||||
|
#define PCRE_ERROR_BADNEWLINE (-23)
|
||||||
|
#define PCRE_ERROR_BADOFFSET (-24)
|
||||||
|
#define PCRE_ERROR_SHORTUTF8 (-25)
|
||||||
|
#define PCRE_ERROR_SHORTUTF16 (-25) /* Same for 8/16 */
|
||||||
|
#define PCRE_ERROR_RECURSELOOP (-26)
|
||||||
|
#define PCRE_ERROR_JIT_STACKLIMIT (-27)
|
||||||
|
#define PCRE_ERROR_BADMODE (-28)
|
||||||
|
#define PCRE_ERROR_BADENDIANNESS (-29)
|
||||||
|
#define PCRE_ERROR_DFA_BADRESTART (-30)
|
||||||
|
#define PCRE_ERROR_JIT_BADOPTION (-31)
|
||||||
|
#define PCRE_ERROR_BADLENGTH (-32)
|
||||||
|
#define PCRE_ERROR_UNSET (-33)
|
||||||
|
|
||||||
|
/* Specific error codes for UTF-8 validity checks */
|
||||||
|
|
||||||
|
#define PCRE_UTF8_ERR0 0
|
||||||
|
#define PCRE_UTF8_ERR1 1
|
||||||
|
#define PCRE_UTF8_ERR2 2
|
||||||
|
#define PCRE_UTF8_ERR3 3
|
||||||
|
#define PCRE_UTF8_ERR4 4
|
||||||
|
#define PCRE_UTF8_ERR5 5
|
||||||
|
#define PCRE_UTF8_ERR6 6
|
||||||
|
#define PCRE_UTF8_ERR7 7
|
||||||
|
#define PCRE_UTF8_ERR8 8
|
||||||
|
#define PCRE_UTF8_ERR9 9
|
||||||
|
#define PCRE_UTF8_ERR10 10
|
||||||
|
#define PCRE_UTF8_ERR11 11
|
||||||
|
#define PCRE_UTF8_ERR12 12
|
||||||
|
#define PCRE_UTF8_ERR13 13
|
||||||
|
#define PCRE_UTF8_ERR14 14
|
||||||
|
#define PCRE_UTF8_ERR15 15
|
||||||
|
#define PCRE_UTF8_ERR16 16
|
||||||
|
#define PCRE_UTF8_ERR17 17
|
||||||
|
#define PCRE_UTF8_ERR18 18
|
||||||
|
#define PCRE_UTF8_ERR19 19
|
||||||
|
#define PCRE_UTF8_ERR20 20
|
||||||
|
#define PCRE_UTF8_ERR21 21
|
||||||
|
#define PCRE_UTF8_ERR22 22 /* Unused (was non-character) */
|
||||||
|
|
||||||
|
/* Specific error codes for UTF-16 validity checks */
|
||||||
|
|
||||||
|
#define PCRE_UTF16_ERR0 0
|
||||||
|
#define PCRE_UTF16_ERR1 1
|
||||||
|
#define PCRE_UTF16_ERR2 2
|
||||||
|
#define PCRE_UTF16_ERR3 3
|
||||||
|
#define PCRE_UTF16_ERR4 4 /* Unused (was non-character) */
|
||||||
|
|
||||||
|
/* Specific error codes for UTF-32 validity checks */
|
||||||
|
|
||||||
|
#define PCRE_UTF32_ERR0 0
|
||||||
|
#define PCRE_UTF32_ERR1 1
|
||||||
|
#define PCRE_UTF32_ERR2 2 /* Unused (was non-character) */
|
||||||
|
#define PCRE_UTF32_ERR3 3
|
||||||
|
|
||||||
/* Request types for pcre_fullinfo() */
|
/* Request types for pcre_fullinfo() */
|
||||||
|
|
||||||
@@ -171,6 +270,17 @@ extern "C" {
|
|||||||
#define PCRE_INFO_OKPARTIAL 12
|
#define PCRE_INFO_OKPARTIAL 12
|
||||||
#define PCRE_INFO_JCHANGED 13
|
#define PCRE_INFO_JCHANGED 13
|
||||||
#define PCRE_INFO_HASCRORLF 14
|
#define PCRE_INFO_HASCRORLF 14
|
||||||
|
#define PCRE_INFO_MINLENGTH 15
|
||||||
|
#define PCRE_INFO_JIT 16
|
||||||
|
#define PCRE_INFO_JITSIZE 17
|
||||||
|
#define PCRE_INFO_MAXLOOKBEHIND 18
|
||||||
|
#define PCRE_INFO_FIRSTCHARACTER 19
|
||||||
|
#define PCRE_INFO_FIRSTCHARACTERFLAGS 20
|
||||||
|
#define PCRE_INFO_REQUIREDCHAR 21
|
||||||
|
#define PCRE_INFO_REQUIREDCHARFLAGS 22
|
||||||
|
#define PCRE_INFO_MATCHLIMIT 23
|
||||||
|
#define PCRE_INFO_RECURSIONLIMIT 24
|
||||||
|
#define PCRE_INFO_MATCH_EMPTY 25
|
||||||
|
|
||||||
/* Request types for pcre_config(). Do not re-arrange, in order to remain
|
/* Request types for pcre_config(). Do not re-arrange, in order to remain
|
||||||
compatible. */
|
compatible. */
|
||||||
@@ -184,8 +294,21 @@ compatible. */
|
|||||||
#define PCRE_CONFIG_UNICODE_PROPERTIES 6
|
#define PCRE_CONFIG_UNICODE_PROPERTIES 6
|
||||||
#define PCRE_CONFIG_MATCH_LIMIT_RECURSION 7
|
#define PCRE_CONFIG_MATCH_LIMIT_RECURSION 7
|
||||||
#define PCRE_CONFIG_BSR 8
|
#define PCRE_CONFIG_BSR 8
|
||||||
|
#define PCRE_CONFIG_JIT 9
|
||||||
|
#define PCRE_CONFIG_UTF16 10
|
||||||
|
#define PCRE_CONFIG_JITTARGET 11
|
||||||
|
#define PCRE_CONFIG_UTF32 12
|
||||||
|
#define PCRE_CONFIG_PARENS_LIMIT 13
|
||||||
|
|
||||||
/* Bit flags for the pcre_extra structure. Do not re-arrange or redefine
|
/* Request types for pcre_study(). Do not re-arrange, in order to remain
|
||||||
|
compatible. */
|
||||||
|
|
||||||
|
#define PCRE_STUDY_JIT_COMPILE 0x0001
|
||||||
|
#define PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE 0x0002
|
||||||
|
#define PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE 0x0004
|
||||||
|
#define PCRE_STUDY_EXTRA_NEEDED 0x0008
|
||||||
|
|
||||||
|
/* Bit flags for the pcre[16|32]_extra structure. Do not re-arrange or redefine
|
||||||
these bits, just add new ones on the end, in order to remain compatible. */
|
these bits, just add new ones on the end, in order to remain compatible. */
|
||||||
|
|
||||||
#define PCRE_EXTRA_STUDY_DATA 0x0001
|
#define PCRE_EXTRA_STUDY_DATA 0x0001
|
||||||
@@ -193,12 +316,51 @@ these bits, just add new ones on the end, in order to remain compatible. */
|
|||||||
#define PCRE_EXTRA_CALLOUT_DATA 0x0004
|
#define PCRE_EXTRA_CALLOUT_DATA 0x0004
|
||||||
#define PCRE_EXTRA_TABLES 0x0008
|
#define PCRE_EXTRA_TABLES 0x0008
|
||||||
#define PCRE_EXTRA_MATCH_LIMIT_RECURSION 0x0010
|
#define PCRE_EXTRA_MATCH_LIMIT_RECURSION 0x0010
|
||||||
|
#define PCRE_EXTRA_MARK 0x0020
|
||||||
|
#define PCRE_EXTRA_EXECUTABLE_JIT 0x0040
|
||||||
|
|
||||||
/* Types */
|
/* Types */
|
||||||
|
|
||||||
struct real_pcre; /* declaration; the definition is private */
|
struct real_pcre; /* declaration; the definition is private */
|
||||||
typedef struct real_pcre pcre;
|
typedef struct real_pcre pcre;
|
||||||
|
|
||||||
|
struct real_pcre16; /* declaration; the definition is private */
|
||||||
|
typedef struct real_pcre16 pcre16;
|
||||||
|
|
||||||
|
struct real_pcre32; /* declaration; the definition is private */
|
||||||
|
typedef struct real_pcre32 pcre32;
|
||||||
|
|
||||||
|
struct real_pcre_jit_stack; /* declaration; the definition is private */
|
||||||
|
typedef struct real_pcre_jit_stack pcre_jit_stack;
|
||||||
|
|
||||||
|
struct real_pcre16_jit_stack; /* declaration; the definition is private */
|
||||||
|
typedef struct real_pcre16_jit_stack pcre16_jit_stack;
|
||||||
|
|
||||||
|
struct real_pcre32_jit_stack; /* declaration; the definition is private */
|
||||||
|
typedef struct real_pcre32_jit_stack pcre32_jit_stack;
|
||||||
|
|
||||||
|
/* If PCRE is compiled with 16 bit character support, PCRE_UCHAR16 must contain
|
||||||
|
a 16 bit wide signed data type. Otherwise it can be a dummy data type since
|
||||||
|
pcre16 functions are not implemented. There is a check for this in pcre_internal.h. */
|
||||||
|
#ifndef PCRE_UCHAR16
|
||||||
|
#define PCRE_UCHAR16 unsigned short
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PCRE_SPTR16
|
||||||
|
#define PCRE_SPTR16 const PCRE_UCHAR16 *
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* If PCRE is compiled with 32 bit character support, PCRE_UCHAR32 must contain
|
||||||
|
a 32 bit wide signed data type. Otherwise it can be a dummy data type since
|
||||||
|
pcre32 functions are not implemented. There is a check for this in pcre_internal.h. */
|
||||||
|
#ifndef PCRE_UCHAR32
|
||||||
|
#define PCRE_UCHAR32 unsigned int
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PCRE_SPTR32
|
||||||
|
#define PCRE_SPTR32 const PCRE_UCHAR32 *
|
||||||
|
#endif
|
||||||
|
|
||||||
/* When PCRE is compiled as a C++ library, the subject pointer type can be
|
/* When PCRE is compiled as a C++ library, the subject pointer type can be
|
||||||
replaced with a custom type. For conventional use, the public interface is a
|
replaced with a custom type. For conventional use, the public interface is a
|
||||||
const char *. */
|
const char *. */
|
||||||
@@ -218,8 +380,36 @@ typedef struct pcre_extra {
|
|||||||
void *callout_data; /* Data passed back in callouts */
|
void *callout_data; /* Data passed back in callouts */
|
||||||
const unsigned char *tables; /* Pointer to character tables */
|
const unsigned char *tables; /* Pointer to character tables */
|
||||||
unsigned long int match_limit_recursion; /* Max recursive calls to match() */
|
unsigned long int match_limit_recursion; /* Max recursive calls to match() */
|
||||||
|
unsigned char **mark; /* For passing back a mark pointer */
|
||||||
|
void *executable_jit; /* Contains a pointer to a compiled jit code */
|
||||||
} pcre_extra;
|
} pcre_extra;
|
||||||
|
|
||||||
|
/* Same structure as above, but with 16 bit char pointers. */
|
||||||
|
|
||||||
|
typedef struct pcre16_extra {
|
||||||
|
unsigned long int flags; /* Bits for which fields are set */
|
||||||
|
void *study_data; /* Opaque data from pcre_study() */
|
||||||
|
unsigned long int match_limit; /* Maximum number of calls to match() */
|
||||||
|
void *callout_data; /* Data passed back in callouts */
|
||||||
|
const unsigned char *tables; /* Pointer to character tables */
|
||||||
|
unsigned long int match_limit_recursion; /* Max recursive calls to match() */
|
||||||
|
PCRE_UCHAR16 **mark; /* For passing back a mark pointer */
|
||||||
|
void *executable_jit; /* Contains a pointer to a compiled jit code */
|
||||||
|
} pcre16_extra;
|
||||||
|
|
||||||
|
/* Same structure as above, but with 32 bit char pointers. */
|
||||||
|
|
||||||
|
typedef struct pcre32_extra {
|
||||||
|
unsigned long int flags; /* Bits for which fields are set */
|
||||||
|
void *study_data; /* Opaque data from pcre_study() */
|
||||||
|
unsigned long int match_limit; /* Maximum number of calls to match() */
|
||||||
|
void *callout_data; /* Data passed back in callouts */
|
||||||
|
const unsigned char *tables; /* Pointer to character tables */
|
||||||
|
unsigned long int match_limit_recursion; /* Max recursive calls to match() */
|
||||||
|
PCRE_UCHAR32 **mark; /* For passing back a mark pointer */
|
||||||
|
void *executable_jit; /* Contains a pointer to a compiled jit code */
|
||||||
|
} pcre32_extra;
|
||||||
|
|
||||||
/* The structure for passing out data via the pcre_callout_function. We use a
|
/* The structure for passing out data via the pcre_callout_function. We use a
|
||||||
structure so that new fields can be added on the end in future versions,
|
structure so that new fields can be added on the end in future versions,
|
||||||
without changing the API of the function, thereby allowing old clients to work
|
without changing the API of the function, thereby allowing old clients to work
|
||||||
@@ -240,9 +430,55 @@ typedef struct pcre_callout_block {
|
|||||||
/* ------------------- Added for Version 1 -------------------------- */
|
/* ------------------- Added for Version 1 -------------------------- */
|
||||||
int pattern_position; /* Offset to next item in the pattern */
|
int pattern_position; /* Offset to next item in the pattern */
|
||||||
int next_item_length; /* Length of next item in the pattern */
|
int next_item_length; /* Length of next item in the pattern */
|
||||||
|
/* ------------------- Added for Version 2 -------------------------- */
|
||||||
|
const unsigned char *mark; /* Pointer to current mark or NULL */
|
||||||
/* ------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------ */
|
||||||
} pcre_callout_block;
|
} pcre_callout_block;
|
||||||
|
|
||||||
|
/* Same structure as above, but with 16 bit char pointers. */
|
||||||
|
|
||||||
|
typedef struct pcre16_callout_block {
|
||||||
|
int version; /* Identifies version of block */
|
||||||
|
/* ------------------------ Version 0 ------------------------------- */
|
||||||
|
int callout_number; /* Number compiled into pattern */
|
||||||
|
int *offset_vector; /* The offset vector */
|
||||||
|
PCRE_SPTR16 subject; /* The subject being matched */
|
||||||
|
int subject_length; /* The length of the subject */
|
||||||
|
int start_match; /* Offset to start of this match attempt */
|
||||||
|
int current_position; /* Where we currently are in the subject */
|
||||||
|
int capture_top; /* Max current capture */
|
||||||
|
int capture_last; /* Most recently closed capture */
|
||||||
|
void *callout_data; /* Data passed in with the call */
|
||||||
|
/* ------------------- Added for Version 1 -------------------------- */
|
||||||
|
int pattern_position; /* Offset to next item in the pattern */
|
||||||
|
int next_item_length; /* Length of next item in the pattern */
|
||||||
|
/* ------------------- Added for Version 2 -------------------------- */
|
||||||
|
const PCRE_UCHAR16 *mark; /* Pointer to current mark or NULL */
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
} pcre16_callout_block;
|
||||||
|
|
||||||
|
/* Same structure as above, but with 32 bit char pointers. */
|
||||||
|
|
||||||
|
typedef struct pcre32_callout_block {
|
||||||
|
int version; /* Identifies version of block */
|
||||||
|
/* ------------------------ Version 0 ------------------------------- */
|
||||||
|
int callout_number; /* Number compiled into pattern */
|
||||||
|
int *offset_vector; /* The offset vector */
|
||||||
|
PCRE_SPTR32 subject; /* The subject being matched */
|
||||||
|
int subject_length; /* The length of the subject */
|
||||||
|
int start_match; /* Offset to start of this match attempt */
|
||||||
|
int current_position; /* Where we currently are in the subject */
|
||||||
|
int capture_top; /* Max current capture */
|
||||||
|
int capture_last; /* Most recently closed capture */
|
||||||
|
void *callout_data; /* Data passed in with the call */
|
||||||
|
/* ------------------- Added for Version 1 -------------------------- */
|
||||||
|
int pattern_position; /* Offset to next item in the pattern */
|
||||||
|
int next_item_length; /* Length of next item in the pattern */
|
||||||
|
/* ------------------- Added for Version 2 -------------------------- */
|
||||||
|
const PCRE_UCHAR32 *mark; /* Pointer to current mark or NULL */
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
} pcre32_callout_block;
|
||||||
|
|
||||||
/* Indirection for store get and free functions. These can be set to
|
/* Indirection for store get and free functions. These can be set to
|
||||||
alternative malloc/free functions if required. Special ones are used in the
|
alternative malloc/free functions if required. Special ones are used in the
|
||||||
non-recursive case for "frames". There is also an optional callout function
|
non-recursive case for "frames". There is also an optional callout function
|
||||||
@@ -255,47 +491,184 @@ PCRE_EXP_DECL void (*pcre_free)(void *);
|
|||||||
PCRE_EXP_DECL void *(*pcre_stack_malloc)(size_t);
|
PCRE_EXP_DECL void *(*pcre_stack_malloc)(size_t);
|
||||||
PCRE_EXP_DECL void (*pcre_stack_free)(void *);
|
PCRE_EXP_DECL void (*pcre_stack_free)(void *);
|
||||||
PCRE_EXP_DECL int (*pcre_callout)(pcre_callout_block *);
|
PCRE_EXP_DECL int (*pcre_callout)(pcre_callout_block *);
|
||||||
|
PCRE_EXP_DECL int (*pcre_stack_guard)(void);
|
||||||
|
|
||||||
|
PCRE_EXP_DECL void *(*pcre16_malloc)(size_t);
|
||||||
|
PCRE_EXP_DECL void (*pcre16_free)(void *);
|
||||||
|
PCRE_EXP_DECL void *(*pcre16_stack_malloc)(size_t);
|
||||||
|
PCRE_EXP_DECL void (*pcre16_stack_free)(void *);
|
||||||
|
PCRE_EXP_DECL int (*pcre16_callout)(pcre16_callout_block *);
|
||||||
|
PCRE_EXP_DECL int (*pcre16_stack_guard)(void);
|
||||||
|
|
||||||
|
PCRE_EXP_DECL void *(*pcre32_malloc)(size_t);
|
||||||
|
PCRE_EXP_DECL void (*pcre32_free)(void *);
|
||||||
|
PCRE_EXP_DECL void *(*pcre32_stack_malloc)(size_t);
|
||||||
|
PCRE_EXP_DECL void (*pcre32_stack_free)(void *);
|
||||||
|
PCRE_EXP_DECL int (*pcre32_callout)(pcre32_callout_block *);
|
||||||
|
PCRE_EXP_DECL int (*pcre32_stack_guard)(void);
|
||||||
#else /* VPCOMPAT */
|
#else /* VPCOMPAT */
|
||||||
PCRE_EXP_DECL void *pcre_malloc(size_t);
|
PCRE_EXP_DECL void *pcre_malloc(size_t);
|
||||||
PCRE_EXP_DECL void pcre_free(void *);
|
PCRE_EXP_DECL void pcre_free(void *);
|
||||||
PCRE_EXP_DECL void *pcre_stack_malloc(size_t);
|
PCRE_EXP_DECL void *pcre_stack_malloc(size_t);
|
||||||
PCRE_EXP_DECL void pcre_stack_free(void *);
|
PCRE_EXP_DECL void pcre_stack_free(void *);
|
||||||
PCRE_EXP_DECL int pcre_callout(pcre_callout_block *);
|
PCRE_EXP_DECL int pcre_callout(pcre_callout_block *);
|
||||||
|
PCRE_EXP_DECL int pcre_stack_guard(void);
|
||||||
|
|
||||||
|
PCRE_EXP_DECL void *pcre16_malloc(size_t);
|
||||||
|
PCRE_EXP_DECL void pcre16_free(void *);
|
||||||
|
PCRE_EXP_DECL void *pcre16_stack_malloc(size_t);
|
||||||
|
PCRE_EXP_DECL void pcre16_stack_free(void *);
|
||||||
|
PCRE_EXP_DECL int pcre16_callout(pcre16_callout_block *);
|
||||||
|
PCRE_EXP_DECL int pcre16_stack_guard(void);
|
||||||
|
|
||||||
|
PCRE_EXP_DECL void *pcre32_malloc(size_t);
|
||||||
|
PCRE_EXP_DECL void pcre32_free(void *);
|
||||||
|
PCRE_EXP_DECL void *pcre32_stack_malloc(size_t);
|
||||||
|
PCRE_EXP_DECL void pcre32_stack_free(void *);
|
||||||
|
PCRE_EXP_DECL int pcre32_callout(pcre32_callout_block *);
|
||||||
|
PCRE_EXP_DECL int pcre32_stack_guard(void);
|
||||||
#endif /* VPCOMPAT */
|
#endif /* VPCOMPAT */
|
||||||
|
|
||||||
|
/* User defined callback which provides a stack just before the match starts. */
|
||||||
|
|
||||||
|
typedef pcre_jit_stack *(*pcre_jit_callback)(void *);
|
||||||
|
typedef pcre16_jit_stack *(*pcre16_jit_callback)(void *);
|
||||||
|
typedef pcre32_jit_stack *(*pcre32_jit_callback)(void *);
|
||||||
|
|
||||||
/* Exported PCRE functions */
|
/* Exported PCRE functions */
|
||||||
|
|
||||||
PCRE_EXP_DECL pcre *pcre_compile(const char *, int, const char **, int *,
|
PCRE_EXP_DECL pcre *pcre_compile(const char *, int, const char **, int *,
|
||||||
const unsigned char *);
|
const unsigned char *);
|
||||||
|
PCRE_EXP_DECL pcre16 *pcre16_compile(PCRE_SPTR16, int, const char **, int *,
|
||||||
|
const unsigned char *);
|
||||||
|
PCRE_EXP_DECL pcre32 *pcre32_compile(PCRE_SPTR32, int, const char **, int *,
|
||||||
|
const unsigned char *);
|
||||||
PCRE_EXP_DECL pcre *pcre_compile2(const char *, int, int *, const char **,
|
PCRE_EXP_DECL pcre *pcre_compile2(const char *, int, int *, const char **,
|
||||||
int *, const unsigned char *);
|
int *, const unsigned char *);
|
||||||
|
PCRE_EXP_DECL pcre16 *pcre16_compile2(PCRE_SPTR16, int, int *, const char **,
|
||||||
|
int *, const unsigned char *);
|
||||||
|
PCRE_EXP_DECL pcre32 *pcre32_compile2(PCRE_SPTR32, int, int *, const char **,
|
||||||
|
int *, const unsigned char *);
|
||||||
PCRE_EXP_DECL int pcre_config(int, void *);
|
PCRE_EXP_DECL int pcre_config(int, void *);
|
||||||
|
PCRE_EXP_DECL int pcre16_config(int, void *);
|
||||||
|
PCRE_EXP_DECL int pcre32_config(int, void *);
|
||||||
PCRE_EXP_DECL int pcre_copy_named_substring(const pcre *, const char *,
|
PCRE_EXP_DECL int pcre_copy_named_substring(const pcre *, const char *,
|
||||||
int *, int, const char *, char *, int);
|
int *, int, const char *, char *, int);
|
||||||
PCRE_EXP_DECL int pcre_copy_substring(const char *, int *, int, int, char *,
|
PCRE_EXP_DECL int pcre16_copy_named_substring(const pcre16 *, PCRE_SPTR16,
|
||||||
int);
|
int *, int, PCRE_SPTR16, PCRE_UCHAR16 *, int);
|
||||||
|
PCRE_EXP_DECL int pcre32_copy_named_substring(const pcre32 *, PCRE_SPTR32,
|
||||||
|
int *, int, PCRE_SPTR32, PCRE_UCHAR32 *, int);
|
||||||
|
PCRE_EXP_DECL int pcre_copy_substring(const char *, int *, int, int,
|
||||||
|
char *, int);
|
||||||
|
PCRE_EXP_DECL int pcre16_copy_substring(PCRE_SPTR16, int *, int, int,
|
||||||
|
PCRE_UCHAR16 *, int);
|
||||||
|
PCRE_EXP_DECL int pcre32_copy_substring(PCRE_SPTR32, int *, int, int,
|
||||||
|
PCRE_UCHAR32 *, int);
|
||||||
PCRE_EXP_DECL int pcre_dfa_exec(const pcre *, const pcre_extra *,
|
PCRE_EXP_DECL int pcre_dfa_exec(const pcre *, const pcre_extra *,
|
||||||
const char *, int, int, int, int *, int , int *, int);
|
const char *, int, int, int, int *, int , int *, int);
|
||||||
|
PCRE_EXP_DECL int pcre16_dfa_exec(const pcre16 *, const pcre16_extra *,
|
||||||
|
PCRE_SPTR16, int, int, int, int *, int , int *, int);
|
||||||
|
PCRE_EXP_DECL int pcre32_dfa_exec(const pcre32 *, const pcre32_extra *,
|
||||||
|
PCRE_SPTR32, int, int, int, int *, int , int *, int);
|
||||||
PCRE_EXP_DECL int pcre_exec(const pcre *, const pcre_extra *, PCRE_SPTR,
|
PCRE_EXP_DECL int pcre_exec(const pcre *, const pcre_extra *, PCRE_SPTR,
|
||||||
int, int, int, int *, int);
|
int, int, int, int *, int);
|
||||||
|
PCRE_EXP_DECL int pcre16_exec(const pcre16 *, const pcre16_extra *,
|
||||||
|
PCRE_SPTR16, int, int, int, int *, int);
|
||||||
|
PCRE_EXP_DECL int pcre32_exec(const pcre32 *, const pcre32_extra *,
|
||||||
|
PCRE_SPTR32, int, int, int, int *, int);
|
||||||
|
PCRE_EXP_DECL int pcre_jit_exec(const pcre *, const pcre_extra *,
|
||||||
|
PCRE_SPTR, int, int, int, int *, int,
|
||||||
|
pcre_jit_stack *);
|
||||||
|
PCRE_EXP_DECL int pcre16_jit_exec(const pcre16 *, const pcre16_extra *,
|
||||||
|
PCRE_SPTR16, int, int, int, int *, int,
|
||||||
|
pcre16_jit_stack *);
|
||||||
|
PCRE_EXP_DECL int pcre32_jit_exec(const pcre32 *, const pcre32_extra *,
|
||||||
|
PCRE_SPTR32, int, int, int, int *, int,
|
||||||
|
pcre32_jit_stack *);
|
||||||
PCRE_EXP_DECL void pcre_free_substring(const char *);
|
PCRE_EXP_DECL void pcre_free_substring(const char *);
|
||||||
|
PCRE_EXP_DECL void pcre16_free_substring(PCRE_SPTR16);
|
||||||
|
PCRE_EXP_DECL void pcre32_free_substring(PCRE_SPTR32);
|
||||||
PCRE_EXP_DECL void pcre_free_substring_list(const char **);
|
PCRE_EXP_DECL void pcre_free_substring_list(const char **);
|
||||||
|
PCRE_EXP_DECL void pcre16_free_substring_list(PCRE_SPTR16 *);
|
||||||
|
PCRE_EXP_DECL void pcre32_free_substring_list(PCRE_SPTR32 *);
|
||||||
PCRE_EXP_DECL int pcre_fullinfo(const pcre *, const pcre_extra *, int,
|
PCRE_EXP_DECL int pcre_fullinfo(const pcre *, const pcre_extra *, int,
|
||||||
void *);
|
void *);
|
||||||
|
PCRE_EXP_DECL int pcre16_fullinfo(const pcre16 *, const pcre16_extra *, int,
|
||||||
|
void *);
|
||||||
|
PCRE_EXP_DECL int pcre32_fullinfo(const pcre32 *, const pcre32_extra *, int,
|
||||||
|
void *);
|
||||||
PCRE_EXP_DECL int pcre_get_named_substring(const pcre *, const char *,
|
PCRE_EXP_DECL int pcre_get_named_substring(const pcre *, const char *,
|
||||||
int *, int, const char *, const char **);
|
int *, int, const char *, const char **);
|
||||||
|
PCRE_EXP_DECL int pcre16_get_named_substring(const pcre16 *, PCRE_SPTR16,
|
||||||
|
int *, int, PCRE_SPTR16, PCRE_SPTR16 *);
|
||||||
|
PCRE_EXP_DECL int pcre32_get_named_substring(const pcre32 *, PCRE_SPTR32,
|
||||||
|
int *, int, PCRE_SPTR32, PCRE_SPTR32 *);
|
||||||
PCRE_EXP_DECL int pcre_get_stringnumber(const pcre *, const char *);
|
PCRE_EXP_DECL int pcre_get_stringnumber(const pcre *, const char *);
|
||||||
|
PCRE_EXP_DECL int pcre16_get_stringnumber(const pcre16 *, PCRE_SPTR16);
|
||||||
|
PCRE_EXP_DECL int pcre32_get_stringnumber(const pcre32 *, PCRE_SPTR32);
|
||||||
PCRE_EXP_DECL int pcre_get_stringtable_entries(const pcre *, const char *,
|
PCRE_EXP_DECL int pcre_get_stringtable_entries(const pcre *, const char *,
|
||||||
char **, char **);
|
char **, char **);
|
||||||
|
PCRE_EXP_DECL int pcre16_get_stringtable_entries(const pcre16 *, PCRE_SPTR16,
|
||||||
|
PCRE_UCHAR16 **, PCRE_UCHAR16 **);
|
||||||
|
PCRE_EXP_DECL int pcre32_get_stringtable_entries(const pcre32 *, PCRE_SPTR32,
|
||||||
|
PCRE_UCHAR32 **, PCRE_UCHAR32 **);
|
||||||
PCRE_EXP_DECL int pcre_get_substring(const char *, int *, int, int,
|
PCRE_EXP_DECL int pcre_get_substring(const char *, int *, int, int,
|
||||||
const char **);
|
const char **);
|
||||||
|
PCRE_EXP_DECL int pcre16_get_substring(PCRE_SPTR16, int *, int, int,
|
||||||
|
PCRE_SPTR16 *);
|
||||||
|
PCRE_EXP_DECL int pcre32_get_substring(PCRE_SPTR32, int *, int, int,
|
||||||
|
PCRE_SPTR32 *);
|
||||||
PCRE_EXP_DECL int pcre_get_substring_list(const char *, int *, int,
|
PCRE_EXP_DECL int pcre_get_substring_list(const char *, int *, int,
|
||||||
const char ***);
|
const char ***);
|
||||||
PCRE_EXP_DECL int pcre_info(const pcre *, int *, int *);
|
PCRE_EXP_DECL int pcre16_get_substring_list(PCRE_SPTR16, int *, int,
|
||||||
|
PCRE_SPTR16 **);
|
||||||
|
PCRE_EXP_DECL int pcre32_get_substring_list(PCRE_SPTR32, int *, int,
|
||||||
|
PCRE_SPTR32 **);
|
||||||
PCRE_EXP_DECL const unsigned char *pcre_maketables(void);
|
PCRE_EXP_DECL const unsigned char *pcre_maketables(void);
|
||||||
|
PCRE_EXP_DECL const unsigned char *pcre16_maketables(void);
|
||||||
|
PCRE_EXP_DECL const unsigned char *pcre32_maketables(void);
|
||||||
PCRE_EXP_DECL int pcre_refcount(pcre *, int);
|
PCRE_EXP_DECL int pcre_refcount(pcre *, int);
|
||||||
|
PCRE_EXP_DECL int pcre16_refcount(pcre16 *, int);
|
||||||
|
PCRE_EXP_DECL int pcre32_refcount(pcre32 *, int);
|
||||||
PCRE_EXP_DECL pcre_extra *pcre_study(const pcre *, int, const char **);
|
PCRE_EXP_DECL pcre_extra *pcre_study(const pcre *, int, const char **);
|
||||||
|
PCRE_EXP_DECL pcre16_extra *pcre16_study(const pcre16 *, int, const char **);
|
||||||
|
PCRE_EXP_DECL pcre32_extra *pcre32_study(const pcre32 *, int, const char **);
|
||||||
|
PCRE_EXP_DECL void pcre_free_study(pcre_extra *);
|
||||||
|
PCRE_EXP_DECL void pcre16_free_study(pcre16_extra *);
|
||||||
|
PCRE_EXP_DECL void pcre32_free_study(pcre32_extra *);
|
||||||
PCRE_EXP_DECL const char *pcre_version(void);
|
PCRE_EXP_DECL const char *pcre_version(void);
|
||||||
|
PCRE_EXP_DECL const char *pcre16_version(void);
|
||||||
|
PCRE_EXP_DECL const char *pcre32_version(void);
|
||||||
|
|
||||||
|
/* Utility functions for byte order swaps. */
|
||||||
|
PCRE_EXP_DECL int pcre_pattern_to_host_byte_order(pcre *, pcre_extra *,
|
||||||
|
const unsigned char *);
|
||||||
|
PCRE_EXP_DECL int pcre16_pattern_to_host_byte_order(pcre16 *, pcre16_extra *,
|
||||||
|
const unsigned char *);
|
||||||
|
PCRE_EXP_DECL int pcre32_pattern_to_host_byte_order(pcre32 *, pcre32_extra *,
|
||||||
|
const unsigned char *);
|
||||||
|
PCRE_EXP_DECL int pcre16_utf16_to_host_byte_order(PCRE_UCHAR16 *,
|
||||||
|
PCRE_SPTR16, int, int *, int);
|
||||||
|
PCRE_EXP_DECL int pcre32_utf32_to_host_byte_order(PCRE_UCHAR32 *,
|
||||||
|
PCRE_SPTR32, int, int *, int);
|
||||||
|
|
||||||
|
/* JIT compiler related functions. */
|
||||||
|
|
||||||
|
PCRE_EXP_DECL pcre_jit_stack *pcre_jit_stack_alloc(int, int);
|
||||||
|
PCRE_EXP_DECL pcre16_jit_stack *pcre16_jit_stack_alloc(int, int);
|
||||||
|
PCRE_EXP_DECL pcre32_jit_stack *pcre32_jit_stack_alloc(int, int);
|
||||||
|
PCRE_EXP_DECL void pcre_jit_stack_free(pcre_jit_stack *);
|
||||||
|
PCRE_EXP_DECL void pcre16_jit_stack_free(pcre16_jit_stack *);
|
||||||
|
PCRE_EXP_DECL void pcre32_jit_stack_free(pcre32_jit_stack *);
|
||||||
|
PCRE_EXP_DECL void pcre_assign_jit_stack(pcre_extra *,
|
||||||
|
pcre_jit_callback, void *);
|
||||||
|
PCRE_EXP_DECL void pcre16_assign_jit_stack(pcre16_extra *,
|
||||||
|
pcre16_jit_callback, void *);
|
||||||
|
PCRE_EXP_DECL void pcre32_assign_jit_stack(pcre32_extra *,
|
||||||
|
pcre32_jit_callback, void *);
|
||||||
|
PCRE_EXP_DECL void pcre_jit_free_unused_memory(void);
|
||||||
|
PCRE_EXP_DECL void pcre16_jit_free_unused_memory(void);
|
||||||
|
PCRE_EXP_DECL void pcre32_jit_free_unused_memory(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
|
|||||||
+6200
-2595
File diff suppressed because it is too large.
Load diff
@@ -1,3 +1,4 @@
|
|||||||
|
#define HAVE_CONFIG_H
|
||||||
/*************************************************
|
/*************************************************
|
||||||
* Perl-Compatible Regular Expressions *
|
* Perl-Compatible Regular Expressions *
|
||||||
*************************************************/
|
*************************************************/
|
||||||
@@ -6,7 +7,7 @@
|
|||||||
and semantics are as close as possible to those of the Perl 5 language.
|
and semantics are as close as possible to those of the Perl 5 language.
|
||||||
|
|
||||||
Written by Philip Hazel
|
Written by Philip Hazel
|
||||||
Copyright (c) 1997-2007 University of Cambridge
|
Copyright (c) 1997-2012 University of Cambridge
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
@@ -45,6 +46,9 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Keep the original link size. */
|
||||||
|
static int real_link_size = LINK_SIZE;
|
||||||
|
|
||||||
#include "pcre_internal.h"
|
#include "pcre_internal.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -62,18 +66,57 @@ Arguments:
|
|||||||
Returns: 0 if data returned, negative on error
|
Returns: 0 if data returned, negative on error
|
||||||
*/
|
*/
|
||||||
|
|
||||||
PCRE_EXP_DEFN int
|
#if defined COMPILE_PCRE8
|
||||||
|
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
|
||||||
pcre_config(int what, void *where)
|
pcre_config(int what, void *where)
|
||||||
|
#elif defined COMPILE_PCRE16
|
||||||
|
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
|
||||||
|
pcre16_config(int what, void *where)
|
||||||
|
#elif defined COMPILE_PCRE32
|
||||||
|
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
|
||||||
|
pcre32_config(int what, void *where)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
switch (what)
|
switch (what)
|
||||||
{
|
{
|
||||||
case PCRE_CONFIG_UTF8:
|
case PCRE_CONFIG_UTF8:
|
||||||
#ifdef SUPPORT_UTF8
|
#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
|
||||||
|
*((int *)where) = 0;
|
||||||
|
return PCRE_ERROR_BADOPTION;
|
||||||
|
#else
|
||||||
|
#if defined SUPPORT_UTF
|
||||||
*((int *)where) = 1;
|
*((int *)where) = 1;
|
||||||
#else
|
#else
|
||||||
*((int *)where) = 0;
|
*((int *)where) = 0;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
case PCRE_CONFIG_UTF16:
|
||||||
|
#if defined COMPILE_PCRE8 || defined COMPILE_PCRE32
|
||||||
|
*((int *)where) = 0;
|
||||||
|
return PCRE_ERROR_BADOPTION;
|
||||||
|
#else
|
||||||
|
#if defined SUPPORT_UTF
|
||||||
|
*((int *)where) = 1;
|
||||||
|
#else
|
||||||
|
*((int *)where) = 0;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
case PCRE_CONFIG_UTF32:
|
||||||
|
#if defined COMPILE_PCRE8 || defined COMPILE_PCRE16
|
||||||
|
*((int *)where) = 0;
|
||||||
|
return PCRE_ERROR_BADOPTION;
|
||||||
|
#else
|
||||||
|
#if defined SUPPORT_UTF
|
||||||
|
*((int *)where) = 1;
|
||||||
|
#else
|
||||||
|
*((int *)where) = 0;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
case PCRE_CONFIG_UNICODE_PROPERTIES:
|
case PCRE_CONFIG_UNICODE_PROPERTIES:
|
||||||
#ifdef SUPPORT_UCP
|
#ifdef SUPPORT_UCP
|
||||||
@@ -83,6 +126,22 @@ switch (what)
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PCRE_CONFIG_JIT:
|
||||||
|
#ifdef SUPPORT_JIT
|
||||||
|
*((int *)where) = 1;
|
||||||
|
#else
|
||||||
|
*((int *)where) = 0;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PCRE_CONFIG_JITTARGET:
|
||||||
|
#ifdef SUPPORT_JIT
|
||||||
|
*((const char **)where) = PRIV(jit_get_target)();
|
||||||
|
#else
|
||||||
|
*((const char **)where) = NULL;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
|
||||||
case PCRE_CONFIG_NEWLINE:
|
case PCRE_CONFIG_NEWLINE:
|
||||||
*((int *)where) = NEWLINE;
|
*((int *)where) = NEWLINE;
|
||||||
break;
|
break;
|
||||||
@@ -96,19 +155,23 @@ switch (what)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PCRE_CONFIG_LINK_SIZE:
|
case PCRE_CONFIG_LINK_SIZE:
|
||||||
*((int *)where) = LINK_SIZE;
|
*((int *)where) = real_link_size;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PCRE_CONFIG_POSIX_MALLOC_THRESHOLD:
|
case PCRE_CONFIG_POSIX_MALLOC_THRESHOLD:
|
||||||
*((int *)where) = POSIX_MALLOC_THRESHOLD;
|
*((int *)where) = POSIX_MALLOC_THRESHOLD;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PCRE_CONFIG_PARENS_LIMIT:
|
||||||
|
*((unsigned long int *)where) = PARENS_NEST_LIMIT;
|
||||||
|
break;
|
||||||
|
|
||||||
case PCRE_CONFIG_MATCH_LIMIT:
|
case PCRE_CONFIG_MATCH_LIMIT:
|
||||||
*((unsigned int *)where) = MATCH_LIMIT;
|
*((unsigned long int *)where) = MATCH_LIMIT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PCRE_CONFIG_MATCH_LIMIT_RECURSION:
|
case PCRE_CONFIG_MATCH_LIMIT_RECURSION:
|
||||||
*((unsigned int *)where) = MATCH_LIMIT_RECURSION;
|
*((unsigned long int *)where) = MATCH_LIMIT_RECURSION;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PCRE_CONFIG_STACKRECURSE:
|
case PCRE_CONFIG_STACKRECURSE:
|
||||||
|
|||||||
+1486
-707
File diff suppressed because it is too large.
Load diff
+3966
-1730
File diff suppressed because it is too large.
Load diff
@@ -1,12 +1,13 @@
|
|||||||
|
#define HAVE_CONFIG_H
|
||||||
/*************************************************
|
/*************************************************
|
||||||
* Perl-Compatible Regular Expressions *
|
* Perl-Compatible Regular Expressions *
|
||||||
*************************************************/
|
*************************************************/
|
||||||
|
|
||||||
/*PCRE is a library of functions to support regular expressions whose syntax
|
/* PCRE is a library of functions to support regular expressions whose syntax
|
||||||
and semantics are as close as possible to those of the Perl 5 language.
|
and semantics are as close as possible to those of the Perl 5 language.
|
||||||
|
|
||||||
Written by Philip Hazel
|
Written by Philip Hazel
|
||||||
Copyright (c) 1997-2007 University of Cambridge
|
Copyright (c) 1997-2013 University of Cambridge
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
@@ -65,13 +66,21 @@ Arguments:
|
|||||||
Returns: 0 if data returned, negative on error
|
Returns: 0 if data returned, negative on error
|
||||||
*/
|
*/
|
||||||
|
|
||||||
PCRE_EXP_DEFN int
|
#if defined COMPILE_PCRE8
|
||||||
pcre_fullinfo(const pcre *argument_re, const pcre_extra *extra_data, int what,
|
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
|
||||||
void *where)
|
pcre_fullinfo(const pcre *argument_re, const pcre_extra *extra_data,
|
||||||
|
int what, void *where)
|
||||||
|
#elif defined COMPILE_PCRE16
|
||||||
|
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
|
||||||
|
pcre16_fullinfo(const pcre16 *argument_re, const pcre16_extra *extra_data,
|
||||||
|
int what, void *where)
|
||||||
|
#elif defined COMPILE_PCRE32
|
||||||
|
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
|
||||||
|
pcre32_fullinfo(const pcre32 *argument_re, const pcre32_extra *extra_data,
|
||||||
|
int what, void *where)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
real_pcre internal_re;
|
const REAL_PCRE *re = (const REAL_PCRE *)argument_re;
|
||||||
pcre_study_data internal_study;
|
|
||||||
const real_pcre *re = (const real_pcre *)argument_re;
|
|
||||||
const pcre_study_data *study = NULL;
|
const pcre_study_data *study = NULL;
|
||||||
|
|
||||||
if (re == NULL || where == NULL) return PCRE_ERROR_NULL;
|
if (re == NULL || where == NULL) return PCRE_ERROR_NULL;
|
||||||
@@ -79,17 +88,23 @@ if (re == NULL || where == NULL) return PCRE_ERROR_NULL;
|
|||||||
if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_STUDY_DATA) != 0)
|
if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_STUDY_DATA) != 0)
|
||||||
study = (const pcre_study_data *)extra_data->study_data;
|
study = (const pcre_study_data *)extra_data->study_data;
|
||||||
|
|
||||||
|
/* Check that the first field in the block is the magic number. If it is not,
|
||||||
|
return with PCRE_ERROR_BADMAGIC. However, if the magic number is equal to
|
||||||
|
REVERSED_MAGIC_NUMBER we return with PCRE_ERROR_BADENDIANNESS, which
|
||||||
|
means that the pattern is likely compiled with different endianness. */
|
||||||
|
|
||||||
if (re->magic_number != MAGIC_NUMBER)
|
if (re->magic_number != MAGIC_NUMBER)
|
||||||
{
|
return re->magic_number == REVERSED_MAGIC_NUMBER?
|
||||||
re = _pcre_try_flipped(re, &internal_re, study, &internal_study);
|
PCRE_ERROR_BADENDIANNESS:PCRE_ERROR_BADMAGIC;
|
||||||
if (re == NULL) return PCRE_ERROR_BADMAGIC;
|
|
||||||
if (study != NULL) study = &internal_study;
|
/* Check that this pattern was compiled in the correct bit mode */
|
||||||
}
|
|
||||||
|
if ((re->flags & PCRE_MODE) == 0) return PCRE_ERROR_BADMODE;
|
||||||
|
|
||||||
switch (what)
|
switch (what)
|
||||||
{
|
{
|
||||||
case PCRE_INFO_OPTIONS:
|
case PCRE_INFO_OPTIONS:
|
||||||
*((unsigned long int *)where) = re->options & PUBLIC_OPTIONS;
|
*((unsigned long int *)where) = re->options & PUBLIC_COMPILE_OPTIONS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PCRE_INFO_SIZE:
|
case PCRE_INFO_SIZE:
|
||||||
@@ -100,6 +115,18 @@ switch (what)
|
|||||||
*((size_t *)where) = (study == NULL)? 0 : study->size;
|
*((size_t *)where) = (study == NULL)? 0 : study->size;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PCRE_INFO_JITSIZE:
|
||||||
|
#ifdef SUPPORT_JIT
|
||||||
|
*((size_t *)where) =
|
||||||
|
(extra_data != NULL &&
|
||||||
|
(extra_data->flags & PCRE_EXTRA_EXECUTABLE_JIT) != 0 &&
|
||||||
|
extra_data->executable_jit != NULL)?
|
||||||
|
PRIV(jit_get_size)(extra_data->executable_jit) : 0;
|
||||||
|
#else
|
||||||
|
*((size_t *)where) = 0;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
|
||||||
case PCRE_INFO_CAPTURECOUNT:
|
case PCRE_INFO_CAPTURECOUNT:
|
||||||
*((int *)where) = re->top_bracket;
|
*((int *)where) = re->top_bracket;
|
||||||
break;
|
break;
|
||||||
@@ -110,24 +137,57 @@ switch (what)
|
|||||||
|
|
||||||
case PCRE_INFO_FIRSTBYTE:
|
case PCRE_INFO_FIRSTBYTE:
|
||||||
*((int *)where) =
|
*((int *)where) =
|
||||||
((re->flags & PCRE_FIRSTSET) != 0)? re->first_byte :
|
((re->flags & PCRE_FIRSTSET) != 0)? (int)re->first_char :
|
||||||
((re->flags & PCRE_STARTLINE) != 0)? -1 : -2;
|
((re->flags & PCRE_STARTLINE) != 0)? -1 : -2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PCRE_INFO_FIRSTCHARACTER:
|
||||||
|
*((pcre_uint32 *)where) =
|
||||||
|
(re->flags & PCRE_FIRSTSET) != 0 ? re->first_char : 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PCRE_INFO_FIRSTCHARACTERFLAGS:
|
||||||
|
*((int *)where) =
|
||||||
|
((re->flags & PCRE_FIRSTSET) != 0) ? 1 :
|
||||||
|
((re->flags & PCRE_STARTLINE) != 0) ? 2 : 0;
|
||||||
|
break;
|
||||||
|
|
||||||
/* Make sure we pass back the pointer to the bit vector in the external
|
/* Make sure we pass back the pointer to the bit vector in the external
|
||||||
block, not the internal copy (with flipped integer fields). */
|
block, not the internal copy (with flipped integer fields). */
|
||||||
|
|
||||||
case PCRE_INFO_FIRSTTABLE:
|
case PCRE_INFO_FIRSTTABLE:
|
||||||
*((const uschar **)where) =
|
*((const pcre_uint8 **)where) =
|
||||||
(study != NULL && (study->options & PCRE_STUDY_MAPPED) != 0)?
|
(study != NULL && (study->flags & PCRE_STUDY_MAPPED) != 0)?
|
||||||
((const pcre_study_data *)extra_data->study_data)->start_bits : NULL;
|
((const pcre_study_data *)extra_data->study_data)->start_bits : NULL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PCRE_INFO_MINLENGTH:
|
||||||
|
*((int *)where) =
|
||||||
|
(study != NULL && (study->flags & PCRE_STUDY_MINLEN) != 0)?
|
||||||
|
(int)(study->minlength) : -1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PCRE_INFO_JIT:
|
||||||
|
*((int *)where) = extra_data != NULL &&
|
||||||
|
(extra_data->flags & PCRE_EXTRA_EXECUTABLE_JIT) != 0 &&
|
||||||
|
extra_data->executable_jit != NULL;
|
||||||
|
break;
|
||||||
|
|
||||||
case PCRE_INFO_LASTLITERAL:
|
case PCRE_INFO_LASTLITERAL:
|
||||||
*((int *)where) =
|
*((int *)where) =
|
||||||
((re->flags & PCRE_REQCHSET) != 0)? re->req_byte : -1;
|
((re->flags & PCRE_REQCHSET) != 0)? (int)re->req_char : -1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PCRE_INFO_REQUIREDCHAR:
|
||||||
|
*((pcre_uint32 *)where) =
|
||||||
|
((re->flags & PCRE_REQCHSET) != 0) ? re->req_char : 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PCRE_INFO_REQUIREDCHARFLAGS:
|
||||||
|
*((int *)where) =
|
||||||
|
((re->flags & PCRE_REQCHSET) != 0);
|
||||||
|
break;
|
||||||
|
|
||||||
case PCRE_INFO_NAMEENTRYSIZE:
|
case PCRE_INFO_NAMEENTRYSIZE:
|
||||||
*((int *)where) = re->name_entry_size;
|
*((int *)where) = re->name_entry_size;
|
||||||
break;
|
break;
|
||||||
@@ -137,13 +197,16 @@ switch (what)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PCRE_INFO_NAMETABLE:
|
case PCRE_INFO_NAMETABLE:
|
||||||
*((const uschar **)where) = (const uschar *)re + re->name_table_offset;
|
*((const pcre_uchar **)where) = (const pcre_uchar *)re + re->name_table_offset;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PCRE_INFO_DEFAULT_TABLES:
|
case PCRE_INFO_DEFAULT_TABLES:
|
||||||
*((const uschar **)where) = (const uschar *)(_pcre_default_tables);
|
*((const pcre_uint8 **)where) = (const pcre_uint8 *)(PRIV(default_tables));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
/* From release 8.00 this will always return TRUE because NOPARTIAL is
|
||||||
|
no longer ever set (the restrictions have been removed). */
|
||||||
|
|
||||||
case PCRE_INFO_OKPARTIAL:
|
case PCRE_INFO_OKPARTIAL:
|
||||||
*((int *)where) = (re->flags & PCRE_NOPARTIAL) == 0;
|
*((int *)where) = (re->flags & PCRE_NOPARTIAL) == 0;
|
||||||
break;
|
break;
|
||||||
@@ -156,6 +219,24 @@ switch (what)
|
|||||||
*((int *)where) = (re->flags & PCRE_HASCRORLF) != 0;
|
*((int *)where) = (re->flags & PCRE_HASCRORLF) != 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PCRE_INFO_MAXLOOKBEHIND:
|
||||||
|
*((int *)where) = re->max_lookbehind;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PCRE_INFO_MATCHLIMIT:
|
||||||
|
if ((re->flags & PCRE_MLSET) == 0) return PCRE_ERROR_UNSET;
|
||||||
|
*((pcre_uint32 *)where) = re->limit_match;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PCRE_INFO_RECURSIONLIMIT:
|
||||||
|
if ((re->flags & PCRE_RLSET) == 0) return PCRE_ERROR_UNSET;
|
||||||
|
*((pcre_uint32 *)where) = re->limit_recursion;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PCRE_INFO_MATCH_EMPTY:
|
||||||
|
*((int *)where) = (re->flags & PCRE_MATCH_EMPTY) != 0;
|
||||||
|
break;
|
||||||
|
|
||||||
default: return PCRE_ERROR_BADOPTION;
|
default: return PCRE_ERROR_BADOPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loaded 100 of 147 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user