This commit is contained in:
Eliezer Croitoru 2025-01-07 01:48:53 +02:00
commit 505e642430
5 changed files with 106 additions and 0 deletions

16
appUpdaterScript.rsc Normal file
View File

@ -0,0 +1,16 @@
{
:do {
:local debug 0;
:foreach script in=[/system/script/find where name~"update[a-zA-Z]+FromDnsCache" ] do={
:do {
/system/script/run ($script->"name");
} on-error={
if ($debug > 0) do={
:log info "error adding ";
}
}
}
} on-error={
:log info "RUNTIME Error";
}
}

5
freetv.json Normal file
View File

@ -0,0 +1,5 @@
{
"staticDomains": [ "images.frp1.ott.kaltura.com", "api.frp1.ott.kaltura.com", "cfvod.kaltura.com", "tdbc.redgalaxy.com" ],
"regexPatterns": [ "(\\.)?il\\.cdn-redge\\.media\$", "(\\.)?freetv\\.tv\$" ],
"appName": "FreeTV"
}

View File

@ -0,0 +1,45 @@
#!/usr/bin/env ruby
require "json"
appUpdateTemplateFile = "updateAppFromDnsCache-template.rsc"
templateFile = File.open(appUpdateTemplateFile)
appUpdateTemplateString = templateFile.readlines
templateFile.close
appJsonFile = ARGV[0]
file = File.open(appJsonFile)
data = JSON.load(file)
file.close
#puts JSON.pretty_generate(data)
domainsString = "\"#{data["staticDomains"].join("\"; \"")}\""
domainsRegexString = "\"#{data["regexPatterns"].join("\"; \"")}\""
domainsRegexString = domainsRegexString.gsub("$",'\$').gsub("\.", "\\.")
#puts domainsRegexString
appUpdateTemplateString.each do |line|
case line
when /##INSERT_LINES.*/
if data["staticDomains"].nil? or data["staticDomains"].empty?
puts(" :local staticDomains;")
else
puts(" :local staticDomains { \"#{data["staticDomains"].join("\"; \"")}\" };")
end
if data["regexPatterns"].nil? or data["regexPatterns"].empty?
puts(" :local regexString;")
else
puts(" :local regexString { #{domainsRegexString} };")
end
when /:local addressList "###ADDRESS_LIST###"/
puts(" :local addressList \"#{data["appName"]}\"")
else
puts(line)
end
end

5
google-firebase.json Normal file
View File

@ -0,0 +1,5 @@
{
"staticDomains": [ "firebaselogging-pa.googleapis.com", "firebaseremoteconfig.googleapis.com", "" ],
"regexPatterns": [ ],
"appName": "googleFireBase"
}

View File

@ -0,0 +1,35 @@
{
:do {
:local debug 0;
:local addressList "###ADDRESS_LIST###";
##INSERT_LINES
:foreach dom in=$staticDomains do={
:do {
/ip/firewall/address-list/add address=$dom list=$addressList;
} on-error={
if ($debug > 0) do={
:log info "error adding ";
}
}
}
:foreach rec in=[/ip/dns/cache/print as-value ] do={
:foreach regexTestString in=$regexString do={
if ( ($rec->"type")~"(CNAME|A)\$" ) do={
if ( ($rec->"name")~"$regexTestString" ) do={
:do {
/ip/firewall/address-list/add address=($rec->"name") list=$addressList;
} on-error={
if ($debug > 0) do={
:log info "error adding ";
}
}
}
}
}
}
} on-error={
:log info "RUNTIME Error";
}
}