Fix/qfeeds unbound blocklist priority conflict (#4979)

* Fix Q-Feeds unbound blocklist handler priority conflict

- Change priority from 100 to 50 to avoid conflicts with predefined handlers
- Add conditional logic to respect enable_unbound_bl setting
- Return empty blocklist when integration is disabled

* Update qfeeds_bl.py
This commit is contained in:
Q-Feeds
2025-10-15 17:39:05 +02:00
committed by GitHub
parent fd1fbf0aec
commit 17b605be7d
@@ -32,7 +32,7 @@ from . import BaseBlocklistHandler
class DefaultBlocklistHandler(BaseBlocklistHandler):
def __init__(self):
super().__init__('/usr/local/etc/unbound/qfeeds-blocklists.conf')
self.priority = 100
self.priority = 50
def get_config(self):
cfg = {'qfeeds_filenames': []}
@@ -42,6 +42,10 @@ class DefaultBlocklistHandler(BaseBlocklistHandler):
return cfg
def get_blocklist(self):
# Only return domains if integration is enabled
if not self._is_enabled():
return {} # Return empty blocklist when disabled
result = {}
for filename in self.get_config()['qfeeds_filenames']:
bl_shortcode = "qf_%s" % os.path.splitext(os.path.basename(filename).strip())[0]
@@ -53,3 +57,14 @@ class DefaultBlocklistHandler(BaseBlocklistHandler):
def get_passlist_patterns(self):
return []
def _is_enabled(self):
# Check if unbound blocklist integration is enabled
try:
import subprocess
result = subprocess.run(['/usr/local/sbin/configctl', 'config', 'get',
'OPNsense.QFeedsConnector.general.enable_unbound_bl'],
capture_output=True, text=True)
return result.stdout.strip() == '1'
except:
return False