mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-10 05:26:50 +03:00
Merge pull request #37 from vernette/feature/fakeip-cache-path-and-ttl
feat(podkop): add configurable cache file path and dns rewrite_ttl options
This commit is contained in:
@@ -697,6 +697,52 @@ return view.extend({
|
||||
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. Change this ONLY if you know what you are doing'));
|
||||
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.default = '/tmp/cache.db';
|
||||
o.rmempty = false;
|
||||
o.ucisection = 'main';
|
||||
|
||||
o.validate = function(section_id, value) {
|
||||
if (!value) {
|
||||
return _('Cache file path cannot be empty');
|
||||
}
|
||||
|
||||
if (!value.startsWith('/')) {
|
||||
return _('Path must be absolute (start with /)');
|
||||
}
|
||||
|
||||
if (!value.endsWith('cache.db')) {
|
||||
return _('Path must end with cache.db');
|
||||
}
|
||||
|
||||
const parts = value.split('/').filter(Boolean);
|
||||
if (parts.length < 2) {
|
||||
return _('Path must contain at least one directory (like /tmp/cache.db)');
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
// Diagnostics tab
|
||||
o = s.tab('diagnostics', _('Diagnostics'));
|
||||
|
||||
|
||||
@@ -521,4 +521,37 @@ msgid "DNS server address cannot be empty"
|
||||
msgstr "Адрес DNS сервера не может быть пустым"
|
||||
|
||||
msgid "Invalid DNS server format. Examples: 8.8.8.8 or dns.example.com"
|
||||
msgstr "Неверный формат DNS сервера. Примеры: 8.8.8.8 или dns.example.com"
|
||||
msgstr "Неверный формат DNS сервера. Примеры: 8.8.8.8 или dns.example.com"
|
||||
|
||||
msgid "DNS Rewrite TTL"
|
||||
msgstr "Перезапись TTL для DNS"
|
||||
|
||||
msgid "Time in seconds for DNS record caching (default: 600)"
|
||||
msgstr "Время в секундах для кэширования DNS записей (по умолчанию: 600)"
|
||||
|
||||
msgid "TTL value cannot be empty"
|
||||
msgstr "Значение TTL не может быть пустым"
|
||||
|
||||
msgid "TTL must be a positive number"
|
||||
msgstr "TTL должно быть положительным числом"
|
||||
|
||||
msgid "Cache File Path"
|
||||
msgstr "Путь к файлу кэша"
|
||||
|
||||
msgid "Select or enter path for sing-box cache file. Change this ONLY if you know what you are doing"
|
||||
msgstr "Выберите или введите путь к файлу кэша sing-box. Меняйте ТОЛЬКО если знаете, что делаете"
|
||||
|
||||
msgid "Cache file path cannot be empty"
|
||||
msgstr "Путь к файлу кэша не может быть пустым"
|
||||
|
||||
msgid "Path must be absolute (start with /)"
|
||||
msgstr "Путь должен быть абсолютным (начинаться с /)"
|
||||
|
||||
msgid "Path must end with cache.db"
|
||||
msgstr "Путь должен заканчиваться на cache.db"
|
||||
|
||||
msgid "Path must contain at least one directory (like /tmp/cache.db)"
|
||||
msgstr "Путь должен содержать хотя бы одну директорию (например /tmp/cache.db)"
|
||||
|
||||
msgid "Invalid path format. Must be like /tmp/cache.db"
|
||||
msgstr "Неверный формат пути. Пример: /tmp/cache.db"
|
||||
@@ -875,4 +875,37 @@ msgid "DNS Server"
|
||||
msgstr ""
|
||||
|
||||
msgid "Select or enter DNS server address"
|
||||
msgstr ""
|
||||
|
||||
msgid "DNS Rewrite TTL"
|
||||
msgstr ""
|
||||
|
||||
msgid "Time in seconds for DNS record caching (default: 600)"
|
||||
msgstr ""
|
||||
|
||||
msgid "TTL value cannot be empty"
|
||||
msgstr ""
|
||||
|
||||
msgid "TTL must be a positive number"
|
||||
msgstr ""
|
||||
|
||||
msgid "Cache File Path"
|
||||
msgstr ""
|
||||
|
||||
msgid "Select or enter path for sing-box cache file. Change this ONLY if you know what you are doing"
|
||||
msgstr ""
|
||||
|
||||
msgid "Cache file path cannot be empty"
|
||||
msgstr ""
|
||||
|
||||
msgid "Path must be absolute (start with /)"
|
||||
msgstr ""
|
||||
|
||||
msgid "Path must end with cache.db"
|
||||
msgstr ""
|
||||
|
||||
msgid "Path must contain at least one directory (like /tmp/cache.db)"
|
||||
msgstr ""
|
||||
|
||||
msgid "Invalid path format. Must be like /tmp/cache.db"
|
||||
msgstr ""
|
||||
@@ -37,7 +37,6 @@ SUBNETS_META="${GITHUB_RAW_URL}/Subnets/IPv4/meta.lst"
|
||||
SUBNETS_DISCORD="${GITHUB_RAW_URL}/Subnets/IPv4/discord.lst"
|
||||
SUBNETS_TELERAM="${GITHUB_RAW_URL}/Subnets/IPv4/telegram.lst"
|
||||
SING_BOX_CONFIG="/etc/sing-box/config.json"
|
||||
CACHE_FILE_PATH="/tmp/cache.db"
|
||||
FAKEIP="198.18.0.0/15"
|
||||
VALID_SERVICES="russia_inside russia_outside ukraine_inside geoblock block porn news anime youtube discord meta twitter hdrezka tiktok telegram"
|
||||
DNS_RESOLVERS="1.1.1.1 1.0.0.1 8.8.8.8 8.8.4.4 9.9.9.9 9.9.9.11 94.140.14.14 94.140.15.15 208.67.220.220 208.67.222.222 77.88.8.1 77.88.8.8"
|
||||
@@ -709,8 +708,13 @@ sing_box_dns() {
|
||||
}
|
||||
|
||||
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 \
|
||||
--arg ttl "$rewrite_ttl" \
|
||||
'.dns += {
|
||||
"rules": [
|
||||
{
|
||||
@@ -727,6 +731,8 @@ sing_box_dns_rule_fakeip() {
|
||||
},
|
||||
{
|
||||
"server": "fakeip-server",
|
||||
"domain": "",
|
||||
"rewrite_ttl": ($ttl | tonumber),
|
||||
"rule_set": []
|
||||
}
|
||||
]
|
||||
@@ -754,14 +760,17 @@ sing_box_dns_rule_fakeip_section() {
|
||||
}
|
||||
|
||||
sing_box_cache_file() {
|
||||
log "Configure cache.db in sing-box"
|
||||
config_get cache_file "main" "cache_file" "/tmp/cache.db"
|
||||
|
||||
log "Configure sing-box cache.db path"
|
||||
|
||||
jq \
|
||||
--arg CACHE_FILE_PATH "$CACHE_FILE_PATH" \
|
||||
--arg cache_file "$cache_file" \
|
||||
'.experimental = {
|
||||
"cache_file": {
|
||||
"enabled": true,
|
||||
"store_fakeip": true,
|
||||
"path": $CACHE_FILE_PATH
|
||||
"path": $cache_file
|
||||
}
|
||||
}' $SING_BOX_CONFIG >/tmp/sing-box-config-tmp.json && mv /tmp/sing-box-config-tmp.json $SING_BOX_CONFIG
|
||||
}
|
||||
@@ -1843,10 +1852,8 @@ sing_box_add_secure_dns_probe_domain() {
|
||||
--arg override "$override_address" \
|
||||
'.dns.rules |= map(
|
||||
if .server == "fakeip-server" then
|
||||
{
|
||||
"server": .server,
|
||||
"domain": $domain,
|
||||
"rule_set": .rule_set
|
||||
. + {
|
||||
"domain": $domain
|
||||
}
|
||||
else
|
||||
.
|
||||
|
||||
Reference in New Issue
Block a user