mirror of
https://github.com/3proxy/3proxy.git
synced 2026-09-03 13:25:48 +08:00
pop3p, imapp and smtpp are built with MAILPROXY=true, and ftppr and the ftp:// scheme of the HTTP proxy with FTP=true; with CMake the switches are 3PROXY_USE_MAILPROXY and 3PROXY_USE_FTP. Neither is in a default build, and the standalone binaries follow what was built. A configuration naming one of them is still read either way. The three mail protocols amount to a STARTTLS negotiation now that mail is carried over TLS, so without a proxy of their own those names are tlspr speaking the protocol: the file holds a stand-in which sets the protocol for the connection and returns tlspr for the caller to run, which serves the service name and a parent chain alike and leaves conf.c and the redirect table untouched. FTP has no such fallback, so the service is known, answers nothing and logs the refusal. The Linux workflow builds both, so all of it is still compiled and run.
150 lines
6.9 KiB
Makefile
150 lines
6.9 KiB
Makefile
#
|
|
# 3 proxy Makefile for GCC/Unix
|
|
#
|
|
# add -DWITH_ODBC to CFLAGS and -lodbc to LDFLAGS to compile with ODBC
|
|
# library support. Add -DSAFESQL for poorely written ODBC library / drivers.
|
|
|
|
BUILDDIR = ../bin/
|
|
PREFIX ?= 3proxy_
|
|
CRYPT_PREFIX ?= $(PREFIX)
|
|
MANDIR ?= /usr/share/man
|
|
CC ?= cc
|
|
|
|
CFLAGS ?= -O3 -flto
|
|
CFLAGS += -c -fno-strict-aliasing -DFD_SETSIZE=4096 -DWITH_POLL -DWITH_UN
|
|
COUT = -o
|
|
LN ?= ${CC}
|
|
LDFLAGS ?= -O3 -flto
|
|
LDFLAGS += -pthread -fno-strict-aliasing
|
|
# Use EXTRA_CFLAGS/EXTRA_LDFLAGS to add flags from the make command line.
|
|
# Setting CFLAGS or LDFLAGS there instead overrides every assignment in this
|
|
# makefile, including the += above and the STATIC/LIBSTATIC handling below.
|
|
CFLAGS += $(EXTRA_CFLAGS)
|
|
LDFLAGS += $(EXTRA_LDFLAGS)
|
|
# -lpthreads may be reuiured on some platforms instead of -pthreads
|
|
# -ldl or -lld may be required for some platforms
|
|
DCFLAGS ?= -fPIC
|
|
MAILPROXY ?= false
|
|
ifeq ($(MAILPROXY),true)
|
|
CFLAGS += -DWITH_POP3P -DWITH_IMAPP -DWITH_SMTPP
|
|
MAIL_EXES = $(BUILDDIR)$(PREFIX)pop3p$(EXESUFFICS) $(BUILDDIR)$(PREFIX)imapp$(EXESUFFICS) $(BUILDDIR)$(PREFIX)smtpp$(EXESUFFICS)
|
|
endif
|
|
FTP ?= false
|
|
ifeq ($(FTP),true)
|
|
CFLAGS += -DWITH_FTP
|
|
FTP_EXES = $(BUILDDIR)$(PREFIX)ftppr$(EXESUFFICS)
|
|
endif
|
|
HTTPSRV ?= true
|
|
ifeq ($(HTTPSRV),true)
|
|
CFLAGS += -DWITH_HTTPSRV
|
|
HTTPSRV_OBJS = srvhttpsrv$(OBJSUFFICS) srvwebadmin$(OBJSUFFICS)
|
|
endif
|
|
DLFLAGS ?= -shared
|
|
DLSUFFICS = .so
|
|
LIBS ?=
|
|
LIBSPREFIX = -l
|
|
LIBSSUFFIX =
|
|
LNOUT = -o
|
|
EXESUFFICS =
|
|
OBJSUFFICS = .o
|
|
DEFINEOPTION = -D
|
|
COMPFILES = *~
|
|
REMOVECOMMAND = rm -f
|
|
AFTERCLEAN = (find . -type f -name "*.o" -delete && find src/ -type f -name "Makefile.var" -delete && find bin/ -type f -perm +111 -delete) || true
|
|
TYPECOMMAND = cat
|
|
COMPATLIBS =
|
|
MAKEFILE = Makefile.FreeBSD
|
|
PLUGINS ?= StringsPlugin TrafficPlugin FilePlugin
|
|
|
|
# Transparent proxying, built in. The destination of a redirected connection
|
|
# comes from pf where its headers are available, and from the socket where a
|
|
# redirection leaves it there (OpenBSD divert-to, FreeBSD ipfw fwd). macOS
|
|
# has /dev/pf but ships no pfvar.h, so only the socket route is built there
|
|
# and no macOS redirection leaves the address on the socket.
|
|
CFLAGS += -DWITH_TRANSPARENT
|
|
TRANSPARENT_OBJS = transparent$(OBJSUFFICS)
|
|
|
|
PF_CHECK ?= $(shell printf "\#include <sys/types.h>\\n\#include <sys/socket.h>\\n\#include <net/if.h>\\n\#include <net/pfvar.h>\\n int main(){return 0;}" | tr -d \\\\ | $(CC) -x c $(CFLAGS) -o testpf.o -c - 2>/dev/null && rm testpf.o && echo true||echo false)
|
|
ifeq ($(PF_CHECK), true)
|
|
CFLAGS += -DWITH_PF
|
|
endif
|
|
ifeq ($(STATIC), true)
|
|
LDFLAGS += -static
|
|
CFLAGS += -DNOPLUGINS -DNOSTDRESOLVE -DNOCRYPT
|
|
ZLIB = -lz -lzstd
|
|
PLUGINS =
|
|
PAM_CHECK = false
|
|
endif
|
|
ifeq ($(LIBSTATIC), true)
|
|
STATIC_PREFIX = -Wl,-Bstatic
|
|
STATIC_SUFFIX = -Wl,-Bdynamic
|
|
ZLIB = -lz -lzstd
|
|
endif
|
|
WOLFSSL_CHECK ?= $(shell printf "\#include <wolfssl/options.h>\\n\#include <wolfssl/openssl/ssl.h>\\n int main(){return 0;}" | tr -d \\\\ | $(CC) -x c $(CFLAGS) -o testwssl.o - 2>/dev/null && $(CC) $(LDFLAGS) -otestwssl testwssl.o $(STATIC_PREFIX) -lwolfssl $(STATIC_SUFFIX) 2>/dev/null && rm testwssl testwssl.o && echo true||echo false)
|
|
ifeq ($(WOLFSSL_CHECK), true)
|
|
LIBS += $(STATIC_PREFIX) -lwolfssl $(STATIC_SUFFIX)
|
|
CFLAGS += -DWITH_SSL -DWITH_WOLFSSL
|
|
SSL_OBJS = ssllib$(OBJSUFFICS) ssl$(OBJSUFFICS)
|
|
ZLIB :=
|
|
else
|
|
OPENSSL_CHECK ?= $(shell printf "\#include <openssl/ssl.h>\\n int main(){return 0;}" | tr -d \\\\ | $(CC) -x c $(CFLAGS) -o testssl.o - 2>/dev/null && $(CC) $(LDFLAGS) -otestssl testssl.o $(STATIC_PREFIX) $(ZLIB) -lcrypto -lssl $(STATIC_SUFFIX) 2>/dev/null && rm testssl testssl.o && echo true||echo false)
|
|
ifeq ($(OPENSSL_CHECK), true)
|
|
LIBS += $(STATIC_PREFIX) $(ZLIB) -l crypto -l ssl $(STATIC_SUFFIX)
|
|
CFLAGS += -DWITH_SSL
|
|
SSL_OBJS = ssllib$(OBJSUFFICS) ssl$(OBJSUFFICS)
|
|
else
|
|
ZLIB :=
|
|
endif
|
|
endif
|
|
PCRE_CHECK ?= $(shell printf "\#define PCRE2_CODE_UNIT_WIDTH 8\\n\#include <pcre2.h>\\n int main(){return 0;}" | tr -d \\\\ | $(CC) -x c $(CFLAGS) -o testpcre.o - 2>/dev/null && $(CC) -o testpcre testpcre.o $(LDFLAGS) -lpcre2-8 2>/dev/null && rm testpcre testpcre.o && echo true||echo false)
|
|
ifeq ($(PCRE_CHECK), true)
|
|
CFLAGS += -DWITH_PCRE
|
|
PCRE_OBJS = pcre$(OBJSUFFICS)
|
|
PCRE_LIBS = $(STATIC_PREFIX) -lpcre2-8 $(STATIC_SUFFIX)
|
|
endif
|
|
PAM_CHECK ?= $(shell printf "\#include <security/pam_appl.h>\\n int main(){return 0;}" | tr -d \\\\ | $(CC) -x c $(CFLAGS) -o testpam.o - 2>/dev/null && $(CC) $(LDFLAGS) -o testpam testpam.o -lpam 2>/dev/null && rm testpam testpam.o && echo true||echo false)
|
|
ifeq ($(PAM_CHECK), true)
|
|
PLUGINS += PamAuth
|
|
endif
|
|
|
|
include Makefile.inc
|
|
|
|
DESTDIR ?=
|
|
prefix ?= /usr/local
|
|
BINPREFIX ?= $(prefix)/bin
|
|
|
|
install: all
|
|
if [ ! -d "$(DESTDIR)$(BINPREFIX)" ]; then mkdir -p $(DESTDIR)$(BINPREFIX)/; fi
|
|
install bin/3proxy $(DESTDIR)$(BINPREFIX)/3proxy
|
|
install bin/$(CRYPT_PREFIX)crypt $(DESTDIR)$(BINPREFIX)/$(CRYPT_PREFIX)crypt
|
|
for f in proxy socks pop3p imapp smtpp ftppr tcppm udppm tlspr; do \
|
|
if [ -f bin/$(PREFIX)$$f ]; then install bin/$(PREFIX)$$f $(DESTDIR)$(BINPREFIX)/$(PREFIX)$$f; fi; \
|
|
done
|
|
install -d $(DESTDIR)$(prefix)/etc/3proxy/conf
|
|
install -d $(DESTDIR)$(prefix)/etc/rc.d/
|
|
sed -e 's|@CMAKE_INSTALL_FULL_BINDIR@|$(BINPREFIX)|g' -e 's|@CMAKE_INSTALL_FULL_SYSCONFDIR@|$(prefix)/etc|g' scripts/rc.d/3proxy.in > $(DESTDIR)$(prefix)/etc/rc.d/3proxy
|
|
chmod 755 $(DESTDIR)$(prefix)/etc/rc.d/3proxy
|
|
sed -e 's|@CMAKE_INSTALL_FULL_BINDIR@|$(BINPREFIX)|g' -e 's|@3PROXY_CONFDIR@|$(prefix)/etc/3proxy/conf|g' -e 's|@CRYPT_PREFIX@|$(CRYPT_PREFIX)|g' scripts/add3proxyuser.sh.in > $(DESTDIR)$(BINPREFIX)/add3proxyuser
|
|
chmod 755 $(DESTDIR)$(BINPREFIX)/add3proxyuser
|
|
if [ -s $(DESTDIR)$(prefix)/etc/3proxy/3proxy.cfg ]; then echo $(prefix)/etc/3proxy/3proxy.cfg already exists; else sed -e 's|@CMAKE_INSTALL_FULL_SYSCONFDIR@|$(prefix)/etc|g' -e 's|@3PROXY_CONFDIR@|$(prefix)/etc/3proxy/conf|g' -e 's|@3PROXY_COUNTERDIR@|/opt/3proxy|g' scripts/3proxy.cfg.in > $(DESTDIR)$(prefix)/etc/3proxy/3proxy.cfg; chmod 640 $(DESTDIR)$(prefix)/etc/3proxy/3proxy.cfg; fi
|
|
if [ ! -d $(DESTDIR)/var/log/3proxy/ ]; then mkdir -p $(DESTDIR)/var/log/3proxy/; fi
|
|
mkdir -p $(DESTDIR)/opt/3proxy
|
|
touch $(DESTDIR)$(prefix)/etc/3proxy/conf/passwd
|
|
touch $(DESTDIR)$(prefix)/etc/3proxy/conf/counters
|
|
touch $(DESTDIR)$(prefix)/etc/3proxy/conf/bandlimiters
|
|
install -d $(DESTDIR)$(MANDIR)/man8
|
|
install -m 644 man/3proxy.8 $(DESTDIR)$(MANDIR)/man8/3proxy.8
|
|
for f in proxy socks pop3p imapp smtpp ftppr tcppm udppm tlspr; do \
|
|
if [ -f man/$$f.8 ]; then install -m 644 man/$$f.8 $(DESTDIR)$(MANDIR)/man8/$(PREFIX)$$f.8; fi; \
|
|
done
|
|
install -m 644 man/3proxy_crypt.8 $(DESTDIR)$(MANDIR)/man8/$(CRYPT_PREFIX)crypt.8
|
|
install -d $(DESTDIR)$(MANDIR)/man5
|
|
install -m 644 man/3proxy.cfg.5 $(DESTDIR)$(MANDIR)/man5/3proxy.cfg.5
|
|
@if [ "$(DESTDIR)" = "" ]; then \
|
|
sh scripts/postinstall.sh $(prefix); \
|
|
fi
|
|
echo Run $(BINPREFIX)/add3proxyuser to add \'admin\' user
|
|
|
|
allplugins:
|
|
@list='$(PLUGINS)'; for p in $$list; do cp Makefile Makefile.var plugins/$$p; cd plugins/$$p ; make ; cd ../.. ; done
|