mirror of
https://github.com/3proxy/3proxy.git
synced 2026-04-12 16:00:11 +08:00
Compare commits
29 Commits
8195e398bf
...
bf35be8e8c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf35be8e8c | ||
|
|
09f8eec6a1 | ||
|
|
0879851870 | ||
|
|
444bfaebca | ||
|
|
ac2bcb9118 | ||
|
|
a7637c6680 | ||
|
|
4abe83eeba | ||
|
|
e600702de8 | ||
|
|
604f9800dd | ||
|
|
66ef22ec35 | ||
|
|
49d88d0884 | ||
|
|
ed4d5bc5f1 | ||
|
|
2dc7c92f0f | ||
|
|
f1b36dadc7 | ||
|
|
e8968cf6df | ||
|
|
e90663da69 | ||
|
|
87def2a707 | ||
|
|
503f593941 | ||
|
|
26679cbb60 | ||
|
|
d93791b815 | ||
|
|
d53a592c8a | ||
|
|
afd71eb6a0 | ||
|
|
8d2a788c58 | ||
|
|
9431810309 | ||
|
|
c61ce2217d | ||
|
|
16b7f90aab | ||
|
|
96c3068a6c | ||
|
|
dfb70a4c60 | ||
|
|
983df6f7ae |
51
.github/workflows/build-rpm-arm64.yml
vendored
Normal file
51
.github/workflows/build-rpm-arm64.yml
vendored
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
name: RPM build arm64
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "master" ]
|
||||||
|
paths: [ 'RELEASE', '.github/workflows/build-rpm-arm64.yml' ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ci:
|
||||||
|
name: "${{ matrix.target }}"
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
target:
|
||||||
|
- ubuntu-24.04-arm
|
||||||
|
runs-on: ${{ matrix.target }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v5
|
||||||
|
- name: env
|
||||||
|
run: |
|
||||||
|
pwd
|
||||||
|
echo "RELEASE=$(cat RELEASE)" >> $GITHUB_ENV
|
||||||
|
echo "VERSION=$(date +%y%m%d%H%M%S)" >> $GITHUB_ENV
|
||||||
|
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
|
||||||
|
- name: make rpmbuild dir
|
||||||
|
run: mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
|
||||||
|
- name: configure rpm env
|
||||||
|
run: |
|
||||||
|
tar -czf ~/rpmbuild/SOURCES/3proxy-$RELEASE.tar.gz --transform "s,^,3proxy-$RELEASE/," .
|
||||||
|
ln -s ~/rpmbuild/SOURCES/3proxy-$RELEASE.tar.gz ~/rpmbuild/SOURCES/$RELEASE.tar.gz
|
||||||
|
cp scripts/rh/3proxy.spec ~/rpmbuild/SPECS/3proxy-$RELEASE.spec
|
||||||
|
- name: rpmbuild
|
||||||
|
run: |
|
||||||
|
ret=`pwd`
|
||||||
|
cd ~/rpmbuild/SPECS
|
||||||
|
rpmbuild -ba 3proxy-$RELEASE.spec
|
||||||
|
cd $ret
|
||||||
|
mv ~/rpmbuild/RPMS/aarch64/3proxy-$RELEASE-1.aarch64.rpm 3proxy-$RELEASE.arm64.rpm
|
||||||
|
- name: Get artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: "3proxy-${{ env.RELEASE }}-arm64.rpm"
|
||||||
|
path: "*.rpm"
|
||||||
|
|
||||||
72
.github/workflows/build-rpm-armhf.yml
vendored
Normal file
72
.github/workflows/build-rpm-armhf.yml
vendored
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
name: RPM build arm
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "master" ]
|
||||||
|
paths: [ 'RELEASE', '.github/workflows/build-rpm-armhf.yml' ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ci:
|
||||||
|
name: "${{ matrix.target }}"
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
target:
|
||||||
|
- ubuntu-latest
|
||||||
|
runs-on: ${{ matrix.target }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v5
|
||||||
|
- name: env
|
||||||
|
run: |
|
||||||
|
pwd
|
||||||
|
echo "RELEASE=$(cat RELEASE)" >> $GITHUB_ENV
|
||||||
|
echo "VERSION=$(date +%y%m%d%H%M%S)" >> $GITHUB_ENV
|
||||||
|
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: Linux libraries
|
||||||
|
run: |
|
||||||
|
sudo apt update
|
||||||
|
sudo dpkg --add-architecture armhf
|
||||||
|
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: armhf" >>~/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:armhf libpam0g:armhf libpam0g-dev:armhf libpcre2-dev:armhf rpm crossbuild-essential-armhf
|
||||||
|
- name: make rpmbuild dir
|
||||||
|
run: mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
|
||||||
|
- name: configure rpm env
|
||||||
|
run: |
|
||||||
|
tar -czf ~/rpmbuild/SOURCES/3proxy-$RELEASE.tar.gz --transform "s,^,3proxy-$RELEASE/," .
|
||||||
|
ln -s ~/rpmbuild/SOURCES/3proxy-$RELEASE.tar.gz ~/rpmbuild/SOURCES/$RELEASE.tar.gz
|
||||||
|
cp scripts/rh/3proxy.spec ~/rpmbuild/SPECS/3proxy-$RELEASE.spec
|
||||||
|
- name: rpmbuild
|
||||||
|
run: |
|
||||||
|
ret=`pwd`
|
||||||
|
cd ~/rpmbuild/SPECS
|
||||||
|
rpmbuild -ba --define "PAMLIB pam0g" --define "_arch arm" --define "cross yes" --target=arm-linux-gnueabi 3proxy-$RELEASE.spec
|
||||||
|
cd $ret
|
||||||
|
mv ~/rpmbuild/RPMS/arm/3proxy-$RELEASE-1.arm.rpm 3proxy-$RELEASE.arm.rpm
|
||||||
|
- name: Get artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: "3proxy-${{ env.RELEASE }}-arm.rpm"
|
||||||
|
path: "*.rpm"
|
||||||
|
|
||||||
51
.github/workflows/build-rpm-x86-64.yml
vendored
Normal file
51
.github/workflows/build-rpm-x86-64.yml
vendored
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
name: RPM build x86-64
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "master" ]
|
||||||
|
paths: [ 'RELEASE', '.github/workflows/build-rpm-x86-64.yml' ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ci:
|
||||||
|
name: "${{ matrix.target }}"
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
target:
|
||||||
|
- ubuntu-latest
|
||||||
|
runs-on: ${{ matrix.target }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v5
|
||||||
|
- name: env
|
||||||
|
run: |
|
||||||
|
pwd
|
||||||
|
echo "RELEASE=$(cat RELEASE)" >> $GITHUB_ENV
|
||||||
|
echo "VERSION=$(date +%y%m%d%H%M%S)" >> $GITHUB_ENV
|
||||||
|
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
|
||||||
|
- name: make rpmbuild dir
|
||||||
|
run: mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
|
||||||
|
- name: configure rpm env
|
||||||
|
run: |
|
||||||
|
tar -czf ~/rpmbuild/SOURCES/3proxy-$RELEASE.tar.gz --transform "s,^,3proxy-$RELEASE/," .
|
||||||
|
ln -s ~/rpmbuild/SOURCES/3proxy-$RELEASE.tar.gz ~/rpmbuild/SOURCES/$RELEASE.tar.gz
|
||||||
|
cp scripts/rh/3proxy.spec ~/rpmbuild/SPECS/3proxy-$RELEASE.spec
|
||||||
|
- name: rpmbuild
|
||||||
|
run: |
|
||||||
|
ret=`pwd`
|
||||||
|
cd ~/rpmbuild/SPECS
|
||||||
|
rpmbuild -ba 3proxy-$RELEASE.spec
|
||||||
|
cd $ret
|
||||||
|
mv ~/rpmbuild/RPMS/x86_64/3proxy-$RELEASE-1.x86_64.rpm 3proxy-$RELEASE.x86_64.rpm
|
||||||
|
- name: Get artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: "3proxy-${{ env.RELEASE }}-x86_64.rpm"
|
||||||
|
path: "*.rpm"
|
||||||
|
|
||||||
9
.github/workflows/build-watcom.yml
vendored
9
.github/workflows/build-watcom.yml
vendored
@ -14,7 +14,7 @@ jobs:
|
|||||||
- windows-2022
|
- windows-2022
|
||||||
runs-on: ${{ matrix.target }}
|
runs-on: ${{ matrix.target }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v5
|
||||||
# - name: configure
|
# - name: configure
|
||||||
# run: ./configure
|
# run: ./configure
|
||||||
- name: Setup Open Watcom
|
- name: Setup Open Watcom
|
||||||
@ -25,14 +25,13 @@ jobs:
|
|||||||
echo "now: $NOW"
|
echo "now: $NOW"
|
||||||
$RELEASE = Get-Content -Path "RELEASE" -Raw
|
$RELEASE = Get-Content -Path "RELEASE" -Raw
|
||||||
echo "release: $RELEASE"
|
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 "RELEASE=$RELEASE" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||||
echo "VERSION=VERSION=`"$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=BUILDDATE=`"$NOW`"" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
echo "BUILDDATE=/D `"BUILDDATE=\`"$NOW\`"`"" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||||
- name: make Watcom
|
- name: make Watcom
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: |
|
run: |
|
||||||
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 "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.watcom
|
nmake /F Makefile.watcom
|
||||||
- name: make dist dir
|
- name: make dist dir
|
||||||
shell: cmd
|
shell: cmd
|
||||||
|
|||||||
11
.github/workflows/build-win32.yml
vendored
11
.github/workflows/build-win32.yml
vendored
@ -14,19 +14,16 @@ jobs:
|
|||||||
- windows-2022
|
- windows-2022
|
||||||
runs-on: ${{ matrix.target }}
|
runs-on: ${{ matrix.target }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v5
|
||||||
# - name: configure
|
# - name: configure
|
||||||
# run: ./configure
|
# run: ./configure
|
||||||
- name: set date
|
- name: set date
|
||||||
run: |
|
run: |
|
||||||
$NOW = Get-Date -Format "yyMMddHHmmss"
|
$NOW = Get-Date -Format "yyMMddHHmmss"
|
||||||
echo "now: $NOW"
|
|
||||||
$RELEASE = Get-Content -Path "RELEASE" -Raw
|
$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 "RELEASE=$RELEASE" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||||
echo "VERSION=VERSION=`"$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=BUILDDATE=`"$NOW`"" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
echo "BUILDDATE=/D `"BUILDDATE=\`"$NOW\`"`"" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||||
- name: install packages
|
- name: install packages
|
||||||
run: vcpkg install pcre2:x86-windows-static openssl:x86-windows-static
|
run: vcpkg install pcre2:x86-windows-static openssl:x86-windows-static
|
||||||
- name: Add msbuild to PATH
|
- name: Add msbuild to PATH
|
||||||
@ -40,7 +37,7 @@ jobs:
|
|||||||
cd "D:/a/3proxy/3proxy"
|
cd "D:/a/3proxy/3proxy"
|
||||||
set "LIB=%LIB%;c:/vcpkg/installed/x86-windows-static/lib"
|
set "LIB=%LIB%;c:/vcpkg/installed/x86-windows-static/lib"
|
||||||
set "INCLUDE=%INCLUDE%;c:/vcpkg/installed/x86-windows-static/include"
|
set "INCLUDE=%INCLUDE%;c:/vcpkg/installed/x86-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 "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
|
nmake /F Makefile.msvc
|
||||||
- name: make dist dir
|
- name: make dist dir
|
||||||
shell: cmd
|
shell: cmd
|
||||||
|
|||||||
11
.github/workflows/build-win64.yml
vendored
11
.github/workflows/build-win64.yml
vendored
@ -14,19 +14,17 @@ jobs:
|
|||||||
- windows-2022
|
- windows-2022
|
||||||
runs-on: ${{ matrix.target }}
|
runs-on: ${{ matrix.target }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v5
|
||||||
# - name: configure
|
# - name: configure
|
||||||
# run: ./configure
|
# run: ./configure
|
||||||
- name: set date
|
- name: set date
|
||||||
run: |
|
run: |
|
||||||
$NOW = Get-Date -Format "yyMMddHHmmss"
|
$NOW = Get-Date -Format "yyMMddHHmmss"
|
||||||
echo "now: $NOW"
|
|
||||||
$RELEASE = Get-Content -Path "RELEASE" -Raw
|
$RELEASE = Get-Content -Path "RELEASE" -Raw
|
||||||
echo "release: $RELEASE"
|
|
||||||
echo "NOW=$NOW" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
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 "RELEASE=$RELEASE" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||||
echo "VERSION=VERSION=`"$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=BUILDDATE=`"$NOW`"" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
echo "BUILDDATE=/D `"BUILDDATE=\`"$NOW\`"`"" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||||
- name: install packages
|
- name: install packages
|
||||||
run: vcpkg install pcre2:x64-windows-static openssl:x64-windows-static
|
run: vcpkg install pcre2:x64-windows-static openssl:x64-windows-static
|
||||||
- name: Add msbuild to PATH
|
- name: Add msbuild to PATH
|
||||||
@ -40,7 +38,8 @@ jobs:
|
|||||||
cd "D:/a/3proxy/3proxy"
|
cd "D:/a/3proxy/3proxy"
|
||||||
set "LIB=%LIB%;c:/vcpkg/installed/x64-windows-static/lib"
|
set "LIB=%LIB%;c:/vcpkg/installed/x64-windows-static/lib"
|
||||||
set "INCLUDE=%INCLUDE%;c:/vcpkg/installed/x64-windows-static/include"
|
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 "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
|
nmake /F Makefile.msvc
|
||||||
- name: make dist dir
|
- name: make dist dir
|
||||||
shell: cmd
|
shell: cmd
|
||||||
|
|||||||
11
.github/workflows/build-winarm64.yml
vendored
11
.github/workflows/build-winarm64.yml
vendored
@ -14,19 +14,16 @@ jobs:
|
|||||||
- windows-2022
|
- windows-2022
|
||||||
runs-on: ${{ matrix.target }}
|
runs-on: ${{ matrix.target }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v5
|
||||||
# - name: configure
|
# - name: configure
|
||||||
# run: ./configure
|
# run: ./configure
|
||||||
- name: set date
|
- name: set date
|
||||||
run: |
|
run: |
|
||||||
$NOW = Get-Date -Format "yyMMddHHmmss"
|
$NOW = Get-Date -Format "yyMMddHHmmss"
|
||||||
echo "now: $NOW"
|
|
||||||
$RELEASE = Get-Content -Path "RELEASE" -Raw
|
$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 "RELEASE=$RELEASE" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||||
echo "VERSION=VERSION=`"$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=BUILDDATE=`"$NOW`"" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
echo "BUILDDATE=/D `"BUILDDATE=\`"$NOW\`"`"" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||||
- name: install packages
|
- name: install packages
|
||||||
run: vcpkg install pcre2:arm64-windows-static openssl:arm64-windows-static
|
run: vcpkg install pcre2:arm64-windows-static openssl:arm64-windows-static
|
||||||
- name: Add msbuild to PATH
|
- name: Add msbuild to PATH
|
||||||
@ -40,7 +37,7 @@ jobs:
|
|||||||
cd "D:/a/3proxy/3proxy"
|
cd "D:/a/3proxy/3proxy"
|
||||||
set "LIB=%LIB%;c:/vcpkg/installed/arm64-windows-static/lib"
|
set "LIB=%LIB%;c:/vcpkg/installed/arm64-windows-static/lib"
|
||||||
set "INCLUDE=%INCLUDE%;c:/vcpkg/installed/arm64-windows-static/include"
|
set "INCLUDE=%INCLUDE%;c:/vcpkg/installed/arm64-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 "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
|
nmake /F Makefile.msvc
|
||||||
- name: make dist dir
|
- name: make dist dir
|
||||||
shell: cmd
|
shell: cmd
|
||||||
|
|||||||
6
.github/workflows/c-cpp-Linux.yml
vendored
6
.github/workflows/c-cpp-Linux.yml
vendored
@ -3,10 +3,10 @@ name: C/C++ CI Linux
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "master" ]
|
branches: [ "master" ]
|
||||||
paths: [ '**.c', '**.h', 'Makefile.**', '.github/configs', '.github/workflows/c-cpp-Linux.yml' ]
|
paths: [ '**.c', '**.h', 'Makefile.Linux', '.github/configs', '.github/workflows/c-cpp-Linux.yml' ]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ "master" ]
|
branches: [ "master" ]
|
||||||
paths: [ '**.c', '**.h', 'Makefile.**', '.github/configs', '.github/workflows/c-cpp-Linux.yml' ]
|
paths: [ '**.c', '**.h', 'Makefile.Linux', '.github/configs', '.github/workflows/c-cpp-Linux.yml' ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ci:
|
ci:
|
||||||
@ -18,7 +18,7 @@ jobs:
|
|||||||
- ubuntu-24.04-arm
|
- ubuntu-24.04-arm
|
||||||
runs-on: ${{ matrix.target }}
|
runs-on: ${{ matrix.target }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v5
|
||||||
# - name: configure
|
# - name: configure
|
||||||
# run: ./configure
|
# run: ./configure
|
||||||
- name: Linux libraries
|
- name: Linux libraries
|
||||||
|
|||||||
6
.github/workflows/c-cpp-MacOS.yml
vendored
6
.github/workflows/c-cpp-MacOS.yml
vendored
@ -3,10 +3,10 @@ name: C/C++ CI MacOS
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "master" ]
|
branches: [ "master" ]
|
||||||
paths: [ '**.c', '**.h', 'Makefile.**', '.github/configs', '.github/workflows/c-cpp-MacOS.yml' ]
|
paths: [ '**.c', '**.h', 'Makefile.FreeBSD', '.github/configs', '.github/workflows/c-cpp-MacOS.yml' ]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ "master" ]
|
branches: [ "master" ]
|
||||||
paths: [ '**.c', '**.h', 'Makefile.**', '.github/configs', '.github/workflows/c-cpp-MacOS.yml' ]
|
paths: [ '**.c', '**.h', 'Makefile.FreeBSD', '.github/configs', '.github/workflows/c-cpp-MacOS.yml' ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ci:
|
ci:
|
||||||
@ -17,7 +17,7 @@ jobs:
|
|||||||
- macos-15
|
- macos-15
|
||||||
runs-on: ${{ matrix.target }}
|
runs-on: ${{ matrix.target }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v5
|
||||||
# - name: configure
|
# - name: configure
|
||||||
# run: ./configure
|
# run: ./configure
|
||||||
- name: Mac libraries
|
- name: Mac libraries
|
||||||
|
|||||||
6
.github/workflows/c-cpp-Windows.yml
vendored
6
.github/workflows/c-cpp-Windows.yml
vendored
@ -3,10 +3,10 @@ name: C/C++ CI Windows
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "master" ]
|
branches: [ "master" ]
|
||||||
paths: [ '**.c', '**.h', 'Makefile.**', '.github/configs', '.github/workflows/c-cpp-Windows.yml' ]
|
paths: [ '**.c', '**.h', 'Makefile.msvc', '.github/configs', '.github/workflows/c-cpp-Windows.yml' ]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ "master" ]
|
branches: [ "master" ]
|
||||||
paths: [ '**.c', '**.h', 'Makefile.**', '.github/configs', '.github/workflows/c-cpp-Windows.yml' ]
|
paths: [ '**.c', '**.h', 'Makefile.msvc', '.github/configs', '.github/workflows/c-cpp-Windows.yml' ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ci:
|
ci:
|
||||||
@ -17,7 +17,7 @@ jobs:
|
|||||||
- windows-2022
|
- windows-2022
|
||||||
runs-on: ${{ matrix.target }}
|
runs-on: ${{ matrix.target }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v5
|
||||||
- name: install Windows libraries
|
- name: install Windows libraries
|
||||||
run: vcpkg install pcre2:x64-windows && c:\msys64\usr\bin\pacman.exe -S --noconfirm mingw-w64-x86_64-pcre2 mingw-w64-x86_64-openssl
|
run: vcpkg install pcre2:x64-windows && c:\msys64\usr\bin\pacman.exe -S --noconfirm mingw-w64-x86_64-pcre2 mingw-w64-x86_64-openssl
|
||||||
- name: make Windows
|
- name: make Windows
|
||||||
|
|||||||
6
.github/workflows/c-cpp-cmake.yml
vendored
6
.github/workflows/c-cpp-cmake.yml
vendored
@ -3,10 +3,10 @@ name: C/C++ CI cmake
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "master" ]
|
branches: [ "master" ]
|
||||||
paths: [ '**.c', '**.h', 'Makefile.**', '.github/configs', '.github/workflows/c-cpp-cmake.yml' ]
|
paths: [ '**.c', '**.h', '**.cmake', 'CMakeLists.txt', '.github/configs', '.github/workflows/c-cpp-cmake.yml' ]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ "master" ]
|
branches: [ "master" ]
|
||||||
paths: [ '**.c', '**.h', 'Makefile.**', '.github/configs', '.github/workflows/c-cpp-cmake.yml' ]
|
paths: [ '**.c', '**.h', '**.cmake', 'CMakeLists.txt', '.github/configs', '.github/workflows/c-cpp-cmake.yml' ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ci:
|
ci:
|
||||||
@ -20,7 +20,7 @@ jobs:
|
|||||||
- windows-2022
|
- windows-2022
|
||||||
runs-on: ${{ matrix.target }}
|
runs-on: ${{ matrix.target }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v5
|
||||||
# - name: configure
|
# - name: configure
|
||||||
# run: ./configure
|
# run: ./configure
|
||||||
- name: Linux libraries
|
- name: Linux libraries
|
||||||
|
|||||||
@ -77,7 +77,6 @@ if(WIN32)
|
|||||||
_WIN32
|
_WIN32
|
||||||
_MBCS
|
_MBCS
|
||||||
_CONSOLE
|
_CONSOLE
|
||||||
PRINTF_INT64_MODIFIER="I64"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if(COMPILER_IS_MSVC)
|
if(COMPILER_IS_MSVC)
|
||||||
|
|||||||
@ -99,7 +99,6 @@ 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
|
$(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)
|
||||||
|
|||||||
@ -6,13 +6,9 @@
|
|||||||
|
|
||||||
BUILDDIR = ../bin/
|
BUILDDIR = ../bin/
|
||||||
CC = cl
|
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" /D "PRINTF_INT64_MODIFIER=\"I64\"" /Fp"proxy.pch" /FD /c
|
VERSION = $(VERSION)
|
||||||
!IFDEF RELEASE
|
BUILDDATE = $(BUILDDATE)
|
||||||
VERSION=/D VERSION=\"3proxy-$(RELEASE)\"
|
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)
|
||||||
!ENDIF
|
|
||||||
!IFDEF NOW
|
|
||||||
BUILDDATE=/D BUILDDATE=\"$(NOW)\"
|
|
||||||
!ENDIF
|
|
||||||
COUT = /Fo
|
COUT = /Fo
|
||||||
LN = link
|
LN = link
|
||||||
LDFLAGS = /nologo /subsystem:console /incremental:no
|
LDFLAGS = /nologo /subsystem:console /incremental:no
|
||||||
@ -33,9 +29,7 @@ COMPATLIBS =
|
|||||||
MAKEFILE = Makefile.msvc
|
MAKEFILE = Makefile.msvc
|
||||||
PLUGINS = utf8tocp1251 WindowsAuthentication TrafficPlugin StringsPlugin FilePlugin SSLPlugin PCREPlugin
|
PLUGINS = utf8tocp1251 WindowsAuthentication TrafficPlugin StringsPlugin FilePlugin SSLPlugin PCREPlugin
|
||||||
VERFILE = 3proxy.res $(VERFILE)
|
VERFILE = 3proxy.res $(VERFILE)
|
||||||
VERSION = $(VERSION)
|
|
||||||
VERSIONDEP = 3proxy.res $(VERSIONDEP)
|
VERSIONDEP = 3proxy.res $(VERSIONDEP)
|
||||||
BUILDDATE = $(BUILDDATE)
|
|
||||||
AFTERCLEAN = if exist src\*.res (del src\*.res) && if exist src\*.err (del src\*.err)
|
AFTERCLEAN = if exist src\*.res (del src\*.res) && if exist src\*.err (del src\*.err)
|
||||||
|
|
||||||
include Makefile.inc
|
include Makefile.inc
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
BUILDDIR = ../bin/
|
BUILDDIR = ../bin/
|
||||||
CC = cl
|
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 "PRINTF_INT64_MODIFIER=\"I64\"" /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 "PRId64=\"I64d\"" /D "PRIu64=\"I64u\"" /D "SCNu64=\"I64u\"" /D "SCNx64=\"I64x\"" /D "SCNd64=\"I64d\"" /D "PRIx64=\"I64x\"" /c $(VERSION) $(BUILDDATE)
|
||||||
COUT = /Fo
|
COUT = /Fo
|
||||||
LN = link
|
LN = link
|
||||||
LDFLAGS = /nologo /subsystem:console /incremental:no
|
LDFLAGS = /nologo /subsystem:console /incremental:no
|
||||||
@ -62,9 +62,3 @@ allplugins:
|
|||||||
nmake
|
nmake
|
||||||
del *.obj *.idb
|
del *.obj *.idb
|
||||||
cd ../../
|
cd ../../
|
||||||
copy Makefile plugins\PCREPlugin
|
|
||||||
copy Makefile.var plugins\PCREPlugin
|
|
||||||
cd plugins\PCREPlugin
|
|
||||||
nmake
|
|
||||||
del *.obj *.idb
|
|
||||||
cd ../../
|
|
||||||
|
|||||||
@ -67,14 +67,10 @@
|
|||||||
<ul>
|
<ul>
|
||||||
<li><A NAME="MSVC">How to compile 3proxy with Visual C++</A>
|
<li><A NAME="MSVC">How to compile 3proxy with Visual C++</A>
|
||||||
<p>
|
<p>
|
||||||
Extract source code files from 3proxy.tgz (with WinZip or another utility).
|
Extract source code files from 3proxy.tgz (with WinZip or another utility) or use git.
|
||||||
For 64-bit Windows use:
|
|
||||||
<pre>
|
<pre>
|
||||||
nmake /f Makefile.msvc64
|
nmake /f Makefile.msvc
|
||||||
</pre>
|
|
||||||
For ARM64 Windows use:
|
|
||||||
<pre>
|
|
||||||
nmake /f Makefile.msvcARM64
|
|
||||||
</pre>
|
</pre>
|
||||||
Binaries will be placed in the <code>bin/</code> directory.
|
Binaries will be placed in the <code>bin/</code> directory.
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@ -73,13 +73,10 @@
|
|||||||
<ul>
|
<ul>
|
||||||
<li><a name="MSVC"><i>Как скомпилировать 3proxy Visual C++</i></a>
|
<li><a name="MSVC"><i>Как скомпилировать 3proxy Visual C++</i></a>
|
||||||
<p>
|
<p>
|
||||||
Извлеките файлы из архива 3proxy.tgz (например, с помощью WinZip).
|
Извлеките файлы из архива 3proxy.tgz (например, с помощью WinZip) или используйте git.
|
||||||
Для 64-битной Windows используйте:
|
|
||||||
<pre>
|
<pre>
|
||||||
nmake /f Makefile.msvc64</pre>
|
nmake /f Makefile.msvc
|
||||||
Для Windows ARM64 используйте:
|
</pre>
|
||||||
<pre>
|
|
||||||
nmake /f Makefile.msvcARM64</pre>
|
|
||||||
Исполняемые файлы будут помещены в каталог <code>bin/</code>.
|
Исполняемые файлы будут помещены в каталог <code>bin/</code>.
|
||||||
</p>
|
</p>
|
||||||
<li><a name="CMAKE"><i>Как скомпилировать 3proxy с помощью CMake</i></a>
|
<li><a name="CMAKE"><i>Как скомпилировать 3proxy с помощью CMake</i></a>
|
||||||
|
|||||||
10
man/socks.8
10
man/socks.8
@ -42,6 +42,16 @@ of IP-IP NAT (will not work for PAT).
|
|||||||
Internal address. IP address the proxy accepts connections to.
|
Internal address. IP address the proxy accepts connections to.
|
||||||
By default, connections to any interface are accepted. It\'s usually unsafe.
|
By default, connections to any interface are accepted. It\'s usually unsafe.
|
||||||
.TP
|
.TP
|
||||||
|
.B -k
|
||||||
|
External address given by
|
||||||
|
.B -e
|
||||||
|
is ignored and the internal address or generally the address client conected to is used instead.
|
||||||
|
This allows to utilize AnyIP Linux feature when
|
||||||
|
.B -i0.0.0.0
|
||||||
|
or in case of IPv6
|
||||||
|
.B -i::
|
||||||
|
is set. Not available for Windows platform.
|
||||||
|
.TP
|
||||||
.B -p
|
.B -p
|
||||||
Port. Port proxy listens for incoming connections. Default is 1080.
|
Port. Port proxy listens for incoming connections. Default is 1080.
|
||||||
.TP
|
.TP
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
Name: 3proxy
|
Name: 3proxy
|
||||||
Version: 0.9.5
|
Version: 0.9.5
|
||||||
Release: 1
|
Release: 1%{?dist}
|
||||||
Summary: 3proxy tiny proxy server
|
Summary: 3proxy tiny proxy server
|
||||||
License: GPL/LGPL/Apache/BSD
|
License: GPL/LGPL/Apache/BSD
|
||||||
URL: https://3proxy.org/
|
URL: https://3proxy.org/
|
||||||
@ -13,11 +13,15 @@ Source: https://github.com/%{packager}/%{name}/archive/%{version}.tar.gz
|
|||||||
3proxy is lightweight yet powerful proxy server
|
3proxy is lightweight yet powerful proxy server
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q -n %{name}-%{version}
|
%setup -q
|
||||||
ln -s Makefile.Linux Makefile
|
ln -s Makefile.Linux Makefile
|
||||||
|
|
||||||
%build
|
%build
|
||||||
make
|
%if "%{?PAMLIB}" != ""
|
||||||
|
make PAMLIB=%{?PAMLIB}
|
||||||
|
%else
|
||||||
|
make
|
||||||
|
%endif
|
||||||
|
|
||||||
%install
|
%install
|
||||||
make DESTDIR=%buildroot install
|
make DESTDIR=%buildroot install
|
||||||
@ -44,33 +48,9 @@ make clean
|
|||||||
%config(noreplace) /usr/local/3proxy/conf/add3proxyuser.sh
|
%config(noreplace) /usr/local/3proxy/conf/add3proxyuser.sh
|
||||||
%config(noreplace) /usr/local/3proxy/conf/bandlimiters
|
%config(noreplace) /usr/local/3proxy/conf/bandlimiters
|
||||||
%config(noreplace) /usr/local/3proxy/conf/counters
|
%config(noreplace) /usr/local/3proxy/conf/counters
|
||||||
/usr/local/3proxy/libexec/PCREPlugin.ld.so
|
/usr/local/3proxy/libexec/*.ld.so
|
||||||
/usr/local/3proxy/libexec/StringsPlugin.ld.so
|
/usr/share/man/man3/*
|
||||||
/usr/local/3proxy/libexec/TrafficPlugin.ld.so
|
/usr/share/man/man8/*
|
||||||
/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/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
|
|
||||||
/usr/share/man/man8/tlspr.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/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
|
|
||||||
/usr/share/man/man8/tlspr.8.gz
|
|
||||||
%endif
|
|
||||||
/var/log/3proxy
|
/var/log/3proxy
|
||||||
|
|
||||||
%doc doc/*
|
%doc doc/*
|
||||||
|
|||||||
@ -206,7 +206,7 @@ void dumpcounters(struct trafcount *tlin, int counterd){
|
|||||||
if(cfp){
|
if(cfp){
|
||||||
for(tl = tlin; cfp && tl; tl = tl->next){
|
for(tl = tlin; cfp && tl; tl = tl->next){
|
||||||
if(tl->type >= conf.countertype)
|
if(tl->type >= conf.countertype)
|
||||||
fprintf(cfp, "%05d %020"PRINTF_INT64_MODIFIER"u%s%s\n", tl->number, tl->traf64, tl->comment?" #" : "", tl->comment? tl->comment : "");
|
fprintf(cfp, "%05d %020"PRIu64"%s%s\n", tl->number, tl->traf64, tl->comment?" #" : "", tl->comment? tl->comment : "");
|
||||||
}
|
}
|
||||||
fclose(cfp);
|
fclose(cfp);
|
||||||
}
|
}
|
||||||
@ -215,7 +215,7 @@ void dumpcounters(struct trafcount *tlin, int counterd){
|
|||||||
|
|
||||||
cheader.updated = conf.time;
|
cheader.updated = conf.time;
|
||||||
lseek(counterd, 0, SEEK_SET);
|
lseek(counterd, 0, SEEK_SET);
|
||||||
write(counterd, &cheader, sizeof(struct counter_header));
|
if(write(counterd, &cheader, sizeof(struct counter_header))){}
|
||||||
for(tl=tlin; tl; tl = tl->next){
|
for(tl=tlin; tl; tl = tl->next){
|
||||||
if(tl->number){
|
if(tl->number){
|
||||||
lseek(counterd,
|
lseek(counterd,
|
||||||
@ -224,7 +224,7 @@ void dumpcounters(struct trafcount *tlin, int counterd){
|
|||||||
crecord.traf64 = tl->traf64;
|
crecord.traf64 = tl->traf64;
|
||||||
crecord.cleared = tl->cleared;
|
crecord.cleared = tl->cleared;
|
||||||
crecord.updated = tl->updated;
|
crecord.updated = tl->updated;
|
||||||
write(counterd, &crecord, sizeof(struct counter_record));
|
if(write(counterd, &crecord, sizeof(struct counter_record))){}
|
||||||
}
|
}
|
||||||
if(tl->type!=NEVER && timechanged(tl->cleared, conf.time, tl->type)){
|
if(tl->type!=NEVER && timechanged(tl->cleared, conf.time, tl->type)){
|
||||||
tl->cleared = conf.time;
|
tl->cleared = conf.time;
|
||||||
@ -315,7 +315,7 @@ void cyclestep(void){
|
|||||||
else
|
else
|
||||||
strcat((char *)tmpbuf, (char *)conf.archiver[i]);
|
strcat((char *)tmpbuf, (char *)conf.archiver[i]);
|
||||||
}
|
}
|
||||||
system((char *)tmpbuf+1);
|
if(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;
|
if(!ha) return 0;
|
||||||
}
|
}
|
||||||
else if(!*SAPORT(&cur->addr) && !SAISNULL(&cur->addr)) {
|
else if(!*SAPORT(&cur->addr) && !SAISNULL(&cur->addr)) {
|
||||||
unsigned short port = *SAPORT(¶m->sinsr);
|
uint16_t port = *SAPORT(¶m->sinsr);
|
||||||
param->sinsr = cur->addr;
|
param->sinsr = cur->addr;
|
||||||
*SAPORT(¶m->sinsr) = port;
|
*SAPORT(¶m->sinsr) = port;
|
||||||
}
|
}
|
||||||
@ -943,7 +943,7 @@ int dnsauth(struct clientparam * param){
|
|||||||
sprintf(s, "ip6.arpa");
|
sprintf(s, "ip6.arpa");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
u = ntohl(*(unsigned long *)SAADDR(¶m->sincr));
|
u = ntohl(*(uint32_t *)SAADDR(¶m->sincr));
|
||||||
|
|
||||||
sprintf(buf, "%u.%u.%u.%u.in-addr.arpa",
|
sprintf(buf, "%u.%u.%u.%u.in-addr.arpa",
|
||||||
((u&0x000000FF)),
|
((u&0x000000FF)),
|
||||||
@ -1155,7 +1155,7 @@ void hashadd(struct hashtable *ht, const unsigned char* name, unsigned char* val
|
|||||||
pthread_mutex_unlock(&hash_mutex);
|
pthread_mutex_unlock(&hash_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long hashresolv(struct hashtable *ht, const unsigned char* name, unsigned char* value, unsigned *ttl){
|
uint32_t hashresolv(struct hashtable *ht, const unsigned char* name, unsigned char* value, uint32_t *ttl){
|
||||||
unsigned char hash[sizeof(unsigned)*4];
|
unsigned char hash[sizeof(unsigned)*4];
|
||||||
struct hashentry ** hep;
|
struct hashentry ** hep;
|
||||||
struct hashentry *he;
|
struct hashentry *he;
|
||||||
@ -1176,7 +1176,7 @@ unsigned long hashresolv(struct hashtable *ht, const unsigned char* name, unsign
|
|||||||
ht->hashempty = he;
|
ht->hashempty = he;
|
||||||
}
|
}
|
||||||
else if(!memcmp(hash, he->hash, sizeof(unsigned)*4)){
|
else if(!memcmp(hash, he->hash, sizeof(unsigned)*4)){
|
||||||
if(ttl) *ttl = (unsigned)(he->expires - conf.time);
|
if(ttl) *ttl = (uint32_t)(he->expires - conf.time);
|
||||||
memcpy(value, he->value, ht->recsize);
|
memcpy(value, he->value, ht->recsize);
|
||||||
pthread_mutex_unlock(&hash_mutex);
|
pthread_mutex_unlock(&hash_mutex);
|
||||||
return 1;
|
return 1;
|
||||||
@ -1191,10 +1191,10 @@ struct nserver nservers[MAXNSERVERS] = {{{0},0}, {{0},0}, {{0},0}, {{0},0}, {{0}
|
|||||||
struct nserver authnserver;
|
struct nserver authnserver;
|
||||||
|
|
||||||
|
|
||||||
unsigned long udpresolve(int af, unsigned char * name, unsigned char * value, unsigned *retttl, struct clientparam* param, int makeauth){
|
uint32_t udpresolve(int af, unsigned char * name, unsigned char * value, uint32_t *retttl, struct clientparam* param, int makeauth){
|
||||||
|
|
||||||
int i,n;
|
int i,n;
|
||||||
unsigned long retval;
|
uint32_t retval;
|
||||||
|
|
||||||
if((af == AF_INET) && (retval = hashresolv(&dns_table, name, value, retttl))) {
|
if((af == AF_INET) && (retval = hashresolv(&dns_table, name, value, retttl))) {
|
||||||
return retval;
|
return retval;
|
||||||
@ -1208,7 +1208,7 @@ unsigned long udpresolve(int af, unsigned char * name, unsigned char * value, un
|
|||||||
unsigned char b[4098], *buf, *s1, *s2;
|
unsigned char b[4098], *buf, *s1, *s2;
|
||||||
int j, k, len, flen;
|
int j, k, len, flen;
|
||||||
SOCKET sock;
|
SOCKET sock;
|
||||||
unsigned ttl;
|
uint32_t ttl;
|
||||||
#ifndef NOIPV6
|
#ifndef NOIPV6
|
||||||
struct sockaddr_in6 addr;
|
struct sockaddr_in6 addr;
|
||||||
struct sockaddr_in6 *sinsr, *sinsl;
|
struct sockaddr_in6 *sinsr, *sinsl;
|
||||||
@ -1343,7 +1343,7 @@ unsigned long udpresolve(int af, unsigned char * name, unsigned char * value, un
|
|||||||
k+= (12 + flen);
|
k+= (12 + flen);
|
||||||
continue; /* we need A IPv4 */
|
continue; /* we need A IPv4 */
|
||||||
}
|
}
|
||||||
ttl = ntohl(*(unsigned long *)(buf + k + 6));
|
ttl = ntohl(*(uint32_t *)(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 < 0 || ttl > (3600*12)) ttl = 3600*12;
|
if(ttl < 0 || ttl > (3600*12)) ttl = 3600*12;
|
||||||
if(!ttl) ttl = 1;
|
if(!ttl) ttl = 1;
|
||||||
@ -1373,11 +1373,11 @@ unsigned long udpresolve(int af, unsigned char * name, unsigned char * value, un
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long myresolver(int af, unsigned char * name, unsigned char * value){
|
uint32_t myresolver(int af, unsigned char * name, unsigned char * value){
|
||||||
return udpresolve(af, name, value, NULL, NULL, 0);
|
return udpresolve(af, name, value, NULL, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long fakeresolver (int af, unsigned char *name, unsigned char * value){
|
uint32_t fakeresolver (int af, unsigned char *name, unsigned char * value){
|
||||||
memset(value, 0, af == AF_INET6? 16 : 4);
|
memset(value, 0, af == AF_INET6? 16 : 4);
|
||||||
if(af == AF_INET6){
|
if(af == AF_INET6){
|
||||||
memset(value, 0, 16);
|
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(!vendor && attr[0] == PW_VENDOR_SPECIFIC) {
|
||||||
if (attr[1] < 6 || count < 6) RETURN(4);
|
if (attr[1] < 6 || count < 6) RETURN(4);
|
||||||
vendorlen = attr[1]-6;
|
vendorlen = attr[1]-6;
|
||||||
vendor = htonl(*((int*)(attr +2)));
|
vendor = htonl(*((uint32_t *)(attr +2)));
|
||||||
count -= 6;
|
count -= 6;
|
||||||
attr += 6;
|
attr += 6;
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
56
src/common.c
56
src/common.c
@ -417,7 +417,7 @@ int ceparseargs(const char *str){
|
|||||||
|
|
||||||
int parsehost(int family, unsigned char *host, struct sockaddr *sa){
|
int parsehost(int family, unsigned char *host, struct sockaddr *sa){
|
||||||
char *sp=NULL,*se=NULL;
|
char *sp=NULL,*se=NULL;
|
||||||
unsigned short port=0;
|
uint16_t port=0;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if(!host) return 2;
|
if(!host) return 2;
|
||||||
@ -436,7 +436,7 @@ int parsehost(int family, unsigned char *host, struct sockaddr *sa){
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int parsehostname(char *hostname, struct clientparam *param, unsigned short port){
|
int parsehostname(char *hostname, struct clientparam *param, uint16_t port){
|
||||||
char *sp=NULL,*se=NULL;
|
char *sp=NULL,*se=NULL;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
@ -498,7 +498,7 @@ int parseusername(char *username, struct clientparam *param, int extpasswd){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int parseconnusername(char *username, struct clientparam *param, int extpasswd, unsigned short port){
|
int parseconnusername(char *username, struct clientparam *param, int extpasswd, uint16_t port){
|
||||||
char *sb, *se;
|
char *sb, *se;
|
||||||
if(!username || !*username) return 1;
|
if(!username || !*username) return 1;
|
||||||
if ((sb=strchr(username, conf.delimchar)) == NULL){
|
if ((sb=strchr(username, conf.delimchar)) == NULL){
|
||||||
@ -563,16 +563,48 @@ 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=param->srv->so._socket(param->sostate, SASOCK(¶m->sinsr), SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) {return (11);}
|
if ((param->remsock=param->srv->so._socket(param->sostate, SASOCK(¶m->sinsr), SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) {return (11);}
|
||||||
if(SAISNULL(¶m->sinsl)){
|
if(SAISNULL(¶m->sinsl)){
|
||||||
|
if (param->srv->keepip) {
|
||||||
#ifndef NOIPV6
|
#ifndef NOIPV6
|
||||||
if(*SAFAMILY(¶m->sinsr) == AF_INET6) param->sinsl = param->srv->extsa6;
|
struct sockaddr_in6 local_addr;
|
||||||
else
|
socklen_t local_addr_len = sizeof(local_addr);
|
||||||
|
getsockname(param->clisock, (struct sockaddr *)&local_addr, &local_addr_len);
|
||||||
|
|
||||||
|
if(*SAFAMILY(&local_addr) == AF_INET6) {
|
||||||
|
if (IN6_IS_ADDR_V4MAPPED(&local_addr.sin6_addr)) {
|
||||||
|
struct sockaddr_in6 local_addr2;
|
||||||
|
memset(&local_addr2, 0, sizeof(local_addr2));
|
||||||
|
local_addr2.sin6_family = AF_INET;
|
||||||
|
local_addr2.sin6_port = local_addr.sin6_port;
|
||||||
|
param->sinsl = local_addr2;
|
||||||
|
} else {
|
||||||
|
param->sinsl = local_addr;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
param->sinsl = local_addr;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
struct sockaddr_in local_addr;
|
||||||
|
socklen_t local_addr_len = sizeof(local_addr);
|
||||||
|
getsockname(new_sock, (struct sockaddr *)&local_addr, &local_addr_len);
|
||||||
|
param->sinsl = local_addr;
|
||||||
#endif
|
#endif
|
||||||
param->sinsl = param->srv->extsa;
|
} else {
|
||||||
|
#ifndef NOIPV6
|
||||||
|
if(*SAFAMILY(¶m->sinsr) == AF_INET6) param->sinsl = param->srv->extsa6;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
param->sinsl = param->srv->extsa;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*SAPORT(¶m->sinsl) = 0;
|
*SAPORT(¶m->sinsl) = 0;
|
||||||
setopts(param->remsock, param->srv->srvsockopts);
|
setopts(param->remsock, param->srv->srvsockopts);
|
||||||
|
|
||||||
param->srv->so._setsockopt(param->sostate, param->remsock, SOL_SOCKET, SO_LINGER, (char *)&lg, sizeof(lg));
|
param->srv->so._setsockopt(param->sostate, param->remsock, SOL_SOCKET, SO_LINGER, (char *)&lg, sizeof(lg));
|
||||||
|
|
||||||
|
if (param->srv->keepip) {
|
||||||
|
int opt = 1;
|
||||||
|
param->srv->so._setsockopt(param->sostate, param->remsock, SOL_IP, IP_FREEBIND, (char *)&opt, sizeof(int));
|
||||||
|
}
|
||||||
#ifdef REUSE
|
#ifdef REUSE
|
||||||
{
|
{
|
||||||
int opt;
|
int opt;
|
||||||
@ -606,7 +638,7 @@ int doconnect(struct clientparam * param){
|
|||||||
if(param->srv->so._bind(param->sostate, param->remsock, (struct sockaddr*)¶m->sinsl, SASIZE(¶m->sinsl))==-1) {
|
if(param->srv->so._bind(param->sostate, param->remsock, (struct sockaddr*)¶m->sinsl, SASIZE(¶m->sinsl))==-1) {
|
||||||
return 12;
|
return 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(param->operation >= 256 || (param->operation & CONNECT)){
|
if(param->operation >= 256 || (param->operation & CONNECT)){
|
||||||
if(connectwithpoll(param, param->remsock,(struct sockaddr *)¶m->sinsr,SASIZE(¶m->sinsr),conf.timeouts[CONNECT_TO])) {
|
if(connectwithpoll(param, param->remsock,(struct sockaddr *)¶m->sinsr,SASIZE(¶m->sinsr),conf.timeouts[CONNECT_TO])) {
|
||||||
return 13;
|
return 13;
|
||||||
@ -625,7 +657,7 @@ int doconnect(struct clientparam * param){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int scanaddr(const unsigned char *s, unsigned long * ip, unsigned long * mask) {
|
int scanaddr(const unsigned char *s, uint32_t * ip, uint32_t * mask) {
|
||||||
unsigned d1, d2, d3, d4, m;
|
unsigned d1, d2, d3, d4, m;
|
||||||
int res;
|
int res;
|
||||||
if ((res = sscanf((char *)s, "%u.%u.%u.%u/%u", &d1, &d2, &d3, &d4, &m)) < 4) return 0;
|
if ((res = sscanf((char *)s, "%u.%u.%u.%u/%u", &d1, &d2, &d3, &d4, &m)) < 4) return 0;
|
||||||
@ -658,8 +690,8 @@ struct hostent * my_gethostbyname(char *name, char *buf, struct hostent *hp){
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NOIPV6
|
#ifdef NOIPV6
|
||||||
unsigned long getip(unsigned char *name){
|
uint32_t getip(unsigned char *name){
|
||||||
unsigned long retval;
|
uint32_t retval;
|
||||||
int i;
|
int i;
|
||||||
int ndots = 0;
|
int ndots = 0;
|
||||||
struct hostent *hp=NULL;
|
struct hostent *hp=NULL;
|
||||||
@ -701,7 +733,7 @@ unsigned long getip(unsigned char *name){
|
|||||||
system(conf.demanddialprog);
|
system(conf.demanddialprog);
|
||||||
hp=gethostbyname((char *)name);
|
hp=gethostbyname((char *)name);
|
||||||
}
|
}
|
||||||
retval = hp?*(unsigned long *)hp->h_addr:0;
|
retval = hp?*(uint32_t *)hp->h_addr:0;
|
||||||
#if !defined(_WIN32) && !defined(GETHOSTBYNAME_R)
|
#if !defined(_WIN32) && !defined(GETHOSTBYNAME_R)
|
||||||
pthread_mutex_unlock(&gethostbyname_mutex);
|
pthread_mutex_unlock(&gethostbyname_mutex);
|
||||||
#endif
|
#endif
|
||||||
@ -744,7 +776,7 @@ int afdetect(unsigned char *name){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long getip46(int family, unsigned char *name, struct sockaddr *sa){
|
uint32_t getip46(int family, unsigned char *name, struct sockaddr *sa){
|
||||||
#ifndef NOIPV6
|
#ifndef NOIPV6
|
||||||
int detect;
|
int detect;
|
||||||
struct addrinfo *ai, hint;
|
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 = '/';
|
*cidr = '/';
|
||||||
chains->cidr = atoi(cidr + 1);
|
chains->cidr = atoi(cidr + 1);
|
||||||
}
|
}
|
||||||
*SAPORT(&chains->addr) = htons((unsigned short)atoi((char *)argv[4]));
|
*SAPORT(&chains->addr) = htons((uint16_t)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) {
|
if(!acl->chains) {
|
||||||
@ -1221,10 +1221,10 @@ static int h_ace(int argc, unsigned char **argv){
|
|||||||
freeacl(acl);
|
freeacl(acl);
|
||||||
return(21);
|
return(21);
|
||||||
}
|
}
|
||||||
memset(acl->chains, 0, sizeof(struct chain));
|
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((uint16_t)atoi((char *)argv[2]));
|
||||||
acl->chains->weight = 1000;
|
acl->chains->weight = 1000;
|
||||||
case ALLOW:
|
case ALLOW:
|
||||||
case DENY:
|
case DENY:
|
||||||
@ -1348,13 +1348,14 @@ static int h_ace(int argc, unsigned char **argv){
|
|||||||
sizeof(struct counter_header) + (tl->number - 1) * sizeof(struct counter_record),
|
sizeof(struct counter_header) + (tl->number - 1) * sizeof(struct counter_record),
|
||||||
SEEK_SET);
|
SEEK_SET);
|
||||||
memset(&crecord, 0, sizeof(struct counter_record));
|
memset(&crecord, 0, sizeof(struct counter_record));
|
||||||
read(conf.counterd, &crecord, sizeof(struct counter_record));
|
if(read(conf.counterd, &crecord, sizeof(struct counter_record)) == sizeof(struct counter_record)){
|
||||||
tl->traf64 = crecord.traf64;
|
tl->traf64 = crecord.traf64;
|
||||||
tl->cleared = crecord.cleared;
|
tl->cleared = crecord.cleared;
|
||||||
tl->updated = crecord.updated;
|
tl->updated = crecord.updated;
|
||||||
if(tl->cleared < 0 || tl->cleared >= MAX_COUNTER_TIME || tl->updated < 0 || tl->updated >= MAX_COUNTER_TIME){
|
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");
|
fprintf(stderr, "Invalid, incompatible or corrupted counter file.\n");
|
||||||
return(6);
|
return(6);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1394,7 +1395,7 @@ static int h_delimchar(int argc, unsigned char **argv){
|
|||||||
|
|
||||||
#ifndef NORADIUS
|
#ifndef NORADIUS
|
||||||
static int h_radius(int argc, unsigned char **argv){
|
static int h_radius(int argc, unsigned char **argv){
|
||||||
unsigned short port;
|
uint16_t port;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
int oldrad;
|
int oldrad;
|
||||||
@ -1575,7 +1576,7 @@ static int h_chroot(int argc, unsigned char **argv){
|
|||||||
fprintf(stderr, "Unable to set uid %d", (int)uid);
|
fprintf(stderr, "Unable to set uid %d", (int)uid);
|
||||||
return(5);
|
return(5);
|
||||||
}
|
}
|
||||||
chdir("/");
|
if(chdir("/")){}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
static void pr_unsigned64(struct node *node, CBFUNC cbf, void*cb){
|
static void pr_unsigned64(struct node *node, CBFUNC cbf, void*cb){
|
||||||
char buf[32];
|
char buf[32];
|
||||||
if(node->value)(*cbf)(cb, buf, sprintf(buf, "%"PRINTF_INT64_MODIFIER"u", *(uint64_t *)node->value));
|
if(node->value)(*cbf)(cb, buf, sprintf(buf, "%"PRIu64"", *(uint64_t *)node->value));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pr_integer(struct node *node, CBFUNC cbf, void*cb){
|
static void pr_integer(struct node *node, CBFUNC cbf, void*cb){
|
||||||
@ -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){
|
static void pr_port(struct node *node, CBFUNC cbf, void*cb){
|
||||||
char buf[8];
|
char buf[8];
|
||||||
if(node->value)(*cbf)(cb, buf, sprintf(buf, "%hu", ntohs(*(unsigned short*)node->value)));
|
if(node->value)(*cbf)(cb, buf, sprintf(buf, "%hu", (unsigned short)ntohs(*(uint16_t*)node->value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pr_datetime(struct node *node, CBFUNC cbf, void*cb){
|
static void pr_datetime(struct node *node, CBFUNC cbf, void*cb){
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
|
|
||||||
void * dnsprchild(struct clientparam* param) {
|
void * dnsprchild(struct clientparam* param) {
|
||||||
unsigned long ip = 0;
|
uint32_t ip = 0;
|
||||||
unsigned char *bbuf;
|
unsigned char *bbuf;
|
||||||
unsigned char *buf, *s1, *s2;
|
unsigned char *buf, *s1, *s2;
|
||||||
char * host = NULL;
|
char * host = NULL;
|
||||||
@ -26,7 +26,7 @@ void * dnsprchild(struct clientparam* param) {
|
|||||||
int res, i;
|
int res, i;
|
||||||
int len;
|
int len;
|
||||||
unsigned type=0;
|
unsigned type=0;
|
||||||
unsigned ttl;
|
uint32_t ttl;
|
||||||
unsigned char addr[16];
|
unsigned char addr[16];
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
unsigned long ul = 1;
|
unsigned long ul = 1;
|
||||||
@ -109,7 +109,7 @@ void * dnsprchild(struct clientparam* param) {
|
|||||||
unsigned a, b, c, d;
|
unsigned a, b, c, d;
|
||||||
sscanf(host, "%u.%u.%u.%u", &a, &b, &c, &d);
|
sscanf(host, "%u.%u.%u.%u", &a, &b, &c, &d);
|
||||||
ip = htonl((d<<24) ^ (c<<16) ^ (b<<8) ^ a);
|
ip = htonl((d<<24) ^ (c<<16) ^ (b<<8) ^ a);
|
||||||
if(*SAFAMILY(¶m->sincl) == AF_INET && ip == *(unsigned long*)SAADDR(¶m->sincl)){
|
if(*SAFAMILY(¶m->sincl) == AF_INET && ip == *(uint32_t *)SAADDR(¶m->sincl)){
|
||||||
buf[2] = 0x85;
|
buf[2] = 0x85;
|
||||||
buf[3] = 0x80;
|
buf[3] = 0x80;
|
||||||
buf[6] = 0;
|
buf[6] = 0;
|
||||||
|
|||||||
@ -195,7 +195,7 @@ SOCKET ftpdata(struct clientparam *param){
|
|||||||
rem = param->remsock;
|
rem = param->remsock;
|
||||||
param->remsock = INVALID_SOCKET;
|
param->remsock = INVALID_SOCKET;
|
||||||
param->req = param->sinsr;
|
param->req = param->sinsr;
|
||||||
*SAPORT(¶m->req) = *SAPORT(¶m->sinsr) = htons((unsigned short)((b5<<8)^b6));
|
*SAPORT(¶m->req) = *SAPORT(¶m->sinsr) = htons((uint16_t)((b5<<8)^b6));
|
||||||
*SAPORT(¶m->sinsl) = 0;
|
*SAPORT(¶m->sinsl) = 0;
|
||||||
i = param->operation;
|
i = param->operation;
|
||||||
param->operation = FTP_DATA;
|
param->operation = FTP_DATA;
|
||||||
|
|||||||
@ -152,7 +152,7 @@ void * ftpprchild(struct clientparam* param) {
|
|||||||
unsigned short b5, b6;
|
unsigned short b5, b6;
|
||||||
|
|
||||||
if(sscanf((char *)buf+5, "%lu,%lu,%lu,%lu,%hu,%hu", &b1, &b2, &b3, &b4, &b5, &b6)!=6) {RETURN(828);}
|
if(sscanf((char *)buf+5, "%lu,%lu,%lu,%lu,%hu,%hu", &b1, &b2, &b3, &b4, &b5, &b6)!=6) {RETURN(828);}
|
||||||
*SAPORT(¶m->sincr) = htons((unsigned short)((b5<<8)^b6));
|
*SAPORT(¶m->sincr) = htons((uint16_t)((b5<<8)^b6));
|
||||||
if(connectwithpoll(param, clidatasock, (struct sockaddr *)¶m->sincr, SASIZE(¶m->sincr),conf.timeouts[CONNECT_TO])) {
|
if(connectwithpoll(param, clidatasock, (struct sockaddr *)¶m->sincr, SASIZE(¶m->sincr),conf.timeouts[CONNECT_TO])) {
|
||||||
param->srv->so._closesocket(param->sostate, clidatasock);
|
param->srv->so._closesocket(param->sostate, clidatasock);
|
||||||
clidatasock = INVALID_SOCKET;
|
clidatasock = INVALID_SOCKET;
|
||||||
|
|||||||
@ -246,15 +246,15 @@ int dobuf2(struct clientparam * param, unsigned char * buf, const unsigned char
|
|||||||
i += (int)strlen((char *)buf+i);
|
i += (int)strlen((char *)buf+i);
|
||||||
break;
|
break;
|
||||||
case 'L':
|
case 'L':
|
||||||
sprintf((char *)buf+i, "%"PRINTF_INT64_MODIFIER"u", param->cycles);
|
sprintf((char *)buf+i, "%"PRIu64"", param->cycles);
|
||||||
i += (int)strlen((char *)buf+i);
|
i += (int)strlen((char *)buf+i);
|
||||||
break;
|
break;
|
||||||
case 'I':
|
case 'I':
|
||||||
sprintf((char *)buf+i, "%"PRINTF_INT64_MODIFIER"u", param->statssrv64);
|
sprintf((char *)buf+i, "%"PRIu64"", param->statssrv64);
|
||||||
i += (int)strlen((char *)buf+i);
|
i += (int)strlen((char *)buf+i);
|
||||||
break;
|
break;
|
||||||
case 'O':
|
case 'O':
|
||||||
sprintf((char *)buf+i, "%"PRINTF_INT64_MODIFIER"u", param->statscli64);
|
sprintf((char *)buf+i, "%"PRIu64"", param->statscli64);
|
||||||
i += (int)strlen((char *)buf+i);
|
i += (int)strlen((char *)buf+i);
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
|
|||||||
@ -415,7 +415,6 @@ static int WINAPI fp_poll(void *state, struct pollfd *fds, unsigned int nfds, in
|
|||||||
struct fp_stream *fps = NULL;
|
struct fp_stream *fps = NULL;
|
||||||
int res;
|
int res;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
int to;
|
|
||||||
|
|
||||||
for(i = 0; i<nfds; i++){
|
for(i = 0; i<nfds; i++){
|
||||||
res = searchsocket(fds[i].fd, &fps);
|
res = searchsocket(fds[i].fd, &fps);
|
||||||
|
|||||||
@ -61,7 +61,7 @@ int savecounters(void)
|
|||||||
unsigned char *tmpbuf,pat_file[]="%s%s.lc";
|
unsigned char *tmpbuf,pat_file[]="%s%s.lc";
|
||||||
|
|
||||||
|
|
||||||
/* timetoexit !=0 - áóäåì çàâåðøàòüñÿ.*/
|
/* timetoexit !=0 - будем завершаться.*/
|
||||||
while (tc != NULL)
|
while (tc != NULL)
|
||||||
{
|
{
|
||||||
tcd = tc;
|
tcd = tc;
|
||||||
@ -72,7 +72,7 @@ int savecounters(void)
|
|||||||
sprintf(tmpbuf,pat_file,ldap_dircount,tcd->ace->users->user);
|
sprintf(tmpbuf,pat_file,ldap_dircount,tcd->ace->users->user);
|
||||||
f=fopen(tmpbuf,"w+b");
|
f=fopen(tmpbuf,"w+b");
|
||||||
fseek(f,0,SEEK_SET);
|
fseek(f,0,SEEK_SET);
|
||||||
fprintf(f,"%"PRINTF_INT64_MODIFIER"u %lu %lu\n",tcd->traf64,
|
fprintf(f,"%"PRIu64" %lu %lu\n",tcd->traf64,
|
||||||
(unsigned long)tcd->cleared,(unsigned long)tcd->updated);
|
(unsigned long)tcd->cleared,(unsigned long)tcd->updated);
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
@ -387,7 +387,7 @@ 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,"%"PRINTF_INT64_MODIFIER"u %lu %lu\n",&rcounter.traf64,
|
sscanf(buf,"%"SCNu64" %lu %lu\n",&rcounter.traf64,
|
||||||
&rcounter.cleared, &rcounter.updated);
|
&rcounter.cleared, &rcounter.updated);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
|
PAMLIB ?= pam
|
||||||
|
|
||||||
all: $(BUILDDIR)pamauth$(DLSUFFICS)
|
all: $(BUILDDIR)pamauth$(DLSUFFICS)
|
||||||
|
|
||||||
pamauth$(OBJSUFFICS): pamauth.c
|
pamauth$(OBJSUFFICS): pamauth.c
|
||||||
$(CC) $(DCFLAGS) $(CFLAGS) pamauth.c
|
$(CC) $(DCFLAGS) $(CFLAGS) pamauth.c
|
||||||
|
|
||||||
$(BUILDDIR)pamauth$(DLSUFFICS): pamauth$(OBJSUFFICS)
|
$(BUILDDIR)pamauth$(DLSUFFICS): pamauth$(OBJSUFFICS)
|
||||||
$(LN) $(LNOUT)../../$(BUILDDIR)pamauth$(DLSUFFICS) $(LDFLAGS) $(DLFLAGS) $(LIBSPREFIX)pam$(LIBSSUFFIX) pamauth$(OBJSUFFICS)
|
$(LN) $(LNOUT)../../$(BUILDDIR)pamauth$(DLSUFFICS) $(LDFLAGS) $(DLFLAGS) $(LIBSPREFIX)$(PAMLIB)$(LIBSSUFFIX) pamauth$(OBJSUFFICS)
|
||||||
|
|
||||||
|
|||||||
@ -32,7 +32,7 @@ char **load_string(FILE *f,int max_count_str, int *countloadstr,
|
|||||||
/*find start service section*/
|
/*find start service section*/
|
||||||
while(!feof(f))
|
while(!feof(f))
|
||||||
{
|
{
|
||||||
fgets(tmpbuf1, 1023,f);
|
if(!fgets(tmpbuf1, 1023,f)) return NULL;
|
||||||
if ((strstr(tmpbuf1,start))!=NULL) { i++; break; }
|
if ((strstr(tmpbuf1,start))!=NULL) { i++; break; }
|
||||||
tmpbuf1[0]='\0';
|
tmpbuf1[0]='\0';
|
||||||
}
|
}
|
||||||
@ -51,7 +51,7 @@ char **load_string(FILE *f,int max_count_str, int *countloadstr,
|
|||||||
i=0;
|
i=0;
|
||||||
while ( !feof(f) || i< max_count_str)
|
while ( !feof(f) || i< max_count_str)
|
||||||
{
|
{
|
||||||
fgets(tmpbuf1, 1023,f);
|
if(!fgets(tmpbuf1, 1023,f)) return NULL;
|
||||||
|
|
||||||
if ((strstr(tmpbuf1,stop))!=NULL) { break; }
|
if ((strstr(tmpbuf1,stop))!=NULL) { break; }
|
||||||
|
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
========================================================================
|
========================================================================
|
||||||
3proxy traffic plugin Changelog
|
3proxy traffic plugin Changelog
|
||||||
========================================================================
|
========================================================================
|
||||||
v0.1.2 (2 января 2007 года)
|
v0.1.2 (2 января 2007 года)
|
||||||
- Плугин обновлён в соответствии с обновлением 3proxy.
|
- Плугин обновлён в соответствии с обновлением 3proxy.
|
||||||
- Добавлена опция debug.
|
- Добавлена опция debug.
|
||||||
|
|
||||||
v0.1.1
|
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 traffic plugin
|
||||||
========================================================================
|
========================================================================
|
||||||
Как известно 3proxy считает траффик не сетевой, а прикладной.
|
Как известно 3proxy считает траффик не сетевой, а прикладной.
|
||||||
Обычно прикладной траффик немного меньше (примерно на 10%) чем сетевой,
|
Обычно прикладной траффик немного меньше (примерно на 10%) чем сетевой,
|
||||||
однако в некоторых случаях, например когда пользователи сети играют в
|
однако в некоторых случаях, например когда пользователи сети играют в
|
||||||
игры, сетевой траффик может превысить прикладной в 4-5 раз. Это довольно неприятно,
|
игры, сетевой траффик может превысить прикладной в 4-5 раз. Это довольно неприятно,
|
||||||
так как получается, что они за это не платят.
|
так как получается, что они за это не платят.
|
||||||
|
|
||||||
Происходит это потому, что в каждом посланом пакете есть заголовок+данные. Заголовок
|
Происходит это потому, что в каждом посланом пакете есть заголовок+данные. Заголовок
|
||||||
весит порядка 50-60 байт а колличество данных может меняться от 15-20 байт (что характерно для игр)
|
весит порядка 50-60 байт а колличество данных может меняться от 15-20 байт (что характерно для игр)
|
||||||
до 800-900 байт (у IE). Также колличество данных в пакете зависит от загрузки сети,
|
до 800-900 байт (у IE). Также колличество данных в пакете зависит от загрузки сети,
|
||||||
удалённости сервера и прочих причин.
|
удалённости сервера и прочих причин.
|
||||||
|
|
||||||
Данный плагин может исправить такую ситуацию. Он может умножать счётчик траффика
|
Данный плагин может исправить такую ситуацию. Он может умножать счётчик траффика
|
||||||
при окончании соединения на некоторый коэффициент либо добавлять к данным размеры заголовков пакетов,
|
при окончании соединения на некоторый коэффициент либо добавлять к данным размеры заголовков пакетов,
|
||||||
которые прошли по сети.
|
которые прошли по сети.
|
||||||
|
|
||||||
Как использовать плагин:
|
Как использовать плагин:
|
||||||
|
|
||||||
загрузка плагина:
|
загрузка плагина:
|
||||||
plugin "TrafficPlugin.dll" start
|
plugin "TrafficPlugin.dll" start
|
||||||
|
|
||||||
Далее недоходимо добавить правила:
|
Далее недоходимо добавить правила:
|
||||||
ДЛЯ РЕЖИМА ДОМНОЖЕНИЯ ТРАФФИКА НА ЧИСЛО:
|
ДЛЯ РЕЖИМА ДОМНОЖЕНИЯ ТРАФФИКА НА ЧИСЛО:
|
||||||
trafcorrect m <сервис> <исходящий порт> <коэффициент>
|
trafcorrect m <сервис> <исходящий порт> <коэффициент>
|
||||||
где: <сервис> может быть proxy, socks4, socks45, socks5, tcppm, udppm, pop3p
|
где: <сервис> может быть proxy, socks4, socks45, socks5, tcppm, udppm, pop3p
|
||||||
если сервис указан неверно то считается, что это может быть любой сервис.
|
если сервис указан неверно то считается, что это может быть любой сервис.
|
||||||
можно использовать *, тогда правило будет считаться для любого сервиса.
|
можно использовать *, тогда правило будет считаться для любого сервиса.
|
||||||
<исходящий порт> - порт, к которому подключается прокси сервер. * - любой
|
<исходящий порт> - порт, к которому подключается прокси сервер. * - любой
|
||||||
<коэффициент> - число на каоторое домнажается траффик. Обязательный параметр.
|
<коэффициент> - число на каоторое домнажается траффик. Обязательный параметр.
|
||||||
Должен быть от больше 0 и меньше 100
|
Должен быть от больше 0 и меньше 100
|
||||||
|
|
||||||
ДЛЯ РЕЖИМА С УЧЁТОМ РАЗМЕРА ЗАГОЛОВКОВ ПАКЕТОВ:
|
ДЛЯ РЕЖИМА С УЧЁТОМ РАЗМЕРА ЗАГОЛОВКОВ ПАКЕТОВ:
|
||||||
trafcorrect p <сервис> <tcp/udp> <исходящий порт> [размер пустого пакета]
|
trafcorrect p <сервис> <tcp/udp> <исходящий порт> [размер пустого пакета]
|
||||||
<tcp/udp> - протокол, по которому осуществляется соединение.
|
<tcp/udp> - протокол, по которому осуществляется соединение.
|
||||||
[размер пакета] - средний размер пустого пакета. Можно определить захватив
|
[размер пакета] - средний размер пустого пакета. Можно определить захватив
|
||||||
данные при помощи такой утилиты как Ethernal. Параметр необязателен. Если отсутствует,
|
данные при помощи такой утилиты как Ethernal. Параметр необязателен. Если отсутствует,
|
||||||
то размер пакета будет считаться равным 66 байт.
|
то размер пакета будет считаться равным 66 байт.
|
||||||
|
|
||||||
Режимы можно смешивать.
|
Режимы можно смешивать.
|
||||||
Следует учитывать, что плугин создаёт список всех правил изменения траффика.
|
Следует учитывать, что плугин создаёт список всех правил изменения траффика.
|
||||||
Когда происходит окончание соединения выполняется первое подходящее правило.
|
Когда происходит окончание соединения выполняется первое подходящее правило.
|
||||||
|
|
||||||
Пример:
|
Пример:
|
||||||
plugin "TrafficPlugin.dll" start
|
plugin "TrafficPlugin.dll" start
|
||||||
trafcorrect m socks5 6112 4.5
|
trafcorrect m socks5 6112 4.5
|
||||||
trafcorrect m socks5 * 1.1
|
trafcorrect m socks5 * 1.1
|
||||||
|
|
||||||
следующее неверно:
|
следующее неверно:
|
||||||
plugin "TrafficPlugin.dll" start
|
plugin "TrafficPlugin.dll" start
|
||||||
trafcorrect m socks5 * 1.1
|
trafcorrect m socks5 * 1.1
|
||||||
trafcorrect m socks5 6112 4.5
|
trafcorrect m socks5 6112 4.5
|
||||||
Вторая строчка выполнена никогда не будет. Так как 1 имеет более широкое назначение.
|
Вторая строчка выполнена никогда не будет. Так как 1 имеет более широкое назначение.
|
||||||
|
|
||||||
РЕЖИМ ОТЛАДКИ ПРАВИЛ:
|
РЕЖИМ ОТЛАДКИ ПРАВИЛ:
|
||||||
1. Запускает прокси в оконном режиме (чтобы видеть stdout).
|
1. Запускает прокси в оконном режиме (чтобы видеть stdout).
|
||||||
2. Загрузка плагина должна выглядеть сл. образом:
|
2. Загрузка плагина должна выглядеть сл. образом:
|
||||||
plugin "TrafficPlugin.dll" start debug
|
plugin "TrafficPlugin.dll" start debug
|
||||||
3. В окне прокси сервера будет написана информация о прохождении правил коррекции траффика.
|
3. В окне прокси сервера будет написана информация о прохождении правил коррекции траффика.
|
||||||
Правила нумеруются с 1.
|
Правила нумеруются с 1.
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
Copyright:
|
Copyright:
|
||||||
|
|||||||
@ -1,16 +1,16 @@
|
|||||||
/*
|
/*
|
||||||
3proxy Traffic correct plugin v0.1 beta
|
3proxy Traffic correct plugin v0.1 beta
|
||||||
|
|
||||||
Написал Maslov Michael aka Flexx(rus)
|
Написал Maslov Michael aka Flexx(rus)
|
||||||
Формула расчёта траффика по размеру пакета by 3APA3A
|
Формула расчёта траффика по размеру пакета by 3APA3A
|
||||||
email: flexx_rus@mail.ru
|
email: flexx_rus@mail.ru
|
||||||
ICQ: 299132764
|
ICQ: 299132764
|
||||||
http://3proxy.ru/
|
http://3proxy.ru/
|
||||||
|
|
||||||
Как работает не знаю (многое зависит от ваших настроек). Никаких гарантий.
|
Как работает не знаю (многое зависит от ваших настроек). Никаких гарантий.
|
||||||
С плугином можете делать всё, что захочется.
|
С плугином можете делать всё, что захочется.
|
||||||
Дожен распростроняться только с исходными кодами или вместе с 3proxy.
|
Дожен распростроняться только с исходными кодами или вместе с 3proxy.
|
||||||
Удалять данный Copyright запрещено.
|
Удалять данный Copyright запрещено.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../../structures.h"
|
#include "../../structures.h"
|
||||||
@ -33,8 +33,8 @@ struct commands * commandhandlers;
|
|||||||
struct pluginlink * pl;
|
struct pluginlink * pl;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
MULTIPLAY, /* метод коррекции умножением на коффициент */
|
MULTIPLAY, /* метод коррекции умножением на коффициент */
|
||||||
IPCORRECT, /* метод коррекции с учётом размера пакета */
|
IPCORRECT, /* метод коррекции с учётом размера пакета */
|
||||||
} TRAFCORRECT_TYPE;
|
} TRAFCORRECT_TYPE;
|
||||||
|
|
||||||
typedef enum {
|
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");
|
if(DBGLEVEL == 1)fprintf(stdout, "See documentation of traffic correct plugin.\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/* режим умножения траффика на коэффициент */
|
/* режим умножения траффика на коэффициент */
|
||||||
if (!strcmp((char *)argv[1], "m")) {
|
if (!strcmp((char *)argv[1], "m")) {
|
||||||
struct trafcorrect * newitem;
|
struct trafcorrect * newitem;
|
||||||
if (argc < 5) {
|
if (argc < 5) {
|
||||||
@ -110,7 +110,7 @@ int h_trafcorrect(int argc, unsigned char ** argv) {
|
|||||||
|
|
||||||
newitem->port = atoi((char *)argv[3]);
|
newitem->port = atoi((char *)argv[3]);
|
||||||
newitem->coeff = atof((char *)argv[4]);
|
newitem->coeff = atof((char *)argv[4]);
|
||||||
/* проверка на корректность ввода */
|
/* проверка на корректность ввода */
|
||||||
if ((newitem->port>65535) || (newitem->coeff<=0) || (newitem->coeff>100)) {
|
if ((newitem->port>65535) || (newitem->coeff<=0) || (newitem->coeff>100)) {
|
||||||
free(newitem);
|
free(newitem);
|
||||||
if(DBGLEVEL == 1)fprintf(stdout, "Port must be 0<p<65535 and coefficient must be 0<c<100.\n");
|
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);
|
addtrafcorrect(newitem);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* режим учёта входящих и исходящих пакетов */
|
/* режим учёта входящих и исходящих пакетов */
|
||||||
if (!strcmp((char *)argv[1], "p")) {
|
if (!strcmp((char *)argv[1], "p")) {
|
||||||
struct trafcorrect * newitem;
|
struct trafcorrect * newitem;
|
||||||
if (argc < 5) {
|
if (argc < 5) {
|
||||||
@ -152,7 +152,7 @@ int h_trafcorrect(int argc, unsigned char ** argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
newitem->port = atoi((char *)argv[4]);
|
newitem->port = atoi((char *)argv[4]);
|
||||||
/* последний необязательный параметр - размер пакета */
|
/* последний необязательный параметр - размер пакета */
|
||||||
if (argc >= 6) {
|
if (argc >= 6) {
|
||||||
newitem->psize = atoi((char *)argv[5]);
|
newitem->psize = atoi((char *)argv[5]);
|
||||||
}
|
}
|
||||||
@ -169,7 +169,7 @@ int h_trafcorrect(int argc, unsigned char ** argv) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned short myhtons(unsigned short port) {
|
static uint16_t myhtons(uint16_t port) {
|
||||||
return (port << 8) | (port >> 8);
|
return (port << 8) | (port >> 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,8 +207,8 @@ void mylogfunc(struct clientparam * param, const unsigned char * pz) {
|
|||||||
(param->operation == ICMPASSOC))
|
(param->operation == ICMPASSOC))
|
||||||
)||(starttrafcorrect->con_type == TCP))) /* TCP support */
|
)||(starttrafcorrect->con_type == TCP))) /* TCP support */
|
||||||
{
|
{
|
||||||
/* фильтр подошёл. можно изменять значение траффика
|
/* фильтр подошёл. можно изменять значение траффика
|
||||||
домножаем на число */
|
домножаем на число */
|
||||||
if (starttrafcorrect->type == MULTIPLAY) {
|
if (starttrafcorrect->type == MULTIPLAY) {
|
||||||
#ifndef NOPSTDINT
|
#ifndef NOPSTDINT
|
||||||
param->statssrv64 = (unsigned)((double)param->statssrv64 *starttrafcorrect->coeff);
|
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);
|
param->statscli = (unsigned)((double)param->statscli * starttrafcorrect->coeff);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
/* с учётом пакетов */
|
/* с учётом пакетов */
|
||||||
if (starttrafcorrect->type == IPCORRECT) {
|
if (starttrafcorrect->type == IPCORRECT) {
|
||||||
if (starttrafcorrect->con_type == TCP) {
|
if (starttrafcorrect->con_type == TCP) {
|
||||||
#ifndef NOPSTDINT
|
#ifndef NOPSTDINT
|
||||||
@ -240,7 +240,7 @@ void mylogfunc(struct clientparam * param, const unsigned char * pz) {
|
|||||||
}
|
}
|
||||||
if (DBGLEVEL == 1) {
|
if (DBGLEVEL == 1) {
|
||||||
#ifndef NOPSTDINT
|
#ifndef NOPSTDINT
|
||||||
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);
|
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);
|
||||||
#else
|
#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);
|
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
|
#endif
|
||||||
@ -294,7 +294,7 @@ PLUGINAPI int PLUGINCALL start(struct pluginlink * pluginlink, int argc, char**
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
already_loaded = 1;
|
already_loaded = 1;
|
||||||
/* добавляем команду "trafcorrect" */
|
/* добавляем команду "trafcorrect" */
|
||||||
starthandler = commandhandlers;
|
starthandler = commandhandlers;
|
||||||
for ( ; starthandler->next; starthandler = starthandler->next);
|
for ( ; starthandler->next; starthandler = starthandler->next);
|
||||||
trafcorrect_handler.next = NULL;
|
trafcorrect_handler.next = NULL;
|
||||||
@ -304,7 +304,7 @@ PLUGINAPI int PLUGINCALL start(struct pluginlink * pluginlink, int argc, char**
|
|||||||
trafcorrect_handler.handler = h_trafcorrect;
|
trafcorrect_handler.handler = h_trafcorrect;
|
||||||
starthandler->next = &trafcorrect_handler;
|
starthandler->next = &trafcorrect_handler;
|
||||||
|
|
||||||
/* подменяем conf->logfunc, с целью контролировать траффик */
|
/* подменяем conf->logfunc, с целью контролировать траффик */
|
||||||
origlogfunc = conf->logfunc;
|
origlogfunc = conf->logfunc;
|
||||||
conf->logfunc = mylogfunc;
|
conf->logfunc = mylogfunc;
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
16
src/proxy.c
16
src/proxy.c
@ -337,10 +337,10 @@ for(;;){
|
|||||||
if(su) {
|
if(su) {
|
||||||
su = (unsigned char *)mystrdup((char *)sb);
|
su = (unsigned char *)mystrdup((char *)sb);
|
||||||
decodeurl(su, 0);
|
decodeurl(su, 0);
|
||||||
if(parseconnusername((char *)su, (struct clientparam *)param, 1, (unsigned short)((ftp)?21:80))) RETURN (100);
|
if(parseconnusername((char *)su, (struct clientparam *)param, 1, (uint16_t)((ftp)?21:80))) RETURN (100);
|
||||||
myfree(su);
|
myfree(su);
|
||||||
}
|
}
|
||||||
else if(parsehostname((char *)sb, (struct clientparam *)param, (unsigned short)((ftp)? 21:80))) RETURN(100);
|
else if(parsehostname((char *)sb, (struct clientparam *)param, (uint16_t)((ftp)? 21:80))) RETURN(100);
|
||||||
if(!isconnect){
|
if(!isconnect){
|
||||||
if(se==sg)*se-- = ' ';
|
if(se==sg)*se-- = ' ';
|
||||||
*se = '/';
|
*se = '/';
|
||||||
@ -455,7 +455,7 @@ for(;;){
|
|||||||
if(!sb)continue;
|
if(!sb)continue;
|
||||||
++sb;
|
++sb;
|
||||||
while(isspace(*sb))sb++;
|
while(isspace(*sb))sb++;
|
||||||
sscanf((char *)sb, "%"PRINTF_INT64_MODIFIER"u",&contentlength64);
|
sscanf((char *)sb, "%"SCNu64"",&contentlength64);
|
||||||
if(param->maxtrafout64 && (param->maxtrafout64 < param->statscli64 || contentlength64 > param->maxtrafout64 - param->statscli64)){
|
if(param->maxtrafout64 && (param->maxtrafout64 < param->statscli64 || contentlength64 > param->maxtrafout64 - param->statscli64)){
|
||||||
RETURN(10);
|
RETURN(10);
|
||||||
}
|
}
|
||||||
@ -527,7 +527,7 @@ for(;;){
|
|||||||
}
|
}
|
||||||
else if(param->ndatfilterscli > 0 && contentlength64 > 0){
|
else if(param->ndatfilterscli > 0 && contentlength64 > 0){
|
||||||
uint64_t newlen64;
|
uint64_t newlen64;
|
||||||
newlen64 = sockfillbuffcli(param, (unsigned long)contentlength64, CONNECTION_S);
|
newlen64 = (uint64_t) sockfillbuffcli(param, (unsigned long)contentlength64, CONNECTION_S);
|
||||||
if(newlen64 == contentlength64) {
|
if(newlen64 == contentlength64) {
|
||||||
action = handledatfltcli(param, ¶m->clibuf, (int *)¶m->clibufsize, 0, (int *)¶m->cliinbuf);
|
action = handledatfltcli(param, ¶m->clibuf, (int *)¶m->clibufsize, 0, (int *)¶m->cliinbuf);
|
||||||
if(action == HANDLED){
|
if(action == HANDLED){
|
||||||
@ -537,7 +537,7 @@ for(;;){
|
|||||||
contentlength64 = param->cliinbuf;
|
contentlength64 = param->cliinbuf;
|
||||||
param->nolongdatfilter = 1;
|
param->nolongdatfilter = 1;
|
||||||
}
|
}
|
||||||
sprintf((char*)buf+strlen((char *)buf), "Content-Length: %"PRINTF_INT64_MODIFIER"u\r\n", contentlength64);
|
sprintf((char*)buf+strlen((char *)buf), "Content-Length: %"PRIu64"\r\n", contentlength64);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -911,7 +911,7 @@ for(;;){
|
|||||||
if(!sb)continue;
|
if(!sb)continue;
|
||||||
++sb;
|
++sb;
|
||||||
while(isspace(*sb))sb++;
|
while(isspace(*sb))sb++;
|
||||||
sscanf((char *)sb, "%"PRINTF_INT64_MODIFIER"u", &contentlength64);
|
sscanf((char *)sb, "%"SCNu64"", &contentlength64);
|
||||||
hascontent = 1;
|
hascontent = 1;
|
||||||
if(param->unsafefilter && param->ndatfilterssrv > 0) {
|
if(param->unsafefilter && param->ndatfilterssrv > 0) {
|
||||||
hascontent = 2;
|
hascontent = 2;
|
||||||
@ -989,7 +989,7 @@ for(;;){
|
|||||||
}
|
}
|
||||||
if(action != PASS) RETURN(517);
|
if(action != PASS) RETURN(517);
|
||||||
contentlength64 = param->srvinbuf;
|
contentlength64 = param->srvinbuf;
|
||||||
sprintf((char*)buf+strlen((char *)buf), "Content-Length: %"PRINTF_INT64_MODIFIER"u\r\n", contentlength64);
|
sprintf((char*)buf+strlen((char *)buf), "Content-Length: %"PRIu64"\r\n", contentlength64);
|
||||||
hascontent = 1;
|
hascontent = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1036,7 +1036,7 @@ for(;;){
|
|||||||
}
|
}
|
||||||
smallbuf[i] = 0;
|
smallbuf[i] = 0;
|
||||||
contentlength64 = 0;
|
contentlength64 = 0;
|
||||||
sscanf((char *)smallbuf, "%"PRINTF_INT64_MODIFIER"x", &contentlength64);
|
sscanf((char *)smallbuf, "%"SCNx64"", &contentlength64);
|
||||||
if(contentlength64 == 0) {
|
if(contentlength64 == 0) {
|
||||||
param->chunked = 2;
|
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 sockgetcharcli(struct clientparam * param, int timeosec, int timeousec);
|
||||||
int sockgetcharsrv(struct clientparam * param, int timeosec, int timeousec);
|
int sockgetcharsrv(struct clientparam * param, int timeosec, int timeousec);
|
||||||
int sockfillbuffcli(struct clientparam * param, unsigned long size, int timeosec);
|
unsigned long sockfillbuffcli(struct clientparam * param, unsigned long size, int timeosec);
|
||||||
int sockfillbuffsrv(struct clientparam * param, unsigned long size, int timeosec);
|
unsigned long 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);
|
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);
|
unsigned bandlimitfunc(struct clientparam *param, unsigned nbytesin, unsigned nbytesout);
|
||||||
int handleredirect(struct clientparam * param, struct ace * acentry);
|
int handleredirect(struct clientparam * param, struct ace * acentry);
|
||||||
|
|
||||||
int scanaddr(const unsigned char *s, unsigned long * ip, unsigned long * mask);
|
int scanaddr(const unsigned char *s, uint32_t * ip, uint32_t * mask);
|
||||||
int myinet_ntop(int af, void *src, char *dst, socklen_t size);
|
int myinet_ntop(int af, void *src, char *dst, socklen_t size);
|
||||||
extern struct nserver nservers[MAXNSERVERS];
|
extern struct nserver nservers[MAXNSERVERS];
|
||||||
extern struct nserver authnserver;
|
extern struct nserver authnserver;
|
||||||
unsigned long getip(unsigned char *name);
|
uint32_t getip(unsigned char *name);
|
||||||
unsigned long getip46(int family, unsigned char *name, struct sockaddr *sa);
|
uint32_t getip46(int family, unsigned char *name, struct sockaddr *sa);
|
||||||
int afdetect(unsigned char *name);
|
int afdetect(unsigned char *name);
|
||||||
unsigned long myresolver(int, unsigned char *, unsigned char *);
|
uint32_t myresolver(int, unsigned char *, unsigned char *);
|
||||||
unsigned long fakeresolver (int, unsigned char *, unsigned char*);
|
uint32_t fakeresolver (int, unsigned char *, unsigned char*);
|
||||||
int inithashtable(struct hashtable *hashtable, unsigned nhashsize);
|
int inithashtable(struct hashtable *hashtable, unsigned nhashsize);
|
||||||
void freeparam(struct clientparam * param);
|
void freeparam(struct clientparam * param);
|
||||||
void clearstat(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);
|
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 parsehost(int family, unsigned char *host, struct sockaddr *sa);
|
||||||
int parsehostname(char *hostname, struct clientparam *param, unsigned short port);
|
int parsehostname(char *hostname, struct clientparam *param, uint16_t port);
|
||||||
int parseusername(char *username, struct clientparam *param, int extpasswd);
|
int parseusername(char *username, struct clientparam *param, int extpasswd);
|
||||||
int parseconnusername(char *username, struct clientparam *param, int extpasswd, unsigned short port);
|
int parseconnusername(char *username, struct clientparam *param, int extpasswd, uint16_t port);
|
||||||
int ACLmatches(struct ace* acentry, struct clientparam * param);
|
int ACLmatches(struct ace* acentry, struct clientparam * param);
|
||||||
int checkACL(struct clientparam * param);
|
int checkACL(struct clientparam * param);
|
||||||
extern int havelog;
|
extern int havelog;
|
||||||
unsigned long udpresolve(int af, unsigned char * name, unsigned char * value, unsigned *retttl, struct clientparam* param, int makeauth);
|
uint32_t udpresolve(int af, unsigned char * name, unsigned char * value, uint32_t *retttl, struct clientparam* param, int makeauth);
|
||||||
|
|
||||||
struct ace * copyacl (struct ace *ac);
|
struct ace * copyacl (struct ace *ac);
|
||||||
struct auth * copyauth (struct auth *);
|
struct auth * copyauth (struct auth *);
|
||||||
|
|||||||
@ -288,6 +288,9 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
"\n"
|
"\n"
|
||||||
" -iIP ip address or internal interface (clients are expected to connect)\n"
|
" -iIP ip address or internal interface (clients are expected to connect)\n"
|
||||||
" -eIP ip address or external interface (outgoing connection will have this)\n"
|
" -eIP ip address or external interface (outgoing connection will have this)\n"
|
||||||
|
#ifndef _WIN32
|
||||||
|
" -k outgoing connection will have local IP where client connected, thus ignores -e (useful in AnyIP case)\n"
|
||||||
|
#endif
|
||||||
" -rHOST:PORT Use IP:port for connect back proxy instead of listen port\n"
|
" -rHOST:PORT Use IP:port for connect back proxy instead of listen port\n"
|
||||||
" -RHOST:PORT Use PORT to listen connect back proxy connection to pass data to\n"
|
" -RHOST:PORT Use PORT to listen connect back proxy connection to pass data to\n"
|
||||||
" -4 Use IPv4 for outgoing connections\n"
|
" -4 Use IPv4 for outgoing connections\n"
|
||||||
@ -426,6 +429,13 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#ifndef _WIN32
|
||||||
|
case 'k':
|
||||||
|
{
|
||||||
|
srv.keepip = 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
case 'N':
|
case 'N':
|
||||||
getip46(46, (unsigned char *)argv[i]+2, (struct sockaddr *)&srv.extNat);
|
getip46(46, (unsigned char *)argv[i]+2, (struct sockaddr *)&srv.extNat);
|
||||||
break;
|
break;
|
||||||
@ -573,7 +583,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
else {
|
else {
|
||||||
#endif
|
#endif
|
||||||
#ifndef NOPORTMAP
|
#ifndef NOPORTMAP
|
||||||
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) {
|
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) {
|
||||||
#ifndef STDMAIN
|
#ifndef STDMAIN
|
||||||
haveerror = 1;
|
haveerror = 1;
|
||||||
pushthreadinit();
|
pushthreadinit();
|
||||||
@ -718,7 +728,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
defparam.clisock = sock;
|
defparam.clisock = sock;
|
||||||
|
|
||||||
if(!srv.silent && !iscbc){
|
if(!srv.silent && !iscbc){
|
||||||
sprintf((char *)buf, "Accepting connections [%"PRINTF_INT64_MODIFIER"u/%"PRINTF_INT64_MODIFIER"u]", (uint64_t)getpid(), (uint64_t)pthread_self());
|
sprintf((char *)buf, "Accepting connections [%"PRIu64"/%"PRIu64"]", (uint64_t)getpid(), (uint64_t)pthread_self());
|
||||||
dolog(&defparam, buf);
|
dolog(&defparam, buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -815,6 +825,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
new_sock = srv.so._accept(srv.so.state, sock, (struct sockaddr*)&defparam.sincr, &size);
|
new_sock = srv.so._accept(srv.so.state, sock, (struct sockaddr*)&defparam.sincr, &size);
|
||||||
|
|
||||||
if(new_sock == INVALID_SOCKET){
|
if(new_sock == INVALID_SOCKET){
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
switch(WSAGetLastError()){
|
switch(WSAGetLastError()){
|
||||||
@ -990,6 +1001,7 @@ void srvinit(struct srvparam * srv, struct clientparam *param){
|
|||||||
srv->logdumpcli = conf.logdumpcli;
|
srv->logdumpcli = conf.logdumpcli;
|
||||||
srv->cbsock = INVALID_SOCKET;
|
srv->cbsock = INVALID_SOCKET;
|
||||||
srv->needuser = 1;
|
srv->needuser = 1;
|
||||||
|
srv->keepip = 0;
|
||||||
#ifdef WITHSPLICE
|
#ifdef WITHSPLICE
|
||||||
srv->usesplice = 1;
|
srv->usesplice = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -87,7 +87,7 @@ int sockgetcharcli(struct clientparam * param, int timeosec, int timeousec){
|
|||||||
return (int)*param->clibuf;
|
return (int)*param->clibuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sockfillbuffcli(struct clientparam * param, unsigned long size, int timeosec){
|
unsigned long sockfillbuffcli(struct clientparam * param, unsigned long size, int timeosec){
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if(!param->clibuf) return 0;
|
if(!param->clibuf) return 0;
|
||||||
@ -107,7 +107,7 @@ int sockfillbuffcli(struct clientparam * param, unsigned long size, int timeosec
|
|||||||
return param->cliinbuf;
|
return param->cliinbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sockfillbuffsrv(struct clientparam * param, unsigned long size, int timeosec){
|
unsigned long sockfillbuffsrv(struct clientparam * param, unsigned long size, int timeosec){
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if(!param->srvbuf) return 0;
|
if(!param->srvbuf) return 0;
|
||||||
|
|||||||
@ -60,7 +60,8 @@ int sockmap(struct clientparam * param, int timeo, int usesplice){
|
|||||||
int res;
|
int res;
|
||||||
SASIZETYPE sasize;
|
SASIZETYPE sasize;
|
||||||
int needaction = 0;
|
int needaction = 0;
|
||||||
int graceclinum=0, gracesrvnum=0, graceclitraf=0, gracesrvtraf=0, gracetime=0;
|
int graceclinum=0, gracesrvnum=0, graceclitraf=0, gracesrvtraf=0;
|
||||||
|
time_t gracetime = 0;
|
||||||
|
|
||||||
#ifdef WITHSPLICE
|
#ifdef WITHSPLICE
|
||||||
uint64_t inclientpipe = 0, inserverpipe = 0;
|
uint64_t inclientpipe = 0, inserverpipe = 0;
|
||||||
|
|||||||
@ -37,7 +37,7 @@ void * sockschild(struct clientparam* param) {
|
|||||||
SOCKET s;
|
SOCKET s;
|
||||||
unsigned size;
|
unsigned size;
|
||||||
SASIZETYPE sasize;
|
SASIZETYPE sasize;
|
||||||
unsigned short port = 0;
|
uint16_t port = 0;
|
||||||
unsigned char * buf=NULL;
|
unsigned char * buf=NULL;
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
unsigned char command=0;
|
unsigned char command=0;
|
||||||
@ -102,7 +102,7 @@ void * sockschild(struct clientparam* param) {
|
|||||||
buf[0] = (unsigned char) res;
|
buf[0] = (unsigned char) res;
|
||||||
if ((res = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(441);}
|
if ((res = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(441);}
|
||||||
buf[1] = (unsigned char) res;
|
buf[1] = (unsigned char) res;
|
||||||
port = *(unsigned short*)buf;
|
port = *(uint16_t*)buf;
|
||||||
c = 1;
|
c = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ void * sockschild(struct clientparam* param) {
|
|||||||
buf[0] = (unsigned char) res;
|
buf[0] = (unsigned char) res;
|
||||||
if ((res = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(441);}
|
if ((res = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(441);}
|
||||||
buf[1] = (unsigned char) res;
|
buf[1] = (unsigned char) res;
|
||||||
port = *(unsigned short*)buf;
|
port = *(uint16_t*)buf;
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@ -15,8 +15,8 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#ifndef PRINTF_INT64_MODIFIER
|
#ifndef PRId64
|
||||||
#define PRINTF_INT64_MODIFIER "ll"
|
#include <inttypes.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -198,7 +198,7 @@ struct srvparam;
|
|||||||
typedef void (*LOGFUNC)(struct clientparam * param, const unsigned char *);
|
typedef void (*LOGFUNC)(struct clientparam * param, const unsigned char *);
|
||||||
typedef int (*AUTHFUNC)(struct clientparam * param);
|
typedef int (*AUTHFUNC)(struct clientparam * param);
|
||||||
typedef void * (*REDIRECTFUNC)(struct clientparam * param);
|
typedef void * (*REDIRECTFUNC)(struct clientparam * param);
|
||||||
typedef unsigned long (*RESOLVFUNC)(int af, unsigned char *name, unsigned char *value);
|
typedef uint32_t (*RESOLVFUNC)(int af, unsigned char *name, unsigned char *value);
|
||||||
typedef unsigned (*BANDLIMFUNC)(struct clientparam * param, unsigned nbytesin, unsigned nbytesout);
|
typedef unsigned (*BANDLIMFUNC)(struct clientparam * param, unsigned nbytesin, unsigned nbytesout);
|
||||||
typedef void (*TRAFCOUNTFUNC)(struct clientparam * param);
|
typedef void (*TRAFCOUNTFUNC)(struct clientparam * param);
|
||||||
typedef void * (*EXTENDFUNC) (struct node *node);
|
typedef void * (*EXTENDFUNC) (struct node *node);
|
||||||
@ -241,8 +241,8 @@ struct iplist {
|
|||||||
|
|
||||||
struct portlist {
|
struct portlist {
|
||||||
struct portlist * next;
|
struct portlist * next;
|
||||||
unsigned short startport;
|
uint16_t startport;
|
||||||
unsigned short endport;
|
uint16_t endport;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct userlist {
|
struct userlist {
|
||||||
@ -493,6 +493,7 @@ struct srvparam {
|
|||||||
int paused, version;
|
int paused, version;
|
||||||
int singlepacket;
|
int singlepacket;
|
||||||
int usentlm;
|
int usentlm;
|
||||||
|
int keepip;
|
||||||
int needuser;
|
int needuser;
|
||||||
int silent;
|
int silent;
|
||||||
int transparent;
|
int transparent;
|
||||||
@ -536,7 +537,7 @@ struct srvparam {
|
|||||||
unsigned char * logformat;
|
unsigned char * logformat;
|
||||||
unsigned char * logtarget;
|
unsigned char * logtarget;
|
||||||
unsigned char * nonprintable;
|
unsigned char * nonprintable;
|
||||||
unsigned short targetport;
|
uint16_t targetport;
|
||||||
unsigned char replace;
|
unsigned char replace;
|
||||||
time_t time_start;
|
time_t time_start;
|
||||||
};
|
};
|
||||||
@ -732,7 +733,7 @@ struct symbol {
|
|||||||
|
|
||||||
struct proxydef {
|
struct proxydef {
|
||||||
PROXYFUNC pf;
|
PROXYFUNC pf;
|
||||||
unsigned short port;
|
uint16_t port;
|
||||||
int isudp;
|
int isudp;
|
||||||
int service;
|
int service;
|
||||||
char * helpmessage;
|
char * helpmessage;
|
||||||
@ -780,8 +781,8 @@ struct pluginlink {
|
|||||||
int (*myinet_ntop)(int af, void *src, char *dst, socklen_t size);
|
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 (*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 (*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, unsigned long * ip, unsigned long * mask);
|
int (*scanaddr)(const unsigned char *s, uint32_t * ip, uint32_t * mask);
|
||||||
unsigned long (*getip46)(int family, unsigned char *name, struct sockaddr *sa);
|
uint32_t (*getip46)(int family, unsigned char *name, struct sockaddr *sa);
|
||||||
int (*sockmap)(struct clientparam * param, int timeo, int usesplice);
|
int (*sockmap)(struct clientparam * param, int timeo, int usesplice);
|
||||||
int (*ACLMatches)(struct ace* acentry, struct clientparam * param);
|
int (*ACLMatches)(struct ace* acentry, struct clientparam * param);
|
||||||
int (*alwaysauth)(struct clientparam * param);
|
int (*alwaysauth)(struct clientparam * param);
|
||||||
@ -807,9 +808,9 @@ struct pluginlink {
|
|||||||
struct proxydef * childdef;
|
struct proxydef * childdef;
|
||||||
int (*start_proxy_thread)(struct child * chp);
|
int (*start_proxy_thread)(struct child * chp);
|
||||||
void (*freeparam)(struct clientparam * param);
|
void (*freeparam)(struct clientparam * param);
|
||||||
int (*parsehostname)(char *hostname, struct clientparam *param, unsigned short port);
|
int (*parsehostname)(char *hostname, struct clientparam *param, uint16_t port);
|
||||||
int (*parseusername)(char *username, struct clientparam *param, int extpasswd);
|
int (*parseusername)(char *username, struct clientparam *param, int extpasswd);
|
||||||
int (*parseconnusername)(char *username, struct clientparam *param, int extpasswd, unsigned short port);
|
int (*parseconnusername)(char *username, struct clientparam *param, int extpasswd, uint16_t port);
|
||||||
struct sockfuncs *so;
|
struct sockfuncs *so;
|
||||||
unsigned char * (*dologname) (unsigned char *buf, unsigned char *name, const unsigned char *ext, ROTATION lt, time_t t);
|
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,13 +38,9 @@ int readtls(struct clientparam *param, int direction, unsigned char *buf, int bu
|
|||||||
#define PROTOLEN (32)
|
#define PROTOLEN (32)
|
||||||
|
|
||||||
|
|
||||||
int parsehello(int type, unsigned char *hello, int len, char *sni, int * snipos, int *lv, char * proto){
|
int parsehello(int type, unsigned char *hello, unsigned len, char *sni, int * snipos, int *lv, char * proto){
|
||||||
int hlen;
|
|
||||||
unsigned offset;
|
unsigned offset;
|
||||||
int slen;
|
unsigned hlen, slen, cslen, elen, snllen, snlen, alpnlen;
|
||||||
int cslen;
|
|
||||||
int elen;
|
|
||||||
int snllen, snlen, alpnlen;
|
|
||||||
int snifound=0;
|
int snifound=0;
|
||||||
|
|
||||||
if(len < 64) return -1;
|
if(len < 64) return -1;
|
||||||
@ -74,7 +70,7 @@ int parsehello(int type, unsigned char *hello, int len, char *sni, int * snipos,
|
|||||||
offset += 2;
|
offset += 2;
|
||||||
if(elen+offset != len) return -9;
|
if(elen+offset != len) return -9;
|
||||||
while(elen > 1){
|
while(elen > 1){
|
||||||
int xlen;
|
unsigned xlen;
|
||||||
xlen = size16(hello+offset+2);
|
xlen = size16(hello+offset+2);
|
||||||
if(xlen+4 > elen) return -10;
|
if(xlen+4 > elen) return -10;
|
||||||
if(type == 1 && hello[offset] == 0 && hello[offset+1] == 0){
|
if(type == 1 && hello[offset] == 0 && hello[offset+1] == 0){
|
||||||
@ -112,8 +108,8 @@ int parsehello(int type, unsigned char *hello, int len, char *sni, int * snipos,
|
|||||||
return snifound;
|
return snifound;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tlstobufcli(struct clientparam *param, int offset){
|
int tlstobufcli(struct clientparam *param){
|
||||||
int len, newlen;
|
unsigned long len, newlen;
|
||||||
if(!param->clibuf){
|
if(!param->clibuf){
|
||||||
if(!(param->clibuf = myalloc(SRVBUFSIZE))) return -1;
|
if(!(param->clibuf = myalloc(SRVBUFSIZE))) return -1;
|
||||||
param->clibufsize = SRVBUFSIZE;
|
param->clibufsize = SRVBUFSIZE;
|
||||||
@ -139,11 +135,11 @@ int tlstobufcli(struct clientparam *param, int offset){
|
|||||||
if(param->cliinbuf <= newlen) return -5;
|
if(param->cliinbuf <= newlen) return -5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return len;
|
return (int)len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tlstobufsrv(struct clientparam *param, int offset){
|
int tlstobufsrv(struct clientparam *param){
|
||||||
int len, newlen;
|
unsigned long len, newlen;
|
||||||
|
|
||||||
if(param->cliinbuf != param->clioffset){
|
if(param->cliinbuf != param->clioffset){
|
||||||
len = socksend(param, param->remsock, param->clibuf+param->clioffset,param->cliinbuf-param->clioffset, conf.timeouts[STRING_S]);
|
len = socksend(param, param->remsock, param->clibuf+param->clioffset,param->cliinbuf-param->clioffset, conf.timeouts[STRING_S]);
|
||||||
@ -157,20 +153,20 @@ int tlstobufsrv(struct clientparam *param, int offset){
|
|||||||
param->srvbufsize = SRVBUFSIZE;
|
param->srvbufsize = SRVBUFSIZE;
|
||||||
param->srvoffset = param->srvinbuf = 0;
|
param->srvoffset = param->srvinbuf = 0;
|
||||||
}
|
}
|
||||||
len = sockfillbuffsrv(param, offset+5, conf.timeouts[STRING_S]);
|
len = sockfillbuffsrv(param, 5, conf.timeouts[STRING_S]);
|
||||||
if(len < offset+5) return -3;
|
if(len < 5) return -3;
|
||||||
if(param->srvbuf[offset+1] != 3) {
|
if(param->srvbuf[1] != 3) {
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
len = offset + 5 + size16(param->srvbuf+offset+3);
|
len = 5 + size16(param->srvbuf+3);
|
||||||
if(len > param->srvbufsize) return -5;
|
if(len > param->srvbufsize) return -5;
|
||||||
for(newlen=param->srvinbuf; newlen < len; newlen=param->srvinbuf){
|
for(newlen=param->srvinbuf; newlen < len; newlen=param->srvinbuf){
|
||||||
sockfillbuffsrv(param, len, conf.timeouts[STRING_S]);
|
sockfillbuffsrv(param, len, conf.timeouts[STRING_S]);
|
||||||
if(param->srvinbuf <= newlen) return -6;
|
if(param->srvinbuf <= newlen) return -6;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return len-offset;
|
return (int)len;
|
||||||
}
|
}
|
||||||
|
|
||||||
void * tlsprchild(struct clientparam* param) {
|
void * tlsprchild(struct clientparam* param) {
|
||||||
@ -181,13 +177,13 @@ void * tlsprchild(struct clientparam* param) {
|
|||||||
char proto[PROTOLEN]="-";
|
char proto[PROTOLEN]="-";
|
||||||
int snipos = 0;
|
int snipos = 0;
|
||||||
|
|
||||||
res = tlstobufcli(param, 0);
|
res = tlstobufcli(param);
|
||||||
if(res <= 0 || param->clibuf[0] != 22){
|
if(res <= 0 || param->clibuf[0] != 22){
|
||||||
if(param->srv->requirecert)RETURN(300-res);
|
if(param->srv->requirecert)RETURN(300-res);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lv = param->clibuf[2];
|
lv = param->clibuf[2];
|
||||||
res = parsehello(1, param->clibuf, res, sni, &snipos, &lv, proto);
|
res = parsehello(1, param->clibuf, (unsigned)res, sni, &snipos, &lv, proto);
|
||||||
if(res > 0){
|
if(res > 0){
|
||||||
if(param->hostname){
|
if(param->hostname){
|
||||||
myfree(param->hostname);
|
myfree(param->hostname);
|
||||||
@ -225,20 +221,20 @@ void * tlsprchild(struct clientparam* param) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(param->srv->requirecert > 1){
|
if(param->srv->requirecert > 1){
|
||||||
res = tlstobufsrv(param, 0);
|
res = tlstobufsrv(param);
|
||||||
if(res <= 0 || param->srvbuf[0] != 22) RETURN(340-res);
|
if(res <= 0 || param->srvbuf[0] != 22) RETURN(340-res);
|
||||||
lv = param->srvbuf[2];
|
lv = param->srvbuf[2];
|
||||||
res = parsehello(2, param->srvbuf, res, sni, &snipos, &lv, proto);
|
res = parsehello(2, param->srvbuf, (unsigned)res, sni, &snipos, &lv, proto);
|
||||||
if (res < 0) RETURN(350-res);
|
if (res < 0) RETURN(350-res);
|
||||||
}
|
}
|
||||||
if(param->srv->requirecert > 2){
|
if(param->srv->requirecert > 2){
|
||||||
int srvcert=0, clicert=0, reqcert=0, len, rlen, done;
|
int srvcert=0, clicert=0, reqcert=0, len, done;
|
||||||
if(lv > 3) RETURN(370);
|
if(lv > 3) RETURN(370);
|
||||||
for(done=0;!done;) {
|
for(done=0;!done;) {
|
||||||
len = param->srvinbuf;
|
len = param->srvinbuf;
|
||||||
if(socksend(param, param->clisock, param->srvbuf,len, conf.timeouts[STRING_S]) != len) RETURN(371);
|
if(socksend(param, param->clisock, param->srvbuf,len, conf.timeouts[STRING_S]) != len) RETURN(371);
|
||||||
param->srvinbuf = 0;
|
param->srvinbuf = 0;
|
||||||
res = tlstobufsrv(param, 0);
|
res = tlstobufsrv(param);
|
||||||
if(res <= 0) RETURN(380-res);
|
if(res <= 0) RETURN(380-res);
|
||||||
if(param->srvbuf[0]!= 22) break;
|
if(param->srvbuf[0]!= 22) break;
|
||||||
switch(param->srvbuf[5]){
|
switch(param->srvbuf[5]){
|
||||||
@ -260,7 +256,7 @@ void * tlsprchild(struct clientparam* param) {
|
|||||||
if(param->srv->requirecert > 3){
|
if(param->srv->requirecert > 3){
|
||||||
if(!reqcert) RETURN(374);
|
if(!reqcert) RETURN(374);
|
||||||
for(done=0;!done;) {
|
for(done=0;!done;) {
|
||||||
res = tlstobufcli(param, 0);
|
res = tlstobufcli(param);
|
||||||
if(res <= 0) RETURN(390-res);
|
if(res <= 0) RETURN(390-res);
|
||||||
len = res;
|
len = res;
|
||||||
if(param->clibuf[0]!= 22) break;
|
if(param->clibuf[0]!= 22) break;
|
||||||
|
|||||||
12
src/udppm.c
12
src/udppm.c
@ -17,16 +17,6 @@
|
|||||||
#define RETURN(xxx) { param->res = xxx; goto CLEANRET; }
|
#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) {
|
void * udppmchild(struct clientparam* param) {
|
||||||
unsigned char *buf = NULL;
|
unsigned char *buf = NULL;
|
||||||
int res, i;
|
int res, i;
|
||||||
@ -34,8 +24,6 @@ void * udppmchild(struct clientparam* param) {
|
|||||||
SASIZETYPE size;
|
SASIZETYPE size;
|
||||||
unsigned long ul = 1;
|
unsigned long ul = 1;
|
||||||
#endif
|
#endif
|
||||||
struct udpmap *udpmappings = NULL;
|
|
||||||
struct pollfd fds[256];
|
|
||||||
|
|
||||||
|
|
||||||
if(!param->hostname && parsehostname((char *)param->srv->target, param, ntohs(param->srv->targetport))) RETURN(100);
|
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 {
|
else {
|
||||||
inbuf += sprintf(buf+inbuf,
|
inbuf += sprintf(buf+inbuf,
|
||||||
"</td><td>%"PRINTF_INT64_MODIFIER"u</td>"
|
"</td><td>%"PRIu64"</td>"
|
||||||
"<td>MB%s</td>"
|
"<td>MB%s</td>"
|
||||||
"<td>%"PRINTF_INT64_MODIFIER"u.%"PRINTF_INT64_MODIFIER"u</td>"
|
"<td>%"PRIu64".%"PRIu64"</td>"
|
||||||
"<td>%s</td>",
|
"<td>%s</td>",
|
||||||
cp->traflim64 / (1024 * 1024),
|
cp->traflim64 / (1024 * 1024),
|
||||||
rotations[cp->type],
|
rotations[cp->type],
|
||||||
@ -593,7 +593,7 @@ void * adminchild(struct clientparam* param) {
|
|||||||
if(writable && !error){
|
if(writable && !error){
|
||||||
fflush(writable);
|
fflush(writable);
|
||||||
#ifndef _WINCE
|
#ifndef _WINCE
|
||||||
ftruncate(fileno(writable), ftell(writable));
|
if(ftruncate(fileno(writable), ftell(writable))){}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
printstr(&pp, error? "<h3><font color=\"red\">Config file is not writable</font></h3>Make sure you have \"writable\" command in configuration file":
|
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