Template
1
0
mirror of https://github.com/bol-van/zapret2.git synced 2026-03-14 06:13:09 +00:00
This commit is contained in:
bol-van
2025-11-21 22:49:11 +03:00
commit ecdaed3dcc
117 changed files with 26779 additions and 0 deletions

View File

@@ -0,0 +1,107 @@
How to compile native programs for use in openwrt
-------------------------------------------------
1) Install required packages to the host system :
debian,ubuntu : apt install build-essential patch libncurses-dev python3-distutils unzip gawk wget git
fedora: dnf install make patch gcc g++ ncurses-devel git perl
Other packages may be required on your distribution. Look for the errors.
2) Download latest SDK for your target platform from https://downloads.openwrt.org
examples :
curl -o - https://downloads.openwrt.org/releases/23.05.5/targets/x86/64/openwrt-sdk-23.05.5-x86-64_gcc-12.3.0_musl.Linux-x86_64.tar.xz | tar -Jxv
cd openwrt-sdk-23.05.5-x86-64_gcc-12.3.0_musl.Linux-x86_64
curl -o - https://downloads.openwrt.org/snapshots/targets/x86/64/openwrt-sdk-x86-64_gcc-13.3.0_musl.Linux-x86_64.tar.zst | tar --zstd -xv
cd openwrt-sdk-x86-64_gcc-13.3.0_musl.Linux-x86_64
3) Install required libs
./scripts/feeds update base packages
./scripts/feeds install libnetfilter-queue zlib libcap luajit
4) If you need static build edit `feeds/packages/lang/luajit/Makefile`
change BUILDMODE from "dynamic" to "mixed"
add '$(CP) $(PKG_INSTALL_DIR)/usr/lib/*a $(1)/usr/lib/'
after '$(CP) $(PKG_INSTALL_DIR)/usr/lib/*so* $(1)/usr/lib/'
should look like :
define Build/Compile
$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
HOST_CC="$(HOSTCC) $(HOST_CFLAGS) $(HOST_BITS)" \
CROSS="$(TARGET_CROSS)" \
DPREFIX=$(PKG_INSTALL_DIR)/usr \
PREFIX=/usr \
TARGET_SYS=Linux \
TARGET_CFLAGS="$(TARGET_CFLAGS)" \
BUILDMODE=mixed
rm -rf $(PKG_INSTALL_DIR)
mkdir -p $(PKG_INSTALL_DIR)
$(MAKE) -C $(PKG_BUILD_DIR) \
DPREFIX=$(PKG_INSTALL_DIR)/usr \
PREFIX=/usr \
TARGET_SYS=Linux \
install
endef
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/include/luajit-2.1
$(CP) $(PKG_INSTALL_DIR)/usr/include/luajit-2.1/*.{h,hpp} $(1)/usr/include/luajit-2.1
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/*so* $(1)/usr/lib/
$(CP) $(PKG_INSTALL_DIR)/usr/lib/*a $(1)/usr/lib/
$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/luajit.pc $(1)/usr/lib/pkgconfig/
$(CP) $(PKG_INSTALL_DIR)/usr/bin/luajit-$(PKG_VERSION) $(PKG_INSTALL_DIR)/usr/bin/$(PKG_NAME)
endef
5) Prepare openwrt package definitions
cp -R /opt/zapret2/docs/compile/openwrt/. .
cp -R /opt/zapret2/nfq2 package/zapret/nfqws2
cp -R /opt/zapret2/mdig package/zapret/mdig
cp -R /opt/zapret2/ip2net package/zapret/ip2net
6) Prepare .config
make defconfig
If you only need bins without packages comment 'CONFIG_AUTOREMOVE=y' line in .config
Change 'y' to 'n' in Config.in
should look like :
config AUTOREMOVE
bool "Automatic removal of build directories"
default n
and in Config-build.in
should look like :
config AUTOREMOVE
bool
default n
7) Compile
dynamic build : make package/{nfqws2,mdig,ip2net}/compile
static build : make CFLAGS=-static LDFLAGS=-lgcc_eh package/{nfqws2,mdig,ip2net}/compile
8) Get result
executables only : build_dir/target/<progname>
ipk or apk packages : bin/packages/*/base
9) Installing to openwrt to use with zapret
zapret with or without binaries should be already installed in /opt/zapret2.
Install ipk's or apk's with all compiled progs using opkg or apk.
Bins are placed to /opt/zapret2/binaries/my.
Or copy binaries there manually and set chmod 755 to them.
Run install_bin.sh or install_easy.sh. They will use bins in 'my' folder.

View File

@@ -0,0 +1,16 @@
debian,ubuntu :
apt install make gcc zlib1g-dev libcap-dev libnetfilter-queue-dev libmnl-dev libsystemd-dev libluajit2-5.1-dev
make -C /opt/zapret2 systemd
FreeBSD :
pkg search luajit-2
# see what's the version available
pkg install luajit-2.1.0.20250728
make -C /opt/zapret2
OpenBSD :
pkg_add luajit gmake bsd
gmake -C /opt/zapret2

