fix: response cache stats missing enabled field; tor status reads from JSON...

fix: response cache stats missing enabled field; tor status reads from JSON config instead of Pydantic singleton
parent 4a217dcd
...@@ -1638,8 +1638,8 @@ class ResponseCache: ...@@ -1638,8 +1638,8 @@ class ResponseCache:
Dict with cache statistics Dict with cache statistics
""" """
stats = self.stats.copy() stats = self.stats.copy()
stats['enabled'] = self.enabled
# Add current cache size stats['backend'] = self.backend
if self.backend == 'redis' and self.redis_client: if self.backend == 'redis' and self.redis_client:
try: try:
pattern = f"{self.key_prefix}*" pattern = f"{self.key_prefix}*"
......
...@@ -15651,10 +15651,11 @@ async def dashboard_tor_status(request: Request): ...@@ -15651,10 +15651,11 @@ async def dashboard_tor_status(request: Request):
return JSONResponse({'success': False, 'error': 'Admin access required'}, status_code=403) return JSONResponse({'success': False, 'error': 'Admin access required'}, status_code=403)
try: try:
from aisbf.config import get_config config_path = get_aisbf_config_path()
config = get_config() with open(config_path) as f:
aisbf_config = json.load(f)
tor_enabled = config and hasattr(config, 'tor') and config.tor and config.tor.enabled tor_cfg = aisbf_config.get('tor', {})
tor_enabled = bool(tor_cfg.get('enabled', False))
tor_running = tor_service is not None and tor_service.is_connected() if tor_service else False tor_running = tor_service is not None and tor_service.is_connected() if tor_service else False
response = { response = {
......
...@@ -347,8 +347,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. ...@@ -347,8 +347,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
<h3 style="margin: 24px 0 16px; font-size:1em; color:#a0a0a0; border-bottom: 1px solid #0f3460; padding-bottom:8px;">Response Cache Configuration</h3> <h3 style="margin: 24px 0 16px; font-size:1em; color:#a0a0a0; border-bottom: 1px solid #0f3460; padding-bottom:8px;">Response Cache Configuration</h3>
<!-- DEBUG: {{ config.response_cache }} -->
<div class="form-group"> <div class="form-group">
<label> <label>
<input type="checkbox" name="response_cache_enabled" {% if config.response_cache and config.response_cache.enabled %}checked{% endif %}> <input type="checkbox" name="response_cache_enabled" {% if config.response_cache and config.response_cache.enabled %}checked{% endif %}>
...@@ -531,7 +529,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. ...@@ -531,7 +529,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
<input type="checkbox" name="tor_enabled" id="tor_enabled" {% if config.tor and config.tor.enabled %}checked{% endif %} onchange="toggleTorFields()"> <input type="checkbox" name="tor_enabled" id="tor_enabled" {% if config.tor and config.tor.enabled %}checked{% endif %} onchange="toggleTorFields()">
Enable TOR Hidden Service Enable TOR Hidden Service
</label> </label>
<!-- DEBUG TOR: {{ config.tor }} -->
<small style="color: #666; display: block; margin-top: 5px;">Expose AISBF over TOR network as a hidden service</small> <small style="color: #666; display: block; margin-top: 5px;">Expose AISBF over TOR network as a hidden service</small>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment