Archived
add_archive_project
This commit is contained in:
Executable
+37
@@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
|
||||
nft_table="xray"
|
||||
nft_set="dst_list"
|
||||
nft_set_exclude="dst_exclude"
|
||||
|
||||
ipset_dir="/etc/xray/ipset"
|
||||
dnsmasq_dir="/etc/dnsmasq.d"
|
||||
|
||||
for ipset_file in "$ipset_dir"/xray_domain*; do
|
||||
ipset_filename=$(basename "$ipset_file")
|
||||
ipnet_file="$dnsmasq_dir/$ipset_filename"
|
||||
|
||||
if echo "$ipset_filename" | grep -qiE "exclude|white"; then
|
||||
target_set="$nft_set_exclude"
|
||||
else
|
||||
target_set="$nft_set"
|
||||
fi
|
||||
|
||||
awk -v t_set="$target_set" -v table="$nft_table" '
|
||||
/^[[:space:]]*#/ || /^[[:space:]]*$/ { next }
|
||||
{
|
||||
sub(/#.*/, "")
|
||||
gsub(/[[:space:]]/, "")
|
||||
if ($0 !~ /\./) next
|
||||
sub(/^[^:]+:/, "", $0)
|
||||
if ($0 ~ /@cn$/) next
|
||||
sub(/@[^@]+$/, "", $0)
|
||||
print "nftset=/" $0 "/4#ip#" table "#" t_set
|
||||
}
|
||||
' "$ipset_file" > "$ipnet_file"
|
||||
|
||||
|
||||
if ! dnsmasq --test -C "$ipnet_file" >/dev/null 2>&1; then
|
||||
logger -t xray-prepare_domain "$dnsmasq_dir/$ipset_filename: validation failed"
|
||||
fi
|
||||
done
|
||||
Reference in New Issue
Block a user