From 4ecf3b21e26961de6d37c47fc6e619e2d80b3523 Mon Sep 17 00:00:00 2001 From: kissshot <4530897+kkkgo@users.noreply.github.com> Date: Mon, 27 May 2024 16:28:19 +0800 Subject: [PATCH] allow_free test --- FILES/usr/bin/ppg.sh | 8 +++++++- ppgw.go | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/FILES/usr/bin/ppg.sh b/FILES/usr/bin/ppg.sh index 1b26dee..cb7e337 100644 --- a/FILES/usr/bin/ppg.sh +++ b/FILES/usr/bin/ppg.sh @@ -138,6 +138,12 @@ load_clash() { if [ -z "$clash_web_password" ]; then clash_web_password="clashpass" fi + if [ "$allow_free" = "yes" ]; then + append_direct=yes + else + append_direct=no + fi + export append_direct sed "s|https://www.youtube.com/generate_204|$test_node_url|g" /etc/config/clash/clash-dashboard/index_base.html >/etc/config/clash/clash-dashboard/index.html closeall_flag="yes" log "[VERSION] :""$(clash -v)" succ @@ -335,7 +341,7 @@ load_ovpn() { gen_hash() { if [ -f /tmp/ppgw.ini ]; then . /tmp/ppgw.ini 2>/dev/tty0 - str="ppgw""$fake_cidr""$dns_ip""$dns_port""$openport""$sleeptime""$clash_web_port""$clash_web_password""$mode""$udp_enable""$socks5_ip""$socks5_port""$ovpnfile""$ovpn_username""$ovpn_password""$yamlfile""$suburl""$subtime""$fast_node""$test_node_url""$ext_node""$cpudelay""$dns_burn""$ex_dns""$net_rec""$max_rec" + str="ppgw""$fake_cidr""$dns_ip""$dns_port""$openport""$sleeptime""$clash_web_port""$clash_web_password""$mode""$udp_enable""$socks5_ip""$socks5_port""$ovpnfile""$ovpn_username""$ovpn_password""$yamlfile""$suburl""$subtime""$fast_node""$test_node_url""$ext_node""$cpudelay""$dns_burn""$ex_dns""$net_rec""$max_rec""$allow_free" echo "$str" | md5sum | grep -Eo "[a-z0-9]{32}" | head -1 else echo "INI does not exist" diff --git a/ppgw.go b/ppgw.go index 23f0d92..827a4df 100644 --- a/ppgw.go +++ b/ppgw.go @@ -974,7 +974,11 @@ func filterNodes(nodes []ClashNode, excludedNodes []string) []ClashNode { } func isSystemNode(nodeName string) bool { - systemNodes := []string{"REJECT", "DIRECT", "GLOBAL", "UNKNOWN"} + systemNodes := []string{"REJECT", "GLOBAL", "UNKNOWN"} + append_direct := os.Getenv("append_direct") + if append_direct != "yes" { + systemNodes = append(systemNodes, "DIRECT") + } nodeName = strings.ToUpper(nodeName) for _, sysNode := range systemNodes { if nodeName == sysNode {