1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00
This commit is contained in:
suyuan168 2022-06-09 11:44:13 +08:00
parent d4ceecb05b
commit a8fff12089
13 changed files with 6747 additions and 0 deletions

61
dnsforwarder/Makefile Normal file
View file

@ -0,0 +1,61 @@
#
# Copyright (C) 2021 ImmortalWrt
# <https://immortalwrt.org>
#
# This is free software, licensed under the GNU General Public License v3.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=dnsforwarder
PKG_VERSION:=6.1.15
PKG_RELEASE:=11
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/1715173329/dnsforwarder.git
PKG_SOURCE_DATE:=2018-06-26
PKG_SOURCE_VERSION:=587e61ae4d75dc976f538088b715a3c8ee26c144
PKG_MIRROR_HASH:=7c141040ae384d254d90b3c3ee502d87330c9fdcd201ff29a669336a27b176d4
PKG_LICENSE:=GPL-3.0
PKG_LICENSE_FILE:=LICENSE
PKG_MAINTAINER:=Dennis <openwrt@tossp.com>
PKG_FIXUP:=autoreconf
PKG_BUILD_PARALLEL:=1
PKG_INSTALL:=1
include $(INCLUDE_DIR)/package.mk
define Package/dnsforwarder
SECTION:=net
CATEGORY:=Network
TITLE:=A simple DNS forwarder
URL:=https://github.com/holmium/dnsforwarder
DEPENDS:=+coreutils +coreutils-base64 +dnsmasq-full +libpthread +wget-ssl
endef
define Package/dnsforwarder/description
Forwarding queries to customized domains (and their subdomains) to specified servers
over a specified protocol (UDP or TCP). non-standard ports are supported.
endef
CONFIGURE_ARGS+= --enable-downloader=wget
define Package/dnsforwarder/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/dnsforwarder $(1)/usr/bin/dnsforwarder
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) files/etc/config/dnsforwarder $(1)/etc/config/dnsforwarder
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) files/etc/init.d/dnsforwarder $(1)/etc/init.d/dnsforwarder
$(INSTALL_DIR) $(1)/etc/dnsforwarder
$(INSTALL_CONF) files/etc/dnsforwarder/gfw.txt $(1)/etc/dnsforwarder/gfw.txt
$(INSTALL_DIR) $(1)/usr/share/dnsforwarder
$(INSTALL_BIN) files/usr/share/dnsforwarder/gfwlist.sh $(1)/usr/share/dnsforwarder/gfwlist.sh
endef
$(eval $(call BuildPackage,dnsforwarder))

View file

