mirror of
https://codeberg.org/prof_x_pvt_ltd/captive.whump.shanti-portal
synced 2024-08-14 22:46:42 +00:00
fixing some config issues with plugins.
This commit is contained in:
parent
4271143896
commit
972140afe4
4 changed files with 13 additions and 7 deletions
|
@ -4,11 +4,13 @@
|
|||
# This is just a sample plugin, comment out or remove in production.
|
||||
[sample_log]
|
||||
enabled = True
|
||||
debug = True
|
||||
|
||||
# Runs an iptables command to add a rule, commonly used for captive portal
|
||||
# firewalls.
|
||||
[iptables]
|
||||
enabled = True
|
||||
enabled = False
|
||||
debug = True
|
||||
|
||||
# If you know you won't be able to get the clients HW address then use this.
|
||||
only_ip = True
|
||||
|
@ -16,7 +18,7 @@ only_ip = True
|
|||
# Command templates for arping and iptables.
|
||||
# Arping might block so make sure you use a timeout and limit the number of
|
||||
# packets it sends.
|
||||
arping = -f -c 1 -w 30 -I wlp3s0 {ip_address}
|
||||
arping = -f -c 1 -w 30 -I eth0 {ip_address}
|
||||
|
||||
iptables_mac = -t mangle -I internet 1 -m mac --mac-source {mac_address} -j RETURN
|
||||
iptables_ip = -t mangle -I internet 1 -m tcp -p tcp --source {ip_address} -j RETURN
|
||||
|
|
|
@ -28,13 +28,15 @@ def run(arg):
|
|||
plugin_config = arg['config']
|
||||
|
||||
config = RawConfigParser(defaults=plugin_config)
|
||||
config.add_section(plugin_config.get('__name__', 'iptables'))
|
||||
config.add_section('iptables')
|
||||
config._sections['iptables'] = plugin_config
|
||||
|
||||
# Setup plugin logging
|
||||
l = getLogger('plugin_iptables')
|
||||
l.addHandler(logHandler)
|
||||
if config.getboolean('iptables', 'debug', False):
|
||||
if config.getboolean('iptables', 'debug'):
|
||||
l.setLevel(DEBUG)
|
||||
l.debug('debug logging enabled')
|
||||
|
||||
client_ip = environ.get(
|
||||
'HTTP_X_FORWARDED_FOR',
|
||||
|
|
|
@ -17,12 +17,14 @@ def run(arg):
|
|||
plugin_config = arg['config']
|
||||
|
||||
config = RawConfigParser(defaults=plugin_config)
|
||||
config.add_section(plugin_config.get('__name__', 'sample_log'))
|
||||
config.add_section('sample_log')
|
||||
config._sections['sample_log'] = plugin_config
|
||||
|
||||
l = getLogger('plugin_log')
|
||||
l.addHandler(logHandler)
|
||||
if config.getboolean('sample_log', 'debug', False):
|
||||
l.setLevel(DEBUG)
|
||||
l.debug('debug logging enabled')
|
||||
|
||||
log_url = '{proto}://{server}:{port}{request}'.format(
|
||||
proto=environ.get('wsgi.url_scheme'),
|
||||
|
|
|
@ -27,7 +27,7 @@ config.read(['/etc/captiveportal/portal.cfg', './portal_local.cfg'])
|
|||
# their section removed/commented from the config file.
|
||||
plugin_config = RawConfigParser()
|
||||
plugin_config.readfp(open('./plugins.cfg'))
|
||||
plugin_config.read(['/etc/captiveportal/plugins.cfg'])
|
||||
plugin_config.read(['/etc/captiveportal/plugins.cfg', './plugins_local.cfg'])
|
||||
|
||||
# Setup logging
|
||||
logFormatter = Formatter(config.get('logging', 'log_format'))
|
||||
|
@ -104,7 +104,7 @@ def dispatch_plugins():
|
|||
|
||||
# Import all the plugin configuration values as OrderedDict
|
||||
config_sections = plugin_config._sections
|
||||
arg['config'] = dict(config_sections[plugin])
|
||||
arg['config'] = config_sections[plugin]
|
||||
|
||||
# Is plugin enabled?
|
||||
if not plugin_config.getboolean(plugin, 'enabled'):
|
||||
|
|
Loading…
Reference in a new issue