mirror of
https://github.com/3proxy/3proxy.git
synced 2026-04-13 00:10:11 +08:00
Compare commits
No commits in common. "9412071f1aa0985acc1404c3902f1cf8692b4f7e" and "7ea4e9b8c2fcc41bcea770041ee066c26e791e27" have entirely different histories.
9412071f1a
...
7ea4e9b8c2
34
.github/workflows/build-rpm-arm64.yml
vendored
34
.github/workflows/build-rpm-arm64.yml
vendored
@ -1,4 +1,4 @@
|
||||
name: RPM build arm64
|
||||
name: RPM build arm
|
||||
|
||||
on:
|
||||
push:
|
||||
@ -11,7 +11,7 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
target:
|
||||
- ubuntu-24.04-arm
|
||||
- ubuntu-latest
|
||||
runs-on: ${{ matrix.target }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@ -23,12 +23,33 @@ jobs:
|
||||
echo "MAJOR=$(cat RELEASE | cut -d "-" -f 1)" >> $GITHUB_ENV
|
||||
echo "SUBMAJOR=$(cat RELEASE | cut -d "-" -f 2)" >> $GITHUB_ENV
|
||||
echo "MINOR=$(cat RELEASE | cut -d "-" -f 3)" >> $GITHUB_ENV
|
||||
- name: echo env
|
||||
run: echo "release $RELEASE version $VERSION major $MAJOR submajor $SUBMAJOR minor $MINOR"
|
||||
- name: Linux libraries
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install libssl-dev libpam-dev libpcre2-dev rpm
|
||||
sudo dpkg --add-architecture arm64
|
||||
echo "Types: deb" > ~/ubuntu.sources
|
||||
echo "URIs: http://archive.ubuntu.com/ubuntu/" >> ~/ubuntu.sources
|
||||
echo "Suites: noble noble-updates noble-backports" >> ~/ubuntu.sources
|
||||
echo "Components: main restricted universe multiverse" >> ~/ubuntu.sources
|
||||
echo "Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg" >> ~/ubuntu.sources
|
||||
echo "Architectures: amd64" >> ~/ubuntu.sources
|
||||
echo "" >> ~/ubuntu.sources
|
||||
echo "Types: deb" >> ~/ubuntu.sources
|
||||
echo "URIs: http://security.ubuntu.com/ubuntu/" >> ~/ubuntu.sources
|
||||
echo "Suites: noble-security" >> ~/ubuntu.sources
|
||||
echo "Components: main restricted universe multiverse" >> ~/ubuntu.sources
|
||||
echo "Architectures: amd64" >> ~/ubuntu.sources
|
||||
echo "Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg" >> ~/ubuntu.sources
|
||||
echo "" >> ~/ubuntu.sources
|
||||
echo "Types: deb" >>~/ubuntu.sources
|
||||
echo "URIs: http://ports.ubuntu.com/ubuntu-ports/" >>~/ubuntu.sources
|
||||
echo "Suites: noble noble-updates" >>~/ubuntu.sources
|
||||
echo "Components: main restricted universe multiverse" >>~/ubuntu.sources
|
||||
echo "Architectures: arm64" >>~/ubuntu.sources
|
||||
echo "Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg" >>~/ubuntu.sources
|
||||
sudo cp ~/ubuntu.sources /etc/apt/sources.list.d/ubuntu.sources
|
||||
sudo apt update
|
||||
sudo apt install libssl-dev:arm64 libpam0g:arm64 libpam0g-dev:arm64 libpcre2-dev:arm64 rpm crossbuild-essential-arm64
|
||||
- name: make rpmbuild dir
|
||||
run: mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
|
||||
- name: configure rpm env
|
||||
@ -40,7 +61,7 @@ jobs:
|
||||
run: |
|
||||
ret=`pwd`
|
||||
cd ~/rpmbuild/SPECS
|
||||
rpmbuild -ba 3proxy-$RELEASE.spec
|
||||
rpmbuild -ba --define "PAMLIB pam0g" --define "_arch aarch64" --define "cross yes" --target=aarch64-linux-gnueabi 3proxy-$RELEASE.spec
|
||||
cd $ret
|
||||
mv ~/rpmbuild/RPMS/aarch64/3proxy-$RELEASE-1.aarch64.rpm 3proxy-$RELEASE.arm64.rpm
|
||||
- name: Get artifact
|
||||
@ -48,4 +69,3 @@ jobs:
|
||||
with:
|
||||
name: "3proxy-${{ env.RELEASE }}-arm64.rpm"
|
||||
path: "*.rpm"
|
||||
|
||||
|
||||
5
.github/workflows/build-watcom.yml
vendored
5
.github/workflows/build-watcom.yml
vendored
@ -25,9 +25,10 @@ jobs:
|
||||
echo "now: $NOW"
|
||||
$RELEASE = Get-Content -Path "RELEASE" -Raw
|
||||
echo "release: $RELEASE"
|
||||
echo "NOW=$NOW" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
echo "RELEASE=$RELEASE" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
echo "VERSION=/D VERSION=`"3proxy-$RELEASE`"" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
echo "BUILDDATE=/D BUILDDATE=`"$NOW`"" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
echo "VERSION=VERSION=`"$RELEASE`"" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
echo "BUILDDATE=BUILDDATE=`"$NOW`"" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
- name: make Watcom
|
||||
shell: cmd
|
||||
run: |
|
||||
|
||||
7
.github/workflows/build-win32.yml
vendored
7
.github/workflows/build-win32.yml
vendored
@ -20,10 +20,13 @@ jobs:
|
||||
- name: set date
|
||||
run: |
|
||||
$NOW = Get-Date -Format "yyMMddHHmmss"
|
||||
echo "now: $NOW"
|
||||
$RELEASE = Get-Content -Path "RELEASE" -Raw
|
||||
echo "release: $RELEASE"
|
||||
echo "NOW=$NOW" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
echo "RELEASE=$RELEASE" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
echo "VERSION=/D VERSION=`"3proxy-$RELEASE`"" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
echo "BUILDDATE=/D BUILDDATE=`"$NOW`"" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
echo "VERSION=VERSION=`"$RELEASE`"" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
echo "BUILDDATE=BUILDDATE=`"$NOW`"" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
- name: install packages
|
||||
run: vcpkg install pcre2:x86-windows-static openssl:x86-windows-static
|
||||
- name: Add msbuild to PATH
|
||||
|
||||
11
.github/workflows/build-win64.yml
vendored
11
.github/workflows/build-win64.yml
vendored
@ -20,11 +20,13 @@ jobs:
|
||||
- name: set date
|
||||
run: |
|
||||
$NOW = Get-Date -Format "yyMMddHHmmss"
|
||||
echo "now: $NOW"
|
||||
$RELEASE = Get-Content -Path "RELEASE" -Raw
|
||||
echo "release: $RELEASE"
|
||||
echo "NOW=$NOW" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
echo "RELEASE=$RELEASE" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
echo "VERSION=/D VERSION=`"3proxy-$RELEASE`"" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
echo "BUILDDATE=/D BUILDDATE=`"$NOW`"" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
echo "VERSION=VERSION=`"$RELEASE`"" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
echo "BUILDDATE=BUILDDATE=`"$NOW`"" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
- name: install packages
|
||||
run: vcpkg install pcre2:x64-windows-static openssl:x64-windows-static
|
||||
- name: Add msbuild to PATH
|
||||
@ -38,9 +40,8 @@ jobs:
|
||||
cd "D:/a/3proxy/3proxy"
|
||||
set "LIB=%LIB%;c:/vcpkg/installed/x64-windows-static/lib"
|
||||
set "INCLUDE=%INCLUDE%;c:/vcpkg/installed/x64-windows-static/include"
|
||||
echo "volatile char VerSion[]=^"3APA3A-3proxy-Internal-Build: 3proxy-%RELEASE%-%NOW%\r\nCode certificate: https://3proxy.org/3proxy.cer\r\n^";" >>src/3proxy.c
|
||||
echo %NOW% / %RELEASE% / %BUILDDATE% / %VERSION%
|
||||
nmake /F Makefile.msvc "BUILDDATE=/D BUILDDATE=\"%NOW%\"" "VERSION=/D VERSION=\"3proxy-%RELEASE%\""
|
||||
echo "volatile char VerSion[]=^"3APA3A-3proxy-Internal-Build: 3proxy-%RELEASE%%-%NOW%\r\nCode certificate: https://3proxy.org/3proxy.cer\r\n^";" >>src/3proxy.c
|
||||
nmake /F Makefile.msvc
|
||||
- name: make dist dir
|
||||
shell: cmd
|
||||
run: |
|
||||
|
||||
7
.github/workflows/build-winarm64.yml
vendored
7
.github/workflows/build-winarm64.yml
vendored
@ -20,10 +20,13 @@ jobs:
|
||||
- name: set date
|
||||
run: |
|
||||
$NOW = Get-Date -Format "yyMMddHHmmss"
|
||||
echo "now: $NOW"
|
||||
$RELEASE = Get-Content -Path "RELEASE" -Raw
|
||||
echo "release: $RELEASE"
|
||||
echo "NOW=$NOW" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
echo "RELEASE=$RELEASE" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
echo "VERSION=/D VERSION=`"3proxy-$RELEASE`"" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
echo "BUILDDATE=/D BUILDDATE=`"$NOW`"" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
echo "VERSION=VERSION=`"$RELEASE`"" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
echo "BUILDDATE=BUILDDATE=`"$NOW`"" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
- name: install packages
|
||||
run: vcpkg install pcre2:arm64-windows-static openssl:arm64-windows-static
|
||||
- name: Add msbuild to PATH
|
||||
|
||||
@ -77,6 +77,7 @@ if(WIN32)
|
||||
_WIN32
|
||||
_MBCS
|
||||
_CONSOLE
|
||||
PRINTF_INT64_MODIFIER="I64"
|
||||
)
|
||||
|
||||
if(COMPILER_IS_MSVC)
|
||||
|
||||
@ -6,7 +6,13 @@
|
||||
|
||||
BUILDDIR = ../bin/
|
||||
CC = cl
|
||||
CFLAGS = /nologo /MT /W3 /Ox /GS /EHs- /GA /GF /D "MSVC" /D "WITH_WSAPOLL" /D "NDEBUG" /D "WIN32" /D "WITH_SSL" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /Fp"proxy.pch" /FD /c $(BUILDDATE) $(VERSION)
|
||||
CFLAGS = /nologo /MT /W3 /Ox /GS /EHs- /GA /GF /D "MSVC" /D "WITH_WSAPOLL" /D "NDEBUG" /D "WIN32" /D "WITH_SSL" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "PRINTF_INT64_MODIFIER=\"I64\"" /Fp"proxy.pch" /FD /c
|
||||
!IFDEF RELEASE
|
||||
VERSION=/D VERSION=\"3proxy-$(RELEASE)\"
|
||||
!ENDIF
|
||||
!IFDEF NOW
|
||||
BUILDDATE=/D BUILDDATE=\"$(NOW)\"
|
||||
!ENDIF
|
||||
COUT = /Fo
|
||||
LN = link
|
||||
LDFLAGS = /nologo /subsystem:console /incremental:no
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
|
||||
BUILDDIR = ../bin/
|
||||
CC = cl
|
||||
CFLAGS = /nologo /Ox /MT /D "NOIPV6" /D "NODEBUG" /D "NOODBC" /D "NORADIUS" /D"WATCOM" /D "MSVC" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "PRId64=\"I64d\"" /D "PRIu64=\"I64u\"" /D "SCNu64=\"I64u\"" /D "SCNx64=\"I64x\"" /D "SCNd64=\"I64d\"" /D "PRIx64=\"I64x\"" /c $(VERSION) $(BUILDDATE)
|
||||
CFLAGS = /nologo /Ox /MT /D "NOIPV6" /D "NODEBUG" /D "NOODBC" /D "NORADIUS" /D"WATCOM" /D "MSVC" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "PRINTF_INT64_MODIFIER=\"I64\"" /c $(VERSION) $(BUILDDATE)
|
||||
COUT = /Fo
|
||||
LN = link
|
||||
LDFLAGS = /nologo /subsystem:console /incremental:no
|
||||
@ -62,3 +62,9 @@ allplugins:
|
||||
nmake
|
||||
del *.obj *.idb
|
||||
cd ../../
|
||||
copy Makefile plugins\PCREPlugin
|
||||
copy Makefile.var plugins\PCREPlugin
|
||||
cd plugins\PCREPlugin
|
||||
nmake
|
||||
del *.obj *.idb
|
||||
cd ../../
|
||||
|
||||
@ -67,10 +67,14 @@
|
||||
<ul>
|
||||
<li><A NAME="MSVC">How to compile 3proxy with Visual C++</A>
|
||||
<p>
|
||||
Extract source code files from 3proxy.tgz (with WinZip or another utility) or use git.
|
||||
|
||||
Extract source code files from 3proxy.tgz (with WinZip or another utility).
|
||||
For 64-bit Windows use:
|
||||
<pre>
|
||||
nmake /f Makefile.msvc
|
||||
nmake /f Makefile.msvc64
|
||||
</pre>
|
||||
For ARM64 Windows use:
|
||||
<pre>
|
||||
nmake /f Makefile.msvcARM64
|
||||
</pre>
|
||||
Binaries will be placed in the <code>bin/</code> directory.
|
||||
</p>
|
||||
|
||||
@ -73,10 +73,13 @@
|
||||
<ul>
|
||||
<li><a name="MSVC"><i>Как скомпилировать 3proxy Visual C++</i></a>
|
||||
<p>
|
||||
Извлеките файлы из архива 3proxy.tgz (например, с помощью WinZip) или используйте git.
|
||||
Извлеките файлы из архива 3proxy.tgz (например, с помощью WinZip).
|
||||
Для 64-битной Windows используйте:
|
||||
<pre>
|
||||
nmake /f Makefile.msvc
|
||||
</pre>
|
||||
nmake /f Makefile.msvc64</pre>
|
||||
Для Windows ARM64 используйте:
|
||||
<pre>
|
||||
nmake /f Makefile.msvcARM64</pre>
|
||||
Исполняемые файлы будут помещены в каталог <code>bin/</code>.
|
||||
</p>
|
||||
<li><a name="CMAKE"><i>Как скомпилировать 3proxy с помощью CMake</i></a>
|
||||
|
||||
@ -206,7 +206,7 @@ void dumpcounters(struct trafcount *tlin, int counterd){
|
||||
if(cfp){
|
||||
for(tl = tlin; cfp && tl; tl = tl->next){
|
||||
if(tl->type >= conf.countertype)
|
||||
fprintf(cfp, "%05d %020"PRIu64"%s%s\n", tl->number, tl->traf64, tl->comment?" #" : "", tl->comment? tl->comment : "");
|
||||
fprintf(cfp, "%05d %020"PRINTF_INT64_MODIFIER"u%s%s\n", tl->number, tl->traf64, tl->comment?" #" : "", tl->comment? tl->comment : "");
|
||||
}
|
||||
fclose(cfp);
|
||||
}
|
||||
@ -215,7 +215,7 @@ void dumpcounters(struct trafcount *tlin, int counterd){
|
||||
|
||||
cheader.updated = conf.time;
|
||||
lseek(counterd, 0, SEEK_SET);
|
||||
if(write(counterd, &cheader, sizeof(struct counter_header))){}
|
||||
write(counterd, &cheader, sizeof(struct counter_header));
|
||||
for(tl=tlin; tl; tl = tl->next){
|
||||
if(tl->number){
|
||||
lseek(counterd,
|
||||
@ -224,7 +224,7 @@ void dumpcounters(struct trafcount *tlin, int counterd){
|
||||
crecord.traf64 = tl->traf64;
|
||||
crecord.cleared = tl->cleared;
|
||||
crecord.updated = tl->updated;
|
||||
if(write(counterd, &crecord, sizeof(struct counter_record))){}
|
||||
write(counterd, &crecord, sizeof(struct counter_record));
|
||||
}
|
||||
if(tl->type!=NEVER && timechanged(tl->cleared, conf.time, tl->type)){
|
||||
tl->cleared = conf.time;
|
||||
@ -315,7 +315,7 @@ void cyclestep(void){
|
||||
else
|
||||
strcat((char *)tmpbuf, (char *)conf.archiver[i]);
|
||||
}
|
||||
if(system((char *)tmpbuf+1)){}
|
||||
system((char *)tmpbuf+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
20
src/auth.c
20
src/auth.c
@ -305,7 +305,7 @@ int handleredirect(struct clientparam * param, struct ace * acentry){
|
||||
if(!ha) return 0;
|
||||
}
|
||||
else if(!*SAPORT(&cur->addr) && !SAISNULL(&cur->addr)) {
|
||||
uint16_t port = *SAPORT(¶m->sinsr);
|
||||
unsigned short port = *SAPORT(¶m->sinsr);
|
||||
param->sinsr = cur->addr;
|
||||
*SAPORT(¶m->sinsr) = port;
|
||||
}
|
||||
@ -943,7 +943,7 @@ int dnsauth(struct clientparam * param){
|
||||
sprintf(s, "ip6.arpa");
|
||||
}
|
||||
else {
|
||||
u = ntohl(*(uint32_t *)SAADDR(¶m->sincr));
|
||||
u = ntohl(*(unsigned long *)SAADDR(¶m->sincr));
|
||||
|
||||
sprintf(buf, "%u.%u.%u.%u.in-addr.arpa",
|
||||
((u&0x000000FF)),
|
||||
@ -1155,7 +1155,7 @@ void hashadd(struct hashtable *ht, const unsigned char* name, unsigned char* val
|
||||
pthread_mutex_unlock(&hash_mutex);
|
||||
}
|
||||
|
||||
uint32_t hashresolv(struct hashtable *ht, const unsigned char* name, unsigned char* value, uint32_t *ttl){
|
||||
unsigned long hashresolv(struct hashtable *ht, const unsigned char* name, unsigned char* value, unsigned *ttl){
|
||||
unsigned char hash[sizeof(unsigned)*4];
|
||||
struct hashentry ** hep;
|
||||
struct hashentry *he;
|
||||
@ -1176,7 +1176,7 @@ uint32_t hashresolv(struct hashtable *ht, const unsigned char* name, unsigned ch
|
||||
ht->hashempty = he;
|
||||
}
|
||||
else if(!memcmp(hash, he->hash, sizeof(unsigned)*4)){
|
||||
if(ttl) *ttl = (uint32_t)(he->expires - conf.time);
|
||||
if(ttl) *ttl = (unsigned)(he->expires - conf.time);
|
||||
memcpy(value, he->value, ht->recsize);
|
||||
pthread_mutex_unlock(&hash_mutex);
|
||||
return 1;
|
||||
@ -1191,10 +1191,10 @@ struct nserver nservers[MAXNSERVERS] = {{{0},0}, {{0},0}, {{0},0}, {{0},0}, {{0}
|
||||
struct nserver authnserver;
|
||||
|
||||
|
||||
uint32_t udpresolve(int af, unsigned char * name, unsigned char * value, uint32_t *retttl, struct clientparam* param, int makeauth){
|
||||
unsigned long udpresolve(int af, unsigned char * name, unsigned char * value, unsigned *retttl, struct clientparam* param, int makeauth){
|
||||
|
||||
int i,n;
|
||||
uint32_t retval;
|
||||
unsigned long retval;
|
||||
|
||||
if((af == AF_INET) && (retval = hashresolv(&dns_table, name, value, retttl))) {
|
||||
return retval;
|
||||
@ -1208,7 +1208,7 @@ uint32_t udpresolve(int af, unsigned char * name, unsigned char * value, uint32_
|
||||
unsigned char b[4098], *buf, *s1, *s2;
|
||||
int j, k, len, flen;
|
||||
SOCKET sock;
|
||||
uint32_t ttl;
|
||||
unsigned ttl;
|
||||
#ifndef NOIPV6
|
||||
struct sockaddr_in6 addr;
|
||||
struct sockaddr_in6 *sinsr, *sinsl;
|
||||
@ -1343,7 +1343,7 @@ uint32_t udpresolve(int af, unsigned char * name, unsigned char * value, uint32_
|
||||
k+= (12 + flen);
|
||||
continue; /* we need A IPv4 */
|
||||
}
|
||||
ttl = ntohl(*(uint32_t *)(buf + k + 6));
|
||||
ttl = ntohl(*(unsigned long *)(buf + k + 6));
|
||||
memcpy(value, buf + k + 12, af == AF_INET6? 16:4);
|
||||
if(ttl < 0 || ttl > (3600*12)) ttl = 3600*12;
|
||||
if(!ttl) ttl = 1;
|
||||
@ -1373,11 +1373,11 @@ uint32_t udpresolve(int af, unsigned char * name, unsigned char * value, uint32_
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t myresolver(int af, unsigned char * name, unsigned char * value){
|
||||
unsigned long myresolver(int af, unsigned char * name, unsigned char * value){
|
||||
return udpresolve(af, name, value, NULL, NULL, 0);
|
||||
}
|
||||
|
||||
uint32_t fakeresolver (int af, unsigned char *name, unsigned char * value){
|
||||
unsigned long fakeresolver (int af, unsigned char *name, unsigned char * value){
|
||||
memset(value, 0, af == AF_INET6? 16 : 4);
|
||||
if(af == AF_INET6){
|
||||
memset(value, 0, 16);
|
||||
|
||||
@ -610,7 +610,7 @@ int radsend(struct clientparam * param, int auth, int stop){
|
||||
if(!vendor && attr[0] == PW_VENDOR_SPECIFIC) {
|
||||
if (attr[1] < 6 || count < 6) RETURN(4);
|
||||
vendorlen = attr[1]-6;
|
||||
vendor = htonl(*((uint32_t *)(attr +2)));
|
||||
vendor = htonl(*((int*)(attr +2)));
|
||||
count -= 6;
|
||||
attr += 6;
|
||||
continue;
|
||||
|
||||
16
src/common.c
16
src/common.c
@ -417,7 +417,7 @@ int ceparseargs(const char *str){
|
||||
|
||||
int parsehost(int family, unsigned char *host, struct sockaddr *sa){
|
||||
char *sp=NULL,*se=NULL;
|
||||
uint16_t port=0;
|
||||
unsigned short port=0;
|
||||
int ret = 0;
|
||||
|
||||
if(!host) return 2;
|
||||
@ -436,7 +436,7 @@ int parsehost(int family, unsigned char *host, struct sockaddr *sa){
|
||||
return ret;
|
||||
}
|
||||
|
||||
int parsehostname(char *hostname, struct clientparam *param, uint16_t port){
|
||||
int parsehostname(char *hostname, struct clientparam *param, unsigned short port){
|
||||
char *sp=NULL,*se=NULL;
|
||||
int ret = 0;
|
||||
|
||||
@ -498,7 +498,7 @@ int parseusername(char *username, struct clientparam *param, int extpasswd){
|
||||
return 0;
|
||||
}
|
||||
|
||||
int parseconnusername(char *username, struct clientparam *param, int extpasswd, uint16_t port){
|
||||
int parseconnusername(char *username, struct clientparam *param, int extpasswd, unsigned short port){
|
||||
char *sb, *se;
|
||||
if(!username || !*username) return 1;
|
||||
if ((sb=strchr(username, conf.delimchar)) == NULL){
|
||||
@ -625,7 +625,7 @@ int doconnect(struct clientparam * param){
|
||||
return 0;
|
||||
}
|
||||
|
||||
int scanaddr(const unsigned char *s, uint32_t * ip, uint32_t * mask) {
|
||||
int scanaddr(const unsigned char *s, unsigned long * ip, unsigned long * mask) {
|
||||
unsigned d1, d2, d3, d4, m;
|
||||
int res;
|
||||
if ((res = sscanf((char *)s, "%u.%u.%u.%u/%u", &d1, &d2, &d3, &d4, &m)) < 4) return 0;
|
||||
@ -658,8 +658,8 @@ struct hostent * my_gethostbyname(char *name, char *buf, struct hostent *hp){
|
||||
#endif
|
||||
|
||||
#ifdef NOIPV6
|
||||
uint32_t getip(unsigned char *name){
|
||||
uint32_t retval;
|
||||
unsigned long getip(unsigned char *name){
|
||||
unsigned long retval;
|
||||
int i;
|
||||
int ndots = 0;
|
||||
struct hostent *hp=NULL;
|
||||
@ -701,7 +701,7 @@ uint32_t getip(unsigned char *name){
|
||||
system(conf.demanddialprog);
|
||||
hp=gethostbyname((char *)name);
|
||||
}
|
||||
retval = hp?*(uint32_t *)hp->h_addr:0;
|
||||
retval = hp?*(unsigned long *)hp->h_addr:0;
|
||||
#if !defined(_WIN32) && !defined(GETHOSTBYNAME_R)
|
||||
pthread_mutex_unlock(&gethostbyname_mutex);
|
||||
#endif
|
||||
@ -744,7 +744,7 @@ int afdetect(unsigned char *name){
|
||||
|
||||
}
|
||||
|
||||
uint32_t getip46(int family, unsigned char *name, struct sockaddr *sa){
|
||||
unsigned long getip46(int family, unsigned char *name, struct sockaddr *sa){
|
||||
#ifndef NOIPV6
|
||||
int detect;
|
||||
struct addrinfo *ai, hint;
|
||||
|
||||
25
src/conf.c
25
src/conf.c
@ -811,7 +811,7 @@ static int h_parent(int argc, unsigned char **argv){
|
||||
*cidr = '/';
|
||||
chains->cidr = atoi(cidr + 1);
|
||||
}
|
||||
*SAPORT(&chains->addr) = htons((uint16_t)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 > 6) chains->extpass = (unsigned char *)mystrdup((char *)argv[6]);
|
||||
if(!acl->chains) {
|
||||
@ -1221,10 +1221,10 @@ static int h_ace(int argc, unsigned char **argv){
|
||||
freeacl(acl);
|
||||
return(21);
|
||||
}
|
||||
memset(acl->chains, 0, sizeof(struct chain));
|
||||
memset(acl->chains, 0, sizeof(struct chain));
|
||||
acl->chains->type = R_HTTP;
|
||||
if(!getip46(46, argv[1], (struct sockaddr *)&acl->chains->addr)) return 5;
|
||||
*SAPORT(&acl->chains->addr) = htons((uint16_t)atoi((char *)argv[2]));
|
||||
*SAPORT(&acl->chains->addr) = htons((unsigned short)atoi((char *)argv[2]));
|
||||
acl->chains->weight = 1000;
|
||||
case ALLOW:
|
||||
case DENY:
|
||||
@ -1348,14 +1348,13 @@ static int h_ace(int argc, unsigned char **argv){
|
||||
sizeof(struct counter_header) + (tl->number - 1) * sizeof(struct counter_record),
|
||||
SEEK_SET);
|
||||
memset(&crecord, 0, sizeof(struct counter_record));
|
||||
if(read(conf.counterd, &crecord, sizeof(struct counter_record)) == sizeof(struct counter_record)){
|
||||
tl->traf64 = crecord.traf64;
|
||||
tl->cleared = crecord.cleared;
|
||||
tl->updated = crecord.updated;
|
||||
if(tl->cleared < 0 || tl->cleared >= MAX_COUNTER_TIME || tl->updated < 0 || tl->updated >= MAX_COUNTER_TIME){
|
||||
fprintf(stderr, "Invalid, incompatible or corrupted counter file.\n");
|
||||
return(6);
|
||||
}
|
||||
read(conf.counterd, &crecord, sizeof(struct counter_record));
|
||||
tl->traf64 = crecord.traf64;
|
||||
tl->cleared = crecord.cleared;
|
||||
tl->updated = crecord.updated;
|
||||
if(tl->cleared < 0 || tl->cleared >= MAX_COUNTER_TIME || tl->updated < 0 || tl->updated >= MAX_COUNTER_TIME){
|
||||
fprintf(stderr, "Invalid, incompatible or corrupted counter file.\n");
|
||||
return(6);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1395,7 +1394,7 @@ static int h_delimchar(int argc, unsigned char **argv){
|
||||
|
||||
#ifndef NORADIUS
|
||||
static int h_radius(int argc, unsigned char **argv){
|
||||
uint16_t port;
|
||||
unsigned short port;
|
||||
|
||||
/*
|
||||
int oldrad;
|
||||
@ -1576,7 +1575,7 @@ static int h_chroot(int argc, unsigned char **argv){
|
||||
fprintf(stderr, "Unable to set uid %d", (int)uid);
|
||||
return(5);
|
||||
}
|
||||
if(chdir("/")){}
|
||||
chdir("/");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
|
||||
static void pr_unsigned64(struct node *node, CBFUNC cbf, void*cb){
|
||||
char buf[32];
|
||||
if(node->value)(*cbf)(cb, buf, sprintf(buf, "%"PRIu64"", *(uint64_t *)node->value));
|
||||
if(node->value)(*cbf)(cb, buf, sprintf(buf, "%"PRINTF_INT64_MODIFIER"u", *(uint64_t *)node->value));
|
||||
}
|
||||
|
||||
static void pr_integer(struct node *node, CBFUNC cbf, void*cb){
|
||||
@ -44,7 +44,7 @@ static void pr_traffic(struct node *node, CBFUNC cbf, void*cb){
|
||||
|
||||
static void pr_port(struct node *node, CBFUNC cbf, void*cb){
|
||||
char buf[8];
|
||||
if(node->value)(*cbf)(cb, buf, sprintf(buf, "%hu", (unsigned short)ntohs(*(uint16_t*)node->value)));
|
||||
if(node->value)(*cbf)(cb, buf, sprintf(buf, "%hu", ntohs(*(unsigned short*)node->value)));
|
||||
}
|
||||
|
||||
static void pr_datetime(struct node *node, CBFUNC cbf, void*cb){
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
|
||||
void * dnsprchild(struct clientparam* param) {
|
||||
uint32_t ip = 0;
|
||||
unsigned long ip = 0;
|
||||
unsigned char *bbuf;
|
||||
unsigned char *buf, *s1, *s2;
|
||||
char * host = NULL;
|
||||
@ -26,7 +26,7 @@ void * dnsprchild(struct clientparam* param) {
|
||||
int res, i;
|
||||
int len;
|
||||
unsigned type=0;
|
||||
uint32_t ttl;
|
||||
unsigned ttl;
|
||||
unsigned char addr[16];
|
||||
#ifdef _WIN32
|
||||
unsigned long ul = 1;
|
||||
@ -109,7 +109,7 @@ void * dnsprchild(struct clientparam* param) {
|
||||
unsigned a, b, c, d;
|
||||
sscanf(host, "%u.%u.%u.%u", &a, &b, &c, &d);
|
||||
ip = htonl((d<<24) ^ (c<<16) ^ (b<<8) ^ a);
|
||||
if(*SAFAMILY(¶m->sincl) == AF_INET && ip == *(uint32_t *)SAADDR(¶m->sincl)){
|
||||
if(*SAFAMILY(¶m->sincl) == AF_INET && ip == *(unsigned long*)SAADDR(¶m->sincl)){
|
||||
buf[2] = 0x85;
|
||||
buf[3] = 0x80;
|
||||
buf[6] = 0;
|
||||
|
||||
@ -195,7 +195,7 @@ SOCKET ftpdata(struct clientparam *param){
|
||||
rem = param->remsock;
|
||||
param->remsock = INVALID_SOCKET;
|
||||
param->req = param->sinsr;
|
||||
*SAPORT(¶m->req) = *SAPORT(¶m->sinsr) = htons((uint16_t)((b5<<8)^b6));
|
||||
*SAPORT(¶m->req) = *SAPORT(¶m->sinsr) = htons((unsigned short)((b5<<8)^b6));
|
||||
*SAPORT(¶m->sinsl) = 0;
|
||||
i = param->operation;
|
||||
param->operation = FTP_DATA;
|
||||
|
||||
@ -152,7 +152,7 @@ void * ftpprchild(struct clientparam* param) {
|
||||
unsigned short b5, b6;
|
||||
|
||||
if(sscanf((char *)buf+5, "%lu,%lu,%lu,%lu,%hu,%hu", &b1, &b2, &b3, &b4, &b5, &b6)!=6) {RETURN(828);}
|
||||
*SAPORT(¶m->sincr) = htons((uint16_t)((b5<<8)^b6));
|
||||
*SAPORT(¶m->sincr) = htons((unsigned short)((b5<<8)^b6));
|
||||
if(connectwithpoll(param, clidatasock, (struct sockaddr *)¶m->sincr, SASIZE(¶m->sincr),conf.timeouts[CONNECT_TO])) {
|
||||
param->srv->so._closesocket(param->sostate, clidatasock);
|
||||
clidatasock = INVALID_SOCKET;
|
||||
|
||||
@ -246,15 +246,15 @@ int dobuf2(struct clientparam * param, unsigned char * buf, const unsigned char
|
||||
i += (int)strlen((char *)buf+i);
|
||||
break;
|
||||
case 'L':
|
||||
sprintf((char *)buf+i, "%"PRIu64"", param->cycles);
|
||||
sprintf((char *)buf+i, "%"PRINTF_INT64_MODIFIER"u", param->cycles);
|
||||
i += (int)strlen((char *)buf+i);
|
||||
break;
|
||||
case 'I':
|
||||
sprintf((char *)buf+i, "%"PRIu64"", param->statssrv64);
|
||||
sprintf((char *)buf+i, "%"PRINTF_INT64_MODIFIER"u", param->statssrv64);
|
||||
i += (int)strlen((char *)buf+i);
|
||||
break;
|
||||
case 'O':
|
||||
sprintf((char *)buf+i, "%"PRIu64"", param->statscli64);
|
||||
sprintf((char *)buf+i, "%"PRINTF_INT64_MODIFIER"u", param->statscli64);
|
||||
i += (int)strlen((char *)buf+i);
|
||||
break;
|
||||
case 'h':
|
||||
|
||||
@ -415,6 +415,7 @@ static int WINAPI fp_poll(void *state, struct pollfd *fds, unsigned int nfds, in
|
||||
struct fp_stream *fps = NULL;
|
||||
int res;
|
||||
unsigned i;
|
||||
int to;
|
||||
|
||||
for(i = 0; i<nfds; i++){
|
||||
res = searchsocket(fds[i].fd, &fps);
|
||||
|
||||
@ -61,7 +61,7 @@ int savecounters(void)
|
||||
unsigned char *tmpbuf,pat_file[]="%s%s.lc";
|
||||
|
||||
|
||||
/* timetoexit !=0 - будем завершаться.*/
|
||||
/* timetoexit !=0 - áóäåì çàâåðøàòüñÿ.*/
|
||||
while (tc != NULL)
|
||||
{
|
||||
tcd = tc;
|
||||
@ -72,7 +72,7 @@ int savecounters(void)
|
||||
sprintf(tmpbuf,pat_file,ldap_dircount,tcd->ace->users->user);
|
||||
f=fopen(tmpbuf,"w+b");
|
||||
fseek(f,0,SEEK_SET);
|
||||
fprintf(f,"%"PRIu64" %lu %lu\n",tcd->traf64,
|
||||
fprintf(f,"%"PRINTF_INT64_MODIFIER"u %lu %lu\n",tcd->traf64,
|
||||
(unsigned long)tcd->cleared,(unsigned long)tcd->updated);
|
||||
|
||||
fclose(f);
|
||||
@ -387,7 +387,7 @@ int h_trafgroup(int argc, unsigned char ** argv)
|
||||
|
||||
fseek(f,0,SEEK_SET);
|
||||
fgets(buf, 256, f);
|
||||
sscanf(buf,"%"SCNu64" %lu %lu\n",&rcounter.traf64,
|
||||
sscanf(buf,"%"PRINTF_INT64_MODIFIER"u %lu %lu\n",&rcounter.traf64,
|
||||
&rcounter.cleared, &rcounter.updated);
|
||||
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ char **load_string(FILE *f,int max_count_str, int *countloadstr,
|
||||
/*find start service section*/
|
||||
while(!feof(f))
|
||||
{
|
||||
if(!fgets(tmpbuf1, 1023,f)) return NULL;
|
||||
fgets(tmpbuf1, 1023,f);
|
||||
if ((strstr(tmpbuf1,start))!=NULL) { i++; break; }
|
||||
tmpbuf1[0]='\0';
|
||||
}
|
||||
@ -51,7 +51,7 @@ char **load_string(FILE *f,int max_count_str, int *countloadstr,
|
||||
i=0;
|
||||
while ( !feof(f) || i< max_count_str)
|
||||
{
|
||||
if(!fgets(tmpbuf1, 1023,f)) return NULL;
|
||||
fgets(tmpbuf1, 1023,f);
|
||||
|
||||
if ((strstr(tmpbuf1,stop))!=NULL) { break; }
|
||||
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
========================================================================
|
||||
3proxy traffic plugin Changelog
|
||||
========================================================================
|
||||
v0.1.2 (2 января 2007 года)
|
||||
- Плугин обновлён в соответствии с обновлением 3proxy.
|
||||
- Добавлена опция debug.
|
||||
v0.1.2 (2 января 2007 года)
|
||||
- Плугин обновлён в соответствии с обновлением 3proxy.
|
||||
- Добавлена опция debug.
|
||||
|
||||
v0.1.1
|
||||
- Теперь udp нельзя задавать proxy, tcppm, pop3p
|
||||
- Исправлена ошибка с выбором типа соединения.
|
||||
- Теперь udp нельзя задавать proxy, tcppm, pop3p
|
||||
- Исправлена ошибка с выбором типа соединения.
|
||||
|
||||
v0.1.0 beta (10 июля 2006)
|
||||
Первый релиз.
|
||||
v0.1.0 beta (10 июля 2006)
|
||||
Первый релиз.
|
||||
@ -1,64 +1,64 @@
|
||||
========================================================================
|
||||
3proxy traffic plugin
|
||||
========================================================================
|
||||
Как известно 3proxy считает траффик не сетевой, а прикладной.
|
||||
Обычно прикладной траффик немного меньше (примерно на 10%) чем сетевой,
|
||||
однако в некоторых случаях, например когда пользователи сети играют в
|
||||
игры, сетевой траффик может превысить прикладной в 4-5 раз. Это довольно неприятно,
|
||||
так как получается, что они за это не платят.
|
||||
Как известно 3proxy считает траффик не сетевой, а прикладной.
|
||||
Обычно прикладной траффик немного меньше (примерно на 10%) чем сетевой,
|
||||
однако в некоторых случаях, например когда пользователи сети играют в
|
||||
игры, сетевой траффик может превысить прикладной в 4-5 раз. Это довольно неприятно,
|
||||
так как получается, что они за это не платят.
|
||||
|
||||
Происходит это потому, что в каждом посланом пакете есть заголовок+данные. Заголовок
|
||||
весит порядка 50-60 байт а колличество данных может меняться от 15-20 байт (что характерно для игр)
|
||||
до 800-900 байт (у IE). Также колличество данных в пакете зависит от загрузки сети,
|
||||
удалённости сервера и прочих причин.
|
||||
Происходит это потому, что в каждом посланом пакете есть заголовок+данные. Заголовок
|
||||
весит порядка 50-60 байт а колличество данных может меняться от 15-20 байт (что характерно для игр)
|
||||
до 800-900 байт (у IE). Также колличество данных в пакете зависит от загрузки сети,
|
||||
удалённости сервера и прочих причин.
|
||||
|
||||
Данный плагин может исправить такую ситуацию. Он может умножать счётчик траффика
|
||||
при окончании соединения на некоторый коэффициент либо добавлять к данным размеры заголовков пакетов,
|
||||
которые прошли по сети.
|
||||
Данный плагин может исправить такую ситуацию. Он может умножать счётчик траффика
|
||||
при окончании соединения на некоторый коэффициент либо добавлять к данным размеры заголовков пакетов,
|
||||
которые прошли по сети.
|
||||
|
||||
Как использовать плагин:
|
||||
Как использовать плагин:
|
||||
|
||||
загрузка плагина:
|
||||
загрузка плагина:
|
||||
plugin "TrafficPlugin.dll" start
|
||||
|
||||
Далее недоходимо добавить правила:
|
||||
ДЛЯ РЕЖИМА ДОМНОЖЕНИЯ ТРАФФИКА НА ЧИСЛО:
|
||||
trafcorrect m <сервис> <исходящий порт> <коэффициент>
|
||||
где: <сервис> может быть proxy, socks4, socks45, socks5, tcppm, udppm, pop3p
|
||||
если сервис указан неверно то считается, что это может быть любой сервис.
|
||||
можно использовать *, тогда правило будет считаться для любого сервиса.
|
||||
<исходящий порт> - порт, к которому подключается прокси сервер. * - любой
|
||||
<коэффициент> - число на каоторое домнажается траффик. Обязательный параметр.
|
||||
Должен быть от больше 0 и меньше 100
|
||||
Далее недоходимо добавить правила:
|
||||
ДЛЯ РЕЖИМА ДОМНОЖЕНИЯ ТРАФФИКА НА ЧИСЛО:
|
||||
trafcorrect m <сервис> <исходящий порт> <коэффициент>
|
||||
где: <сервис> может быть proxy, socks4, socks45, socks5, tcppm, udppm, pop3p
|
||||
если сервис указан неверно то считается, что это может быть любой сервис.
|
||||
можно использовать *, тогда правило будет считаться для любого сервиса.
|
||||
<исходящий порт> - порт, к которому подключается прокси сервер. * - любой
|
||||
<коэффициент> - число на каоторое домнажается траффик. Обязательный параметр.
|
||||
Должен быть от больше 0 и меньше 100
|
||||
|
||||
ДЛЯ РЕЖИМА С УЧЁТОМ РАЗМЕРА ЗАГОЛОВКОВ ПАКЕТОВ:
|
||||
trafcorrect p <сервис> <tcp/udp> <исходящий порт> [размер пустого пакета]
|
||||
<tcp/udp> - протокол, по которому осуществляется соединение.
|
||||
[размер пакета] - средний размер пустого пакета. Можно определить захватив
|
||||
данные при помощи такой утилиты как Ethernal. Параметр необязателен. Если отсутствует,
|
||||
то размер пакета будет считаться равным 66 байт.
|
||||
ДЛЯ РЕЖИМА С УЧЁТОМ РАЗМЕРА ЗАГОЛОВКОВ ПАКЕТОВ:
|
||||
trafcorrect p <сервис> <tcp/udp> <исходящий порт> [размер пустого пакета]
|
||||
<tcp/udp> - протокол, по которому осуществляется соединение.
|
||||
[размер пакета] - средний размер пустого пакета. Можно определить захватив
|
||||
данные при помощи такой утилиты как Ethernal. Параметр необязателен. Если отсутствует,
|
||||
то размер пакета будет считаться равным 66 байт.
|
||||
|
||||
Режимы можно смешивать.
|
||||
Следует учитывать, что плугин создаёт список всех правил изменения траффика.
|
||||
Когда происходит окончание соединения выполняется первое подходящее правило.
|
||||
Режимы можно смешивать.
|
||||
Следует учитывать, что плугин создаёт список всех правил изменения траффика.
|
||||
Когда происходит окончание соединения выполняется первое подходящее правило.
|
||||
|
||||
Пример:
|
||||
Пример:
|
||||
plugin "TrafficPlugin.dll" start
|
||||
trafcorrect m socks5 6112 4.5
|
||||
trafcorrect m socks5 * 1.1
|
||||
|
||||
следующее неверно:
|
||||
следующее неверно:
|
||||
plugin "TrafficPlugin.dll" start
|
||||
trafcorrect m socks5 * 1.1
|
||||
trafcorrect m socks5 6112 4.5
|
||||
Вторая строчка выполнена никогда не будет. Так как 1 имеет более широкое назначение.
|
||||
Вторая строчка выполнена никогда не будет. Так как 1 имеет более широкое назначение.
|
||||
|
||||
РЕЖИМ ОТЛАДКИ ПРАВИЛ:
|
||||
1. Запускает прокси в оконном режиме (чтобы видеть stdout).
|
||||
2. Загрузка плагина должна выглядеть сл. образом:
|
||||
РЕЖИМ ОТЛАДКИ ПРАВИЛ:
|
||||
1. Запускает прокси в оконном режиме (чтобы видеть stdout).
|
||||
2. Загрузка плагина должна выглядеть сл. образом:
|
||||
plugin "TrafficPlugin.dll" start debug
|
||||
3. В окне прокси сервера будет написана информация о прохождении правил коррекции траффика.
|
||||
Правила нумеруются с 1.
|
||||
3. В окне прокси сервера будет написана информация о прохождении правил коррекции траффика.
|
||||
Правила нумеруются с 1.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Copyright:
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
/*
|
||||
3proxy Traffic correct plugin v0.1 beta
|
||||
|
||||
Написал Maslov Michael aka Flexx(rus)
|
||||
Формула расчёта траффика по размеру пакета by 3APA3A
|
||||
Написал Maslov Michael aka Flexx(rus)
|
||||
Формула расчёта траффика по размеру пакета by 3APA3A
|
||||
email: flexx_rus@mail.ru
|
||||
ICQ: 299132764
|
||||
http://3proxy.ru/
|
||||
|
||||
Как работает не знаю (многое зависит от ваших настроек). Никаких гарантий.
|
||||
С плугином можете делать всё, что захочется.
|
||||
Дожен распростроняться только с исходными кодами или вместе с 3proxy.
|
||||
Удалять данный Copyright запрещено.
|
||||
Как работает не знаю (многое зависит от ваших настроек). Никаких гарантий.
|
||||
С плугином можете делать всё, что захочется.
|
||||
Дожен распростроняться только с исходными кодами или вместе с 3proxy.
|
||||
Удалять данный Copyright запрещено.
|
||||
*/
|
||||
|
||||
#include "../../structures.h"
|
||||
@ -33,8 +33,8 @@ struct commands * commandhandlers;
|
||||
struct pluginlink * pl;
|
||||
|
||||
typedef enum {
|
||||
MULTIPLAY, /* метод коррекции умножением на коффициент */
|
||||
IPCORRECT, /* метод коррекции с учётом размера пакета */
|
||||
MULTIPLAY, /* метод коррекции умножением на коффициент */
|
||||
IPCORRECT, /* метод коррекции с учётом размера пакета */
|
||||
} TRAFCORRECT_TYPE;
|
||||
|
||||
typedef enum {
|
||||
@ -84,7 +84,7 @@ int h_trafcorrect(int argc, unsigned char ** argv) {
|
||||
if(DBGLEVEL == 1)fprintf(stdout, "See documentation of traffic correct plugin.\n");
|
||||
return 1;
|
||||
}
|
||||
/* режим умножения траффика на коэффициент */
|
||||
/* режим умножения траффика на коэффициент */
|
||||
if (!strcmp((char *)argv[1], "m")) {
|
||||
struct trafcorrect * newitem;
|
||||
if (argc < 5) {
|
||||
@ -110,7 +110,7 @@ int h_trafcorrect(int argc, unsigned char ** argv) {
|
||||
|
||||
newitem->port = atoi((char *)argv[3]);
|
||||
newitem->coeff = atof((char *)argv[4]);
|
||||
/* проверка на корректность ввода */
|
||||
/* проверка на корректность ввода */
|
||||
if ((newitem->port>65535) || (newitem->coeff<=0) || (newitem->coeff>100)) {
|
||||
free(newitem);
|
||||
if(DBGLEVEL == 1)fprintf(stdout, "Port must be 0<p<65535 and coefficient must be 0<c<100.\n");
|
||||
@ -119,7 +119,7 @@ int h_trafcorrect(int argc, unsigned char ** argv) {
|
||||
addtrafcorrect(newitem);
|
||||
return 0;
|
||||
}
|
||||
/* режим учёта входящих и исходящих пакетов */
|
||||
/* режим учёта входящих и исходящих пакетов */
|
||||
if (!strcmp((char *)argv[1], "p")) {
|
||||
struct trafcorrect * newitem;
|
||||
if (argc < 5) {
|
||||
@ -152,7 +152,7 @@ int h_trafcorrect(int argc, unsigned char ** argv) {
|
||||
}
|
||||
|
||||
newitem->port = atoi((char *)argv[4]);
|
||||
/* последний необязательный параметр - размер пакета */
|
||||
/* последний необязательный параметр - размер пакета */
|
||||
if (argc >= 6) {
|
||||
newitem->psize = atoi((char *)argv[5]);
|
||||
}
|
||||
@ -169,7 +169,7 @@ int h_trafcorrect(int argc, unsigned char ** argv) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static uint16_t myhtons(uint16_t port) {
|
||||
static unsigned short myhtons(unsigned short port) {
|
||||
return (port << 8) | (port >> 8);
|
||||
}
|
||||
|
||||
@ -207,8 +207,8 @@ void mylogfunc(struct clientparam * param, const unsigned char * pz) {
|
||||
(param->operation == ICMPASSOC))
|
||||
)||(starttrafcorrect->con_type == TCP))) /* TCP support */
|
||||
{
|
||||
/* фильтр подошёл. можно изменять значение траффика
|
||||
домножаем на число */
|
||||
/* фильтр подошёл. можно изменять значение траффика
|
||||
домножаем на число */
|
||||
if (starttrafcorrect->type == MULTIPLAY) {
|
||||
#ifndef NOPSTDINT
|
||||
param->statssrv64 = (unsigned)((double)param->statssrv64 *starttrafcorrect->coeff);
|
||||
@ -218,7 +218,7 @@ void mylogfunc(struct clientparam * param, const unsigned char * pz) {
|
||||
param->statscli = (unsigned)((double)param->statscli * starttrafcorrect->coeff);
|
||||
#endif
|
||||
}
|
||||
/* с учётом пакетов */
|
||||
/* с учётом пакетов */
|
||||
if (starttrafcorrect->type == IPCORRECT) {
|
||||
if (starttrafcorrect->con_type == TCP) {
|
||||
#ifndef NOPSTDINT
|
||||
@ -240,7 +240,7 @@ void mylogfunc(struct clientparam * param, const unsigned char * pz) {
|
||||
}
|
||||
if (DBGLEVEL == 1) {
|
||||
#ifndef NOPSTDINT
|
||||
fprintf(stdout, "Port=%hd; Before: srv=%"PRId64", cli=%"PRId64"; After: srv=%"PRId64", cli=%"PRId64"; nreads=%ld; nwrites=%ld; Rule=%d\n",myhtons(*SAPORT(¶m->sinsr)), statssrv_before, statscli_before, param->statssrv64, param->statscli64,param->nreads,param->nwrites,rule);
|
||||
fprintf(stdout, "Port=%hd; Before: srv=%"PRINTF_INT64_MODIFIER"d, cli=%"PRINTF_INT64_MODIFIER"d; After: srv=%"PRINTF_INT64_MODIFIER"d, cli=%"PRINTF_INT64_MODIFIER"d; nreads=%ld; nwrites=%ld; Rule=%d\n",myhtons(*SAPORT(¶m->sinsr)), statssrv_before, statscli_before, param->statssrv64, param->statscli64,param->nreads,param->nwrites,rule);
|
||||
#else
|
||||
fprintf(stdout, "Port=%hd; Before: srv=%lu, cli=%lu; After: srv=%lu, cli=%lu; nreads=%ld; nwrites=%ld; Rule=%d\n",myhtons(param->sins.sin_port), statssrv_before, statscli_before, param->statssrv, param->statscli,param->nreads,param->nwrites,rule);
|
||||
#endif
|
||||
@ -294,7 +294,7 @@ PLUGINAPI int PLUGINCALL start(struct pluginlink * pluginlink, int argc, char**
|
||||
return 0;
|
||||
}
|
||||
already_loaded = 1;
|
||||
/* добавляем команду "trafcorrect" */
|
||||
/* добавляем команду "trafcorrect" */
|
||||
starthandler = commandhandlers;
|
||||
for ( ; starthandler->next; starthandler = starthandler->next);
|
||||
trafcorrect_handler.next = NULL;
|
||||
@ -304,7 +304,7 @@ PLUGINAPI int PLUGINCALL start(struct pluginlink * pluginlink, int argc, char**
|
||||
trafcorrect_handler.handler = h_trafcorrect;
|
||||
starthandler->next = &trafcorrect_handler;
|
||||
|
||||
/* подменяем conf->logfunc, с целью контролировать траффик */
|
||||
/* подменяем conf->logfunc, с целью контролировать траффик */
|
||||
origlogfunc = conf->logfunc;
|
||||
conf->logfunc = mylogfunc;
|
||||
return 0;
|
||||
|
||||
16
src/proxy.c
16
src/proxy.c
@ -337,10 +337,10 @@ for(;;){
|
||||
if(su) {
|
||||
su = (unsigned char *)mystrdup((char *)sb);
|
||||
decodeurl(su, 0);
|
||||
if(parseconnusername((char *)su, (struct clientparam *)param, 1, (uint16_t)((ftp)?21:80))) RETURN (100);
|
||||
if(parseconnusername((char *)su, (struct clientparam *)param, 1, (unsigned short)((ftp)?21:80))) RETURN (100);
|
||||
myfree(su);
|
||||
}
|
||||
else if(parsehostname((char *)sb, (struct clientparam *)param, (uint16_t)((ftp)? 21:80))) RETURN(100);
|
||||
else if(parsehostname((char *)sb, (struct clientparam *)param, (unsigned short)((ftp)? 21:80))) RETURN(100);
|
||||
if(!isconnect){
|
||||
if(se==sg)*se-- = ' ';
|
||||
*se = '/';
|
||||
@ -455,7 +455,7 @@ for(;;){
|
||||
if(!sb)continue;
|
||||
++sb;
|
||||
while(isspace(*sb))sb++;
|
||||
sscanf((char *)sb, "%"SCNu64"",&contentlength64);
|
||||
sscanf((char *)sb, "%"PRINTF_INT64_MODIFIER"u",&contentlength64);
|
||||
if(param->maxtrafout64 && (param->maxtrafout64 < param->statscli64 || contentlength64 > param->maxtrafout64 - param->statscli64)){
|
||||
RETURN(10);
|
||||
}
|
||||
@ -527,7 +527,7 @@ for(;;){
|
||||
}
|
||||
else if(param->ndatfilterscli > 0 && contentlength64 > 0){
|
||||
uint64_t newlen64;
|
||||
newlen64 = (uint64_t) sockfillbuffcli(param, (unsigned long)contentlength64, CONNECTION_S);
|
||||
newlen64 = sockfillbuffcli(param, (unsigned long)contentlength64, CONNECTION_S);
|
||||
if(newlen64 == contentlength64) {
|
||||
action = handledatfltcli(param, ¶m->clibuf, (int *)¶m->clibufsize, 0, (int *)¶m->cliinbuf);
|
||||
if(action == HANDLED){
|
||||
@ -537,7 +537,7 @@ for(;;){
|
||||
contentlength64 = param->cliinbuf;
|
||||
param->nolongdatfilter = 1;
|
||||
}
|
||||
sprintf((char*)buf+strlen((char *)buf), "Content-Length: %"PRIu64"\r\n", contentlength64);
|
||||
sprintf((char*)buf+strlen((char *)buf), "Content-Length: %"PRINTF_INT64_MODIFIER"u\r\n", contentlength64);
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -911,7 +911,7 @@ for(;;){
|
||||
if(!sb)continue;
|
||||
++sb;
|
||||
while(isspace(*sb))sb++;
|
||||
sscanf((char *)sb, "%"SCNu64"", &contentlength64);
|
||||
sscanf((char *)sb, "%"PRINTF_INT64_MODIFIER"u", &contentlength64);
|
||||
hascontent = 1;
|
||||
if(param->unsafefilter && param->ndatfilterssrv > 0) {
|
||||
hascontent = 2;
|
||||
@ -989,7 +989,7 @@ for(;;){
|
||||
}
|
||||
if(action != PASS) RETURN(517);
|
||||
contentlength64 = param->srvinbuf;
|
||||
sprintf((char*)buf+strlen((char *)buf), "Content-Length: %"PRIu64"\r\n", contentlength64);
|
||||
sprintf((char*)buf+strlen((char *)buf), "Content-Length: %"PRINTF_INT64_MODIFIER"u\r\n", contentlength64);
|
||||
hascontent = 1;
|
||||
}
|
||||
}
|
||||
@ -1036,7 +1036,7 @@ for(;;){
|
||||
}
|
||||
smallbuf[i] = 0;
|
||||
contentlength64 = 0;
|
||||
sscanf((char *)smallbuf, "%"SCNx64"", &contentlength64);
|
||||
sscanf((char *)smallbuf, "%"PRINTF_INT64_MODIFIER"x", &contentlength64);
|
||||
if(contentlength64 == 0) {
|
||||
param->chunked = 2;
|
||||
}
|
||||
|
||||
20
src/proxy.h
20
src/proxy.h
@ -164,8 +164,8 @@ int sockrecvfrom(struct clientparam *param, SOCKET sock, struct sockaddr * sin,
|
||||
|
||||
int sockgetcharcli(struct clientparam * param, int timeosec, int timeousec);
|
||||
int sockgetcharsrv(struct clientparam * param, int timeosec, int timeousec);
|
||||
unsigned long sockfillbuffcli(struct clientparam * param, unsigned long size, int timeosec);
|
||||
unsigned long sockfillbuffsrv(struct clientparam * param, unsigned long size, int timeosec);
|
||||
int sockfillbuffcli(struct clientparam * param, unsigned long size, int timeosec);
|
||||
int sockfillbuffsrv(struct clientparam * param, unsigned long size, int timeosec);
|
||||
|
||||
int sockgetlinebuf(struct clientparam * param, DIRECTION which, unsigned char * buf, int bufsize, int delim, int to);
|
||||
|
||||
@ -195,15 +195,15 @@ void trafcountfunc(struct clientparam *param);
|
||||
unsigned bandlimitfunc(struct clientparam *param, unsigned nbytesin, unsigned nbytesout);
|
||||
int handleredirect(struct clientparam * param, struct ace * acentry);
|
||||
|
||||
int scanaddr(const unsigned char *s, uint32_t * ip, uint32_t * mask);
|
||||
int scanaddr(const unsigned char *s, unsigned long * ip, unsigned long * mask);
|
||||
int myinet_ntop(int af, void *src, char *dst, socklen_t size);
|
||||
extern struct nserver nservers[MAXNSERVERS];
|
||||
extern struct nserver authnserver;
|
||||
uint32_t getip(unsigned char *name);
|
||||
uint32_t getip46(int family, unsigned char *name, struct sockaddr *sa);
|
||||
unsigned long getip(unsigned char *name);
|
||||
unsigned long getip46(int family, unsigned char *name, struct sockaddr *sa);
|
||||
int afdetect(unsigned char *name);
|
||||
uint32_t myresolver(int, unsigned char *, unsigned char *);
|
||||
uint32_t fakeresolver (int, unsigned char *, unsigned char*);
|
||||
unsigned long myresolver(int, unsigned char *, unsigned char *);
|
||||
unsigned long fakeresolver (int, unsigned char *, unsigned char*);
|
||||
int inithashtable(struct hashtable *hashtable, unsigned nhashsize);
|
||||
void freeparam(struct clientparam * param);
|
||||
void clearstat(struct clientparam * param);
|
||||
@ -248,13 +248,13 @@ struct hashtable;
|
||||
void hashadd(struct hashtable *ht, const unsigned char* name, unsigned char* value, time_t expires);
|
||||
|
||||
int parsehost(int family, unsigned char *host, struct sockaddr *sa);
|
||||
int parsehostname(char *hostname, struct clientparam *param, uint16_t port);
|
||||
int parsehostname(char *hostname, struct clientparam *param, unsigned short port);
|
||||
int parseusername(char *username, struct clientparam *param, int extpasswd);
|
||||
int parseconnusername(char *username, struct clientparam *param, int extpasswd, uint16_t port);
|
||||
int parseconnusername(char *username, struct clientparam *param, int extpasswd, unsigned short port);
|
||||
int ACLmatches(struct ace* acentry, struct clientparam * param);
|
||||
int checkACL(struct clientparam * param);
|
||||
extern int havelog;
|
||||
uint32_t udpresolve(int af, unsigned char * name, unsigned char * value, uint32_t *retttl, struct clientparam* param, int makeauth);
|
||||
unsigned long udpresolve(int af, unsigned char * name, unsigned char * value, unsigned *retttl, struct clientparam* param, int makeauth);
|
||||
|
||||
struct ace * copyacl (struct ace *ac);
|
||||
struct auth * copyauth (struct auth *);
|
||||
|
||||
@ -573,7 +573,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
||||
else {
|
||||
#endif
|
||||
#ifndef NOPORTMAP
|
||||
if (error || argc != i+3 || *argv[i]=='-'|| (*SAPORT(&srv.intsa) = htons((uint16_t)atoi(argv[i])))==0 || (srv.targetport = htons((uint16_t)atoi(argv[i+2])))==0) {
|
||||
if (error || argc != i+3 || *argv[i]=='-'|| (*SAPORT(&srv.intsa) = htons((unsigned short)atoi(argv[i])))==0 || (srv.targetport = htons((unsigned short)atoi(argv[i+2])))==0) {
|
||||
#ifndef STDMAIN
|
||||
haveerror = 1;
|
||||
pushthreadinit();
|
||||
@ -718,7 +718,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
||||
defparam.clisock = sock;
|
||||
|
||||
if(!srv.silent && !iscbc){
|
||||
sprintf((char *)buf, "Accepting connections [%"PRIu64"/%"PRIu64"]", (uint64_t)getpid(), (uint64_t)pthread_self());
|
||||
sprintf((char *)buf, "Accepting connections [%"PRINTF_INT64_MODIFIER"u/%"PRINTF_INT64_MODIFIER"u]", (uint64_t)getpid(), (uint64_t)pthread_self());
|
||||
dolog(&defparam, buf);
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,7 +87,7 @@ int sockgetcharcli(struct clientparam * param, int timeosec, int timeousec){
|
||||
return (int)*param->clibuf;
|
||||
}
|
||||
|
||||
unsigned long sockfillbuffcli(struct clientparam * param, unsigned long size, int timeosec){
|
||||
int sockfillbuffcli(struct clientparam * param, unsigned long size, int timeosec){
|
||||
int len;
|
||||
|
||||
if(!param->clibuf) return 0;
|
||||
@ -107,7 +107,7 @@ unsigned long sockfillbuffcli(struct clientparam * param, unsigned long size, in
|
||||
return param->cliinbuf;
|
||||
}
|
||||
|
||||
unsigned long sockfillbuffsrv(struct clientparam * param, unsigned long size, int timeosec){
|
||||
int sockfillbuffsrv(struct clientparam * param, unsigned long size, int timeosec){
|
||||
int len;
|
||||
|
||||
if(!param->srvbuf) return 0;
|
||||
|
||||
@ -60,8 +60,7 @@ int sockmap(struct clientparam * param, int timeo, int usesplice){
|
||||
int res;
|
||||
SASIZETYPE sasize;
|
||||
int needaction = 0;
|
||||
int graceclinum=0, gracesrvnum=0, graceclitraf=0, gracesrvtraf=0;
|
||||
time_t gracetime = 0;
|
||||
int graceclinum=0, gracesrvnum=0, graceclitraf=0, gracesrvtraf=0, gracetime=0;
|
||||
|
||||
#ifdef WITHSPLICE
|
||||
uint64_t inclientpipe = 0, inserverpipe = 0;
|
||||
|
||||
@ -37,7 +37,7 @@ void * sockschild(struct clientparam* param) {
|
||||
SOCKET s;
|
||||
unsigned size;
|
||||
SASIZETYPE sasize;
|
||||
uint16_t port = 0;
|
||||
unsigned short port = 0;
|
||||
unsigned char * buf=NULL;
|
||||
unsigned char c;
|
||||
unsigned char command=0;
|
||||
@ -102,7 +102,7 @@ void * sockschild(struct clientparam* param) {
|
||||
buf[0] = (unsigned char) res;
|
||||
if ((res = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(441);}
|
||||
buf[1] = (unsigned char) res;
|
||||
port = *(uint16_t*)buf;
|
||||
port = *(unsigned short*)buf;
|
||||
c = 1;
|
||||
}
|
||||
|
||||
@ -162,7 +162,7 @@ void * sockschild(struct clientparam* param) {
|
||||
buf[0] = (unsigned char) res;
|
||||
if ((res = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(441);}
|
||||
buf[1] = (unsigned char) res;
|
||||
port = *(uint16_t*)buf;
|
||||
port = *(unsigned short*)buf;
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
@ -15,8 +15,8 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdint.h>
|
||||
#ifndef PRId64
|
||||
#include <inttypes.h>
|
||||
#ifndef PRINTF_INT64_MODIFIER
|
||||
#define PRINTF_INT64_MODIFIER "ll"
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -198,7 +198,7 @@ struct srvparam;
|
||||
typedef void (*LOGFUNC)(struct clientparam * param, const unsigned char *);
|
||||
typedef int (*AUTHFUNC)(struct clientparam * param);
|
||||
typedef void * (*REDIRECTFUNC)(struct clientparam * param);
|
||||
typedef uint32_t (*RESOLVFUNC)(int af, unsigned char *name, unsigned char *value);
|
||||
typedef unsigned long (*RESOLVFUNC)(int af, unsigned char *name, unsigned char *value);
|
||||
typedef unsigned (*BANDLIMFUNC)(struct clientparam * param, unsigned nbytesin, unsigned nbytesout);
|
||||
typedef void (*TRAFCOUNTFUNC)(struct clientparam * param);
|
||||
typedef void * (*EXTENDFUNC) (struct node *node);
|
||||
@ -241,8 +241,8 @@ struct iplist {
|
||||
|
||||
struct portlist {
|
||||
struct portlist * next;
|
||||
uint16_t startport;
|
||||
uint16_t endport;
|
||||
unsigned short startport;
|
||||
unsigned short endport;
|
||||
};
|
||||
|
||||
struct userlist {
|
||||
@ -536,7 +536,7 @@ struct srvparam {
|
||||
unsigned char * logformat;
|
||||
unsigned char * logtarget;
|
||||
unsigned char * nonprintable;
|
||||
uint16_t targetport;
|
||||
unsigned short targetport;
|
||||
unsigned char replace;
|
||||
time_t time_start;
|
||||
};
|
||||
@ -732,7 +732,7 @@ struct symbol {
|
||||
|
||||
struct proxydef {
|
||||
PROXYFUNC pf;
|
||||
uint16_t port;
|
||||
unsigned short port;
|
||||
int isudp;
|
||||
int service;
|
||||
char * helpmessage;
|
||||
@ -780,8 +780,8 @@ struct pluginlink {
|
||||
int (*myinet_ntop)(int af, void *src, char *dst, socklen_t size);
|
||||
int (*dobuf)(struct clientparam * param, unsigned char * buf, const unsigned char *s, const unsigned char * doublec);
|
||||
int (*dobuf2)(struct clientparam * param, unsigned char * buf, const unsigned char *s, const unsigned char * doublec, struct tm* tm, char * format);
|
||||
int (*scanaddr)(const unsigned char *s, uint32_t * ip, uint32_t * mask);
|
||||
uint32_t (*getip46)(int family, unsigned char *name, struct sockaddr *sa);
|
||||
int (*scanaddr)(const unsigned char *s, unsigned long * ip, unsigned long * mask);
|
||||
unsigned long (*getip46)(int family, unsigned char *name, struct sockaddr *sa);
|
||||
int (*sockmap)(struct clientparam * param, int timeo, int usesplice);
|
||||
int (*ACLMatches)(struct ace* acentry, struct clientparam * param);
|
||||
int (*alwaysauth)(struct clientparam * param);
|
||||
@ -807,9 +807,9 @@ struct pluginlink {
|
||||
struct proxydef * childdef;
|
||||
int (*start_proxy_thread)(struct child * chp);
|
||||
void (*freeparam)(struct clientparam * param);
|
||||
int (*parsehostname)(char *hostname, struct clientparam *param, uint16_t port);
|
||||
int (*parsehostname)(char *hostname, struct clientparam *param, unsigned short port);
|
||||
int (*parseusername)(char *username, struct clientparam *param, int extpasswd);
|
||||
int (*parseconnusername)(char *username, struct clientparam *param, int extpasswd, uint16_t port);
|
||||
int (*parseconnusername)(char *username, struct clientparam *param, int extpasswd, unsigned short port);
|
||||
struct sockfuncs *so;
|
||||
unsigned char * (*dologname) (unsigned char *buf, unsigned char *name, const unsigned char *ext, ROTATION lt, time_t t);
|
||||
};
|
||||
|
||||
44
src/tlspr.c
44
src/tlspr.c
@ -38,9 +38,13 @@ int readtls(struct clientparam *param, int direction, unsigned char *buf, int bu
|
||||
#define PROTOLEN (32)
|
||||
|
||||
|
||||
int parsehello(int type, unsigned char *hello, unsigned len, char *sni, int * snipos, int *lv, char * proto){
|
||||
int parsehello(int type, unsigned char *hello, int len, char *sni, int * snipos, int *lv, char * proto){
|
||||
int hlen;
|
||||
unsigned offset;
|
||||
unsigned hlen, slen, cslen, elen, snllen, snlen, alpnlen;
|
||||
int slen;
|
||||
int cslen;
|
||||
int elen;
|
||||
int snllen, snlen, alpnlen;
|
||||
int snifound=0;
|
||||
|
||||
if(len < 64) return -1;
|
||||
@ -70,7 +74,7 @@ int parsehello(int type, unsigned char *hello, unsigned len, char *sni, int * sn
|
||||
offset += 2;
|
||||
if(elen+offset != len) return -9;
|
||||
while(elen > 1){
|
||||
unsigned xlen;
|
||||
int xlen;
|
||||
xlen = size16(hello+offset+2);
|
||||
if(xlen+4 > elen) return -10;
|
||||
if(type == 1 && hello[offset] == 0 && hello[offset+1] == 0){
|
||||
@ -108,8 +112,8 @@ int parsehello(int type, unsigned char *hello, unsigned len, char *sni, int * sn
|
||||
return snifound;
|
||||
}
|
||||
|
||||
int tlstobufcli(struct clientparam *param){
|
||||
unsigned long len, newlen;
|
||||
int tlstobufcli(struct clientparam *param, int offset){
|
||||
int len, newlen;
|
||||
if(!param->clibuf){
|
||||
if(!(param->clibuf = myalloc(SRVBUFSIZE))) return -1;
|
||||
param->clibufsize = SRVBUFSIZE;
|
||||
@ -135,11 +139,11 @@ int tlstobufcli(struct clientparam *param){
|
||||
if(param->cliinbuf <= newlen) return -5;
|
||||
}
|
||||
}
|
||||
return (int)len;
|
||||
return len;
|
||||
}
|
||||
|
||||
int tlstobufsrv(struct clientparam *param){
|
||||
unsigned long len, newlen;
|
||||
int tlstobufsrv(struct clientparam *param, int offset){
|
||||
int len, newlen;
|
||||
|
||||
if(param->cliinbuf != param->clioffset){
|
||||
len = socksend(param, param->remsock, param->clibuf+param->clioffset,param->cliinbuf-param->clioffset, conf.timeouts[STRING_S]);
|
||||
@ -153,20 +157,20 @@ int tlstobufsrv(struct clientparam *param){
|
||||
param->srvbufsize = SRVBUFSIZE;
|
||||
param->srvoffset = param->srvinbuf = 0;
|
||||
}
|
||||
len = sockfillbuffsrv(param, 5, conf.timeouts[STRING_S]);
|
||||
if(len < 5) return -3;
|
||||
if(param->srvbuf[1] != 3) {
|
||||
len = sockfillbuffsrv(param, offset+5, conf.timeouts[STRING_S]);
|
||||
if(len < offset+5) return -3;
|
||||
if(param->srvbuf[offset+1] != 3) {
|
||||
return -4;
|
||||
}
|
||||
else {
|
||||
len = 5 + size16(param->srvbuf+3);
|
||||
len = offset + 5 + size16(param->srvbuf+offset+3);
|
||||
if(len > param->srvbufsize) return -5;
|
||||
for(newlen=param->srvinbuf; newlen < len; newlen=param->srvinbuf){
|
||||
sockfillbuffsrv(param, len, conf.timeouts[STRING_S]);
|
||||
if(param->srvinbuf <= newlen) return -6;
|
||||
}
|
||||
}
|
||||
return (int)len;
|
||||
return len-offset;
|
||||
}
|
||||
|
||||
void * tlsprchild(struct clientparam* param) {
|
||||
@ -177,13 +181,13 @@ void * tlsprchild(struct clientparam* param) {
|
||||
char proto[PROTOLEN]="-";
|
||||
int snipos = 0;
|
||||
|
||||
res = tlstobufcli(param);
|
||||
res = tlstobufcli(param, 0);
|
||||
if(res <= 0 || param->clibuf[0] != 22){
|
||||
if(param->srv->requirecert)RETURN(300-res);
|
||||
}
|
||||
else {
|
||||
lv = param->clibuf[2];
|
||||
res = parsehello(1, param->clibuf, (unsigned)res, sni, &snipos, &lv, proto);
|
||||
res = parsehello(1, param->clibuf, res, sni, &snipos, &lv, proto);
|
||||
if(res > 0){
|
||||
if(param->hostname){
|
||||
myfree(param->hostname);
|
||||
@ -221,20 +225,20 @@ void * tlsprchild(struct clientparam* param) {
|
||||
}
|
||||
|
||||
if(param->srv->requirecert > 1){
|
||||
res = tlstobufsrv(param);
|
||||
res = tlstobufsrv(param, 0);
|
||||
if(res <= 0 || param->srvbuf[0] != 22) RETURN(340-res);
|
||||
lv = param->srvbuf[2];
|
||||
res = parsehello(2, param->srvbuf, (unsigned)res, sni, &snipos, &lv, proto);
|
||||
res = parsehello(2, param->srvbuf, res, sni, &snipos, &lv, proto);
|
||||
if (res < 0) RETURN(350-res);
|
||||
}
|
||||
if(param->srv->requirecert > 2){
|
||||
int srvcert=0, clicert=0, reqcert=0, len, done;
|
||||
int srvcert=0, clicert=0, reqcert=0, len, rlen, done;
|
||||
if(lv > 3) RETURN(370);
|
||||
for(done=0;!done;) {
|
||||
len = param->srvinbuf;
|
||||
if(socksend(param, param->clisock, param->srvbuf,len, conf.timeouts[STRING_S]) != len) RETURN(371);
|
||||
param->srvinbuf = 0;
|
||||
res = tlstobufsrv(param);
|
||||
res = tlstobufsrv(param, 0);
|
||||
if(res <= 0) RETURN(380-res);
|
||||
if(param->srvbuf[0]!= 22) break;
|
||||
switch(param->srvbuf[5]){
|
||||
@ -256,7 +260,7 @@ void * tlsprchild(struct clientparam* param) {
|
||||
if(param->srv->requirecert > 3){
|
||||
if(!reqcert) RETURN(374);
|
||||
for(done=0;!done;) {
|
||||
res = tlstobufcli(param);
|
||||
res = tlstobufcli(param, 0);
|
||||
if(res <= 0) RETURN(390-res);
|
||||
len = res;
|
||||
if(param->clibuf[0]!= 22) break;
|
||||
|
||||
12
src/udppm.c
12
src/udppm.c
@ -17,6 +17,16 @@
|
||||
#define RETURN(xxx) { param->res = xxx; goto CLEANRET; }
|
||||
|
||||
|
||||
struct udpmap {
|
||||
struct udpmap *next;
|
||||
time_t updated;
|
||||
SOCKET s;
|
||||
int single;
|
||||
unsigned long cliip;
|
||||
unsigned short cliport;
|
||||
};
|
||||
|
||||
|
||||
void * udppmchild(struct clientparam* param) {
|
||||
unsigned char *buf = NULL;
|
||||
int res, i;
|
||||
@ -24,6 +34,8 @@ void * udppmchild(struct clientparam* param) {
|
||||
SASIZETYPE size;
|
||||
unsigned long ul = 1;
|
||||
#endif
|
||||
struct udpmap *udpmappings = NULL;
|
||||
struct pollfd fds[256];
|
||||
|
||||
|
||||
if(!param->hostname && parsehostname((char *)param->srv->target, param, ntohs(param->srv->targetport))) RETURN(100);
|
||||
|
||||
@ -510,9 +510,9 @@ void * adminchild(struct clientparam* param) {
|
||||
}
|
||||
else {
|
||||
inbuf += sprintf(buf+inbuf,
|
||||
"</td><td>%"PRIu64"</td>"
|
||||
"</td><td>%"PRINTF_INT64_MODIFIER"u</td>"
|
||||
"<td>MB%s</td>"
|
||||
"<td>%"PRIu64".%"PRIu64"</td>"
|
||||
"<td>%"PRINTF_INT64_MODIFIER"u.%"PRINTF_INT64_MODIFIER"u</td>"
|
||||
"<td>%s</td>",
|
||||
cp->traflim64 / (1024 * 1024),
|
||||
rotations[cp->type],
|
||||
@ -593,7 +593,7 @@ void * adminchild(struct clientparam* param) {
|
||||
if(writable && !error){
|
||||
fflush(writable);
|
||||
#ifndef _WINCE
|
||||
if(ftruncate(fileno(writable), ftell(writable))){}
|
||||
ftruncate(fileno(writable), ftell(writable));
|
||||
#endif
|
||||
}
|
||||
printstr(&pp, error? "<h3><font color=\"red\">Config file is not writable</font></h3>Make sure you have \"writable\" command in configuration file":
|
||||
|
||||
Loading…
Reference in New Issue
Block a user