OSDN Git Service

luci-app-unblockneteasemusic: compatible with ipset
authorZiMing Mo <msylgj@immortalwrt.org>
Wed, 15 Jun 2022 16:58:58 +0000 (00:58 +0800)
committerZiMing Mo <msylgj@immortalwrt.org>
Wed, 15 Jun 2022 16:58:58 +0000 (00:58 +0800)
applications/luci-app-unblockneteasemusic/root/etc/init.d/unblockneteasemusic

index aba137d..aa19422 100755 (executable)
@@ -118,18 +118,22 @@ start_service()
        local tmp="/tmp/$NAME"
        if [ "${hijack_ways}" = "use_ipset" ]; then
                local ipset="ipset"
-               [ -n "$(dnsmasq --version | grep -m1 'Compile time options:' | cut -d: -f2 | grep ' nftset')" ] && ipset="nftset"
+               local nftflag=""
+               [ -n "$(dnsmasq --version | grep -m1 'Compile time options:' | cut -d: -f2 | grep ' nftset')" ] && {
+                       ipset="nftset"
+                       nftflag="inet#fw4#"
+               }
                mkdir -p "/tmp/dnsmasq.d"
                rm -f "/tmp/dnsmasq.d/dnsmasq-$NAME.conf"
                cat <<-EOF > "/tmp/dnsmasq.d/dnsmasq-$NAME.conf"
                        dhcp-option=252,http://${lan_addr}:${http_port}/proxy.pac
-                       ${ipset}=/.music.163.com/inet#fw4#neteasemusic
-                       ${ipset}=/interface.music.163.com/inet#fw4#neteasemusic
-                       ${ipset}=/interface3.music.163.com/inet#fw4#neteasemusic
-                       ${ipset}=/apm.music.163.com/inet#fw4#neteasemusic
-                       ${ipset}=/apm3.music.163.com/inet#fw4#neteasemusic
-                       ${ipset}=/clientlog.music.163.com/inet#fw4#neteasemusic
-                       ${ipset}=/clientlog3.music.163.com/inet#fw4#neteasemusic
+                       ${ipset}=/.music.163.com/${nftflag}neteasemusic
+                       ${ipset}=/interface.music.163.com/${nftflag}neteasemusic
+                       ${ipset}=/interface3.music.163.com/${nftflag}neteasemusic
+                       ${ipset}=/apm.music.163.com/${nftflag}neteasemusic
+                       ${ipset}=/apm3.music.163.com/${nftflag}neteasemusic
+                       ${ipset}=/clientlog.music.163.com/${nftflag}neteasemusic
+                       ${ipset}=/clientlog3.music.163.com/${nftflag}neteasemusic
                EOF
                /etc/init.d/dnsmasq reload