Skip to content

Commit

Permalink
antiblock: Add AntiBlock package
Browse files Browse the repository at this point in the history
AntiBlock program proxies DNS requests.
The IP addresses of the specified domains are added to
the routing table for routing through the specified interface.

Signed-off-by: Khachatryan Karen <[email protected]>
  • Loading branch information
karen07 committed Jan 12, 2025
1 parent 99a4a0f commit 2529678
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 0 deletions.
47 changes: 47 additions & 0 deletions net/antiblock/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=antiblock
PKG_VERSION:=2.0.0
PKG_RELEASE:=1

PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/karen07/antiblock
PKG_SOURCE_VERSION:=f97a9790ae2310e0cb0fa97786974f0cecfda789
PKG_MIRROR_HASH:=51b37291f603a7f84e736ba0683ceccf79a8cd231788531824b1341b16cbb22a

PKG_MAINTAINER:=Khachatryan Karen <[email protected]>
PKG_LICENSE:=GPL-3.0-or-later

include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk

define Package/antiblock
SECTION:=net
CATEGORY:=Network
DEPENDS:=+libcurl
TITLE:=AntiBlock
URL:=https://github.com/karen07/antiblock
endef

define Package/antiblock/description
AntiBlock program proxies DNS requests.
The IP addresses of the specified domains are added to
the routing table for routing through the specified interface.
endef

define Package/antiblock/conffiles
/etc/config/antiblock
endef

define Package/antiblock/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/antiblock $(1)/usr/bin/antiblock

$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/etc/init.d/antiblock $(1)/etc/init.d/antiblock

$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) ./files/etc/config/antiblock $(1)/etc/config/antiblock
endef

$(eval $(call BuildPackage,antiblock))
13 changes: 13 additions & 0 deletions net/antiblock/files/etc/config/antiblock
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

#config antiblock
#At least one parameters needs to be filled:
#option url 'https://antifilter.download/list/domains.lst'
#option file '/root/my_urls.txt'
#Required parameters:
#option listen '192.168.1.1:5053'
#option DNS '1.1.1.1:53'
#option VPN_name 'VPN'
#Optional parameters:
#option log '1'
#option stat '1'
#option output '/tmp/antiblock'
71 changes: 71 additions & 0 deletions net/antiblock/files/etc/init.d/antiblock
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/sh /etc/rc.common

START=99
USE_PROCD=1

start_service() {
echo "AntiBlock start"

local log="$(uci -q get antiblock.@antiblock[0].log)"
local stat="$(uci -q get antiblock.@antiblock[0].stat)"
local url="$(uci -q get antiblock.@antiblock[0].url)"
local file="$(uci -q get antiblock.@antiblock[0].file)"
local output="$(uci -q get antiblock.@antiblock[0].output)"
local DNS="$(uci -q get antiblock.@antiblock[0].DNS)"
local listen="$(uci -q get antiblock.@antiblock[0].listen)"
local VPN_name="$(uci -q get antiblock.@antiblock[0].VPN_name)"

procd_open_instance

procd_set_param command "/usr/bin/antiblock"
procd_set_param stdout 1

if [ -n "$log" ]; then
procd_append_param command -log
fi
if [ -n "$stat" ]; then
procd_append_param command -stat
fi
if [ -n "$url" ]; then
procd_append_param command -url "$url"
fi
if [ -n "$file" ]; then
procd_append_param command -file "$file"
fi
if [ -n "$output" ]; then
mkdir -p "$output"
procd_append_param command -output "$output"
fi
if [ -n "$DNS" ]; then
procd_append_param command -DNS "$DNS"
fi
if [ -n "$listen" ]; then
local listen_IP="$(echo "$listen" | cut -d ':' -f1)"
local listen_port="$(echo "$listen" | cut -d ':' -f2)"
uci -q set dhcp.@dnsmasq[0].noresolv="1"
uci -q delete dhcp.@dnsmasq[0].server
uci -q add_list dhcp.@dnsmasq[0].server="$listen_IP#$listen_port"

procd_append_param command -listen "$listen"
fi
if [ -n "$VPN_name" ]; then
local gateway="$(uci -q get network."$VPN_name".addresses | cut -d '/' -f1)"
procd_append_param command -gateway "$gateway"
fi

procd_close_instance

/etc/init.d/dnsmasq restart >/dev/null 2>&1
}

stop_service() {
echo "AntiBlock stop"

uci -q revert dhcp.@dnsmasq[0]

/etc/init.d/dnsmasq restart >/dev/null 2>&1
}

service_triggers() {
procd_add_reload_trigger "antiblock"
}
3 changes: 3 additions & 0 deletions net/antiblock/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

antiblock | grep "AntiBlock started"

0 comments on commit 2529678

Please sign in to comment.