View File

@@ -0,0 +1,36 @@
Windows x64
1) Download latest cygwin for windows 7
curl -O https://www.cygwin.com/setup-x86_64.exe
setup-x86_64.exe --allow-unsupported-windows --no-verify --site http://ctm.crouchingtigerhiddenfruitbat.org/pub/cygwin/circa/64bit/2024/01/30/231215
2) During setup install packages : make gcc-core zlib-devel
3) Run Cygwin.bat
4) install and compile luajit from here : https://github.com/openresty/luajit2
download latest releast, unpack, cd to it's directory
make BUILDMODE=static CFLAGS="-Os"
make install
5) cd to %ZAPRET_BASE%/nfq
cd C:/Users/user/Downloads/zapret2/nfq
6) Compile nfqws2
make cygwin64
use winws2.exe
7) Take windivert.dll and windivert64.sys here : https://reqrypt.org/download
Choose version 2.2.2 for Windows 10 and 2.2.0 for Windows 7.
8) Copy cygwin1.dll, winws2.exe, windivert.dll and windivert64.sys to one folder.
9) Run winws2.exe from cmd.exe running as administrator.
winws will not run from cygwin shell with cygwin1.dll copy in it's folder.
winws will not run without cygwin1.dll outside of cygwin shell.

View File

@@ -0,0 +1,32 @@
#
include $(TOPDIR)/rules.mk
PKG_NAME:=ip2net
PKG_RELEASE:=1
include $(INCLUDE_DIR)/package.mk
define Package/ip2net
SECTION:=net
CATEGORY:=Network
TITLE:=ip2net
SUBMENU:=Zapret
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./ip2net/* $(PKG_BUILD_DIR)/
endef
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) $(TARGET_CONFIGURE_OPTS)
endef
define Package/ip2net/install
$(INSTALL_DIR) $(1)/opt/zapret/binaries/my
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ip2net $(1)/opt/zapret/binaries/my
endef
$(eval $(call BuildPackage,ip2net))

View File

@@ -0,0 +1 @@
Copy "ip2net" folder here !

View File

@@ -0,0 +1,32 @@
#
include $(TOPDIR)/rules.mk
PKG_NAME:=mdig
PKG_RELEASE:=1
include $(INCLUDE_DIR)/package.mk
define Package/mdig
SECTION:=net
CATEGORY:=Network
TITLE:=mdig
SUBMENU:=Zapret
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./mdig/* $(PKG_BUILD_DIR)/
endef
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) $(TARGET_CONFIGURE_OPTS)
endef
define Package/mdig/install
$(INSTALL_DIR) $(1)/opt/zapret/binaries/my
$(INSTALL_BIN) $(PKG_BUILD_DIR)/mdig $(1)/opt/zapret/binaries/my
endef
$(eval $(call BuildPackage,mdig))

View File

@@ -0,0 +1 @@
Copy "mdig" folder here !

View File

@@ -0,0 +1,46 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=nfqws2
PKG_RELEASE:=1
LUA_JIT?=1
ifeq ($(LUA_JIT),1)
LUAJIT_VER?=2.1
LUA_VER?=5.1
LUA_DEP:=luajit
#LUA_DEP:=luajit2
LUA_INCLUDE:=-I$(STAGING_DIR)/usr/include/luajit-$(LUAJIT_VER)
LUA_LIBRARY:=-L$(STAGING_DIR)/usr/lib -lluajit-$(LUA_VER)
else
LUA_VER?=5.3
LUA_DEP:=lua$(LUA_VER)
LUA_INCLUDE:=-I$(STAGING_DIR)/usr/include/lua$(LUA_VER)
LUA_LIBRARY:=-L$(STAGING_DIR)/usr/lib -llua$(LUA_VER)
endif
include $(INCLUDE_DIR)/package.mk
define Package/nfqws2
SECTION:=net
CATEGORY:=Network
TITLE:=nfqws2
SUBMENU:=Zapret
DEPENDS:=+libnetfilter-queue +lmnl +libcap +zlib +$(LUA_DEP)
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./nfq/* $(PKG_BUILD_DIR)/
endef
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) $(TARGET_CONFIGURE_OPTS) LUA_CFLAGS="$(LUA_INCLUDE)" LUA_LIB="$(LUA_LIBRARY)"
endef
define Package/nfqws2/install
$(INSTALL_DIR) $(1)/opt/zapret/binaries/my
$(INSTALL_BIN) $(PKG_BUILD_DIR)/nfqws2 $(1)/opt/zapret/binaries/my
endef
$(eval $(call BuildPackage,nfqws2))

View File

@@ -0,0 +1 @@
Copy "nfq" folder here !