mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-05 09:25:49 +08:00
Builds: no Open Watcom, no build without IPv6, no select()
The Win32 "lite" build with Open Watcom (Makefile.watcom, its release workflow, the CMake branch for it) was the only one built without IPv6 (NOIPV6), without fibers and event loops, with a select() of its own for poll() (mypoll()), and with the calling conventions of Watcom's pragmas in the plugins. They are gone with it: every build has IPv6, and polls with poll() on Unix and WSAPoll() on Windows, which were what every other build asked for (WITH_POLL, WITH_WSAPOLL, the 3PROXY_USE_POLL and 3PROXY_USE_WSAPOLL options of CMake, FD_SETSIZE for select()). getip(), the IPv4-only resolver of NOIPV6, goes too. Plugin binary compatibility: plugins built with Open Watcom, and their calling convention, are no longer supported. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
055d274f50
commit
fa3807c6f1
116
.github/workflows/build-watcom.yml
vendored
116
.github/workflows/build-watcom.yml
vendored
@ -1,116 +0,0 @@
|
||||
name: Build Win32 3proxy-lite with Watcom
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
kind:
|
||||
uses: ./.github/workflows/release-kind.yml
|
||||
|
||||
ci:
|
||||
# not for a release of the development branch
|
||||
needs: kind
|
||||
if: github.event_name != 'release' || needs.kind.outputs.devel != 'true'
|
||||
permissions:
|
||||
contents: write
|
||||
id-token: write
|
||||
attestations: write
|
||||
name: "${{ matrix.target }}"
|
||||
strategy:
|
||||
matrix:
|
||||
target:
|
||||
- windows-2022
|
||||
runs-on: ${{ matrix.target }}
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
# - name: configure
|
||||
# run: ./configure
|
||||
- name: Setup Open Watcom
|
||||
uses: open-watcom/setup-watcom@v1
|
||||
- name: set date
|
||||
run: |
|
||||
$NOW = Get-Date -Format "yyMMddHHmmss"
|
||||
echo "now: $NOW"
|
||||
$RELEASE = Get-Content -Path "RELEASE" -Raw
|
||||
echo "release: $RELEASE"
|
||||
echo "RELEASE=$RELEASE" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
echo "VERSION=/D `"VERSION=\`"3proxy-$RELEASE\`"`"" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
echo "BUILDDATE=/D `"BUILDDATE=\`"$NOW\`"`"" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
- name: make Watcom
|
||||
shell: cmd
|
||||
run: |
|
||||
echo "volatile char VerSion[]=^"3APA3A-3proxy-Internal-Build: 3proxy-%RELEASE%-%NOW%\r\n^";" >>src/3proxy.c
|
||||
nmake /F Makefile.watcom
|
||||
if errorlevel 1 exit /b 1
|
||||
if not exist bin\3proxy.exe (echo bin\3proxy.exe was not built & exit /b 1)
|
||||
- name: make dist dir
|
||||
shell: cmd
|
||||
run: |
|
||||
mkdir dist
|
||||
mkdir dist\3proxy
|
||||
mkdir dist\3proxy\bin
|
||||
mkdir dist\3proxy\cfg
|
||||
mkdir dist\3proxy\cfg\sql
|
||||
mkdir dist\3proxy\doc
|
||||
mkdir dist\3proxy\doc\ru
|
||||
mkdir dist\3proxy\doc\html
|
||||
mkdir dist\3proxy\doc\html\plugins
|
||||
mkdir dist\3proxy\doc\html\man5
|
||||
mkdir dist\3proxy\doc\html\man8
|
||||
mkdir dist\3proxy\doc\html\devel
|
||||
copy bin\3proxy.exe dist\3proxy\bin\
|
||||
copy bin\*.dll dist\3proxy\bin\
|
||||
copy bin\3proxy_crypt.exe dist\3proxy\bin\
|
||||
copy cfg\*.* dist\3proxy\cfg\
|
||||
copy cfg\sql\*.* dist\3proxy\cfg\sql\
|
||||
copy doc\ru\*.* dist\3proxy\doc\ru\
|
||||
copy doc\html\*.* dist\3proxy\doc\html\
|
||||
copy doc\html\plugins\*.* dist\3proxy\doc\html\plugins\
|
||||
copy doc\html\man8\*.* dist\3proxy\doc\html\man8\
|
||||
copy doc\html\man5\*.* dist\3proxy\doc\html\man5\
|
||||
copy doc\html\devel\*.* dist\3proxy\doc\html\devel\
|
||||
copy copying dist\3proxy\
|
||||
copy authors dist\3proxy\
|
||||
copy README.md dist\3proxy\
|
||||
copy rus.3ps dist\3proxy\
|
||||
- name: Get artifact
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: "3proxy-${{ env.RELEASE }}-lite"
|
||||
path: dist/
|
||||
- name: Create zip
|
||||
if: github.event_name == 'release'
|
||||
shell: pwsh
|
||||
run: Compress-Archive -Path dist/* -DestinationPath 3proxy-${{ env.RELEASE }}-lite.zip
|
||||
- name: Checksums and detached signature
|
||||
if: github.event_name == 'release'
|
||||
shell: bash
|
||||
env:
|
||||
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
|
||||
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
|
||||
run: |
|
||||
if [ -z "$GPG_PRIVATE_KEY" ]; then echo "GPG_PRIVATE_KEY is not set"; exit 1; fi
|
||||
printf '%s' "$GPG_PRIVATE_KEY" | gpg --batch --import
|
||||
KEYID=$(gpg --list-secret-keys --with-colons | awk -F: '/^sec:/{print $5; exit}')
|
||||
sha256sum *.zip > SHA256SUMS-win-lite
|
||||
gpg --batch --yes --pinentry-mode loopback --passphrase "$GPG_PASSPHRASE" \
|
||||
-u "$KEYID" --armor --detach-sign SHA256SUMS-win-lite
|
||||
sha256sum -c SHA256SUMS-win-lite
|
||||
- name: Attest build provenance
|
||||
if: github.event_name == 'release'
|
||||
uses: actions/attest-build-provenance@v4
|
||||
with:
|
||||
subject-path: |
|
||||
*.zip
|
||||
- name: Upload to release
|
||||
if: github.event_name == 'release'
|
||||
shell: bash
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
TAG: ${{ github.event.release.tag_name }}
|
||||
run: gh release upload "$TAG" *.zip SHA256SUMS-win-lite SHA256SUMS-win-lite.asc
|
||||
@ -64,8 +64,6 @@ option(3PROXY_USE_PCRE2 "Enable PCRE2 regex filtering" ON)
|
||||
option(3PROXY_USE_PAM "Enable PAM/PamAuth" ON)
|
||||
option(3PROXY_USE_ODBC "Enable ODBC support (Unix only, always ON on Windows)" OFF)
|
||||
option(3PROXY_USE_SPLICE "Build Linux splice() support, used by services given -s (Linux only)" ON)
|
||||
option(3PROXY_USE_POLL "Use poll() instead of select() (Unix only)" ON)
|
||||
option(3PROXY_USE_WSAPOLL "Use WSAPoll instead of select() (Windows only)" ON)
|
||||
option(3PROXY_USE_NETFILTER "Enable Linux netfilter support (Linux only)" ON)
|
||||
option(3PROXY_USE_TRANSPARENT "Build transparent proxying support (Linux and BSD only)" ON)
|
||||
option(3PROXY_USE_UNIX_SOCKETS "Enable Unix domain socket support (Unix only)" ON)
|
||||
@ -158,16 +156,6 @@ if(WIN32)
|
||||
# Clang or GCC on Windows (MinGW-like)
|
||||
add_compile_definitions(WITH_STD_MALLOC)
|
||||
add_compile_options(-fno-strict-aliasing)
|
||||
|
||||
elseif(WATCOM)
|
||||
# OpenWatcom-specific flags
|
||||
add_compile_definitions(
|
||||
WATCOM
|
||||
MSVC
|
||||
NOIPV6
|
||||
NODEBUG
|
||||
NORADIUS
|
||||
)
|
||||
endif()
|
||||
|
||||
# Windows libraries
|
||||
@ -289,23 +277,6 @@ if(NOT 3PROXY_USE_UNIX_SOCKETS)
|
||||
add_compile_definitions(NO_UN)
|
||||
endif()
|
||||
|
||||
# Common definitions
|
||||
if(WIN32)
|
||||
# Windows: use WSAPOLL
|
||||
if(3PROXY_USE_WSAPOLL)
|
||||
add_compile_definitions(WITH_WSAPOLL)
|
||||
else()
|
||||
add_compile_definitions(FD_SETSIZE=4096)
|
||||
endif()
|
||||
else()
|
||||
# Unix: use poll
|
||||
if(3PROXY_USE_POLL)
|
||||
add_compile_definitions(WITH_POLL)
|
||||
else()
|
||||
add_compile_definitions(FD_SETSIZE=4096)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Find dependencies
|
||||
|
||||
# TLS/SSL backend: prefer wolfSSL when detected, fall back to OpenSSL.
|
||||
@ -1004,7 +975,6 @@ message(STATUS " USE_PCRE2: ${3PROXY_USE_PCRE2}")
|
||||
message(STATUS " TRANSPARENT: ${3PROXY_TRANSPARENT_BUILT}")
|
||||
message(STATUS " USE_PAM: ${3PROXY_USE_PAM}")
|
||||
message(STATUS " USE_ODBC: ${3PROXY_USE_ODBC}")
|
||||
message(STATUS " USE_POLL: ${3PROXY_USE_POLL}")
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
message(STATUS " USE_SPLICE: ${3PROXY_USE_SPLICE}")
|
||||
message(STATUS " USE_NETFILTER: ${3PROXY_USE_NETFILTER}")
|
||||
@ -1012,9 +982,6 @@ endif()
|
||||
if(NOT WIN32 AND NOT APPLE)
|
||||
message(STATUS " STATIC_LINK: ${3PROXY_STATIC_LINK}")
|
||||
endif()
|
||||
if(WIN32)
|
||||
message(STATUS " USE_WSAPOLL: ${3PROXY_USE_WSAPOLL}")
|
||||
endif()
|
||||
message(STATUS "")
|
||||
message(STATUS " Libraries found:")
|
||||
message(STATUS " wolfSSL: ${WOLFSSL_FOUND}")
|
||||
|
||||
@ -11,7 +11,7 @@ MANDIR ?= /usr/share/man
|
||||
CC ?= cc
|
||||
|
||||
CFLAGS ?= -O3 -flto
|
||||
CFLAGS += -c -fno-strict-aliasing -DFD_SETSIZE=4096 -DWITH_POLL -DWITH_UN
|
||||
CFLAGS += -c -fno-strict-aliasing -DWITH_UN
|
||||
COUT = -o
|
||||
LN ?= ${CC}
|
||||
LDFLAGS ?= -O3 -flto
|
||||
|
||||
@ -14,7 +14,7 @@ CRYPT_PREFIX ?= $(PREFIX)
|
||||
CC ?= gcc
|
||||
|
||||
CFLAGS ?= -O3 -flto
|
||||
CFLAGS += -fno-strict-aliasing -c -pthread -DWITHSPLICE -D_GNU_SOURCE -DGETHOSTBYNAME_R -D_THREAD_SAFE -D_REENTRANT -DFD_SETSIZE=4096 -DWITH_POLL -DWITH_NETFILTER -D WITH_UN
|
||||
CFLAGS += -fno-strict-aliasing -c -pthread -DWITHSPLICE -D_GNU_SOURCE -DGETHOSTBYNAME_R -D_THREAD_SAFE -D_REENTRANT -DWITH_NETFILTER -D WITH_UN
|
||||
COUT = -o
|
||||
LN ?= ${CC}
|
||||
DCFLAGS ?= -fPIC
|
||||
|
||||
@ -9,7 +9,7 @@ BUILDDIR = ../bin/
|
||||
PREFIX ?= 3proxy_
|
||||
CRYPT_PREFIX ?= $(PREFIX)
|
||||
CC ?= cc
|
||||
CFLAGS = -xO3 -c -D_SOLARIS -D_THREAD_SAFE -DGETHOSTBYNAME_R -D_REENTRANT -DFD_SETSIZE=4096 -DWITH_POLL
|
||||
CFLAGS = -xO3 -c -D_SOLARIS -D_THREAD_SAFE -DGETHOSTBYNAME_R -D_REENTRANT
|
||||
COUT = -o ./
|
||||
LN = $(CC)
|
||||
LDFLAGS = -xO3
|
||||
|
||||
@ -18,7 +18,7 @@ SSL_LIBS = wolfssl.lib
|
||||
SSL_DEFS = /D "WITH_SSL"
|
||||
SSL_LIBS = libcrypto.lib libssl.lib
|
||||
!ENDIF
|
||||
CFLAGS = /D "WITH_HTTPSRV" /nologo /MT /W3 /Ox /GS /EHs- /GA /GF /D "MSVC" /D "WITH_WSAPOLL" /D "NDEBUG" /D "WIN32" $(SSL_DEFS) /D "WITH_PCRE" /D "WITH_ODBC" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /Fp"proxy.pch" /FD /c $(BUILDDATE) $(VERSION)
|
||||
CFLAGS = /D "WITH_HTTPSRV" /nologo /MT /W3 /Ox /GS /EHs- /GA /GF /D "MSVC" /D "NDEBUG" /D "WIN32" $(SSL_DEFS) /D "WITH_PCRE" /D "WITH_ODBC" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /Fp"proxy.pch" /FD /c $(BUILDDATE) $(VERSION)
|
||||
COUT = /Fo
|
||||
LN = link
|
||||
LDFLAGS = /nologo /subsystem:console /incremental:no
|
||||
|
||||
@ -13,7 +13,7 @@ CC ?= gcc
|
||||
|
||||
# you may need -L/usr/pkg/lib for older NetBSD versions
|
||||
CFLAGS ?= -O3 -flto
|
||||
CFLAGS += -fno-strict-aliasing -c -pthread -D_THREAD_SAFE -D_REENTRANT -DFD_SETSIZE=4096 -DWITH_POLL -DWITH_UN
|
||||
CFLAGS += -fno-strict-aliasing -c -pthread -D_THREAD_SAFE -D_REENTRANT -DWITH_UN
|
||||
COUT = -o
|
||||
LN ?= $(CC)
|
||||
LDFLAGS ?= -O3 -flto
|
||||
|
||||
@ -1,66 +0,0 @@
|
||||
#
|
||||
# 3 proxy Makefile for Open Watcom 2
|
||||
#
|
||||
#
|
||||
# Add /DSAFESQL to CFLAGS if you are using poorely written/tested ODBC driver
|
||||
|
||||
BUILDDIR = ../bin/
|
||||
PREFIX = 3proxy_
|
||||
CRYPT_PREFIX = 3proxy_
|
||||
CC = cl
|
||||
CFLAGS = /D "WITH_HTTPSRV" /nologo /Ox /MT /D "NOIPV6" /D "NO_UN" /D "NODEBUG" /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
|
||||
LN = link
|
||||
LDFLAGS = /nologo /subsystem:console /incremental:no
|
||||
DLFLAGS = /DLL
|
||||
DLSUFFICS = .dll
|
||||
LIBS = ws2_32.lib mswsock.lib advapi32.lib user32.lib kernel32.lib
|
||||
LIBSPREFIX =
|
||||
LIBSSUFFIX = .lib
|
||||
LIBEXT = .lib
|
||||
LNOUT = /out:
|
||||
EXESUFFICS = .exe
|
||||
OBJSUFFICS = .obj
|
||||
HTTPSRV_OBJS = srvhttpsrv$(OBJSUFFICS) srvwebadmin$(OBJSUFFICS)
|
||||
DEFINEOPTION = /D
|
||||
COMPFILES = *.pch *.idb *.err
|
||||
REMOVECOMMAND = del 2>NUL >NUL
|
||||
TYPECOMMAND = type
|
||||
COMPATLIBS =
|
||||
MAKEFILE = Makefile.watcom
|
||||
PLUGINS = utf8tocp1251 WindowsAuthentication TrafficPlugin StringsPlugin
|
||||
VERFILE = $(VERFILE)
|
||||
VERSION = $(VERSION)
|
||||
VERSIONDEP = 3proxy.res $(VERSIONDEP)
|
||||
BUILDDATE = $(BUILDDATE)
|
||||
|
||||
include Makefile.inc
|
||||
|
||||
3proxy.res:
|
||||
rc 3proxy.rc
|
||||
|
||||
allplugins:
|
||||
copy Makefile plugins\utf8tocp1251
|
||||
copy Makefile.var plugins\utf8tocp1251
|
||||
cd plugins\utf8tocp1251
|
||||
nmake
|
||||
del *.obj *.idb
|
||||
cd ../../
|
||||
copy Makefile plugins\WindowsAuthentication
|
||||
copy Makefile.var plugins\WindowsAuthentication
|
||||
cd plugins\WindowsAuthentication
|
||||
nmake
|
||||
del *.obj *.idb
|
||||
cd ../../
|
||||
copy Makefile plugins\TrafficPlugin
|
||||
copy Makefile.var plugins\TrafficPlugin
|
||||
cd plugins\TrafficPlugin
|
||||
nmake
|
||||
del *.obj *.idb
|
||||
cd ../../
|
||||
copy Makefile plugins\StringsPlugin
|
||||
copy Makefile.var plugins\StringsPlugin
|
||||
cd plugins\StringsPlugin
|
||||
nmake
|
||||
del *.obj *.idb
|
||||
cd ../../
|
||||
@ -10,7 +10,7 @@ PREFIX ?= 3proxy_
|
||||
CRYPT_PREFIX ?= $(PREFIX)
|
||||
CC ?= gcc
|
||||
CFLAGS ?= -O3 -flto
|
||||
CFLAGS += -fno-strict-aliasing -c -mthreads -DWITH_WSAPOLL -DWITH_ODBC
|
||||
CFLAGS += -fno-strict-aliasing -c -mthreads -DWITH_ODBC
|
||||
COUT = -o
|
||||
LN ?= $(CC)
|
||||
LDFLAGS ?= -O3 -flto
|
||||
|
||||
@ -359,7 +359,6 @@ sudo launchctl unload /Library/LaunchDaemons/org.3proxy.3proxy.plist
|
||||
### 7. Compilation
|
||||
|
||||
- MSVC (static)
|
||||
- OpenWatcom (static)
|
||||
- Intel Windows Compiler (msvcrt.dll)
|
||||
- Windows/gcc (msvcrt.dll)
|
||||
- Cygwin/gcc (cygwin.dll)
|
||||
@ -368,7 +367,6 @@ sudo launchctl unload /Library/LaunchDaemons/org.3proxy.3proxy.plist
|
||||
- Solaris
|
||||
- Mac OS X, iPhone OS
|
||||
- Linux and derived systems
|
||||
- Lite version for Windows 95/98/NT/2000/XP/2003
|
||||
- 32 bit and 64 bit versions for Windows Vista and above, Windows 2008 server and above
|
||||
|
||||
## Executables
|
||||
|
||||
@ -87,9 +87,7 @@ int cacheauth(struct clientparam * param){
|
||||
((type & 4) && !*param->password) ||
|
||||
(
|
||||
(type & 1) && *SAFAMILY(¶m->sincr) != AF_INET
|
||||
#ifndef NOIPV6
|
||||
&& *SAFAMILY(¶m->sincr) != AF_INET6
|
||||
#endif
|
||||
) || (!hashresolv(&auth_table, param, &ac, &ttl))) {
|
||||
return 4;
|
||||
}
|
||||
@ -128,18 +126,14 @@ int doauth(struct clientparam * param){
|
||||
strncpy((char *)ac.username, (char *)param->username, 64);
|
||||
ac.username[63] = 0;
|
||||
if(*SAFAMILY(¶m->sincr) == AF_INET
|
||||
#ifndef NOIPV6
|
||||
|| *SAFAMILY(¶m->sincr) == AF_INET6
|
||||
#endif
|
||||
) {
|
||||
ac.sincr_family = *SAFAMILY(¶m->sincr);
|
||||
memcpy(ac.sincr_addr, SAADDR(¶m->sincr), SAADDRLEN(¶m->sincr));
|
||||
}
|
||||
|
||||
if(*SAFAMILY(¶m->sinsl) == AF_INET
|
||||
#ifndef NOIPV6
|
||||
|| *SAFAMILY(¶m->sinsl) == AF_INET6
|
||||
#endif
|
||||
) {
|
||||
ac.sinsl_family = *SAFAMILY(¶m->sinsl);
|
||||
memcpy(ac.sinsl_addr, SAADDR(¶m->sinsl), SAADDRLEN(¶m->sinsl));
|
||||
|
||||
@ -526,15 +526,9 @@ int radsend(struct clientparam * param, int auth, int stop){
|
||||
|
||||
|
||||
saremote = auth?param->srv->config->radiuslist[loop].authaddr : param->srv->config->radiuslist[loop].logaddr;
|
||||
#ifdef NOIPV6
|
||||
if(*SAFAMILY(&saremote)!= AF_INET) {
|
||||
continue;
|
||||
}
|
||||
#else
|
||||
if(*SAFAMILY(&saremote)!= AF_INET && *SAFAMILY(&saremote)!= AF_INET6){
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
if(auth) {
|
||||
|
||||
134
src/common.c
134
src/common.c
@ -16,16 +16,11 @@ int socks5_setaddr(int family, int atyp, const unsigned char *addr, PROXYSOCKADD
|
||||
|
||||
memset(sa, 0, sizeof(*sa));
|
||||
if(atyp == 4){
|
||||
#ifdef NOIPV6
|
||||
return 1;
|
||||
#else
|
||||
if(family == 4) return 1;
|
||||
len = 16;
|
||||
*SAFAMILY(sa) = AF_INET6;
|
||||
memcpy(SAADDR(sa), addr, 16);
|
||||
#endif
|
||||
}
|
||||
#ifndef NOIPV6
|
||||
else if(family == 6){
|
||||
unsigned char prefix[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255};
|
||||
|
||||
@ -33,7 +28,6 @@ int socks5_setaddr(int family, int atyp, const unsigned char *addr, PROXYSOCKADD
|
||||
memcpy(SAADDR(sa), prefix, 12);
|
||||
memcpy(12 + (unsigned char *)SAADDR(sa), addr, 4);
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
*SAFAMILY(sa) = AF_INET;
|
||||
memcpy(SAADDR(sa), addr, 4);
|
||||
@ -104,14 +98,9 @@ char * copyright = COPYRIGHT;
|
||||
# define MYRAND_GETRANDOM 1
|
||||
# include <sys/random.h>
|
||||
#elif defined(_WIN32)
|
||||
# if defined(__WATCOMC__)
|
||||
# define MYRAND_CRYPTGENRANDOM 1
|
||||
# include <wincrypt.h>
|
||||
# else
|
||||
# define MYRAND_BCRYPTGENRANDOM 1
|
||||
# include <bcrypt.h>
|
||||
# pragma comment(lib, "bcrypt.lib")
|
||||
# endif
|
||||
#else
|
||||
# define MYRAND_FALLBACK 1
|
||||
#endif
|
||||
@ -171,21 +160,17 @@ int myinet_ntop(int af, void *src, char *dst, socklen_t size){
|
||||
return (int)strlen(dst);
|
||||
}
|
||||
#endif
|
||||
#ifndef NOIPV6
|
||||
if(af != AF_INET6){
|
||||
#endif
|
||||
unsigned u = ntohl(((struct in_addr *)src)->s_addr);
|
||||
return sprintf(dst, "%u.%u.%u.%u",
|
||||
((u&0xFF000000)>>24),
|
||||
((u&0x00FF0000)>>16),
|
||||
((u&0x0000FF00)>>8),
|
||||
((u&0x000000FF)));
|
||||
#ifndef NOIPV6
|
||||
}
|
||||
*dst = 0;
|
||||
inet_ntop(af, src, dst, size);
|
||||
return (int)strlen(dst);
|
||||
#endif
|
||||
}
|
||||
|
||||
char *rotations[] = {
|
||||
@ -286,50 +271,6 @@ uint32_t myrand(void){
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef WITH_POLL
|
||||
#ifndef WITH_WSAPOLL
|
||||
int
|
||||
#ifdef _WIN32
|
||||
WINAPI
|
||||
#endif
|
||||
|
||||
mypoll(struct mypollfd *fds, unsigned int nfds, int timeout){
|
||||
fd_set readfd;
|
||||
fd_set writefd;
|
||||
fd_set oobfd;
|
||||
struct timeval tv;
|
||||
unsigned i;
|
||||
int num;
|
||||
SOCKET maxfd = 0;
|
||||
|
||||
tv.tv_sec = timeout/1000;
|
||||
tv.tv_usec = (timeout%1000)*1000;
|
||||
FD_ZERO(&readfd);
|
||||
FD_ZERO(&writefd);
|
||||
FD_ZERO(&oobfd);
|
||||
for(i=0; i<nfds; i++){
|
||||
#ifndef _WIN32
|
||||
if(fds[i].fd >= FD_SETSIZE) continue;
|
||||
#endif
|
||||
if((fds[i].events&POLLIN))FD_SET(fds[i].fd, &readfd);
|
||||
if((fds[i].events&POLLOUT))FD_SET(fds[i].fd, &writefd);
|
||||
if((fds[i].events&POLLPRI))FD_SET(fds[i].fd, &oobfd);
|
||||
fds[i].revents = 0;
|
||||
if(fds[i].fd > maxfd) maxfd = fds[i].fd;
|
||||
}
|
||||
if((num = select(((int)(maxfd))+1, &readfd, &writefd, &oobfd, &tv)) < 1) return num;
|
||||
for(i=0; i<nfds; i++){
|
||||
#ifndef _WIN32
|
||||
if(fds[i].fd >= FD_SETSIZE) continue;
|
||||
#endif
|
||||
if(FD_ISSET(fds[i].fd, &readfd)) fds[i].revents |= POLLIN;
|
||||
if(FD_ISSET(fds[i].fd, &writefd)) fds[i].revents |= POLLOUT;
|
||||
if(FD_ISSET(fds[i].fd, &oobfd)) fds[i].revents |= POLLPRI;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Set while clients are served by fibers on event loops, which keep their
|
||||
@ -567,12 +508,8 @@ int sockpoll(struct sockfuncs *sf, void *state, struct pollfd *fds, unsigned nfd
|
||||
if(!(res = sf->_prepoll(state, fds, nfds))){
|
||||
/* a fiber waits in its loop */
|
||||
if(!fiberpollfunc || (res = fiberpollfunc(fds, nfds, timeout)) == -2){
|
||||
#ifndef WITH_POLL
|
||||
#ifndef WITH_WSAPOLL
|
||||
res = mypoll(fds, nfds, timeout);
|
||||
#else
|
||||
#ifdef _WIN32
|
||||
res = WSAPoll(fds, nfds, timeout);
|
||||
#endif
|
||||
#else
|
||||
res = poll(fds, (nfds_t)nfds, timeout);
|
||||
#endif
|
||||
@ -822,12 +759,10 @@ int bindtodevice(struct sockfuncs *sf, void *state, SOCKET sock, const char *dev
|
||||
idx = if_nametoindex(device);
|
||||
if(!idx || (family == AF_INET && sf->_setsockopt(state, sock, IPPROTO_IP, IP_BOUND_IF, &idx, sizeof(idx))))
|
||||
return 1;
|
||||
#ifndef NOIPV6
|
||||
#ifndef IPV6_BOUND_IF
|
||||
#define IPV6_BOUND_IF 125
|
||||
#endif
|
||||
if(family == AF_INET6 && sf->_setsockopt(state, sock, IPPROTO_IPV6, IPV6_BOUND_IF, &idx, sizeof(idx))) return 1;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
@ -889,10 +824,8 @@ int doconnect(struct clientparam * param){
|
||||
if(*SAFAMILY(¶m->sinsr) == AF_UNIX) param->sinsl = param->sinsr;
|
||||
else
|
||||
#endif
|
||||
#ifndef NOIPV6
|
||||
if(*SAFAMILY(¶m->sinsr) == AF_INET6) param->sinsl = param->srv->extsa6;
|
||||
else
|
||||
#endif
|
||||
param->sinsl = param->srv->extsa;
|
||||
}
|
||||
*SAPORT(¶m->sinsl) = 0;
|
||||
@ -1086,62 +1019,6 @@ struct hostent * my_gethostbyname(char *name, char *buf, struct hostent *hp){
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef NOIPV6
|
||||
static uint32_t getipm(int mode, unsigned char *name){
|
||||
uint32_t retval;
|
||||
int i;
|
||||
int ndots = 0;
|
||||
struct hostent *hp=NULL;
|
||||
RESOLVFUNC tmpresolv;
|
||||
|
||||
#ifdef GETHOSTBYNAME_R
|
||||
struct hostent he;
|
||||
char ghbuf[1024];
|
||||
#define gethostbyname(NAME) my_gethostbyname(NAME, ghbuf, &he)
|
||||
#endif
|
||||
|
||||
if(strlen((char *)name)>255)name[255] = 0;
|
||||
for(i=0; name[i]; i++){
|
||||
if(name[i] == '.'){
|
||||
if(++ndots > 3) break;
|
||||
continue;
|
||||
}
|
||||
if(name[i] <'0' || name[i] >'9') break;
|
||||
}
|
||||
if(!name[i] && ndots == 3){
|
||||
if(scanaddr(name, &retval, NULL) == 4){
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
if((tmpresolv=moderesolver(mode))){
|
||||
return (*tmpresolv)(AF_INET, name, (unsigned char *)&retval)?retval:0;
|
||||
}
|
||||
#ifndef NOSTDRESOLVE
|
||||
#if !defined(_WIN32) && !defined(GETHOSTBYNAME_R)
|
||||
if(!ghbn_init){
|
||||
_3proxy_mutex_init(&gethostbyname_mutex);
|
||||
ghbn_init++;
|
||||
}
|
||||
_3proxy_mutex_lock(&gethostbyname_mutex);
|
||||
#endif
|
||||
hp=gethostbyname((char *)name);
|
||||
retval = hp?*(uint32_t *)hp->h_addr:0;
|
||||
#if !defined(_WIN32) && !defined(GETHOSTBYNAME_R)
|
||||
_3proxy_mutex_unlock(&gethostbyname_mutex);
|
||||
#endif
|
||||
#ifdef GETHOSTBYNAME_R
|
||||
#undef gethostbyname
|
||||
#endif
|
||||
#else
|
||||
retval=0;
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
|
||||
uint32_t getip(unsigned char *name){
|
||||
return getipm(resolvmode, name);
|
||||
}
|
||||
#endif
|
||||
|
||||
int afdetect(unsigned char *name){
|
||||
int ndots=0, ncols=0, nhex=0;
|
||||
@ -1176,7 +1053,7 @@ int afdetect(unsigned char *name){
|
||||
}
|
||||
|
||||
/* A name resolved the way a mode says: a service's names with its own */
|
||||
#if !defined(NOIPV6) && !defined(NOSTDRESOLVE)
|
||||
#ifndef NOSTDRESOLVE
|
||||
/* What the C library's resolver is asked, and its answer */
|
||||
struct stdresolve {
|
||||
unsigned char *name;
|
||||
@ -1213,18 +1090,12 @@ static void stdresolve46(void *arg){
|
||||
#endif
|
||||
|
||||
uint32_t getip46m(int mode, int family, unsigned char *name, struct sockaddr *sa){
|
||||
#ifndef NOIPV6
|
||||
int detect;
|
||||
RESOLVFUNC tmpresolv;
|
||||
|
||||
if(!sa) return 0;
|
||||
if(!family) {
|
||||
family = 4;
|
||||
#else
|
||||
((struct sockaddr_in *)sa)->sin_family = AF_INET;
|
||||
return (((struct sockaddr_in *)sa)->sin_addr.s_addr = getipm(mode, name))? AF_INET:0;
|
||||
#endif
|
||||
#ifndef NOIPV6
|
||||
}
|
||||
|
||||
detect = afdetect(name);
|
||||
@ -1258,7 +1129,6 @@ uint32_t getip46m(int mode, int family, unsigned char *name, struct sockaddr *s
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t getip46(int family, unsigned char *name, struct sockaddr *sa){
|
||||
|
||||
17
src/conf.c
17
src/conf.c
@ -235,11 +235,6 @@ static int h_proxy(int argc, unsigned char ** argv){
|
||||
childdef.service = S_PROXY;
|
||||
#ifdef WITH_FTP
|
||||
childdef.helpmessage = " -Xftp - fetch ftp:// URLs\n";
|
||||
#endif
|
||||
#ifdef NOIPV6
|
||||
if(noresolver()){
|
||||
fprintf(stderr, "[line %d] Warning: no nserver/nscache configured, proxy may run very slow\n", linenum);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if(!strcmp((char *)argv[0], "pop3p")) {
|
||||
@ -275,11 +270,6 @@ static int h_proxy(int argc, unsigned char ** argv){
|
||||
childdef.port = 1080;
|
||||
childdef.isudp = 0;
|
||||
childdef.service = S_SOCKS;
|
||||
#ifdef NOIPV6
|
||||
if(noresolver()){
|
||||
fprintf(stderr, "[line %d] Warning: no nserver/nscache configured, socks may run very slow\n", linenum);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if(!strcmp((char *)argv[0], "auto")) {
|
||||
childdef.pf = autochild;
|
||||
@ -343,11 +333,9 @@ static int h_proxy(int argc, unsigned char ** argv){
|
||||
childdef.isudp = 1;
|
||||
childdef.service = S_DNSPR;
|
||||
childdef.helpmessage = " -s - simple DNS forwarding - do not use 3proxy resolver / name cache\n -Fip - fake: answer all A queries with this IP\n";
|
||||
#ifndef NOIPV6
|
||||
if(noresolver() || conf->resolvmode == RESOLVE_FAKE){
|
||||
fprintf(stderr, "[line %d] Warning: no nserver/nscache configured, dnspr will not work as expected\n", linenum);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return start_proxy_thread(&ch);
|
||||
}
|
||||
@ -365,17 +353,12 @@ static int h_internal(int argc, unsigned char ** argv){
|
||||
|
||||
static int h_external(int argc, unsigned char ** argv){
|
||||
int res;
|
||||
#ifndef NOIPV6
|
||||
PROXYSOCKADDRTYPE sa6;
|
||||
memset(&sa6, 0, sizeof(sa6));
|
||||
res = getip46(46, argv[1], (struct sockaddr *)&sa6);
|
||||
if(!res) return 1;
|
||||
if (*SAFAMILY(&sa6)==AF_INET) conf->extsa = sa6;
|
||||
else conf->extsa6 = sa6;
|
||||
#else
|
||||
res = getip46(46, argv[1], (struct sockaddr *)&conf->extsa);
|
||||
if(!res) return 1;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -50,14 +50,9 @@
|
||||
.logtype = NONE,
|
||||
.countertype = NONE,
|
||||
.counterfile = NULL,
|
||||
#ifndef NOIPV6
|
||||
.intsa = {AF_INET},
|
||||
.extsa6 = {AF_INET6},
|
||||
.extsa = {AF_INET},
|
||||
#else
|
||||
.intsa = {AF_INET},
|
||||
.extsa = {AF_INET},
|
||||
#endif
|
||||
.pwl = NULL,
|
||||
.authenticate = NULL,
|
||||
.authfunc = doconnect,
|
||||
|
||||
@ -62,16 +62,12 @@ static void pr_ip(struct node *node, CBFUNC cbf, void*cb){
|
||||
}
|
||||
|
||||
static void pr_sa(struct node *node, CBFUNC cbf, void*cb){
|
||||
#ifdef NOIPV6
|
||||
if(node->value)pr_ip(node, cbf, cb);
|
||||
#else
|
||||
char buf[64];
|
||||
buf[0] = '[';
|
||||
buf[1] = 0;
|
||||
inet_ntop(*SAFAMILY(node->value), SAADDR(node->value), buf+1, sizeof(buf)-10);
|
||||
sprintf(buf + strlen(buf), "]:%hu", (unsigned short)*SAPORT(node->value));
|
||||
if(node->value)(*cbf)(cb, buf, strlen(buf));
|
||||
#endif
|
||||
}
|
||||
|
||||
static void pr_wdays(struct node *node, CBFUNC cbf, void*cb){
|
||||
@ -620,11 +616,9 @@ static void * ef_server_extsa(struct node * node){
|
||||
return &((struct srvparam *)node->value) -> extsa;
|
||||
}
|
||||
|
||||
#ifndef NOIPV6
|
||||
static void * ef_server_extsa6(struct node * node){
|
||||
return &((struct srvparam *)node->value) -> extsa6;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void * ef_server_intNat(struct node * node){
|
||||
return &((struct srvparam *)node->value) -> intNat;
|
||||
@ -916,9 +910,7 @@ static struct property prop_server[] = {
|
||||
{"extsa", ef_server_extsa, TYPE_SA, "ip address of external interface"},
|
||||
{"intnat", ef_server_intNat, TYPE_SA, "internal NAT address"},
|
||||
{"extnat", ef_server_extNat, TYPE_SA, "external NAT address"},
|
||||
#ifndef NOIPV6
|
||||
{"extsa6", ef_server_extsa6, TYPE_SA, "ipv6 address of external interface"},
|
||||
#endif
|
||||
{"child", ef_server_child, TYPE_CLIENT, "connected clients"},
|
||||
{"next", ef_server_next, TYPE_SERVER, "next"}
|
||||
};
|
||||
|
||||
@ -253,12 +253,10 @@ static int dnsprfirst(struct udploop *u, struct udpsession *ss, unsigned char *q
|
||||
ip = 1;
|
||||
*(uint32_t *)q->addr = param->srv->fakeip;
|
||||
}
|
||||
#ifndef NOIPV6
|
||||
else if(q->type==0x1c && *(uint32_t *)param->srv->fakeip6){
|
||||
ip = 1;
|
||||
memcpy(q->addr, param->srv->fakeip6, 16);
|
||||
}
|
||||
#endif
|
||||
/* the name cache only: what it does not have the name servers are
|
||||
asked, without waiting here */
|
||||
else if((q->type==0x01 || q->type==0x1c) && !param->srv->s_option){
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
#define _FIBER_H
|
||||
|
||||
#if defined _WIN32
|
||||
#if !defined __WATCOMC__ && !defined _WINCE
|
||||
#ifndef _WINCE
|
||||
#define FIBER_WINDOWS
|
||||
#endif
|
||||
#elif defined __x86_64__ && defined __LP64__
|
||||
|
||||
@ -480,19 +480,9 @@ static int filemeta(const char *path, struct filemeta *m)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
wchar_t wide[HTTPSRV_LINE];
|
||||
#ifdef __WATCOMC__
|
||||
/* Open Watcom has the 64-bit stat under its older name */
|
||||
#ifndef _S_IFREG
|
||||
#define _S_IFREG S_IFREG
|
||||
#endif
|
||||
struct _stati64 st;
|
||||
|
||||
if(widepath(path, wide, HTTPSRV_LINE) || _wstati64(wide, &st)) return 1;
|
||||
#else
|
||||
struct _stat64 st;
|
||||
|
||||
if(widepath(path, wide, HTTPSRV_LINE) || _wstat64(wide, &st)) return 1;
|
||||
#endif
|
||||
m->size = (uint64_t)st.st_size;
|
||||
m->mtime = st.st_mtime;
|
||||
m->isreg = (st.st_mode & _S_IFREG) != 0;
|
||||
|
||||
@ -18,9 +18,7 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(WATCOM)
|
||||
#define BLAKE2_PACKED(x) _Packed x
|
||||
#elif defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)
|
||||
#define BLAKE2_PACKED(x) __pragma(pack(push, 1)) x __pragma(pack(pop))
|
||||
#else
|
||||
#define BLAKE2_PACKED(x) x __attribute__((packed))
|
||||
|
||||
@ -969,12 +969,10 @@ int looponce(struct loop *l, int maxwait){
|
||||
{
|
||||
unsigned j;
|
||||
|
||||
#if defined WITH_POLL
|
||||
n = poll(l->pfds, (nfds_t)l->npfds, timeo);
|
||||
#elif defined WITH_WSAPOLL
|
||||
#ifdef _WIN32
|
||||
n = WSAPoll(l->pfds, l->npfds, timeo);
|
||||
#else
|
||||
n = mypoll(l->pfds, l->npfds, timeo);
|
||||
n = poll(l->pfds, (nfds_t)l->npfds, timeo);
|
||||
#endif
|
||||
if(n > 0 && l->pfds[0].revents) woken = 1;
|
||||
for(j = 1; n > 0 && j < l->npfds && l->nready < LOOPREADY; j++)
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
#define LOOP_EPOLL
|
||||
#elif !defined LOOP_POLL && (defined __APPLE__ || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ || defined __DragonFly__)
|
||||
#define LOOP_KQUEUE
|
||||
#elif !defined LOOP_POLL && defined _WIN32 && !defined __WATCOMC__ && !defined _WINCE
|
||||
#elif !defined LOOP_POLL && defined _WIN32 && !defined _WINCE
|
||||
#define LOOP_AFD
|
||||
#elif !defined LOOP_POLL
|
||||
#define LOOP_POLL
|
||||
|
||||
@ -369,7 +369,6 @@ static int srvprepare(struct srvstart *s, int argc, char **argv){
|
||||
break;
|
||||
case 'e':
|
||||
{
|
||||
#ifndef NOIPV6
|
||||
PROXYSOCKADDRTYPE sa6;
|
||||
memset(&sa6, 0, sizeof(sa6));
|
||||
error = !getip46(46, (unsigned char *)argv[i]+2, (struct sockaddr *)&sa6);
|
||||
@ -377,9 +376,6 @@ static int srvprepare(struct srvstart *s, int argc, char **argv){
|
||||
if (*SAFAMILY(&sa6)==AF_INET) srv->extsa = sa6;
|
||||
else srv->extsa6 = sa6;
|
||||
}
|
||||
#else
|
||||
error = !getip46(46, (unsigned char *)argv[i]+2, (struct sockaddr *)&srv->extsa);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case 'N':
|
||||
@ -467,9 +463,7 @@ static int srvprepare(struct srvstart *s, int argc, char **argv){
|
||||
memset(&fsa, 0, sizeof(fsa));
|
||||
if(!getip46(46, (unsigned char *)argv[i]+2, (struct sockaddr *)&fsa)) error = 1;
|
||||
else if(*SAFAMILY(&fsa) == AF_INET) srv->fakeip = *(uint32_t *)SAADDR(&fsa);
|
||||
#ifndef NOIPV6
|
||||
else if(*SAFAMILY(&fsa) == AF_INET6) memcpy(srv->fakeip6, SAADDR(&fsa), 16);
|
||||
#endif
|
||||
else error = 1;
|
||||
}
|
||||
break;
|
||||
@ -632,9 +626,7 @@ static int srvprepare(struct srvstart *s, int argc, char **argv){
|
||||
if(!*SAFAMILY(&srv->intsa)) *SAFAMILY(&srv->intsa) = AF_INET;
|
||||
if(!*SAPORT(&srv->intsa)) *SAPORT(&srv->intsa) = htons(childdef.port);
|
||||
*SAFAMILY(&srv->extsa) = AF_INET;
|
||||
#ifndef NOIPV6
|
||||
*SAFAMILY(&srv->extsa6) = AF_INET6;
|
||||
#endif
|
||||
if(hostname)parsehostname(hostname, defparam, childdef.port);
|
||||
|
||||
#ifdef __linux__
|
||||
@ -788,9 +780,7 @@ void srvinit(struct srvparam * srv, struct clientparam *param){
|
||||
(void)_3proxy_sem_init_timed(srv->childslots, srv->maxchild, srv->maxchild);
|
||||
srv->intsa = conf->intsa;
|
||||
srv->extsa = conf->extsa;
|
||||
#ifndef NOIPV6
|
||||
srv->extsa6 = conf->extsa6;
|
||||
#endif
|
||||
srv->so = so;
|
||||
srv->authcachetime = conf->authcachetime;
|
||||
srv->authcachetype = conf->authcachetype;
|
||||
@ -817,10 +807,8 @@ void srvinit2(struct srvparam * srv, struct clientparam *param){
|
||||
*SAFAMILY(¶m->sinsr) = AF_INET;
|
||||
*SAFAMILY(¶m->req) = AF_INET;
|
||||
param->sincr = param->sincl = srv->intsa;
|
||||
#ifndef NOIPV6
|
||||
if (srv->family == 6 || srv->family == 64) param->sinsr = srv->extsa6;
|
||||
else
|
||||
#endif
|
||||
param->sinsr = srv->extsa;
|
||||
}
|
||||
|
||||
|
||||
@ -905,11 +905,6 @@ static struct commands file_commandhandlers[] = {
|
||||
|
||||
static int file_loaded=0;
|
||||
|
||||
#ifdef WATCOM
|
||||
#pragma aux file_plugin "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
|
||||
#undef PLUGINCALL
|
||||
#define PLUGINCALL
|
||||
#endif
|
||||
|
||||
PLUGINAPI int PLUGINCALL file_plugin (struct pluginlink * pluginlink,
|
||||
int argc, char** argv){
|
||||
|
||||
@ -506,11 +506,6 @@ int h_dircount(int argc, unsigned char ** argv)
|
||||
/*------------------------------- MAIN --------------------------------------
|
||||
start plugin init */
|
||||
|
||||
#ifdef WATCOM
|
||||
#pragma aux start "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
|
||||
#undef PLUGINCALL
|
||||
#define PLUGINCALL
|
||||
#endif
|
||||
|
||||
PLUGINAPI int PLUGINCALL start(struct pluginlink * pluginlink,
|
||||
int argc, char** argv)
|
||||
|
||||
@ -116,11 +116,6 @@ static int pamfunc(struct clientparam *param)
|
||||
|
||||
}
|
||||
|
||||
#ifdef WATCOM
|
||||
#pragma aux start "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
|
||||
#undef PLUGINCALL
|
||||
#define PLUGINCALL
|
||||
#endif
|
||||
|
||||
/*------------------------------- MAIN --------------------------------------
|
||||
start plugin init */
|
||||
|
||||
@ -170,11 +170,6 @@ BOOL WINAPI DllMain( HINSTANCE hModule,
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef WATCOM
|
||||
#pragma aux start "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
|
||||
#undef PLUGINCALL
|
||||
#define PLUGINCALL
|
||||
#endif
|
||||
|
||||
PLUGINAPI int PLUGINCALL start(struct pluginlink * pluginlink,
|
||||
int argc, char** argv)
|
||||
|
||||
@ -268,11 +268,6 @@ BOOL WINAPI DllMain( HINSTANCE hModule,
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef WATCOM
|
||||
#pragma aux start "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
|
||||
#undef PLUGINCALL
|
||||
#define PLUGINCALL
|
||||
#endif
|
||||
|
||||
PLUGINAPI int PLUGINCALL start(struct pluginlink * pluginlink, int argc, char** argv) {
|
||||
|
||||
|
||||
@ -57,11 +57,6 @@ extern "C" {
|
||||
return 7;
|
||||
}
|
||||
|
||||
#ifdef WATCOM
|
||||
#pragma aux WindowsAuthentication "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
|
||||
#undef PLUGINCALL
|
||||
#define PLUGINCALL
|
||||
#endif
|
||||
|
||||
PLUGINAPI int PLUGINCALL WindowsAuthentication(struct pluginlink * pluginlink, int argc, char** argv){
|
||||
char tmpbuf[4096];
|
||||
|
||||
@ -61,11 +61,6 @@ unsigned char * conv_utf8_to_cp1251(unsigned char *s){
|
||||
}
|
||||
|
||||
|
||||
#ifdef WATCOM
|
||||
#pragma aux utf8tocp1251 "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx]
|
||||
#undef PLUGINCALL
|
||||
#define PLUGINCALL
|
||||
#endif
|
||||
|
||||
PLUGINAPI int PLUGINCALL utf8tocp1251(struct pluginlink * pluginlink, int argc, char** argv){
|
||||
static int loaded = 0;
|
||||
|
||||
@ -70,9 +70,6 @@
|
||||
#define SHUT_WR SD_SEND
|
||||
#define SHUT_RD SD_RECEIVE
|
||||
#else
|
||||
#ifndef FD_SETSIZE
|
||||
#define FD_SETSIZE 4096
|
||||
#endif
|
||||
#include <signal.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
@ -388,7 +388,6 @@ int handleredirect(struct clientparam * param, struct ace * acentry){
|
||||
if(cur->type == R_EXTIP){
|
||||
param->sinsl = cur->addr;
|
||||
if(SAISNULL(¶m->sinsl) && (*SAFAMILY(¶m->sincr) == AF_INET || *SAFAMILY(¶m->sincr) == AF_INET6))param->sinsl = param->sincr;
|
||||
#ifndef NOIPV6
|
||||
else if(cur->cidr && *SAFAMILY(¶m->sinsl) == AF_INET6){
|
||||
uint16_t c;
|
||||
int i;
|
||||
@ -403,7 +402,6 @@ int handleredirect(struct clientparam * param, struct ace * acentry){
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if(after)continue;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -285,9 +285,7 @@ static int addns(struct nserver *ns, int n, const char *s){
|
||||
if(n >= MAXNSERVERS) return n;
|
||||
memset(&sa, 0, sizeof(sa));
|
||||
if(inet_pton(AF_INET, s, SAADDR(&sa)) > 0) *SAFAMILY(&sa) = AF_INET;
|
||||
#ifndef NOIPV6
|
||||
else if(inet_pton(AF_INET6, s, SAADDR(&sa)) > 0) *SAFAMILY(&sa) = AF_INET6;
|
||||
#endif
|
||||
else return n; /* a link-local one with %scope is not */
|
||||
*SAPORT(&sa) = htons(53);
|
||||
for(i = 0; i < n; i++)
|
||||
@ -363,9 +361,7 @@ static int readsysns(struct nserver *ns){
|
||||
RegCloseKey(k);
|
||||
}
|
||||
n = regifaces(ns, n, "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces", "NameServer", 1);
|
||||
#ifndef NOIPV6
|
||||
n = regifaces(ns, n, "SYSTEM\\CurrentControlSet\\Services\\Tcpip6\\Parameters\\Interfaces", "NameServer", 0);
|
||||
#endif
|
||||
n = regifaces(ns, n, "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces", "DhcpNameServer", 1);
|
||||
if(n < MAXNSERVERS && !RegOpenKeyExA(HKEY_LOCAL_MACHINE, tcpip, 0, KEY_READ, &k)){
|
||||
if(regstr(k, "DhcpNameServer", buf, sizeof(buf))) n = addnslist(ns, n, buf);
|
||||
@ -475,9 +471,7 @@ static void hostsimport(void){
|
||||
memcpy(name, tok, l);
|
||||
name[l] = 0;
|
||||
if(inet_pton(AF_INET, name, addr) > 0) af = 4;
|
||||
#ifndef NOIPV6
|
||||
else if(inet_pton(AF_INET6, name, addr) > 0) af = 6;
|
||||
#endif
|
||||
else continue;
|
||||
ht = (af == 6)? &hosts6_table : &hosts_table;
|
||||
/* its names */
|
||||
@ -532,9 +526,7 @@ static int sysdnsread(void){
|
||||
void sysdnsinit(void){
|
||||
_3proxy_mutex_init(&nservers_mutex);
|
||||
inithashtable(&hosts_table, 256, 256, 1 << 22);
|
||||
#ifndef NOIPV6
|
||||
inithashtable(&hosts6_table, 256, 256, 1 << 22);
|
||||
#endif
|
||||
sysdnsread();
|
||||
sysdns.checked = time(NULL);
|
||||
if(!sysdns.n) return;
|
||||
|
||||
@ -117,10 +117,8 @@ void * sockschild(struct clientparam* param) {
|
||||
|
||||
size = 4;
|
||||
switch(c) {
|
||||
#ifndef NOIPV6
|
||||
case 4:
|
||||
size = 16;
|
||||
#endif
|
||||
case 1:
|
||||
for (i = 0; i<size; i++){
|
||||
if ((res = sockgetcharcli(param, param->srv->timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(441);}
|
||||
@ -180,11 +178,7 @@ void * sockschild(struct clientparam* param) {
|
||||
case 2:
|
||||
case 3:
|
||||
|
||||
#ifndef NOIPV6
|
||||
param->sinsl = *SAFAMILY(¶m->req)==AF_INET6? param->srv->extsa6 : param->srv->extsa;
|
||||
#else
|
||||
param->sinsl = param->srv->extsa;
|
||||
#endif
|
||||
param->operation = command == 2?BIND:UDPASSOC;
|
||||
if(command == 2){
|
||||
if ((param->remsock=nssocket(param->srv, ¶m->srv->so, param->sostate, NS_OUT, SASOCK(¶m->req), SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) {RETURN (11);}
|
||||
|
||||
@ -71,44 +71,10 @@ typedef struct _3proxy_sem_s {
|
||||
#define WEIGHTSCALE 1000000000u
|
||||
#define WEIGHTFUZZ 1000000u
|
||||
|
||||
#ifdef WITH_POLL
|
||||
#include <poll.h>
|
||||
#else
|
||||
#ifdef WITH_WSAPOLL
|
||||
|
||||
#define poll(A,B,C) WSAPoll(A,B,C)
|
||||
|
||||
#else
|
||||
struct mypollfd {
|
||||
SOCKET fd; /* file descriptor */
|
||||
short events; /* events to look for */
|
||||
short revents; /* events returned */
|
||||
};
|
||||
#define pollfd mypollfd
|
||||
int
|
||||
#ifdef _WIN32
|
||||
WINAPI
|
||||
#endif
|
||||
mypoll(struct mypollfd *fds, unsigned int nfds, int timeout);
|
||||
#ifndef POLLIN
|
||||
#define POLLIN 1
|
||||
#endif
|
||||
#ifndef POLLOUT
|
||||
#define POLLOUT 2
|
||||
#endif
|
||||
#ifndef POLLPRI
|
||||
#define POLLPRI 4
|
||||
#endif
|
||||
#ifndef POLLERR
|
||||
#define POLLERR 8
|
||||
#endif
|
||||
#ifndef POLLHUP
|
||||
#define POLLHUP 16
|
||||
#endif
|
||||
#ifndef POLLNVAL
|
||||
#define POLLNVAL 32
|
||||
#endif
|
||||
#endif
|
||||
#define poll(A,B,C) WSAPoll(A,B,C)
|
||||
#else
|
||||
#include <poll.h>
|
||||
#endif
|
||||
|
||||
#ifdef WITH_UN
|
||||
@ -174,30 +140,17 @@ int
|
||||
#define UN_SAISNULL(sa)
|
||||
#endif
|
||||
|
||||
#ifndef NOIPV6
|
||||
#define SAPORT(sa) ( UN_SAPORT(sa) ((struct sockaddr_in *)sa)->sin_family == AF_INET6? &((struct sockaddr_in6 *)sa)->sin6_port : &((struct sockaddr_in *)sa)->sin_port)
|
||||
#define SAADDR(sa) ( UN_SAADDR(sa) ((struct sockaddr_in *)sa)->sin_family == AF_INET6? (unsigned char *)&((struct sockaddr_in6 *)sa)->sin6_addr : (unsigned char *)&((struct sockaddr_in *)sa)->sin_addr.s_addr)
|
||||
#define SAADDRLEN(sa) ( UN_SAADDRLEN(sa) ((struct sockaddr_in *)sa)->sin_family == AF_INET6? 16:4)
|
||||
#define SASOCK(sa) ( UN_SASOCK(sa) ((struct sockaddr_in *)sa)->sin_family == AF_INET6? PF_INET6:PF_INET)
|
||||
#define SASIZE(sa) ( UN_SASIZE(sa) ((struct sockaddr_in *)sa)->sin_family == AF_INET6? sizeof(struct sockaddr_in6):sizeof(struct sockaddr_in))
|
||||
#define SAISNULL(sa) ( UN_SAISNULL(sa) !memcmp(((struct sockaddr_in *)sa)->sin_family == AF_INET6? (unsigned char *)&((struct sockaddr_in6 *)sa)->sin6_addr : (unsigned char *)&((struct sockaddr_in *)sa)->sin_addr.s_addr, NULLADDR, (((struct sockaddr_in *)sa)->sin_family == AF_INET6? 16:4)))
|
||||
#else
|
||||
#define SAPORT(sa) ( UN_SAPORT(sa) &((struct sockaddr_in *)sa)->sin_port)
|
||||
#define SAADDR(sa) ( UN_SAADDR(sa) (unsigned char *)&((struct sockaddr_in *)sa)->sin_addr.s_addr)
|
||||
#define SAADDRLEN(sa) ( UN_SAADDRLEN(sa) 4)
|
||||
#define SASOCK(sa) ( UN_SASOCK(sa) PF_INET)
|
||||
#define SASIZE(sa) ( UN_SASIZE(sa) sizeof(struct sockaddr_in))
|
||||
#define SAISNULL(sa) ( UN_SAISNULL(sa) ((struct sockaddr_in *)sa)->sin_addr.s_addr == 0)
|
||||
#endif
|
||||
|
||||
#ifdef WITH_UN
|
||||
#define PROXYSOCKADDRTYPE struct sockaddr_storage
|
||||
#else
|
||||
#ifndef NOIPV6
|
||||
#define PROXYSOCKADDRTYPE struct sockaddr_in6
|
||||
#else
|
||||
#define PROXYSOCKADDRTYPE struct sockaddr_in
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define MAX_HASH_SIZE (64)
|
||||
@ -777,9 +730,7 @@ struct srvparam {
|
||||
unsigned authcachetype, authcachetime;
|
||||
unsigned logdumpsrv, logdumpcli;
|
||||
PROXYSOCKADDRTYPE intsa, intNat, extNat;
|
||||
#ifndef NOIPV6
|
||||
PROXYSOCKADDRTYPE extsa6;
|
||||
#endif
|
||||
PROXYSOCKADDRTYPE extsa;
|
||||
_3proxy_mutex_t counter_mutex;
|
||||
_3proxy_sem_t childslots; /* maxchild of them, one held by each child */
|
||||
@ -1017,9 +968,7 @@ struct extparam {
|
||||
ROTATION logtype, countertype; /* logtype: the rotation of the last log */
|
||||
char * counterfile;
|
||||
PROXYSOCKADDRTYPE intsa;
|
||||
#ifndef NOIPV6
|
||||
PROXYSOCKADDRTYPE extsa6;
|
||||
#endif
|
||||
PROXYSOCKADDRTYPE extsa;
|
||||
struct passwords *pwl;
|
||||
struct auth * authenticate;
|
||||
@ -1120,13 +1069,8 @@ extern const struct hashtable pwl_template;
|
||||
|
||||
struct authcache {
|
||||
unsigned char username[64];
|
||||
#ifndef NOIPV6
|
||||
uint8_t sincr_addr[16];
|
||||
uint8_t sinsl_addr[16];
|
||||
#else
|
||||
uint8_t sincr_addr[4];
|
||||
uint8_t sinsl_addr[4];
|
||||
#endif
|
||||
uint16_t sincr_family;
|
||||
uint16_t sinsl_family;
|
||||
};
|
||||
|
||||
@ -62,14 +62,12 @@ static int transparent_pf(struct clientparam *param)
|
||||
memset(&nl, 0, sizeof(nl));
|
||||
nl.proto = IPPROTO_TCP;
|
||||
nl.direction = PF_OUT;
|
||||
#ifndef NOIPV6
|
||||
if(*SAFAMILY(¶m->sincr) == AF_INET6){
|
||||
nl.af = AF_INET6;
|
||||
memcpy(&nl.saddr.v6, SAADDR(¶m->sincr), 16);
|
||||
memcpy(&nl.daddr.v6, SAADDR(¶m->sincl), 16);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
nl.af = AF_INET;
|
||||
memcpy(&nl.saddr.v4, SAADDR(¶m->sincr), 4);
|
||||
@ -82,10 +80,8 @@ static int transparent_pf(struct clientparam *param)
|
||||
|
||||
memset(¶m->req, 0, sizeof(param->req));
|
||||
*SAFAMILY(¶m->req) = nl.af;
|
||||
#ifndef NOIPV6
|
||||
if(nl.af == AF_INET6) memcpy(SAADDR(¶m->req), &nl.rdaddr.v6, 16);
|
||||
else
|
||||
#endif
|
||||
memcpy(SAADDR(¶m->req), &nl.rdaddr.v4, 4);
|
||||
*SAPORT(¶m->req) = nl.rdport;
|
||||
return 0;
|
||||
@ -100,10 +96,8 @@ static int transparent_netfilter(struct clientparam *param)
|
||||
|
||||
#ifdef SO_ORIGINAL_DST
|
||||
if(getsockopt(param->clisock,
|
||||
#ifndef NOIPV6
|
||||
#ifdef SOL_IPV6
|
||||
*SAFAMILY(¶m->sincr) == AF_INET6?SOL_IPV6:
|
||||
#endif
|
||||
#endif
|
||||
SOL_IP, SO_ORIGINAL_DST, (struct sockaddr *) ¶m->req, &len)
|
||||
|| !memcmp((char *)SAADDR(¶m->req), "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", SAADDRLEN(¶m->req))){
|
||||
|
||||
@ -44,11 +44,7 @@ static int udppmfirst(struct udploop *u, struct udpsession *ss, unsigned char *b
|
||||
int res;
|
||||
|
||||
if(parsehostname((char *)param->srv->target, param, ntohs(param->srv->targetport))) return (param->res = 100);
|
||||
#ifndef NOIPV6
|
||||
param->sinsl = *SAFAMILY(¶m->req) == AF_INET6? param->srv->extsa6 : param->srv->extsa;
|
||||
#else
|
||||
param->sinsl = param->srv->extsa;
|
||||
#endif
|
||||
*SAPORT(¶m->sinsl) = 0;
|
||||
param->sinsr = param->req;
|
||||
param->operation = UDPASSOC;
|
||||
|
||||
@ -141,11 +141,7 @@ static void udpreset(struct clientparam *param)
|
||||
param->redirected = 0;
|
||||
param->udp_nhops = 0;
|
||||
memset(param->udp_relay, 0, sizeof(param->udp_relay));
|
||||
#ifndef NOIPV6
|
||||
param->sinsl = *SAFAMILY(¶m->req) == AF_INET6? param->srv->extsa6 : param->srv->extsa;
|
||||
#else
|
||||
param->sinsl = param->srv->extsa;
|
||||
#endif
|
||||
param->sinsr = param->req;
|
||||
}
|
||||
|
||||
@ -259,13 +255,11 @@ int udpsockmap(struct clientparam *param, int timeo)
|
||||
if (socks5_setaddr(param->srv->family, 1, base + 4, &dst)) continue;
|
||||
i = 8;
|
||||
break;
|
||||
#ifndef NOIPV6
|
||||
case 4:
|
||||
if (len < 22) return 484;
|
||||
if (socks5_setaddr(param->srv->family, 4, base + 4, &dst)) continue;
|
||||
i = 20;
|
||||
break;
|
||||
#endif
|
||||
case 3: {
|
||||
int sz = base[4];
|
||||
if (len < 7 + sz) return 485;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user