diff --git a/.github/workflows/build-binaries.yml b/.github/workflows/build-binaries.yml
index 6813d6dd0..58faaa9f9 100644
--- a/.github/workflows/build-binaries.yml
+++ b/.github/workflows/build-binaries.yml
@@ -23,7 +23,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- arch: [arm, arm64, mips, x86]
+ arch: [arm, arm64, x86]
include:
- arch: arm
target: arm-linux-gnueabihf
@@ -33,10 +33,6 @@ jobs:
target: aarch64-linux-gnu
cc: aarch64-linux-gnu-gcc
strip: aarch64-linux-gnu-strip
- - arch: mips
- target: mips-linux-gnu
- cc: mips-linux-gnu-gcc
- strip: mips-linux-gnu-strip
- arch: x86
target: i686-linux-gnu
cc: i686-linux-gnu-gcc
@@ -52,9 +48,66 @@ jobs:
sudo apt-get install -y \
build-essential \
wget \
- gcc-${{ matrix.target }} \
+ unzip \
file
+ - name: Set up Android NDK
+ run: |
+ NDK_VERSION="r26d"
+ echo "Downloading Android NDK ${NDK_VERSION}..."
+
+ # Download with retries and better error handling
+ for i in {1..3}; do
+ if wget -q "https://dl.google.com/android/repository/android-ndk-${NDK_VERSION}-linux.zip"; then
+ echo "✓ Downloaded android-ndk-${NDK_VERSION}-linux.zip (attempt $i)"
+ break
+ fi
+ echo "Download attempt $i failed, retrying..."
+ sleep 5
+ done
+
+ # Verify download
+ if [ ! -f "android-ndk-${NDK_VERSION}-linux.zip" ]; then
+ echo "❌ Failed to download NDK after 3 attempts"
+ exit 1
+ fi
+
+ echo "Extracting NDK..."
+ unzip -q android-ndk-${NDK_VERSION}-linux.zip
+
+ # Verify extraction
+ if [ ! -d "android-ndk-${NDK_VERSION}" ]; then
+ echo "❌ NDK extraction failed - directory not found"
+ ls -la
+ exit 1
+ fi
+
+ export ANDROID_NDK_ROOT="$(pwd)/android-ndk-${NDK_VERSION}"
+ echo "✓ NDK setup complete: ${ANDROID_NDK_ROOT}"
+ echo "ANDROID_NDK_ROOT=${ANDROID_NDK_ROOT}" >> $GITHUB_ENV
+
+ # Set up NDK toolchain paths (including NDK_AR for llvm-ar)
+ case "${{ matrix.arch }}" in
+ arm64)
+ echo "NDK_CC=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android28-clang" >> $GITHUB_ENV
+ echo "NDK_STRIP=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip" >> $GITHUB_ENV
+ echo "NDK_AR=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" >> $GITHUB_ENV
+ echo "NDK_TARGET=aarch64-linux-android" >> $GITHUB_ENV
+ ;;
+ arm)
+ echo "NDK_CC=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi28-clang" >> $GITHUB_ENV
+ echo "NDK_STRIP=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip" >> $GITHUB_ENV
+ echo "NDK_AR=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" >> $GITHUB_ENV
+ echo "NDK_TARGET=armv7a-linux-androideabi" >> $GITHUB_ENV
+ ;;
+ x86)
+ echo "NDK_CC=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android28-clang" >> $GITHUB_ENV
+ echo "NDK_STRIP=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip" >> $GITHUB_ENV
+ echo "NDK_AR=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" >> $GITHUB_ENV
+ echo "NDK_TARGET=i686-linux-android" >> $GITHUB_ENV
+ ;;
+ esac
+
- name: Download Busybox source
run: |
BUSYBOX_VERSION="${{ github.event.inputs.busybox_version || '1.36.1' }}"
@@ -77,66 +130,200 @@ jobs:
run: |
cd "$BUSYBOX_DIR"
- # Start with minimal config to avoid cross-compilation issues
- make ARCH=${{ matrix.arch }} CROSS_COMPILE=${{ matrix.target }}- allnoconfig
-
- # Enable only essential features for AFWall+
- cat >> .config << EOF
- CONFIG_STATIC=y
- CONFIG_INSTALL_NO_USR=y
- CONFIG_BUSYBOX=y
- CONFIG_BUSYBOX_EXEC_PATH="/system/xbin/busybox"
- CONFIG_ASH=y
- CONFIG_SH_IS_ASH=y
- CONFIG_BASH_IS_NONE=y
- CONFIG_CAT=y
- CONFIG_CHMOD=y
- CONFIG_CP=y
- CONFIG_ECHO=y
- CONFIG_GREP=y
- CONFIG_KILL=y
- CONFIG_KILLALL=y
- CONFIG_LS=y
- CONFIG_MKDIR=y
- CONFIG_MV=y
- CONFIG_PS=y
- CONFIG_RM=y
- CONFIG_TEST=y
- CONFIG_WHICH=y
- CONFIG_IPTABLES=y
- CONFIG_IP6TABLES=y
- CONFIG_FEATURE_PREFER_APPLETS=n
- CONFIG_FEATURE_SH_STANDALONE=y
- EOF
+ # Use the basic Android default config (more stable than android_ndk_defconfig)
+ cp configs/android_defconfig .config
+
+ # Fix the cross-compiler prefix for NDK
+ sed -i 's/CONFIG_CROSS_COMPILER_PREFIX=.*/CONFIG_CROSS_COMPILER_PREFIX=""/' .config
+
+ # Process the initial config
+ yes '' | make ARCH=${{ matrix.arch }} oldconfig
+
+ # Disable problematic applets for Android bionic libc compatibility
+ echo "Disabling problematic applets for Android..."
+ sed -i 's/CONFIG_SWAPON=y/# CONFIG_SWAPON is not set/g' .config
+ sed -i 's/CONFIG_SWAPOFF=y/# CONFIG_SWAPOFF is not set/g' .config
+ sed -i 's/CONFIG_FEATURE_SWAPON_DISCARD=y/# CONFIG_FEATURE_SWAPON_DISCARD is not set/g' .config
+ sed -i 's/CONFIG_FEATURE_SWAPON_PRI=y/# CONFIG_FEATURE_SWAPON_PRI is not set/g' .config
- # Apply minimal config (use yes to answer all prompts with default)
- yes '' | make ARCH=${{ matrix.arch }} CROSS_COMPILE=${{ matrix.target }}- oldconfig
+ # Disable problematic archival features
+ sed -i 's/CONFIG_TAR=y/# CONFIG_TAR is not set/g' .config
+ sed -i 's/CONFIG_FEATURE_TAR_TO_COMMAND=y/# CONFIG_FEATURE_TAR_TO_COMMAND is not set/g' .config
+ sed -i 's/CONFIG_FEATURE_TAR_FROM=y/# CONFIG_FEATURE_TAR_FROM is not set/g' .config
+ sed -i 's/CONFIG_AR=y/# CONFIG_AR is not set/g' .config
+ sed -i 's/CONFIG_DPKG=y/# CONFIG_DPKG is not set/g' .config
+ sed -i 's/CONFIG_DPKG_DEB=y/# CONFIG_DPKG_DEB is not set/g' .config
+ sed -i 's/CONFIG_RPM=y/# CONFIG_RPM is not set/g' .config
+ sed -i 's/CONFIG_RPM2CPIO=y/# CONFIG_RPM2CPIO is not set/g' .config
- # Fix cross-compilation issues for all architectures
- # Replace the problematic off_t size check that fails during cross-compilation
+ # Disable features that require crypt.h (not available in Android bionic)
+ sed -i 's/CONFIG_LOGIN=y/# CONFIG_LOGIN is not set/g' .config
+ sed -i 's/CONFIG_PASSWD=y/# CONFIG_PASSWD is not set/g' .config
+ sed -i 's/CONFIG_SU=y/# CONFIG_SU is not set/g' .config
+ sed -i 's/CONFIG_SULOGIN=y/# CONFIG_SULOGIN is not set/g' .config
+ sed -i 's/CONFIG_VLOCK=y/# CONFIG_VLOCK is not set/g' .config
+ sed -i 's/CONFIG_CRYPTPW=y/# CONFIG_CRYPTPW is not set/g' .config
+ sed -i 's/CONFIG_CHPASSWD=y/# CONFIG_CHPASSWD is not set/g' .config
+ sed -i 's/CONFIG_FEATURE_SHADOWPASSWDS=y/# CONFIG_FEATURE_SHADOWPASSWDS is not set/g' .config
+
+ # Disable other bionic-incompatible features
+ sed -i 's/CONFIG_FEATURE_UTMP=y/# CONFIG_FEATURE_UTMP is not set/g' .config
+ sed -i 's/CONFIG_FEATURE_WTMP=y/# CONFIG_FEATURE_WTMP is not set/g' .config
+ sed -i 's/CONFIG_LAST=y/# CONFIG_LAST is not set/g' .config
+ sed -i 's/CONFIG_USERS=y/# CONFIG_USERS is not set/g' .config
+ sed -i 's/CONFIG_WHO=y/# CONFIG_WHO is not set/g' .config
+ sed -i 's/CONFIG_W=y/# CONFIG_W is not set/g' .config
+
+ # Disable networking features that require crypt.h
+ sed -i 's/CONFIG_FTPD=y/# CONFIG_FTPD is not set/g' .config
+ sed -i 's/CONFIG_FEATURE_FTP_AUTHENTICATION=y/# CONFIG_FEATURE_FTP_AUTHENTICATION is not set/g' .config
+ sed -i 's/CONFIG_FEATURE_HTTPD_AUTH_MD5=y/# CONFIG_FEATURE_HTTPD_AUTH_MD5 is not set/g' .config
+ sed -i 's/CONFIG_FEATURE_HTTPD_BASIC_AUTH=y/# CONFIG_FEATURE_HTTPD_BASIC_AUTH is not set/g' .config
+ sed -i 's/CONFIG_MKPASSWD=y/# CONFIG_MKPASSWD is not set/g' .config
+
+ # Reprocess config
+ yes '' | make ARCH=${{ matrix.arch }} oldconfig
+
+ # Fix x86 register pressure issue in TLS code
+ if [ "${{ matrix.arch }}" = "x86" ]; then
+ echo "Disabling ALL TLS and crypto features for x86 due to register pressure"
+
+ # Disable all TLS/SSL-related features comprehensively
+ sed -i 's/CONFIG_TLS=y/# CONFIG_TLS is not set/g' .config
+ sed -i 's/CONFIG_FEATURE_TLS_SHA1=y/# CONFIG_FEATURE_TLS_SHA1 is not set/g' .config
+ sed -i 's/CONFIG_FEATURE_WGET_HTTPS=y/# CONFIG_FEATURE_WGET_HTTPS is not set/g' .config
+ sed -i 's/CONFIG_FTPS=y/# CONFIG_FTPS is not set/g' .config
+ sed -i 's/CONFIG_SHA1SUM=y/# CONFIG_SHA1SUM is not set/g' .config
+ sed -i 's/CONFIG_SHA256SUM=y/# CONFIG_SHA256SUM is not set/g' .config
+ sed -i 's/CONFIG_SHA512SUM=y/# CONFIG_SHA512SUM is not set/g' .config
+ sed -i 's/CONFIG_MD5SUM=y/# CONFIG_MD5SUM is not set/g' .config
+
+ # Disable SSL client utilities that depend on TLS
+ sed -i 's/CONFIG_SSL_CLIENT=y/# CONFIG_SSL_CLIENT is not set/g' .config
+ sed -i 's/CONFIG_FEATURE_SSL_CLIENT=y/# CONFIG_FEATURE_SSL_CLIENT is not set/g' .config
+
+ # Disable wget entirely if it depends on TLS (safer approach)
+ sed -i 's/CONFIG_WGET=y/# CONFIG_WGET is not set/g' .config
+ sed -i 's/CONFIG_FEATURE_WGET_STATUSBAR=y/# CONFIG_FEATURE_WGET_STATUSBAR is not set/g' .config
+ sed -i 's/CONFIG_FEATURE_WGET_AUTHENTICATION=y/# CONFIG_FEATURE_WGET_AUTHENTICATION is not set/g' .config
+ sed -i 's/CONFIG_FEATURE_WGET_LONG_OPTIONS=y/# CONFIG_FEATURE_WGET_LONG_OPTIONS is not set/g' .config
+ sed -i 's/CONFIG_FEATURE_WGET_TIMEOUT=y/# CONFIG_FEATURE_WGET_TIMEOUT is not set/g' .config
+
+ # Disable any crypto/hash utilities that might link to TLS code
+ sed -i 's/CONFIG_BASE64=y/# CONFIG_BASE64 is not set/g' .config
+ sed -i 's/CONFIG_UUENCODE=y/# CONFIG_UUENCODE is not set/g' .config
+ sed -i 's/CONFIG_UUDECODE=y/# CONFIG_UUDECODE is not set/g' .config
+
+ # Multiple reprocessing to ensure all dependencies are resolved
+ yes '' | make ARCH=${{ matrix.arch }} oldconfig
+ yes '' | make ARCH=${{ matrix.arch }} oldconfig
+
+ # Remove ALL TLS/SSL-related source files to prevent any compilation
+ echo "Removing all TLS/SSL source files for x86..."
+ for pattern in "tls*.c" "ssl_client.c"; do
+ find networking -name "$pattern" -type f | while read tls_file; do
+ if [ -f "$tls_file" ]; then
+ echo "Removing $tls_file"
+ rm "$tls_file"
+ touch "$tls_file"
+ fi
+ done
+ done
+ fi
+
+ # Show what's enabled for debugging
+ echo "=== Essential applets for AFWall+ ==="
+ grep -E "CONFIG_(PING|IFCONFIG|LS|ECHO|CAT|GREP|FEATURE_INSTALLER)=" .config || true
+
+ echo "=== Problematic features (should be disabled) ==="
+ grep -E "CONFIG_(SWAPON|TAR_TO_COMMAND|DPKG|RPM|TLS).*=" .config || true
+
+ # Fix cross-compilation and duplicate symbol issues
+ echo "Applying Android compatibility fixes..."
+
+ # Fix off_t size check
if grep -q "struct BUG_off_t_size_is_misdetected" include/libbb.h; then
sed -i '/struct BUG_off_t_size_is_misdetected/,/};/c\
- /* Cross-compilation fix: off_t size check disabled for all architectures */' include/libbb.h
- echo "Applied cross-compilation fix for ${{ matrix.arch }}"
+ /* Cross-compilation fix: off_t size check disabled */' include/libbb.h
+ fi
+
+ # Fix FAST_FUNC calling convention
+ sed -i 's/__attribute__((regparm(3),stdcall))/__attribute__((regparm(3)))/g' include/platform.h
+
+ # Remove strchrnul conflicts
+ sed -i '/extern char \*strchrnul.*FAST_FUNC;/d' include/platform.h
+ sed -i '/char\* FAST_FUNC strchrnul/,/^}/d' libbb/platform.c
+
+ # Create stub for data_extract_to_command to fix linking
+ if [ ! -f "archival/libarchive/data_extract_to_command.c.bak" ]; then
+ cp archival/libarchive/data_extract_to_command.c archival/libarchive/data_extract_to_command.c.bak
+ cat > archival/libarchive/data_extract_to_command.c << 'EOF'
+ /* Stub for data_extract_to_command when FEATURE_TAR_TO_COMMAND is disabled */
+ #include "libbb.h"
+ #include "bb_archive.h"
+
+ void FAST_FUNC data_extract_to_command(archive_handle_t *archive_handle)
+ {
+ bb_simple_error_msg_and_die("--to-command feature not compiled");
+ }
+ EOF
+ # Force compile the stub by enabling it in Kbuild temporarily
+ sed -i 's/lib-\$(CONFIG_FEATURE_TAR_TO_COMMAND)/lib-y/' archival/libarchive/Kbuild
+ fi
+
+ # Create stub for pw_encrypt to fix linking issues when password features are disabled
+ if [ ! -f "libbb/pw_encrypt.c.bak" ]; then
+ cp libbb/pw_encrypt.c libbb/pw_encrypt.c.bak
+ cat > libbb/pw_encrypt.c << 'EOF'
+ /* Stub for pw_encrypt when crypt.h features are disabled */
+ #include "libbb.h"
+
+ char* FAST_FUNC pw_encrypt(const char *clear, const char *salt, int cleanup)
+ {
+ bb_simple_error_msg_and_die("password encryption not supported");
+ return NULL;
+ }
+ EOF
+ fi
+
+ # Fix duplicate syscall symbols
+ if [ -f "libbb/missing_syscalls.c" ]; then
+ echo "Fixing duplicate syscall symbols..."
+ sed -i '/pid_t.*getsid/,/^}/d' libbb/missing_syscalls.c
+ sed -i '/int.*adjtimex/,/^}/d' libbb/missing_syscalls.c
+ sed -i '/int.*sethostname/,/^}/d' libbb/missing_syscalls.c
+ sed -i '/getsid.*(/d' libbb/missing_syscalls.c
+ sed -i '/adjtimex.*(/d' libbb/missing_syscalls.c
+ sed -i '/sethostname.*(/d' libbb/missing_syscalls.c
+ fi
+
+ if [ -f "include/libbb.h" ]; then
+ sed -i '/extern.*getsid.*(/d' include/libbb.h
+ sed -i '/extern.*adjtimex.*(/d' include/libbb.h
+ sed -i '/extern.*sethostname.*(/d' include/libbb.h
fi
- name: Build Busybox
run: |
cd "$BUSYBOX_DIR"
- # Build with explicit compiler settings
+ # Build with Android NDK
make ARCH=${{ matrix.arch }} \
- CROSS_COMPILE=${{ matrix.target }}- \
- CC=${{ matrix.cc }} \
+ CC="${NDK_CC}" \
+ AR="${NDK_AR}" \
HOSTCC=gcc \
HOSTCXX=g++ \
+ STRIP="${NDK_STRIP}" \
+ CFLAGS="-static -DHAVE_STRCHRNUL" \
+ EXTRA_CFLAGS="-DHAVE_STRCHRNUL" \
+ LDFLAGS="-static" \
-j$(nproc)
# Verify binary
file busybox
# Strip and copy
- ${{ matrix.strip }} busybox
+ ${NDK_STRIP} busybox
cp busybox ../busybox_${{ matrix.arch }}
- name: Upload Busybox artifact
@@ -150,7 +337,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- arch: [arm, arm64, mips, x86]
+ arch: [arm, arm64, x86]
include:
- arch: arm
target: arm-linux-gnueabihf
@@ -162,11 +349,6 @@ jobs:
cc: aarch64-linux-gnu-gcc
strip: aarch64-linux-gnu-strip
configure_host: aarch64-linux-gnu
- - arch: mips
- target: mips-linux-gnu
- cc: mips-linux-gnu-gcc
- strip: mips-linux-gnu-strip
- configure_host: mips-linux-gnu
- arch: x86
target: i686-linux-gnu
cc: i686-linux-gnu-gcc
@@ -183,13 +365,67 @@ jobs:
sudo apt-get install -y \
build-essential \
wget \
- gcc-${{ matrix.target }} \
+ unzip \
pkg-config \
autoconf \
automake \
libtool \
file
+ - name: Set up Android NDK
+ run: |
+ NDK_VERSION="r26d"
+ echo "Downloading Android NDK ${NDK_VERSION}..."
+
+ # Download with retries and better error handling
+ for i in {1..3}; do
+ if wget -q "https://dl.google.com/android/repository/android-ndk-${NDK_VERSION}-linux.zip"; then
+ echo "✓ Downloaded android-ndk-${NDK_VERSION}-linux.zip (attempt $i)"
+ break
+ fi
+ echo "Download attempt $i failed, retrying..."
+ sleep 5
+ done
+
+ # Verify download
+ if [ ! -f "android-ndk-${NDK_VERSION}-linux.zip" ]; then
+ echo "❌ Failed to download NDK after 3 attempts"
+ exit 1
+ fi
+
+ echo "Extracting NDK..."
+ unzip -q android-ndk-${NDK_VERSION}-linux.zip
+
+ # Verify extraction
+ if [ ! -d "android-ndk-${NDK_VERSION}" ]; then
+ echo "❌ NDK extraction failed - directory not found"
+ ls -la
+ exit 1
+ fi
+
+ export ANDROID_NDK_ROOT="$(pwd)/android-ndk-${NDK_VERSION}"
+ echo "✓ NDK setup complete: ${ANDROID_NDK_ROOT}"
+ echo "ANDROID_NDK_ROOT=${ANDROID_NDK_ROOT}" >> $GITHUB_ENV
+
+ # Set up NDK toolchain paths
+ case "${{ matrix.arch }}" in
+ arm64)
+ echo "NDK_CC=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android28-clang" >> $GITHUB_ENV
+ echo "NDK_STRIP=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip" >> $GITHUB_ENV
+ echo "NDK_TARGET=aarch64-linux-android" >> $GITHUB_ENV
+ ;;
+ arm)
+ echo "NDK_CC=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi28-clang" >> $GITHUB_ENV
+ echo "NDK_STRIP=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip" >> $GITHUB_ENV
+ echo "NDK_TARGET=armv7a-linux-androideabi" >> $GITHUB_ENV
+ ;;
+ x86)
+ echo "NDK_CC=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android28-clang" >> $GITHUB_ENV
+ echo "NDK_STRIP=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip" >> $GITHUB_ENV
+ echo "NDK_TARGET=i686-linux-android" >> $GITHUB_ENV
+ ;;
+ esac
+
- name: Download iptables source
run: |
IPTABLES_VERSION="${{ github.event.inputs.iptables_version || '1.8.10' }}"
@@ -212,33 +448,67 @@ jobs:
run: |
cd "$IPTABLES_DIR"
- # Set cross-compilation environment
- export CC=${{ matrix.cc }}
- export STRIP=${{ matrix.strip }}
- export CFLAGS="-static -Os -DANDROID"
+ # Set Android NDK cross-compilation environment
+ export CC="${NDK_CC}"
+ export STRIP="${NDK_STRIP}"
+
+ # Set architecture-specific TLS flags and fix lock path
+ case "${{ matrix.arch }}" in
+ arm64)
+ export CFLAGS="-static -Os -DANDROID -D_GNU_SOURCE -Wno-logical-op -Wno-unknown-warning-option -fno-emulated-tls -DXTABLES_LOCK_DIR='\"/data/local/tmp\"'"
+ ;;
+ *)
+ export CFLAGS="-static -Os -DANDROID -D_GNU_SOURCE -Wno-logical-op -Wno-unknown-warning-option -DXTABLES_LOCK_DIR='\"/data/local/tmp\"'"
+ ;;
+ esac
+
export LDFLAGS="-static"
export PKG_CONFIG_PATH=""
- # Configure for cross-compilation
+ # Configure for Android cross-compilation
./configure \
- --host=${{ matrix.configure_host }} \
+ --host=${NDK_TARGET} \
--enable-static \
--disable-shared \
--disable-nftables \
--disable-bpf-compiler \
--disable-connlabel \
--disable-devel \
- --with-kernel=/usr/include
+ --with-kernel=/usr/include \
+ --disable-libipq \
+ --with-xtlockdir=/data/local/tmp
- name: Build iptables
run: |
cd "$IPTABLES_DIR"
- export CC=${{ matrix.cc }}
- export STRIP=${{ matrix.strip }}
- export CFLAGS="-static -Os -DANDROID"
+ export CC="${NDK_CC}"
+ export STRIP="${NDK_STRIP}"
+
+ # Set architecture-specific TLS flags and fix lock path
+ case "${{ matrix.arch }}" in
+ arm64)
+ export CFLAGS="-static -Os -DANDROID -D_GNU_SOURCE -Wno-logical-op -Wno-unknown-warning-option -fno-emulated-tls -DXTABLES_LOCK_DIR='\"/data/local/tmp\"'"
+ ;;
+ *)
+ export CFLAGS="-static -Os -DANDROID -D_GNU_SOURCE -Wno-logical-op -Wno-unknown-warning-option -DXTABLES_LOCK_DIR='\"/data/local/tmp\"'"
+ ;;
+ esac
+
export LDFLAGS="-static"
+ # Remove only the cgroup extension (has O_PATH macro conflict)
+ rm -f extensions/libxt_cgroup.c
+
+ # Fix prioritynames issue in LOG extension for Android compatibility
+ sed -i 's/prioritynames\[i\]\.c_name/0/g; s/prioritynames\[i\]\.c_val/0/g' extensions/libxt_LOG.c
+
+ # Fix hardcoded lock path for Android - replace /run/xtables.lock with /data/local/tmp/xtables.lock
+ find . -name "*.c" -o -name "*.h" | xargs grep -l "/run/xtables.lock" | while read file; do
+ sed -i 's|/run/xtables\.lock|/data/local/tmp/xtables.lock|g' "$file"
+ echo "Fixed lock path in $file"
+ done
+
# Build
make -j$(nproc) V=1
@@ -257,8 +527,8 @@ jobs:
file "../iptables_${{ matrix.arch }}"
file "../ip6tables_${{ matrix.arch }}"
- ${{ matrix.strip }} "../iptables_${{ matrix.arch }}"
- ${{ matrix.strip }} "../ip6tables_${{ matrix.arch }}"
+ ${NDK_STRIP} "../iptables_${{ matrix.arch }}"
+ ${NDK_STRIP} "../ip6tables_${{ matrix.arch }}"
- name: Upload iptables artifacts
uses: actions/upload-artifact@v4
@@ -273,7 +543,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- arch: [arm, arm64, mips, x86]
+ arch: [arm, arm64, x86]
include:
- arch: arm
target: arm-linux-gnueabihf
@@ -283,10 +553,6 @@ jobs:
target: aarch64-linux-gnu
cc: aarch64-linux-gnu-gcc
strip: aarch64-linux-gnu-strip
- - arch: mips
- target: mips-linux-gnu
- cc: mips-linux-gnu-gcc
- strip: mips-linux-gnu-strip
- arch: x86
target: i686-linux-gnu
cc: i686-linux-gnu-gcc
@@ -302,22 +568,25 @@ jobs:
sudo apt-get install -y \
build-essential \
wget \
- gcc-${{ matrix.target }} \
+ unzip \
pkg-config \
file \
- libnetfilter-log-dev
+ gcc-arm-linux-gnueabihf \
+ gcc-aarch64-linux-gnu \
+ gcc-i686-linux-gnu
- name: Build nflog from AFWall+ source
run: |
cd external/nflog
- # Compile nflog using AFWall+ source code
+ # Use GCC cross-compilers (revert from NDK to fix TLS issues) - no header fixes needed
${{ matrix.cc }} -static \
-I. -Ilibmnl \
+ -D_GNU_SOURCE \
-o nflog_${{ matrix.arch }} \
nflog.c attr.c callback.c nlmsg.c socket.c
- # Verify and strip
+ # Verify the binary
file nflog_${{ matrix.arch }}
${{ matrix.strip }} nflog_${{ matrix.arch }}
ls -la nflog_${{ matrix.arch }}
@@ -328,63 +597,11 @@ jobs:
name: nflog-${{ matrix.arch }}
path: external/nflog/nflog_${{ matrix.arch }}
- build-run-pie:
- name: Build run_pie (${{ matrix.arch }})
- runs-on: ubuntu-latest
- strategy:
- matrix:
- include:
- - arch: arm
- target: arm-linux-gnueabihf
- cc: arm-linux-gnueabihf-gcc
- strip: arm-linux-gnueabihf-strip
- - arch: arm64
- target: aarch64-linux-gnu
- cc: aarch64-linux-gnu-gcc
- strip: aarch64-linux-gnu-strip
- - arch: mips
- target: mips-linux-gnu
- cc: mips-linux-gnu-gcc
- strip: mips-linux-gnu-strip
- - arch: x86
- target: i686-linux-gnu
- cc: i686-linux-gnu-gcc
- strip: i686-linux-gnu-strip
-
- steps:
- - name: Checkout repository
- uses: actions/checkout@v4
-
- - name: Set up build environment
- run: |
- sudo apt-get update
- sudo apt-get install -y \
- build-essential \
- gcc-${{ matrix.target }} \
- file
-
- - name: Build run_pie from AFWall+ source
- run: |
- cd external/run_pie
-
- # Compile run_pie using AFWall+ source code
- ${{ matrix.cc }} -static -ldl -o run_pie_${{ matrix.arch }} run_pie.c
-
- # Verify the binary
- file run_pie_${{ matrix.arch }}
- ${{ matrix.strip }} run_pie_${{ matrix.arch }}
- ls -la run_pie_${{ matrix.arch }}
-
- - name: Upload run_pie artifact
- uses: actions/upload-artifact@v4
- with:
- name: run-pie-${{ matrix.arch }}
- path: external/run_pie/run_pie_${{ matrix.arch }}
collect-binaries:
name: Collect and Update Binaries
runs-on: ubuntu-latest
- needs: [build-busybox, build-iptables, build-nflog, build-run-pie]
+ needs: [build-busybox, build-iptables, build-nflog]
steps:
- name: Checkout repository
@@ -400,7 +617,7 @@ jobs:
# Create binaries directory for testing (separate from res/raw)
mkdir -p binaries
- for arch in arm arm64 mips x86; do
+ for arch in arm arm64 x86; do
# Busybox
if [ -f "artifacts/busybox-${arch}/busybox_${arch}" ]; then
cp "artifacts/busybox-${arch}/busybox_${arch}" "binaries/"
@@ -425,11 +642,6 @@ jobs:
echo "✓ nflog_${arch} -> binaries/"
fi
- # run_pie
- if [ -f "artifacts/run-pie-${arch}/run_pie_${arch}" ]; then
- cp "artifacts/run-pie-${arch}/run_pie_${arch}" "binaries/"
- echo "✓ run_pie_${arch} -> binaries/"
- fi
done
echo "Binary inventory:"
@@ -453,7 +665,7 @@ jobs:
echo "No new binaries to commit"
else
# Create commit message
- git commit -m "Update cross-compiled binaries - busybox v${{ github.event.inputs.busybox_version || '1.36.1' }}, iptables v${{ github.event.inputs.iptables_version || '1.8.10' }} for arm/arm64/mips/x86. Ready for testing in /binaries directory."
+ git commit -m "Update cross-compiled binaries - busybox v${{ github.event.inputs.busybox_version || '1.36.1' }}, iptables v${{ github.event.inputs.iptables_version || '1.8.10' }} for arm/arm64/x86. Ready for testing in /binaries directory."
# Push changes back to repository
git push
@@ -480,11 +692,10 @@ jobs:
name: AFWall+ Cross-compiled Binaries ${{ github.event.inputs.release_tag }}
body: |
Cross-compiled binaries for AFWall+:
- - busybox (arm, arm64, mips, x86)
- - iptables (arm, arm64, mips, x86)
- - ip6tables (arm, arm64, mips, x86)
- - nflog (arm, arm64, mips, x86)
- - run_pie (arm, arm64, mips, x86)
+ - busybox (arm, arm64, x86)
+ - iptables (arm, arm64, x86)
+ - ip6tables (arm, arm64, x86)
+ - nflog (arm, arm64, x86)
Built from commit: ${{ github.sha }}
files: binaries/*
diff --git a/Changelog.md b/Changelog.md
index fa1d929a9..e054d8bbe 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -1,6 +1,101 @@
AFWall+ Changelog
==================
+AFWall+ v4.0.1
+
+ Fixed boot rules not being applied (#1438)
+ Fixed app search not working (#1445)
+ Fixed pull to refresh when list is empty (#1439)
+ Updated Magisk binary location (#1437)
+ Relaxed sanitize rule to allow existing custom rules
+ Added back button to PreferencesActivity
+ Optimized pattern handling and memory management
+ Added build scripts for F-Droid (#1441)
+
+AFWall+ v4.0.0
+
+🚀 Major Features & Enhancements
+
+🎯 Rule Management & Stability
+
+- Fixed critical rule application issues - Resolved iptables command failures and cascade errors
+- Improved error handling - Smart selective error handling prevents unnecessary fallbacks
+- Enhanced chain management - Better synchronization prevents race conditions
+- Owner module compatibility - Automatic detection and fallback for devices without owner
+ iptables module
+
+🎨 Material Design Overhaul
+
+- Modernized UI - Material Design enhancements for rules, help, and custom scripts views
+- Revamped help section - Complete redesign with better organization and moved legends
+- Visual widget indicators - Added pulse animations and visual feedback for toggle widgets
+- Improved layouts - Fixed layout issues for devices with merged status bars
+
+📊 Enhanced Logging System
+
+- Better log details view - Enhanced display with allow/deny address information
+- Improved UID detection - Better handling of special UIDs (including uid -100) and bug fixes
+- Seamless log target switching - Dynamic switching between LOG and NFLOG in preferences
+- NFLOG improvements - Better NFLOG and LOG handling with updated binaries
+
+🔒 Security Enhancements
+
+- Upgraded encryption - Migrated from DES to AES for better security
+- Enhanced security utilities - New SecureCrypto and SecurityUtil classes
+- Input validation improvements - Better validation and security checks
+
+🛠 Platform & Compatibility
+
+📱 Android Support
+
+- Android 16 preparation - Updated build configuration for future Android support
+- Binary updates - Cross-compiled binaries: busybox v1.36.1, iptables v1.8.10
+- Architecture support - Added ARM64 binaries and improved architecture detection
+- GitHub Actions CI - Automated binary builds and improved CI/CD pipeline
+
+🔧 Bug Fixes & Stability
+
+- Export/Import fixes - Resolved bugs when handling large numbers of files (#1399, #1401)
+- Build error fixes - Fixed app:tint and other build-related issues
+- Service leak fixes - Improved thread safety and fixed service connection leaks
+- USB tethering support - Added auto-detection and support for USB tethering
+- DNS forwarding - Improved DNS handling for tethering scenarios
+
+🔧 Technical Improvements
+
+⚡ Performance & Threading
+
+- Thread safety - Improved synchronization and thread-safe operations
+- Better exception handling - More robust error handling and recovery
+- Optimized rule processing - Faster and more reliable rule application
+
+🛠 Developer Experience
+
+- Code cleanup - Extensive refactoring and code organization improvements
+- CI/CD enhancements - Updated GitHub Actions and automated workflows
+- Binary management - Automated cross-compilation and binary distribution
+
+📋 Specific Issue Fixes
+
+- #1386 - Default chain rules only applied when necessary (with smart revert)
+- #1410 - Fallback on default commands when needed
+- #1423, #1382 - Various stability and functionality fixes
+- #1400 - Layout fixes for merged status bar screens
+- #1399 - Export only enabled rule types
+- #1169 - Export/import rule improvements
+
+⚠️ Breaking Changes
+
+- Security upgrade - DES encryption deprecated in favor of AES
+- Removed legacy views - Old unsupported view components removed
+- Binary updates - Requires newer binaries for optimal performance
+
+🙏 Contributors
+
+- @getgo-nobugs - Syntax fixes and improvements
+- @NeroProtagonist - CI/CD updates (upload-artifact@v4)
+- @Fry-kun - Multiple fixes: typos, layout improvements, export fixes, ARM64 NFLOG binary (initial version)
+
Version 3.6.0
* Updated libraries and SDK (33)
diff --git a/README.md b/README.md
index 29f35494e..d3333d19d 100644
--- a/README.md
+++ b/README.md
@@ -4,33 +4,70 @@
> **Your Privacy, Your Control** - AFWall+ gives you complete control over which apps can access the internet on your Android device.
+---
+
+
+## Support AFWall+ Development
+
+AFWall+ is developed and maintained by volunteers. If you find it useful, please consider supporting the project:
+
+### How to Donate
+
+**Why donate?** AFWall+ is free and open-source. Your support helps:
+- Continue development and add new features
+- Fix bugs and keep the app stable
+- Support more Android versions and devices
+- Maintain documentation and help the community
+
+**Donation options:**
+- **PayPal**: [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6E4VZTULRB8GU)
+- **Google Play**: Purchase the [unlocker key](https://play.google.com/store/apps/details?id=dev.ukanth.ufirewall.donate) for extra features
+- **Amazon Gift Cards**: `cumakt+amazon at gmail.com` (not preferred)
+- **Bitcoin**: `bc1q54nf3y9zmdcpasxx9sywkprd6309rfhav3mape`
+- **Ethereum**: `0x5e65649C2B26eD816fCeD25a8E507C90D4b1D697`
+
+After donating, please send your receipt to contact@portgenix.com to receive an unlocker. Please allow 1-2 days for a response.
+
+### Other Ways to Help
+- Star this repository
+- Report bugs and test new features
+- Contribute translations on [Crowdin](http://crowdin.net/project/afwall)
+- Improve documentation
+- Help other users in forums
+
+---
+
-## 🔥 What is AFWall+?
+
+## What is AFWall+?
**AFWall+ (Android Firewall+)** is a powerful, open-source firewall application for rooted Android devices. Built on Linux's robust `iptables` framework, AFWall+ provides **granular network control** at the system level - something impossible with standard Android permissions.
-### 🎯 **Core Purpose**
-- **Block unwanted network access** by apps, even when they have internet permission
-- **Prevent data leaks** and unauthorized background connections
-- **Monitor network activity** with comprehensive logging
-- **Save battery and data** by controlling which apps can connect when
-- **Enhance privacy** by blocking tracking and analytics
-### 🛡️ **How It Works**
-AFWall+ operates at the **Linux kernel level** using `iptables` rules to:
-1. **Intercept all network requests** before they leave your device
-2. **Apply custom firewall rules** based on your preferences
-3. **Allow or block connections** per app, per network type (WiFi, mobile, VPN)
-4. **Log blocked attempts** for monitoring and analysis
+### Core Purpose
+- Block unwanted network access by apps, even if they have internet permission
+- Prevent data leaks and unauthorized background connections
+- Monitor network activity with comprehensive logging
+- Save battery and data by controlling which apps can connect
+- Enhance privacy by blocking tracking and analytics
-This approach is **far more powerful** than app-level solutions because it works regardless of how apps try to connect to the internet.
+
+### How It Works
+AFWall+ operates at the Linux kernel level using `iptables` rules to:
+1. Intercept all network requests before they leave your device
+2. Apply custom firewall rules based on your preferences
+3. Allow or block connections per app, per network type (WiFi, mobile, VPN)
+4. Log blocked attempts for monitoring and analysis
+
+This approach is much more powerful than app-level solutions because it works regardless of how apps try to connect to the internet.
---
-## 📥 Download
+
+## Download