Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
fix(#12): dhcp dns control
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed May 1, 2019
1 parent 8b08d43 commit f01a0c5
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions koolclash/scripts/koolclash_control.sh
Expand Up @@ -21,14 +21,13 @@ get_lan_cidr() {

#--------------------------------------------------------------------------
restore_dnsmasq_conf() {
# delete server setting in dnsmasq.conf
#pc_delete "server=" "/etc/dnsmasq.conf"
#pc_delete "all-servers" "/etc/dnsmasq.conf"
#pc_delete "no-resolv" "/etc/dnsmasq.conf"
#pc_delete "no-poll" "/etc/dnsmasq.conf"

echo_date "删除 KoolClash 的 dnsmasq 配置..."
rm -rf /tmp/dnsmasq.d/koolclash.conf

echo_date "还原 DHCP/DNS 中 resolvfile 配置..."
uci set dhcp.@dnsmasq[0].resolvfile=/tmp/resolv.conf.auto
uci set dhcp.@dnsmasq[0].noresolv=0
uci commit dhcp
}

restore_start_file() {
Expand Down Expand Up @@ -56,6 +55,16 @@ kill_process() {
}

create_dnsmasq_conf() {
echo_date "删除 DHCP/DNS 中 resolvfile 和 cachesize 配置"
dhcp_server=$(uci get dhcp.@dnsmasq[0].server 2>/dev/null)
if [ $dhcp_server ]; then
uci delete dhcp.@dnsmasq[0].server >/dev/null 2>&1
fi
uci delete dhcp.@dnsmasq[0].resolvfile
uci delete dhcp.@dnsmasq[0].cachesize
uci set dhcp.@dnsmasq[0].noresolv=1
uci commit dhcp

touch /tmp/dnsmasq.d/koolclash.conf
echo_date "修改 dnsmasq 配置使 dnsmasq 将所有的 DNS 请求转发给 Clash"
echo "no-resolv" >>/tmp/dnsmasq.d/koolclash.conf
Expand Down Expand Up @@ -165,7 +174,7 @@ add_white_black_ip() {

if [ ! -z $koolclash_firewall_whiteip_base64 ]; then
ip_white=$(echo $koolclash_firewall_whiteip_base64 | base64_decode | sed '/\#/d')
echo_date '应用 IP/CIDR 白名单'
echo_date '应用外网目标 IP/CIDR 白名单'
for ip in $ip_white; do
ipset -! add koolclash_white $ip >/dev/null 2>&1
done
Expand Down

0 comments on commit f01a0c5

Please sign in to comment.