add openwrt-chinadns-ng
This commit is contained in:
parent
f3c5affbfb
commit
7605339c58
@ -52,7 +52,8 @@ v2ray-plugin source: [honwen/openwrt-v2ray-plugin](https://github.com/honwen/ope
|
||||
Package zxlhhyccc: [zxlhhyccc/MY-lede](https://github.com/zxlhhyccc/MY-lede).<br/>
|
||||
luci-theme-argonv3 source: [jerrykuku/luci-theme-argon](https://github.com/jerrykuku/luci-theme-argon).<br/>
|
||||
luci-theme-darkmatter source: [apollo-ng/luci-theme-darkmatter](https://github.com/apollo-ng/luci-theme-darkmatter).<br/>
|
||||
luci-app-koolproxyR source: [tzxiaozhen88/koolproxyR](https://github.com/tzxiaozhen88/koolproxyR).
|
||||
luci-app-koolproxyR source: [tzxiaozhen88/koolproxyR](https://github.com/tzxiaozhen88/koolproxyR).<br/>
|
||||
openwrt-chinadns-ng source: [pexcn/openwrt-chinadns-ng](https://github.com/pexcn/openwrt-chinadns-ng).
|
||||
|
||||
# License
|
||||
### [GPL v3](https://www.gnu.org/licenses/gpl-3.0.html).
|
||||
|
||||
58
package/cnsztl/openwrt-chinadns-ng/Makefile
Normal file
58
package/cnsztl/openwrt-chinadns-ng/Makefile
Normal file
@ -0,0 +1,58 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=chinadns-ng
|
||||
PKG_VERSION:=1.0-beta.11
|
||||
PKG_RELEASE:=1
|
||||
#PKG_USE_MIPS16:=0
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/zfl9/chinadns-ng.git
|
||||
PKG_SOURCE_VERSION:=0b4883634cd23f3038bb34e68cc74f924d91903d
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION)
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)/$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION)
|
||||
|
||||
PKG_LICENSE:=GPLv3
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
PKG_MAINTAINER:=pexcn <i@pexcn.me>
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/chinadns-ng
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=ChinaDNS next generation, refactoring with epoll and ipset.
|
||||
URL:=https://github.com/zfl9/chinadns-ng
|
||||
DEPENDS:=+ipset
|
||||
endef
|
||||
|
||||
define Package/chinadns-ng/description
|
||||
ChinaDNS next generation, refactoring with epoll and ipset.
|
||||
endef
|
||||
|
||||
define Package/chinadns-ng/conffiles
|
||||
/etc/config/chinadns-ng
|
||||
/etc/chinadns-ng/chnroute.txt
|
||||
/etc/chinadns-ng/chnroute6.txt
|
||||
endef
|
||||
|
||||
define Package/chinadns-ng/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/chinadns-ng $(1)/usr/bin
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) files/chinadns-ng.init $(1)/etc/init.d/chinadns-ng
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_DATA) files/chinadns-ng.config $(1)/etc/config/chinadns-ng
|
||||
$(INSTALL_DIR) $(1)/etc/chinadns-ng
|
||||
$(INSTALL_DATA) files/chnroute.txt $(1)/etc/chinadns-ng/chnroute.txt
|
||||
$(INSTALL_DATA) files/chnroute6.txt $(1)/etc/chinadns-ng/chnroute6.txt
|
||||
endef
|
||||
|
||||
define Package/chinadns-ng/postrm
|
||||
#!/bin/sh
|
||||
rmdir --ignore-fail-on-non-empty /etc/chinadns-ng
|
||||
exit 0
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,chinadns-ng))
|
||||
15
package/cnsztl/openwrt-chinadns-ng/files/chinadns-ng.config
Normal file
15
package/cnsztl/openwrt-chinadns-ng/files/chinadns-ng.config
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
config chinadns-ng
|
||||
option enable '0'
|
||||
option bind_addr '0.0.0.0'
|
||||
option bind_port '5353'
|
||||
option china_dns '119.29.29.29'
|
||||
option trust_dns '127.0.0.1#5300'
|
||||
option ipset_name_4 'chnroute'
|
||||
option ipset_name_6 'chnroute6'
|
||||
option timeout_sec '3'
|
||||
option repeat_times '1'
|
||||
option fair_mode '0'
|
||||
option reuse_port '1'
|
||||
option noip_as_chnip '0'
|
||||
|
||||
142
package/cnsztl/openwrt-chinadns-ng/files/chinadns-ng.init
Normal file
142
package/cnsztl/openwrt-chinadns-ng/files/chinadns-ng.init
Normal file
@ -0,0 +1,142 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
#
|
||||
# Copyright (C) 2019 pexcn <i@pexcn.me>
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
START=90
|
||||
|
||||
USE_PROCD=1
|
||||
#PROCD_DEBUG=1
|
||||
|
||||
append_param() {
|
||||
local section="$1"
|
||||
local option="$2"
|
||||
local switch="$3"
|
||||
local default="$4"
|
||||
local _loctmp
|
||||
config_get _loctmp "$section" "$option"
|
||||
[ -n "$_loctmp" -o -n "$default" ] || return 0
|
||||
procd_append_param command "$switch" "${_loctmp:-$default}"
|
||||
}
|
||||
|
||||
append_bool() {
|
||||
local section="$1"
|
||||
local option="$2"
|
||||
local value="$3"
|
||||
local default="$4"
|
||||
local _loctmp
|
||||
config_get_bool _loctmp "$section" "$option" "$default"
|
||||
[ "$_loctmp" = 1 ] || return 0
|
||||
procd_append_param command "$value"
|
||||
}
|
||||
|
||||
create_chnroute_ipset() {
|
||||
local enable
|
||||
config_get_bool enable $1 enable
|
||||
[ "$enable" = 1 ] || return 0
|
||||
|
||||
create_ipv4_ipset
|
||||
create_ipv6_ipset
|
||||
}
|
||||
|
||||
create_ipv4_ipset() {
|
||||
local ipset_name
|
||||
config_get ipset_name "$1" "ipset_name_4" "chnroute"
|
||||
|
||||
if ipset list -n $ipset_name &>/dev/null; then
|
||||
ipset flush $ipset_name
|
||||
else
|
||||
ipset create $ipset_name hash:net hashsize 64 family inet
|
||||
fi
|
||||
|
||||
# add chnroute
|
||||
ipset restore <<- EOF
|
||||
$(cat /etc/chinadns-ng/chnroute.txt | sed "s/^/add $ipset_name /")
|
||||
EOF
|
||||
}
|
||||
|
||||
create_ipv6_ipset() {
|
||||
local ipset_name
|
||||
config_get ipset_name "$1" "ipset_name_6" "chnroute6"
|
||||
|
||||
if ipset list -n $ipset_name &>/dev/null; then
|
||||
ipset flush $ipset_name
|
||||
else
|
||||
ipset create $ipset_name hash:net hashsize 64 family inet6
|
||||
fi
|
||||
|
||||
# add chnroute6
|
||||
ipset restore <<- EOF
|
||||
$(cat /etc/chinadns-ng/chnroute6.txt | sed "s/^/add $ipset_name /")
|
||||
EOF
|
||||
}
|
||||
|
||||
destroy_chnroute_ipset() {
|
||||
# now force destroy
|
||||
#local enable
|
||||
#config_get_bool enable $1 enable
|
||||
#[ "$enable" = 1 ] || return 0
|
||||
|
||||
destroy_ipv4_ipset
|
||||
destroy_ipv6_ipset
|
||||
}
|
||||
|
||||
destroy_ipv4_ipset() {
|
||||
local ipset_name
|
||||
config_get ipset_name "$1" "ipset_name_4" "chnroute"
|
||||
ipset flush $ipset_name 2>/dev/null
|
||||
ipset destroy $ipset_name 2>/dev/null
|
||||
}
|
||||
|
||||
destroy_ipv6_ipset() {
|
||||
local ipset_name
|
||||
config_get ipset_name "$1" "ipset_name_6" "chnroute6"
|
||||
ipset flush $ipset_name 2>/dev/null
|
||||
ipset destroy $ipset_name 2>/dev/null
|
||||
}
|
||||
|
||||
start_chinadns_ng() {
|
||||
local enable
|
||||
config_get_bool enable $1 enable
|
||||
[ "$enable" = 1 ] || return 0
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param respawn
|
||||
procd_set_param stderr 1
|
||||
procd_set_param nice -5
|
||||
procd_set_param limits nofile="65535 65535"
|
||||
[ -e /proc/sys/kernel/core_pattern ] && {
|
||||
procd_append_param limits core="unlimited"
|
||||
}
|
||||
procd_set_param command /usr/bin/chinadns-ng
|
||||
append_param $1 bind_addr "-b"
|
||||
append_param $1 bind_port "-l"
|
||||
append_param $1 china_dns "-c"
|
||||
append_param $1 trust_dns "-t"
|
||||
append_param $1 ipset_name_4 "-4"
|
||||
append_param $1 ipset_name_6 "-6"
|
||||
append_param $1 timeout_sec "-o"
|
||||
local repeat_times_tmp
|
||||
config_get repeat_times_tmp "$1" "repeat_times" "1"
|
||||
[ $repeat_times_tmp -gt "1" ] && {
|
||||
append_param $1 repeat_times "-p"
|
||||
}
|
||||
append_bool $1 fair_mode "-f"
|
||||
append_bool $1 reuse_port "-r"
|
||||
append_bool $1 noip_as_chnip "-n"
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
start_service() {
|
||||
config_load chinadns-ng
|
||||
config_foreach create_chnroute_ipset chinadns-ng
|
||||
config_foreach start_chinadns_ng chinadns-ng
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
config_load chinadns-ng
|
||||
config_foreach destroy_chnroute_ipset chinadns-ng
|
||||
}
|
||||
5404
package/cnsztl/openwrt-chinadns-ng/files/chnroute.txt
Normal file
5404
package/cnsztl/openwrt-chinadns-ng/files/chnroute.txt
Normal file
File diff suppressed because it is too large
Load Diff
1773
package/cnsztl/openwrt-chinadns-ng/files/chnroute6.txt
Normal file
1773
package/cnsztl/openwrt-chinadns-ng/files/chnroute6.txt
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user