-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
1 parent
80768df
commit 64f1a28
Showing
4 changed files
with
148 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
|
||
antiblock | grep "AntiBlock started" |