Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
cb08c275
Commit
cb08c275
authored
Oct 18, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(Captiveportal, new) add wrapper class for config.xml (read user template code)
parent
f22f4ad0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
__init__.py
src/opnsense/scripts/OPNsense/CaptivePortal/lib/__init__.py
+27
-0
No files found.
src/opnsense/scripts/OPNsense/CaptivePortal/lib/__init__.py
View file @
cb08c275
...
...
@@ -26,6 +26,7 @@
"""
import
os.path
import
stat
import
xml.etree.ElementTree
from
ConfigParser
import
ConfigParser
class
Config
(
object
):
...
...
@@ -75,3 +76,29 @@ class Config(object):
else
:
result
[
zoneid
][
'allowedmacaddresses'
]
=
list
()
return
result
class
OPNSenseConfig
(
object
):
""" Read configuration data from config.xml
"""
def
__init__
(
self
):
self
.
load_config
()
def
load_config
(
self
):
""" load config.xml
"""
tree
=
xml
.
etree
.
ElementTree
.
parse
(
'/conf/config.xml'
)
self
.
rootNode
=
tree
.
getroot
()
def
get_template
(
self
,
fileid
):
""" fetch template content from config.xml
:param fileid: internal fileid (field in template node)
:return: string, bse64 encoded data or None if not found
"""
templates
=
self
.
rootNode
.
findall
(
"./OPNsense/captiveportal/templates/template"
)
if
templates
is
not
None
:
for
template
in
templates
:
if
template
.
find
(
'fileid'
)
is
not
None
and
template
.
find
(
'content'
)
is
not
None
:
if
template
.
find
(
'fileid'
)
.
text
==
fileid
:
return
template
.
find
(
'content'
)
.
text
return
None
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment