From e17422a0cf7f26923069f494d6b6bf38b5579ba5 Mon Sep 17 00:00:00 2001 From: itdoginfo Date: Fri, 21 Feb 2025 15:37:20 +0300 Subject: [PATCH] Fix #37 #41 --- .../resources/view/podkop/podkop.js | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js b/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js index 5048098..51ddf9e 100644 --- a/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js +++ b/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js @@ -525,6 +525,50 @@ return view.extend({ return true; }; + o = mainSection.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 = mainSection.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; + }; + // Extra IPs and exclusions (main section) o = mainSection.taboption('basic', form.Flag, 'exclude_from_ip_enabled', _('IP for exclusion'), _('Specify local IP addresses that will never use the configured route')); o.default = '0';