@ -0,0 +1,79 @@
config arguments
option enabled '0'
option addr '127.0.0.1:5053'
config config
option cache 'true'
option cache_size '102400'
option cache_ignore 'false'
option gfw 'true'
list block_ip '74.125.127.102'
list block_ip '74.125.155.102'
list block_ip '74.125.39.102'
list block_ip '74.125.39.113'
list block_ip '209.85.229.138'
list block_ip '128.121.126.139'
list block_ip '159.106.121.75'
list block_ip '169.132.13.103'
list block_ip '192.67.198.6'
list block_ip '202.106.1.2'
list block_ip '202.181.7.85'
list block_ip '203.161.230.171'
list block_ip '203.98.7.65'
list block_ip '207.12.88.98'
list block_ip '208.56.31.43'
list block_ip '209.145.54.50'
list block_ip '209.220.30.174'
list block_ip '209.36.73.33'
list block_ip '211.94.66.147'
list block_ip '213.169.251.35'
list block_ip '216.221.188.182'
list block_ip '216.234.179.13'
list block_ip '243.185.187.39'
list block_ip '37.61.54.158'
list block_ip '4.36.66.178'
list block_ip '46.82.174.68'
list block_ip '59.24.3.173'
list block_ip '64.33.88.161'
list block_ip '64.33.99.47'
list block_ip '64.66.163.251'
list block_ip '65.104.202.252'
list block_ip '65.160.219.113'
list block_ip '66.45.252.237'
list block_ip '69.55.52.253'
list block_ip '72.14.205.104'
list block_ip '72.14.205.99'
list block_ip '78.16.49.15'
list block_ip '8.7.198.45'
list block_ip '93.46.8.89'
list block_ip '37.61.54.158'
list block_ip '243.185.187.39'
list block_ip '190.93.247.4'
list block_ip '190.93.246.4'
list block_ip '190.93.245.4'
list block_ip '190.93.244.4'
list block_ip '65.49.2.178'
list block_ip '189.163.17.5'
list block_ip '23.89.5.60'
list block_ip '49.2.123.56'
list block_ip '54.76.135.1'
list block_ip '77.4.7.92'
list block_ip '118.5.49.6'
list block_ip '159.24.3.173'
list block_ip '188.5.4.96'
list block_ip '197.4.4.12'
list block_ip '220.250.64.24'
list block_ip '243.185.187.30'
list block_ip '249.129.46.48'
list block_ip '253.157.14.165'
option block_ipv6 'false'
list cache_control 'tossp.com $orig'
list cache_control '* fixed 3600'
option log 'false'
list udp_group '9.9.9.9,119.29.29.29,223.5.5.5,114.114.114.114 * on'
option block_negative_resp 'true'
list udp_local '0.0.0.0:5053'
list udp_local '[::0]:5053'
option domain_statistic 'false'

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,260 @@
#!/bin/sh /etc/rc.common
START=60
EXTRA_COMMANDS="makeconfig makegfwlist health"
CRON_FILE=/etc/crontabs/root
PID_PATH=/var/run/dnsforwarder
PID_FILE=${PID_PATH}/dns.pid
DNSFORWARDER_CONF=/tmp/dnsforwarder.conf
add_cron()
{
sed -i '/dnsforwarder/d' $CRON_FILE
echo '*/5 * * * * /etc/init.d/dnsforwarder health' >> $CRON_FILE
echo '0 1 * * 0 /etc/init.d/dnsforwarder makegfwlist' >> $CRON_FILE
crontab $CRON_FILE
}
del_cron()
{
sed -i '/dnsforwarder/d' $CRON_FILE
/etc/init.d/cron restart
}
fixturboacc(){
dns=$(uci get turboacc.config.dns_caching 2>/dev/null)
if [ $dns -eq 1 ]; then
uci set turboacc.config.dns_caching=0 && uci commit turboacc
/etc/init.d/turboacc restart
fi
}
makelist() {
[ -z "$2" ] && return
local i
local t="$1"; shift
for i in "$@"
do
echo "$t $i"
done
}
health(){
rm /var/log/dnsforwarder.log.* 2>/dev/null
local pid=$(cat ${PID_FILE} 2>/dev/null)
if [ -n "${pid}" -a -d /proc/$pid ]; then
echo "[health] process exists ${pid}"
else
echo "[health] Dnsforwarder is not running ${pid}"
start
fi
}
makegfwlist(){
local GFW_FILE='/etc/dnsforwarder/gfw.txt'
local GFW_TMP_FILE='/tmp/dnsforwarder-gfw.old'
local TSTIME=`date '+%Y-%m-%d %H:%M:%S'`
touch ${GFW_TMP_FILE}
cat /etc/config/gfw.list 2>/dev/null > /tmp/edf.ts
cat /etc/dnsmasq.ssr/gfw_base.conf 2>/dev/null | awk -F '/' '{print $2}' | sed 's/^.//g' >> /tmp/edf.ts
cat /etc/dnsmasq.ssr/gfw_list.conf 2>/dev/null | awk -F '/' '{print $2}' | sed 's/^.//g' >> /tmp/edf.ts
sort /tmp/edf.ts | uniq > /tmp/edf.ts
/usr/share/dnsforwarder/gfwlist.sh -i -l -o /tmp/dnsforwarder-gfw.tmp --extra-domain-file /tmp/edf.ts
if [ $? != 0 ]; then
echo 'Failed to fetch gfwlist'
logger -t Failed to fetch gfwlist
return 2
fi
local gfw=$(cat /tmp/dnsforwarder-gfw.tmp)
echo "# GenerationAt TS_BUILD_TIME" > ${GFW_TMP_FILE}.new
echo "protocol tcp" >> ${GFW_TMP_FILE}.new
echo "server 8.8.8.8,8.8.4.4,1.1.1.1,1.0.0.1,208.67.222.222,208.67.220.220,209.244.0.3,209.244.0.4,8.26.56.26,8.20.247.20,156.154.70.1,156.154.71.1,199.85.126.10" >> ${GFW_TMP_FILE}.new
echo -e 'proxy no\n\n\n' >> ${GFW_TMP_FILE}.new
echo "${gfw}" >> ${GFW_TMP_FILE}.new
if [ "`cat ${GFW_TMP_FILE}.new | md5sum`" == "`cat ${GFW_TMP_FILE} | md5sum`" ]; then
printf "[\e[32m%s\e[0m]\n" "hold"
else
cp ${GFW_TMP_FILE}.new ${GFW_TMP_FILE}
cp ${GFW_TMP_FILE} ${GFW_FILE}
sed -i "s/TS_BUILD_TIME/${TSTIME}/g" ${GFW_FILE}
printf "[\e[33m%s\e[0m]" "PID"
restart
fi
}
makeconfig () {
config_load dnsforwarder
local log=$(uci get dnsforwarder.@config[0].log 2>/dev/null)
local log_size=$(uci get dnsforwarder.@config[0].log_size 2>/dev/null)
local gfw=$(uci get dnsforwarder.@config[0].gfw 2>/dev/null)
local udp_local=$(uci -d ',' get dnsforwarder.@config[0].udp_local 2>/dev/null)
local udp_local_list=$(uci get dnsforwarder.@config[0].udp_local 2>/dev/null)
local tcp_group=$(uci get dnsforwarder.@config[0].tcp_group 2>/dev/null)
local udp_group=$(uci get dnsforwarder.@config[0].udp_group 2>/dev/null)
local group_file=$(uci get dnsforwarder.@config[0].group_file 2>/dev/null)
local block_ip=$(uci -d ',' get dnsforwarder.@config[0].block_ip 2>/dev/null)
local ip_substituting=$(uci -d ',' get dnsforwarder.@config[0].ip_substituting 2>/dev/null)
local block_negative_resp=$(uci get dnsforwarder.@config[0].block_negative_resp 2>/dev/null)
local append_host=$(uci get dnsforwarder.@config[0].append_host 2>/dev/null)
local block_ipv6=$(uci get dnsforwarder.@config[0].block_ipv6 2>/dev/null)
local cache=$(uci get dnsforwarder.@config[0].cache 2>/dev/null)
local cache_size=$(uci get dnsforwarder.@config[0].cache_size 2>/dev/null)
local cache_ignore=$(uci get dnsforwarder.@config[0].cache_ignore 2>/dev/null)
local cache_control=$(uci get dnsforwarder.@config[0].cache_control 2>/dev/null)
local domain_statistic=$(uci get dnsforwarder.@config[0].domain_statistic 2>/dev/null)
local udp_local_addr=$(uci get dnsforwarder.@arguments[0].addr 2>/dev/null)
udp_local_addr=${udp_local_addr/:/#}
echo "LogOn ${log}" > $DNSFORWARDER_CONF
if [ $log = "true" ]; then
rm /var/log/dnsforwarder.log.* 2>/dev/null
echo '' > /var/log/dnsforwarder.log
echo "LogFileThresholdLength ${log_size}" >> $DNSFORWARDER_CONF
echo "LogFileFolder /var/log" >> $DNSFORWARDER_CONF
fi
[ -n "$udp_local" ] && echo "UDPLocal ${udp_local}" >> $DNSFORWARDER_CONF
[ -n "$udp_local_addr" ] && eval "makelist 'server=' $udp_local_addr" > /tmp/dnsmasq.dnsforwarder.conf
sed -i "s/ //g" /tmp/dnsmasq.dnsforwarder.conf
eval "makelist 'TCPGroup' $tcp_group" >> $DNSFORWARDER_CONF
eval "makelist 'UDPGroup' $udp_group" >> $DNSFORWARDER_CONF
eval "makelist 'GroupFile' $group_file" >> $DNSFORWARDER_CONF
if [ $gfw = "true" ]; then
echo 'GroupFile /etc/dnsforwarder/gfw.txt' >> $DNSFORWARDER_CONF
fi
echo "BlockIP ${block_ip}" >> $DNSFORWARDER_CONF
eval "makelist 'IPSubstituting' $ip_substituting" >> $DNSFORWARDER_CONF
echo "BlockNegativeResponse ${block_negative_resp}" >> $DNSFORWARDER_CONF
eval "makelist 'AppendHosts' $append_host" >> $DNSFORWARDER_CONF
echo "BlockIpv6WhenIpv4Exists ${block_ipv6}" >> $DNSFORWARDER_CONF
echo "UseCache ${cache}" >> $DNSFORWARDER_CONF
if [ $cache = "true" ]; then
echo "CacheSize ${cache_size}" >> $DNSFORWARDER_CONF
echo "MemoryCache false" >> $DNSFORWARDER_CONF
echo "CacheFile /tmp/dnsforwarder.cache" >> $DNSFORWARDER_CONF
echo "IgnoreTTL ${cache_ignore}" >> $DNSFORWARDER_CONF
eval "makelist 'CacheControl' $cache_control" >> $DNSFORWARDER_CONF
echo "ReloadCache true" >> $DNSFORWARDER_CONF
echo "OverwriteCache true" >> $DNSFORWARDER_CONF
fi
echo "DomainStatistic ${domain_statistic}" >> $DNSFORWARDER_CONF
if [ $domain_statistic = "true" ]; then
touch /tmp/dnsforwarder-statistic.html
mkdir -p /root/.dnsforwarder
rm /root/.dnsforwarder/statistic.html 2 > /dev/null
ln -s /tmp/dnsforwarder-statistic.html /root/.dnsforwarder/statistic.html
local domain_statistic_tag='<!-- TS DNSFORWARDER -->'
echo "DomainStatisticTempletFile /tmp/dnsforwarder-statistic.html" >> $DNSFORWARDER_CONF
echo "StatisticInsertionPosition ${domain_statistic_tag}" >> $DNSFORWARDER_CONF
echo "StatisticUpdateInterval 60" >> $DNSFORWARDER_CONF
echo "${domain_statistic_tag}" > /tmp/dnsforwarder-statistic.html
fi
}
start()
{
echo luci for dnsforwarder
local vt_enabled=$(uci get dnsforwarder.@arguments[0].enabled 2>/dev/null)
if [ $vt_enabled = 0 ]; then
echo dnsforwarder is not enabled
exit
fi
makeconfig
fixturboacc
dnsforwarder -f $DNSFORWARDER_CONF -d
sleep 10
mkdir -p ${PID_PATH}
pid=$(ps | awk '$5 ~ /\[dnsforwarder\]/ {print $1}')
echo "dnsforwarder running pid is ${pid}"
logger -t The pid of dnsforwarder is ${PID_FILE} ${pid}
echo ${pid} > ${PID_FILE}
/etc/init.d/dnsforwarder enable
local dnsmasq=$(uci get dnsforwarder.@arguments[0].dnsmasq 2>/dev/null)
local addr=$(uci get dnsforwarder.@arguments[0].addr 2>/dev/null)
[ -n "${addr}" ] && addr=${addr/:/#}
if [ "${dnsmasq}" = "1" ]; then
uci delete dhcp.@dnsmasq[0].server 2>/dev/null
# uci add_list dhcp.@dnsmasq[0].server=$addr
uci delete dhcp.@dnsmasq[0].resolvfile 2>/dev/null
uci set dhcp.@dnsmasq[0].noresolv=1
uci set dhcp.@dnsmasq[0].serversfile=/tmp/dnsmasq.dnsforwarder.conf
uci commit dhcp
/etc/init.d/dnsmasq restart
fi
local dnsmasq_server_addr=$(uci get dhcp.@dnsmasq[0].server 2>/dev/null)
if [ -n "${dnsmasq_server_addr}" ]; then
uci set dhcp.@dnsmasq[0].noresolv=1
uci commit dhcp
/etc/init.d/dnsmasq restart
fi
add_cron
}
stop()
{
del_cron
logger -t stopping dnsforwarder
local addr=$(uci get dnsforwarder.@arguments[0].addr 2>/dev/null)
local dnsmasq=$(uci get dnsforwarder.@arguments[0].dnsmasq 2>/dev/null)
addr=${addr/:/#}
if [ "${dnsmasq}" = "1" ]; then
uci del_list dhcp.@dnsmasq[0].server=$addr 2>/dev/null
fi
uci set dhcp.@dnsmasq[0].resolvfile=/tmp/resolv.conf.d/resolv.conf.auto 2>/dev/null
uci delete dhcp.@dnsmasq[0].noresolv 2>/dev/null
uci delete dhcp.@dnsmasq[0].serversfile 2>/dev/null
uci commit dhcp
/etc/init.d/dnsmasq restart
[ -e ${PID_FILE} ] && {
pid=$(cat ${PID_FILE})
logger -t killing dnsforwarder pid ${pid}
echo killing dnsforwarder pid ${pid}
kill ${pid}
rm -f ${PID_FILE}
} || {
logger -t Cannot find dnsforwarder pid file
}
}
restart()
{
pid=$(cat ${PID_FILE} 2>/dev/null)
echo Dnsforwarder pid file is ${pid}
[ -n "$pid" ] && {
echo stopping pid ${pid}
logger -t There is dnsforwarder pid ${pid}
stop
} || {
logger -t Dnsforwarder is not running
}
sleep 7
local vt_enabled=$(uci get dnsforwarder.@arguments[0].enabled 2>/dev/null)
echo dnsforwarder status is ${vt_enabled}
logger -t Dnsforwarder is initializing enabled is ${vt_enabled}
if [ ${vt_enabled} = 1 ]; then
[ -n "$pid" ] && {
logger -t There is dnsforwarder pid ${pid}
stop
} || {
logger -t Dnsforwarder is not running
}
logger -t Restarting dnsforwarder
start
else
/etc/init.d/dnsforwarder disable
fi
}

View file

@ -0,0 +1,313 @@
#/bin/sh
# Name: gfwlist2dnsmasq.sh
# Desription: A shell script which convert gfwlist into dnsmasq rules.
# Version: 0.8.0 (2017.12.25)
# Author: Cokebar Chi
# Website: https://github.com/cokebar
_green() {
printf '\033[1;31;32m'
printf -- "%b" "$1"
printf '\033[0m'
}
_red() {
printf '\033[1;31;31m'
printf -- "%b" "$1"
printf '\033[0m'
}
_yellow() {
printf '\033[1;31;33m'
printf -- "%b" "$1"
printf '\033[0m'
}
usage() {
cat <<-EOF
Name: gfwlist2dnsmasq.sh
Desription: A shell script which convert gfwlist into dnsmasq rules.
Version: 0.8.0 (2017.12.25)
Author: Cokebar Chi
Website: https://github.com/cokebar
Usage: sh gfwlist2dnsmasq.sh [options] -o FILE
Valid options are:
-d, --dns <dns_ip>
DNS IP address for the GfwList Domains (Default: 127.0.0.1)
-p, --port <dns_port>
DNS Port for the GfwList Domains (Default: 5353)
-s, --ipset <ipset_name>
Ipset name for the GfwList domains
(If not given, ipset rules will not be generated.)
-o, --output <FILE>
/path/to/output_filename
-i, --insecure
Force bypass certificate validation (insecure)
-l, --domain-list
Convert Gfwlist into domain list instead of dnsmasq rules
(If this option is set, DNS IP/Port & ipset are not needed)
--exclude-domain-file <FILE>
Delete specific domains in the result from a domain list text file
Please put one domain per line
--extra-domain-file <FILE>
Include extra domains to the result from a domain list text file
This file will be processed after the exclude-domain-file
Please put one domain per line
-h, --help
Usage
EOF
exit $1
}
clean_and_exit(){
# Clean up temp files
printf 'Cleaning up... '
rm -rf $TMP_DIR
_green 'Done\n\n'
[ $1 -eq 0 ] && _green 'Job Finished.\n\n' || _red 'Exit with Error code '$1'.\n'
exit $1
}
check_depends(){
which sed base64 curl >/dev/null
if [ $? != 0 ]; then
_red 'Error: Missing Dependency.\nPlease check whether you have the following binaries on you system:\nwhich, sed, base64, curl.\n'
exit 3
fi
SYS_KERNEL=`uname -s`
if [ $SYS_KERNEL = "Darwin" -o $SYS_KERNEL = "FreeBSD" ]; then
BASE64_DECODE='base64 -D'
SED_ERES='sed -E'
else
BASE64_DECODE='base64 -d'
SED_ERES='sed -r'
fi
}
get_args(){
OUT_TYPE='DNSMASQ_RULES'
DNS_IP='127.0.0.1'
DNS_PORT='5353'
IPSET_NAME=''
FILE_FULLPATH=''
CURL_EXTARG=''
WITH_IPSET=0
EXTRA_DOMAIN_FILE=''
EXCLUDE_DOMAIN_FILE=''
IPV4_PATTERN='^((2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?)\.){3}(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?)$'
IPV6_PATTERN='^((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:)))(%.+)?$'
while [ ${#} -gt 0 ]; do
case "${1}" in
--help | -h)
usage 0
;;
--domain-list | -l)
OUT_TYPE='DOMAIN_LIST'
;;
--insecure | -i)
CURL_EXTARG='--insecure'
;;
--dns | -d)
DNS_IP="$2"
shift
;;
--port | -p)
DNS_PORT="$2"
shift
;;
--ipset | -s)
IPSET_NAME="$2"
shift
;;
--output | -o)
OUT_FILE="$2"
shift
;;
--extra-domain-file)
EXTRA_DOMAIN_FILE="$2"
shift
;;
--exclude-domain-file)
EXCLUDE_DOMAIN_FILE="$2"
shift
;;
*)
_red "Invalid argument: $1"
usage 1
;;
esac
shift 1
done
# Check path & file name
if [ -z $OUT_FILE ]; then
_red 'Error: Please specify the path to the output file(using -o/--output argument).\n'
exit 1
else
if [ -z ${OUT_FILE##*/} ]; then
_red 'Error: '$OUT_FILE' is a path, not a file.\n'
exit 1
else
if [ ${OUT_FILE}a != ${OUT_FILE%/*}a ] && [ ! -d ${OUT_FILE%/*} ]; then
_red 'Error: Folder do not exist: '${OUT_FILE%/*}'\n'
exit 1
fi
fi
fi
if [ $OUT_TYPE = 'DNSMASQ_RULES' ]; then
# Check DNS IP
IPV4_TEST=$(echo $DNS_IP | grep -E $IPV4_PATTERN)
IPV6_TEST=$(echo $DNS_IP | grep -E $IPV6_PATTERN)
if [ "$IPV4_TEST" != "$DNS_IP" -a "$IPV6_TEST" != "$DNS_IP" ]; then
_red 'Error: Please enter a valid DNS server IP address.\n'
exit 1
fi
# Check DNS port
if [ $DNS_PORT -lt 1 -o $DNS_PORT -gt 65535 ]; then
_red 'Error: Please enter a valid DNS server port.\n'
exit 1
fi
# Check ipset name
if [ -z $IPSET_NAME ]; then
WITH_IPSET=0
else
IPSET_TEST=$(echo $IPSET_NAME | grep -E '^\w+$')
if [ "$IPSET_TEST" != "$IPSET_NAME" ]; then
_red 'Error: Please enter a valid IP set name.\n'
exit 1
else
WITH_IPSET=1
fi
fi
fi
if [ ! -z $EXTRA_DOMAIN_FILE ] && [ ! -f $EXTRA_DOMAIN_FILE ]; then
_yellow 'WARNING:\nExtra domain file does not exist, ignored.\n\n'
EXTRA_DOMAIN_FILE=''
fi
if [ ! -z $EXCLUDE_DOMAIN_FILE ] && [ ! -f $EXCLUDE_DOMAIN_FILE ]; then
_yellow 'WARNING:\nExclude domain file does not exist, ignored.\n\n'
EXCLUDE_DOMAIN_FILE=''
fi
}
process(){
# Set Global Var
BASE_URL='https://github.com/gfwlist/gfwlist/raw/master/gfwlist.txt'
TMP_DIR=`mktemp -d /tmp/gfwlist2dnsmasq.XXXXXX`
BASE64_FILE="$TMP_DIR/base64.txt"
GFWLIST_FILE="$TMP_DIR/gfwlist.txt"
DOMAIN_TEMP_FILE="$TMP_DIR/gfwlist2domain.tmp"
DOMAIN_FILE="$TMP_DIR/gfwlist2domain.txt"
CONF_TMP_FILE="$TMP_DIR/gfwlist.conf.tmp"
OUT_TMP_FILE="$TMP_DIR/gfwlist.out.tmp"
# Fetch GfwList and decode it into plain text
printf 'Fetching GfwList... '
local tscurl='curl -L --connect-timeout 5 -m 300 --retry 3 --retry-delay 1'
$tscurl $CURL_EXTARG -o$BASE64_FILE $BASE_URL \
|| $tscurl $CURL_EXTARG -o$BASE64_FILE https://gitlab.com/gfwlist/gfwlist/raw/master/gfwlist.txt \
|| $tscurl $CURL_EXTARG -o$BASE64_FILE https://git.tuxfamily.org/gfwlist/gfwlist.git/plain/gfwlist.txt \
|| $tscurl $CURL_EXTARG -o$BASE64_FILE https://pagure.io/gfwlist/raw/master/f/gfwlist.txt \
|| $tscurl $CURL_EXTARG -o$BASE64_FILE http://repo.or.cz/gfwlist.git/blob_plain/HEAD:/gfwlist.txt \
|| $tscurl $CURL_EXTARG -o$BASE64_FILE https://bitbucket.org/gfwlist/gfwlist/raw/HEAD/gfwlist.txt \
|| $tscurl $CURL_EXTARG -o$BASE64_FILE $BASE_URL
if [ $? != 0 ]; then
_red '\nFailed to fetch gfwlist.txt. Please check your Internet connection.\n'
clean_and_exit 2
fi
$BASE64_DECODE $BASE64_FILE > $GFWLIST_FILE || ( _red 'Failed to decode gfwlist.txt. Quit.\n'; clean_and_exit 2 )
_green 'Done.\n\n'
# Convert
IGNORE_PATTERN='^\!|\[|^@@|(https?://){0,1}[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+'
HEAD_FILTER_PATTERN='s#^(\|\|?)?(https?://)?##g'
TAIL_FILTER_PATTERN='s#/.*$|%2F.*$##g'
DOMAIN_PATTERN='([a-zA-Z0-9][-a-zA-Z0-9]*(\.[a-zA-Z0-9][-a-zA-Z0-9]*)+)'
HANDLE_WILDCARD_PATTERN='s#^(([a-zA-Z0-9]*\*[-a-zA-Z0-9]*)?(\.))?([a-zA-Z0-9][-a-zA-Z0-9]*(\.[a-zA-Z0-9][-a-zA-Z0-9]*)+)(\*)?#\4#g'
printf 'Converting GfwList to ' && _green $OUT_TYPE && printf ' ...\n'
_yellow '\nWARNING:\nThe following lines in GfwList contain regex, and might be ignored:\n\n'
cat $GFWLIST_FILE | grep -n '^/.*$'
_yellow "\nThis script will try to convert some of the regex rules. But you should know this may not be a equivalent conversion.\nIf there's regex rules which this script do not deal with, you should add the domain manually to the list.\n\n"
grep -vE $IGNORE_PATTERN $GFWLIST_FILE | $SED_ERES $HEAD_FILTER_PATTERN | $SED_ERES $TAIL_FILTER_PATTERN | grep -E $DOMAIN_PATTERN | $SED_ERES $HANDLE_WILDCARD_PATTERN > $DOMAIN_TEMP_FILE
printf 'google.com\ngoogle.ad\ngoogle.ae\ngoogle.com.af\ngoogle.com.ag\ngoogle.com.ai\ngoogle.al\ngoogle.am\ngoogle.co.ao\ngoogle.com.ar\ngoogle.as\ngoogle.at\ngoogle.com.au\ngoogle.az\ngoogle.ba\ngoogle.com.bd\ngoogle.be\ngoogle.bf\ngoogle.bg\ngoogle.com.bh\ngoogle.bi\ngoogle.bj\ngoogle.com.bn\ngoogle.com.bo\ngoogle.com.br\ngoogle.bs\ngoogle.bt\ngoogle.co.bw\ngoogle.by\ngoogle.com.bz\ngoogle.ca\ngoogle.cd\ngoogle.cf\ngoogle.cg\ngoogle.ch\ngoogle.ci\ngoogle.co.ck\ngoogle.cl\ngoogle.cm\ngoogle.cn\ngoogle.com.co\ngoogle.co.cr\ngoogle.com.cu\ngoogle.cv\ngoogle.com.cy\ngoogle.cz\ngoogle.de\ngoogle.dj\ngoogle.dk\ngoogle.dm\ngoogle.com.do\ngoogle.dz\ngoogle.com.ec\ngoogle.ee\ngoogle.com.eg\ngoogle.es\ngoogle.com.et\ngoogle.fi\ngoogle.com.fj\ngoogle.fm\ngoogle.fr\ngoogle.ga\ngoogle.ge\ngoogle.gg\ngoogle.com.gh\ngoogle.com.gi\ngoogle.gl\ngoogle.gm\ngoogle.gp\ngoogle.gr\ngoogle.com.gt\ngoogle.gy\ngoogle.com.hk\ngoogle.hn\ngoogle.hr\ngoogle.ht\ngoogle.hu\ngoogle.co.id\ngoogle.ie\ngoogle.co.il\ngoogle.im\ngoogle.co.in\ngoogle.iq\ngoogle.is\ngoogle.it\ngoogle.je\ngoogle.com.jm\ngoogle.jo\ngoogle.co.jp\ngoogle.co.ke\ngoogle.com.kh\ngoogle.ki\ngoogle.kg\ngoogle.co.kr\ngoogle.com.kw\ngoogle.kz\ngoogle.la\ngoogle.com.lb\ngoogle.li\ngoogle.lk\ngoogle.co.ls\ngoogle.lt\ngoogle.lu\ngoogle.lv\ngoogle.com.ly\ngoogle.co.ma\ngoogle.md\ngoogle.me\ngoogle.mg\ngoogle.mk\ngoogle.ml\ngoogle.com.mm\ngoogle.mn\ngoogle.ms\ngoogle.com.mt\ngoogle.mu\ngoogle.mv\ngoogle.mw\ngoogle.com.mx\ngoogle.com.my\ngoogle.co.mz\ngoogle.com.na\ngoogle.com.nf\ngoogle.com.ng\ngoogle.com.ni\ngoogle.ne\ngoogle.nl\ngoogle.no\ngoogle.com.np\ngoogle.nr\ngoogle.nu\ngoogle.co.nz\ngoogle.com.om\ngoogle.com.pa\ngoogle.com.pe\ngoogle.com.pg\ngoogle.com.ph\ngoogle.com.pk\ngoogle.pl\ngoogle.pn\ngoogle.com.pr\ngoogle.ps\ngoogle.pt\ngoogle.com.py\ngoogle.com.qa\ngoogle.ro\ngoogle.ru\ngoogle.rw\ngoogle.com.sa\ngoogle.com.sb\ngoogle.sc\ngoogle.se\ngoogle.com.sg\ngoogle.sh\ngoogle.si\ngoogle.sk\ngoogle.com.sl\ngoogle.sn\ngoogle.so\ngoogle.sm\ngoogle.sr\ngoogle.st\ngoogle.com.sv\ngoogle.td\ngoogle.tg\ngoogle.co.th\ngoogle.com.tj\ngoogle.tk\ngoogle.tl\ngoogle.tm\ngoogle.tn\ngoogle.to\ngoogle.com.tr\ngoogle.tt\ngoogle.com.tw\ngoogle.co.tz\ngoogle.com.ua\ngoogle.co.ug\ngoogle.co.uk\ngoogle.com.uy\ngoogle.co.uz\ngoogle.com.vc\ngoogle.co.ve\ngoogle.vg\ngoogle.co.vi\ngoogle.com.vn\ngoogle.vu\ngoogle.ws\ngoogle.rs\ngoogle.co.za\ngoogle.co.zm\ngoogle.co.zw\ngoogle.cat\n' >> $DOMAIN_TEMP_FILE
printf 'Google search domains... ' && _green 'Added\n'
# Add blogspot domains
printf 'blogspot.ca\nblogspot.co.uk\nblogspot.com\nblogspot.com.ar\nblogspot.com.au\nblogspot.com.br\nblogspot.com.by\nblogspot.com.co\nblogspot.com.cy\nblogspot.com.ee\nblogspot.com.eg\nblogspot.com.es\nblogspot.com.mt\nblogspot.com.ng\nblogspot.com.tr\nblogspot.com.uy\nblogspot.de\nblogspot.gr\nblogspot.in\nblogspot.mx\nblogspot.ch\nblogspot.fr\nblogspot.ie\nblogspot.it\nblogspot.pt\nblogspot.ro\nblogspot.sg\nblogspot.be\nblogspot.no\nblogspot.se\nblogspot.jp\nblogspot.in\nblogspot.ae\nblogspot.al\nblogspot.am\nblogspot.ba\nblogspot.bg\nblogspot.ch\nblogspot.cl\nblogspot.cz\nblogspot.dk\nblogspot.fi\nblogspot.gr\nblogspot.hk\nblogspot.hr\nblogspot.hu\nblogspot.ie\nblogspot.is\nblogspot.kr\nblogspot.li\nblogspot.lt\nblogspot.lu\nblogspot.md\nblogspot.mk\nblogspot.my\nblogspot.nl\nblogspot.no\nblogspot.pe\nblogspot.qa\nblogspot.ro\nblogspot.ru\nblogspot.se\nblogspot.sg\nblogspot.si\nblogspot.sk\nblogspot.sn\nblogspot.tw\nblogspot.ug\nblogspot.cat\n' >> $DOMAIN_TEMP_FILE
printf 'Blogspot domains... ' && _green 'Added\n'
# Add twimg.edgesuite.net
printf 'twimg.edgesuite.net\n' >> $DOMAIN_TEMP_FILE
printf 'twimg.edgesuite.net... ' && _green 'Added\n'
# Delete exclude domains
if [ ! -z $EXCLUDE_DOMAIN_FILE ]; then
for line in $(cat $EXCLUDE_DOMAIN_FILE)
do
cat $DOMAIN_TEMP_FILE | grep -vF -f $EXCLUDE_DOMAIN_FILE > $DOMAIN_FILE
done
printf 'Domains in exclude domain file '$EXCLUDE_DOMAIN_FILE'... ' && _green 'Deleted\n'
else
cat $DOMAIN_TEMP_FILE > $DOMAIN_FILE
fi
# Add extra domains
if [ ! -z $EXTRA_DOMAIN_FILE ]; then
cat $EXTRA_DOMAIN_FILE >> $DOMAIN_FILE
printf 'Extra domain file '$EXTRA_DOMAIN_FILE'... ' && _green 'Added\n'
fi
if [ $OUT_TYPE = 'DNSMASQ_RULES' ]; then
# Convert domains into dnsmasq rules
if [ $WITH_IPSET -eq 1 ]; then
_green 'Ipset rules included.'
sort -u $DOMAIN_FILE | $SED_ERES 's#(.+)#server=/\1/'$DNS_IP'\#'$DNS_PORT'\
ipset=/\1/'$IPSET_NAME'#g' > $CONF_TMP_FILE
else
_green 'Ipset rules not included.'
sort -u $DOMAIN_FILE | $SED_ERES 's#(.+)#server=/\1/'$DNS_IP'\#'$DNS_PORT'#g' > $CONF_TMP_FILE
fi
# Generate output file
echo '# dnsmasq rules generated by gfwlist' > $OUT_TMP_FILE
echo "# Last Updated on $(date "+%Y-%m-%d %H:%M:%S")" >> $OUT_TMP_FILE
echo '# ' >> $OUT_TMP_FILE
cat $CONF_TMP_FILE >> $OUT_TMP_FILE
cp $OUT_TMP_FILE $OUT_FILE
else
sort -u $DOMAIN_FILE > $OUT_TMP_FILE
fi
cp $OUT_TMP_FILE $OUT_FILE
printf '\nConverting GfwList to '$OUT_TYPE'... ' && _green 'Done\n\n'
# Clean up
clean_and_exit 0
}
main() {
if [ -z "$1" ]; then
usage 0
else
check_depends
get_args "$@"
_green '\nJob Started.\n\n'
process
fi
}
main "$@"

59
dnsproxy/Makefile Normal file
View file

@ -0,0 +1,59 @@
# SPDX-License-Identifier: GPL-3.0-only
#
# Copyright (C) 2021 ImmortalWrt.org
include $(TOPDIR)/rules.mk
PKG_NAME:=dnsproxy
PKG_VERSION:=0.42.2
PKG_RELEASE:=$(AUTORELEASE)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/AdguardTeam/dnsproxy/tar.gz/v$(PKG_VERSION)?
PKG_HASH:=399a7a1f7d1afef85d8557bbe445541872bfe005e15c36e242f69b78fa94f1ca
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
PKG_LICENSE:=Apache-2.0
PKG_LICENSE_FILES:=LICENSE
PKG_BUILD_DEPENDS:=golang/host
PKG_BUILD_PARALLEL:=1
PKG_USE_MIPS16:=0
GO_PKG:=github.com/AdguardTeam/dnsproxy
GO_PKG_LDFLAGS_X:=main.VersionString=v$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
include ../../lang/golang/golang-package.mk
define Package/dnsproxy
SECTION:=net
CATEGORY:=Network
SUBMENU:=IP Addresses and Names
TITLE:=Simple DNS proxy with DoH, DoT, DoQ and DNSCrypt support
URL:=https://github.com/AdguardTeam/dnsproxy
DEPENDS:=$(GO_ARCH_DEPENDS) +ca-bundle
USERID:=dnsproxy=411:dnsproxy=411
endef
define Package/dnsproxy/description
A simple DNS proxy server that supports all existing DNS protocols including
DNS-over-TLS, DNS-over-HTTPS, DNSCrypt, and DNS-over-QUIC.Moreover, it can
work as a DNS-over-HTTPS, DNS-over-TLS or DNS-over-QUIC server.
endef
define Package/dnsproxy/install
$(call GoPackage/Package/Install/Bin,$(1))
$(INSTALL_DIR) $(1)/etc/config/
$(INSTALL_CONF) $(CURDIR)/files/dnsproxy.config $(1)/etc/config/dnsproxy
$(INSTALL_DIR) $(1)/etc/init.d/
$(INSTALL_BIN) $(CURDIR)/files/dnsproxy.init $(1)/etc/init.d/dnsproxy
endef
define Package/dnsproxy/conffiles
/etc/config/dnsproxy
endef
$(eval $(call GoBinPackage,dnsproxy))
$(eval $(call BuildPackage,dnsproxy))

View file

@ -0,0 +1,41 @@
# For documents, please see https://github.com/AdguardTeam/dnsproxy#usage
config dnsproxy 'global'
option enabled '0'
option listen_addr '127.0.0.1'
option listen_port '5353'
option log_file ''
option all_servers '0'
option fastest_addr '0'
option insecure '0'
option ipv6_disabled '0'
option max_go_routines ''
option rate_limit ''
option refuse_any '0'
option udp_buf_size ''
option verbose '0'
config dnsproxy 'bogus_nxdomain'
list ip_addr ''
config dnsproxy 'cache'
option enabled '0'
option cache_optimistic '0'
option size '65535'
option min_ttl ''
option max_ttl ''
config dnsproxy 'dns64'
option enabled '0'
option dns64_prefix '64:ff9b::'
config dnsproxy 'edns'
option enabled '0'
option edns_addr ''
config dnsproxy 'servers'
list bootstrap 'tls://8.8.8.8'
list fallback 'tls://9.9.9.9'
list upstream 'tls://1.1.1.1'

View file

@ -0,0 +1,115 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2021 Tianling Shen <cnsztl@immortalwrt.org>
USE_PROCD=1
START=90
CONF="dnsproxy"
PROG="/usr/bin/dnsproxy"
is_enabled() {
local enabled
config_get enabled "$1" "$2" "0"
if [ "$enabled" -eq "1" ]; then
return 0
else
return 1
fi
}
is_empty() {
local empty
config_get empty "$1" "$2" $3
if [ -z "$empty" ]; then
return 0
else
return 1
fi
}
append_param() {
procd_append_param command "$1" $2
}
append_param_arg() {
local value
config_get value "$1" "$2" $4
[ -n "$value" ] && append_param "$3" "$value"
}
append_param_bool() {
is_enabled "$1" "$2" && append_param "--${2//_/-}"
}
load_config_arg() {
append_param_bool "$1" "all_servers"
append_param_bool "$1" "fastest_addr"
append_param_bool "$1" "insecure"
append_param_bool "$1" "ipv6_disabled"
append_param_bool "$1" "refuse_any"
append_param_bool "$1" "verbose"
}
load_config_list() {
is_empty "bogus_nxdomain" "ip_addr" || config_list_foreach "bogus_nxdomain" "ip_addr" "append_param '--bogus-nxdomain'"
for i in "bootstrap" "fallback" "upstream"; do
is_empty "servers" "$i" || config_list_foreach "servers" "$i" "append_param '--$i'"
done
}
load_config_param() {
append_param_arg "global" "listen_addr" "--listen" "127.0.0.1"
append_param_arg "global" "listen_port" "--port" "5353"
append_param_arg "global" "log_file" "--output"
append_param_arg "global" "max_go_routines" "--max-go-routines"
append_param_arg "global" "rate_limit" "--ratelimit"
append_param_arg "global" "udp_buf_size" "--udp-buf-size"
is_enabled "cache" "enabled" && {
append_param "--cache"
append_param_bool "cache" "cache_optimistic"
append_param_arg "cache" "size" "--cache-size"
append_param_arg "cache" "min_ttl" "--cache-min-ttl"
append_param_arg "cache" "max_ttl" "--cache-max-ttl"
}
is_enabled "dns64" "enabled" && {
append_param "--dns64"
append_param_arg "dns64" "dns64_prefix" "--dns64-prefix"
}
is_enabled "edns" "enabled" && {
append_param "--edns"
append_param_arg "edns" "edns_addr" "--edns-addr"
}
}
start_service() {
config_load "$CONF"
is_enabled "global" "enabled" || exit 1
procd_open_instance "$CONF"
procd_set_param command "$PROG"
load_config_arg "global"
load_config_list
load_config_param
procd_set_param respawn
procd_set_param stdout 1
procd_set_param stderr 1
procd_set_param user dnsproxy
procd_close_instance
}
reload_service() {
stop
start
}
service_triggers() {
procd_add_reload_trigger "$CONF"
}

3
dnsproxy/test.sh Normal file
View file

@ -0,0 +1,3 @@
#!/bin/sh
dnsproxy --version | grep "$PKG_VERSION"

57
pdnsd-alt/Makefile Normal file
View file

@ -0,0 +1,57 @@
# SPDX-License-Identifier: GPL-3.0-only
#
# Copyright (C) 2021 ImmortalWrt.org
include $(TOPDIR)/rules.mk
PKG_NAME:=pdnsd
PKG_VERSION:=1.2.9b-par
PKG_RELEASE:=3
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/shadowsocks/pdnsd.git
PKG_SOURCE_DATE:=2012-04-26
PKG_SOURCE_VERSION:=a8e46ccba7b0fa2230d6c42ab6dcd92926f6c21d
PKG_MIRROR_HASH:=e3e9c56cf91b12d8db73def2c247be2f726a052bed012f7a1e48946375f8e478
PKG_BUILD_PARALLEL:=1
PKG_INSTALL:=1
include $(INCLUDE_DIR)/package.mk
define Package/pdnsd-alt
SECTION:=net
CATEGORY:=Network
SUBMENU:=IP Addresses and Names
TITLE:=Proxy DNS Server
DEPENDS:=+libpthread
endef
define Package/pdnsd-alt/description
pdnsd, is an IPv6 capable proxy DNS server with permanent caching (the cache
contents are written to hard disk on exit) that is designed to cope with
unreachable or down DNS servers (for example in dial-in networking).
pdnsd can be used with applications that do dns lookups, eg on startup, and
can't be configured to change that behaviour, to prevent the often
minute-long hangs (or even crashes) that result from stalled dns queries.
endef
TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
CONFIGURE_ARGS += \
--with-cachedir=/var/pdnsd \
--with-target=Linux
define Package/pdnsd-alt/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/pdnsd $(1)/usr/sbin/pdnsd
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/pdnsd-ctl $(1)/usr/sbin/pdnsd-ctl
#$(INSTALL_DIR) $(1)/etc
#$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/pdnsd.conf.sample $(1)/etc/pdnsd.conf
#$(INSTALL_DIR) $(1)/etc/init.d
#$(INSTALL_BIN) ./files/pdnsd.init $(1)/etc/init.d/pdnsd
endef
$(eval $(call BuildPackage,pdnsd-alt))

46
pdnsd-alt/files/pdnsd.init Executable file
View file

@ -0,0 +1,46 @@
#!/bin/sh /etc/rc.common
START=65
NAME=pdnsd
DESC="proxy DNS server"
DAEMON=/usr/sbin/pdnsd
PID_FILE=/var/run/$NAME.pid
CACHEDIR=/var/pdnsd
CACHE=$CACHEDIR/pdnsd.cache
USER=nobody
GROUP=nogroup
start() {
echo -n "Starting $DESC: $NAME"
gen_cache
$DAEMON --daemon -p $PID_FILE
echo " ."
}
stop() {
echo -n "Stopping $DESC: $NAME"
kill `cat $PID_FILE` > /dev/null 2>&1
rm -rf $PID_FILE
echo " ."
}
restart() {
echo "Restarting $DESC: $NAME... "
stop
sleep 2
start
}
gen_cache()
{
if ! test -f "$CACHE"; then
mkdir -p `dirname $CACHE`
dd if=/dev/zero of="$CACHE" bs=1 count=4 2> /dev/null
chown -R $USER.$GROUP $CACHEDIR
fi
}

View file

@ -0,0 +1,42 @@
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,5 +1,5 @@
-SUBDIRS = src doc contrib
+SUBDIRS = src contrib
EXTRA_DIST = version ChangeLog.old COPYING.BSD README.par README.par.old PKGBUILD
--- a/Makefile.in
+++ b/Makefile.in
@@ -196,7 +196,7 @@ threadlib = @threadlib@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-SUBDIRS = src doc contrib
+SUBDIRS = src contrib
EXTRA_DIST = version ChangeLog.old COPYING.BSD README.par README.par.old PKGBUILD
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -15,7 +15,7 @@ EXTRA_DIST = make_rr_types_h.pl rr_types
## Try to do this last
-SUBDIRS = . pdnsd-ctl rc test
+SUBDIRS = . pdnsd-ctl
$(pdnsd_OBJECTS): rr_types.h
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -215,7 +215,7 @@ pdnsd_SOURCES = conf-parser.c conff.c co
freebsd_netinet_ip_icmp.h
EXTRA_DIST = make_rr_types_h.pl rr_types.in
-SUBDIRS = . pdnsd-ctl rc test
+SUBDIRS = . pdnsd-ctl
all: all-recursive
.SUFFIXES:

View file

@ -0,0 +1,66 @@
--- a/src/conff.h
+++ b/src/conff.h
@@ -32,7 +32,7 @@
#include <stdio.h>
#include <pthread.h>
#include <sys/socket.h>
-#include <net/if.h>
+#include <linux/if.h>
#include "ipvers.h"
#include "list.h"
--- a/src/dns.h
+++ b/src/dns.h
@@ -27,7 +27,7 @@
#include <config.h>
#include <arpa/inet.h>
#include <sys/socket.h>
-#include <net/if.h>
+#include <linux/if.h>
#include <sys/types.h>
#include <inttypes.h>
#include "rr_types.h"
--- a/src/dns_answer.c
+++ b/src/dns_answer.c
@@ -37,7 +37,7 @@
#include <sys/uio.h>
#include <sys/types.h>
#ifdef HAVE_SYS_POLL_H
-#include <sys/poll.h>
+#include <poll.h>
#endif
#include <sys/param.h>
#include <netdb.h>
--- a/src/dns_query.c
+++ b/src/dns_query.c
@@ -23,7 +23,7 @@
#include <config.h>
#include <sys/types.h>
#ifdef HAVE_SYS_POLL_H
-#include <sys/poll.h>
+#include <poll.h>
#endif
#include <stdlib.h>
#include <netdb.h>
--- a/src/icmp.c
+++ b/src/icmp.c
@@ -28,7 +28,7 @@
#include <config.h>
#ifdef HAVE_SYS_POLL_H
-#include <sys/poll.h>
+#include <poll.h>
#endif
#include <sys/time.h>
#include <stdlib.h>
--- a/src/netdev.c
+++ b/src/netdev.c
@@ -59,7 +59,7 @@
#include "ipvers.h"
#include <sys/stat.h>
#include <sys/ioctl.h>
-#include <net/if.h>
+#include <linux/if.h>
#include <netdb.h>
#include <string.h>
#include <unistd.h>