mirror of
https://github.com/netbirdio/plugins.git
synced 2026-05-22 18:44:07 -07:00
security/q-feeds-connector - cleanup blocklist
This commit is contained in:
@@ -35,19 +35,18 @@ class DefaultBlocklistHandler(BaseBlocklistHandler):
|
||||
self.priority = 50
|
||||
|
||||
def get_config(self):
|
||||
cfg = {'qfeeds_filenames': []}
|
||||
if self.cnf and self.cnf.has_section('settings'):
|
||||
if self.cnf.has_option('settings', 'filenames'):
|
||||
cfg['qfeeds_filenames'] = self.cnf.get('settings', 'filenames').split(',')
|
||||
return cfg
|
||||
# do not use, unbound worker settings
|
||||
return {}
|
||||
|
||||
def get_blocklist(self):
|
||||
# Only return domains if integration is enabled
|
||||
if not self._is_enabled():
|
||||
return {} # Return empty blocklist when disabled
|
||||
|
||||
# Only return domains if integration is enabled (filenames are offered)
|
||||
qfeeds_filenames = []
|
||||
if self.cnf and self.cnf.has_section('settings'):
|
||||
if self.cnf.has_option('settings', 'filenames'):
|
||||
qfeeds_filenames = self.cnf.get('settings', 'filenames').split(',')
|
||||
|
||||
result = {}
|
||||
for filename in self.get_config()['qfeeds_filenames']:
|
||||
for filename in qfeeds_filenames:
|
||||
bl_shortcode = "qf_%s" % os.path.splitext(os.path.basename(filename).strip())[0]
|
||||
if os.path.exists(filename):
|
||||
with open(filename, 'r') as f_in:
|
||||
@@ -57,14 +56,3 @@ 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
|
||||
|
||||
Reference in New Issue
Block a user