Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

antiblock: add new package #25694

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions net/antiblock/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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:=v$(PKG_VERSION)
PKG_MIRROR_HASH:=3ea495e825edb75bc0bec9010d4b0195442dbcc745fc4d3150ae41ca11e9dfc4

PKG_MAINTAINER:=Khachatryan Karen <[email protected]>
PKG_LICENSE:=GPL-3.0-or-later
karen07 marked this conversation as resolved.
Show resolved Hide resolved
PKG_LICENSE_FILES:=LICENSE

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))
14 changes: 14 additions & 0 deletions net/antiblock/files/etc/config/antiblock
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

#config antiblock 'config'
#option enabled '0'
#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'
83 changes: 83 additions & 0 deletions net/antiblock/files/etc/init.d/antiblock
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/sh /etc/rc.common

USE_PROCD=1
START=99

CONF="antiblock"

start_service() {
config_load "$CONF"

local _enabled
config_get_bool _enabled "config" "enabled" "0"
[ "${_enabled}" -eq "0" ] && return 1

echo "AntiBlock start"

local _url
local _file
local _listen
local _DNS
local _VPN_name
local _log
local _stat
local _output

config_get _url "config" "url"
config_get _file "config" "file"

config_get _listen "config" "listen"
config_get _DNS "config" "DNS"
config_get _VPN_name "config" "VPN_name"

config_get_bool _log "config" "log" "0"
config_get_bool _stat "config" "stat" "0"
config_get _output "config" "output"

procd_open_instance "$CONF"

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

[ -n "${_url}" ] && procd_append_param command -url "${_url}"
[ -n "${_file}" ] && procd_append_param command -file "${_file}"

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
[ -n "${_DNS}" ] && procd_append_param command -DNS "${_DNS}"
if [ -n "${_VPN_name}" ]; then
local gateway="$(uci -q get network."${_VPN_name}".addresses | cut -d '/' -f1)"
procd_append_param command -gateway "$gateway"
fi

[ "${_log}" -ne "0" ] && procd_append_param command -log
[ "${_stat}" -ne "0" ] && procd_append_param command -stat
if [ -n "${_output}" ]; then
mkdir -p "${_output}"
procd_append_param command -output "${_output}"
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 "$CONF"
}
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"
Loading