From ec936e236942ae518b2a3a1da3d950c54731facf Mon Sep 17 00:00:00 2001 From: Nikita Skryabin Date: Thu, 20 Feb 2025 22:49:58 +0300 Subject: [PATCH] feat(podkop): add configurable cache file path support --- .../luci-static/resources/view/podkop/podkop.js | 7 +++++++ podkop/files/etc/init.d/podkop | 15 +++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) 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 ffd136d..01f02fc 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 @@ -697,6 +697,13 @@ return view.extend({ return true; }; + 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('/usr/share/sing-box/cache.db', 'Flash (/usr/share/sing-box/cache.db)'); + o.default = '/tmp/cache.db'; + o.rmempty = false; + o.ucisection = 'main'; + // Diagnostics tab o = s.tab('diagnostics', _('Diagnostics')); diff --git a/podkop/files/etc/init.d/podkop b/podkop/files/etc/init.d/podkop index 4caf1a7..30794e1 100755 --- a/podkop/files/etc/init.d/podkop +++ b/podkop/files/etc/init.d/podkop @@ -754,9 +754,20 @@ sing_box_dns_rule_fakeip_section() { } sing_box_cache_file() { - log "Configure cache.db in sing-box" + local cache_path + + config_get cache_file "main" "cache_file" "/tmp/cache.db" + + if [ "$cache_file" = "custom" ]; then + config_get cache_path "main" "custom_cache_path" + else + cache_path="$cache_file" + fi + + log "Configure sing-box cache.db path" + jq \ - --arg CACHE_FILE_PATH "$CACHE_FILE_PATH" \ + --arg CACHE_FILE_PATH "$cache_path" \ '.experimental = { "cache_file": { "enabled": true,