3proxy/scripts/openwrt/Makefile
Vladimir Dubrovin 2cbdc6e845 Add an OpenWrt package
3proxy is not in the OpenWrt feed, and the static binaries built here install
nowhere in particular: they carry no service definition, no configuration and
no way to survive a sysupgrade.

Add the package as it would be submitted to openwrt/packages - a Makefile, a
procd init script and a UCI schema. Built in the 24.10 SDK for mipsel_24kc
against the distribution's libraries, so the result is a 220kB package
depending on libopenssl and libpcre2 rather than a static binary, with TLS and
PCRE support actually present.

3proxy.cfg is order dependent, which is the whole difficulty of generating it
from UCI, where sections are unordered:

  - access rules are named sections referenced by a service through an ordered
    list, so the reference order decides precedence, and the list is flushed
    before each service so rules do not leak into the next one
  - parent proxies extend the allow rule they follow, so they hang off the
    access rule rather than the service
  - the TLS switches apply to every service below them, so the generator
    tracks what is in effect and emits a directive only when a service needs a
    different state, rather than letting certificate spoofing leak into a
    service that did not ask for it
  - bandwidth, connection and counter limits are global and match on their own
    ACL pattern, so they are a separate ordered list

Nothing is enabled by default: the global switch is off, no service ships
enabled, and a service section that omits the option does not start either, so
installing the package opens no ports.

Values that would make 3proxy reject the whole configuration at boot are
checked while writing it - unknown access actions, limiter types, pcre types
and actions - and reported instead of being passed through.
2026-08-23 15:40:26 +03:00

67 lines
1.8 KiB
Makefile

#
# Copyright (C) 2026 3proxy.org
#
# This is free software, licensed under the BSD 3-Clause License.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=3proxy
PKG_VERSION:=1.0.0
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
# A trailing ? tells the download helper the URL is complete and PKG_SOURCE
# must not be appended to it.
PKG_SOURCE_URL:=https://codeload.github.com/3proxy/3proxy/tar.gz/refs/tags/$(PKG_VERSION)?
PKG_HASH:=35b07de1046f3aaeac4a7085101b7e5c453efa3527cbdc42a84690366c7ecfa8
PKG_MAINTAINER:=Vladimir Dubrovin <vlad@3proxy.org>
PKG_LICENSE:=BSD-3-Clause
PKG_LICENSE_FILES:=copying
PKG_CPE_ID:=cpe:/a:3proxy:3proxy
PKG_BUILD_PARALLEL:=1
include $(INCLUDE_DIR)/package.mk
define Package/3proxy
SECTION:=net
CATEGORY:=Network
SUBMENU:=Web Servers/Proxies
TITLE:=tiny free proxy server
URL:=https://3proxy.org/
DEPENDS:=+libopenssl +libpcre2
endef
define Package/3proxy/description
3proxy is a tiny free proxy server supporting HTTP, HTTPS, FTP, SOCKS v4/v4a/v5,
POP3, SMTP, IMAP, TCP and UDP port mapping, with access control, bandwidth
limiting and traffic accounting.
endef
define Package/3proxy/conffiles
/etc/config/3proxy
endef
# Makefile.Linux appends to CFLAGS and LDFLAGS internally; the target flags have
# to be added rather than substituted, or the defines it relies on are lost.
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) -f Makefile.Linux \
CC="$(TARGET_CC)" \
EXTRA_CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
EXTRA_LDFLAGS="$(TARGET_LDFLAGS)" \
PLUGINS=
endef
define Package/3proxy/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/3proxy $(1)/usr/bin/3proxy
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) ./files/3proxy.config $(1)/etc/config/3proxy
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/3proxy.init $(1)/etc/init.d/3proxy
endef
$(eval $(call BuildPackage,3proxy))