feat(podkop): add DNS Rewrite TTL configuration option

This commit is contained in:
Nikita Skryabin
2025-02-20 23:27:50 +03:00
parent ec936e2369
commit 1f3a65347e
2 changed files with 28 additions and 5 deletions

View File

@@ -697,6 +697,24 @@ return view.extend({
return true; return true;
}; };
o = s.taboption('additional', form.Value, 'dns_rewrite_ttl', 'DNS Rewrite TTL', 'Time in seconds for DNS record caching (default: 600)');
o.default = '600';
o.rmempty = false;
o.ucisection = 'main';
o.validate = function (section_id, value) {
if (!value) {
return 'TTL value cannot be empty';
}
const ttl = parseInt(value);
if (isNaN(ttl) || ttl < 0) {
return 'TTL must be a positive number';
}
return true;
};
o = s.taboption('additional', form.Value, 'cache_file', 'Cache File Path', 'Select or enter path for sing-box cache file'); o = s.taboption('additional', form.Value, 'cache_file', 'Cache File Path', 'Select or enter path for sing-box cache file');
o.value('/tmp/cache.db', 'RAM (/tmp/cache.db)'); o.value('/tmp/cache.db', 'RAM (/tmp/cache.db)');
o.value('/usr/share/sing-box/cache.db', 'Flash (/usr/share/sing-box/cache.db)'); o.value('/usr/share/sing-box/cache.db', 'Flash (/usr/share/sing-box/cache.db)');

View File

@@ -709,8 +709,13 @@ sing_box_dns() {
} }
sing_box_dns_rule_fakeip() { sing_box_dns_rule_fakeip() {
log "Configure fakeip route in sing-box" local rewrite_ttl
config_get rewrite_ttl "main" "dns_rewrite_ttl" "600"
log "Configure fakeip route in sing-box and set TTL to $rewrite_ttl seconds"
jq \ jq \
--arg ttl "$rewrite_ttl" \
'.dns += { '.dns += {
"rules": [ "rules": [
{ {
@@ -727,6 +732,8 @@ sing_box_dns_rule_fakeip() {
}, },
{ {
"server": "fakeip-server", "server": "fakeip-server",
"domain": "",
"rewrite_ttl": ($ttl | tonumber),
"rule_set": [] "rule_set": []
} }
] ]
@@ -1854,10 +1861,8 @@ sing_box_add_secure_dns_probe_domain() {
--arg override "$override_address" \ --arg override "$override_address" \
'.dns.rules |= map( '.dns.rules |= map(
if .server == "fakeip-server" then if .server == "fakeip-server" then
{ . + {
"server": .server, "domain": $domain
"domain": $domain,
"rule_set": .rule_set
} }
else else
. .