Browse Source

chore(nftables): cleanup command block

Signed-off-by: Tianling Shen <[email protected]>
Tianling Shen 2 years ago
parent
commit
f5cea69d17
1 changed files with 7 additions and 23 deletions
  1. 7 23
      root/usr/share/unblockneteasemusic/nftables.ut

+ 7 - 23
root/usr/share/unblockneteasemusic/nftables.ut

@@ -1,32 +1,24 @@
 #!/usr/bin/utpl -S
 #!/usr/bin/utpl -S
 
 
-{% if (acl_http_addr): %}
 set acl_neteasemusic_http {
 set acl_neteasemusic_http {
 	type ipv4_addr;
 	type ipv4_addr;
 	flags interval;
 	flags interval;
 	auto-merge;
 	auto-merge;
 
 
-	elements = {
-		{% for (let addr in split(trim(acl_http_addr), '\n')): %}
-		{{ addr }},
-		{% endfor %}
-	};
+	{% if (acl_http_addr): %}
+	elements = { {{ join(', ', split(trim(acl_http_addr), '\n')) }} }
+	{% endif %}
 }
 }
-{% endif -%}
 
 
-{% if (acl_https_addr): %}
 set acl_neteasemusic_https {
 set acl_neteasemusic_https {
 	type ipv4_addr;
 	type ipv4_addr;
 	flags interval;
 	flags interval;
 	auto-merge;
 	auto-merge;
 
 
-	elements = {
-		{% for (let addr in split(trim(acl_https_addr), '\n')): %}
-		{{ addr }},
-		{% endfor %}
-	};
+	{% if (acl_https_addr): %}
+	elements = { {{ join(', ', split(trim(acl_https_addr), '\n')) }} }
+	{% endif %}
 }
 }
-{% endif -%}
 
 
 {% if (hijack_ways === 'use_ipset'): %}
 {% if (hijack_ways === 'use_ipset'): %}
 set neteasemusic {
 set neteasemusic {
@@ -35,11 +27,7 @@ set neteasemusic {
 	auto-merge;
 	auto-merge;
 
 
 	{% if (neteasemusic_addr): %}
 	{% if (neteasemusic_addr): %}
-	elements = {
-		{% for (let addr in split(trim(neteasemusic_addr), '\n')): %}
-		{{ addr }},
-		{% endfor %}
-	}
+	elements = { {{ join(', ', split(trim(neteasemusic_addr), '\n')) }} }
 	{% endif %}
 	{% endif %}
 }
 }
 
 
@@ -67,12 +55,8 @@ chain netease_cloud_music_redir {
 		2001::/32, 2001:10::/28, 2001:20::/28, 2001:db8::/28, 2002::/16,
 		2001::/32, 2001:10::/28, 2001:20::/28, 2001:db8::/28, 2002::/16,
 		fc00::/7, fe80::/10, ff00::/8 } counter return;
 		fc00::/7, fe80::/10, ff00::/8 } counter return;
 
 
-	{% if (acl_http_addr): %}
 	ip saddr @acl_neteasemusic_http tcp dport 80 counter return;
 	ip saddr @acl_neteasemusic_http tcp dport 80 counter return;
-	{% endif %}
-	{% if (acl_https_addr): %}
 	ip saddr @acl_neteasemusic_https tcp dport 443 counter return;
 	ip saddr @acl_neteasemusic_https tcp dport 443 counter return;
-	{% endif %}
 
 
 	tcp dport 80 counter redirect to :{{ http_port }};
 	tcp dport 80 counter redirect to :{{ http_port }};
 	tcp dport 443 counter redirect to :{{ https_port }};
 	tcp dport 443 counter redirect to :{{ https_port }};