Skip to content

Commit

Permalink
refactor: remove chromecast
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed May 10, 2019
1 parent 643a4f9 commit 7fd46d7
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 43 deletions.
1 change: 0 additions & 1 deletion docs/ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
![](/img/ui-3.png)

- IP/CIDR 白名单:不通过 Clash 的 IP/CIDR 外网地址,一行一个
- Chromecast 开关:是否劫持局域网内的 DNS 请求到 Clash

- 默认主机设置:Clash 全局代理控制

Expand Down
4 changes: 3 additions & 1 deletion docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ KoolClash 启动以后,你可以通过检查「Clash 运行状态」和「IP

?> KoolClash 的 IP/CIDR 白名单已经包含所有局域网 IP 段和保留 IP 段,无需在这里重复提交。

### Chromecast
### ~~Chromecast~~

?> 从 KoolClash `0.17.0-beta` 版本开始,KoolClash 使用 Clash 的 Fake-IP,不再提供 Chromecast 功能。

启用 Chromecast 功能后,将会劫持使用 UDP 协议发往不位于当前 LAN 网段的 53 端口的所有请求、并转发给 Clash,最终返回 Clash 给出的解析结果(即劫持常规 DNS 解析)。

Expand Down
27 changes: 0 additions & 27 deletions koolclash/scripts/koolclash_control.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,6 @@ flush_nat() {
iptables -t nat -F koolclash >/dev/null 2>&1 && iptables -t nat -X koolclash >/dev/null 2>&1
iptables -t mangle -F koolclash >/dev/null 2>&1 && iptables -t mangle -X koolclash >/dev/null 2>&1

echo_date "停用 Chromecast(劫持 DNS)功能"
# flush chromecast
chromecast_nu=$(iptables -t nat -L PREROUTING -v -n --line-numbers | grep "dpt:53" | awk '{print $1}')
iptables -t nat -D PREROUTING $chromecast_nu >/dev/null 2>&1

#flush_ipset
echo_date "删除 KoolClash 添加的 ipsets 名单"
ipset -F koolclash_white >/dev/null 2>&1 && ipset -X koolclash_white >/dev/null 2>&1
Expand Down Expand Up @@ -182,27 +177,6 @@ add_white_black_ip() {
}

#--------------------------------------------------------------------------
chromecast() {
chromecast_nu=$(iptables -t nat -L PREROUTING -v -n --line-numbers | grep "dpt:53" | awk '{print $1}')
is_right_lanip=$(iptables -t nat -L PREROUTING -v -n --line-numbers | grep "dpt:53" | grep "$lan_ip")
if [ $koolclash_firewall_chromecast == "true" ]; then
if [ -z "$chromecast_nu" ]; then
iptables -t nat -A PREROUTING -p udp -s $(get_lan_cidr) --dport 53 -j DNAT --to $lan_ip >/dev/null 2>&1
echo_date '启用 Chromecast(劫持 DNS)'
else
if [ -z "$is_right_lanip" ]; then
echo_date '启用 Chromecast(劫持 DNS)'
iptables -t nat -D PREROUTING $chromecast_nu >/dev/null 2>&1
iptables -t nat -A PREROUTING -p udp -s $(get_lan_cidr) --dport 53 -j DNAT --to $lan_ip >/dev/null 2>&1
else
echo_date '检测到 DNS 劫持功能已经启用'
fi
fi
else
echo_date '不启用 Chromecast(劫持 DNS)功能'
fi
}

get_mode_name() {
case "$1" in
0)
Expand Down Expand Up @@ -334,7 +308,6 @@ load_nat() {
creat_ipset
add_white_black_ip
apply_nat_rules
chromecast
}

start_koolclash() {
Expand Down
3 changes: 1 addition & 2 deletions koolclash/scripts/koolclash_firewall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ wan_ip=$(ubus call network.interface.wan status | grep \"address\" | grep -oE '[

case $2 in
white)
dbus set koolclash_firewall_chromecast=$3
dbus set koolclash_firewall_whiteip_base64=$4
dbus set koolclash_firewall_whiteip_base64=$3
http_response 'ok'
;;
default)
Expand Down
13 changes: 1 addition & 12 deletions koolclash/webs/Module_koolclash.asp
Original file line number Diff line number Diff line change
Expand Up @@ -575,13 +575,6 @@
value: Base64.decode(window.dbus.koolclash_firewall_whiteip_base64 || '') || '',
style: 'width: 80%; height: 150px;'
},
{
title: '<b>Chromecast 开关</b><br><br><p style="color: #999">强烈建议暂时不要使用!</p>',
name: 'koolclash-chromecast-switch',
prefix: '<br>',
type: 'checkbox',
style: `margin-top:16px;`
},
]);
$('#koolclash-acl-default-panel').forms([
Expand Down Expand Up @@ -644,8 +637,6 @@
$('#_koolclash-acl-default-port-user').hide();
}
document.getElementById('_koolclash-chromecast-switch').checked = (window.dbus.koolclash_firewall_chromecast === 'true') ? true : false;
$('.koolclash-nav-log').on('click', KoolClash.getLog);
},
// 选择 Tab
Expand Down Expand Up @@ -1327,7 +1318,6 @@ KoolClash 版本:${window.dbus.koolclash_version}
Clash 核心版本:${data.clash_version}
KoolClash 当前状态:${(window.dbus.koolclash_enable === '1') ? `Clash 进程正在运行` : `Clash 进程未在运行`}
用户指定 Clash 外部控制 Host:${(window.dbus.koolclash_api_host) ? koolclash_api_host : `未改动`}
Chromecast(劫持 DNS)是否启用:${window.dbus.koolclash_firewall_chromecast}
IP 数据库是否存在:${data.ipdb_exists}
-------------------------- Clash 进程信息 --------------------------
${Base64.decode(data.clash_process)}
Expand Down Expand Up @@ -1371,14 +1361,13 @@ ${Base64.decode(data.firewall_white_ip)}
submitWhiteIP: () => {
KoolClash.disableAllButton();
let data = Base64.encode(document.getElementById('_koolclash_firewall_white_ipset').value);
let chromecast = document.getElementById('_koolclash-chromecast-switch').checked;
document.getElementById('koolclash-btn-submit-white-ip').innerHTML = `正在提交`;
let id = parseInt(Math.random() * 100000000),
postData = JSON.stringify({
id,
"method": "koolclash_firewall.sh",
"params": ['white', `${chromecast}`, `${data}`],
"params": ['white', `${data}`],
"fields": ""
});
Expand Down

0 comments on commit 7fd46d7

Please sign in to comment.