Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
ffbs-gluon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
darkbit
ffbs-gluon
Commits
5266a073
Commit
5266a073
authored
10 years ago
by
Nils Schneider
Browse files
Options
Downloads
Patches
Plain Diff
status-page: escape html, move script to body
parent
710cb8b3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/status
+19
-14
19 additions, 14 deletions
...tatus-page/files/lib/gluon/status-page/www/cgi-bin/status
with
19 additions
and
14 deletions
package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/status
+
19
−
14
View file @
5266a073
...
...
@@ -10,6 +10,10 @@ local hostname = sys.hostname()
local model = platform_info.get_model()
local release = util.trim(fs.readfile("/lib/gluon/release") or "")
function escape_html(s)
return (s:gsub('
&
', '
&
'):gsub('
<
',
'&
lt
;')
:gsub
('
>
', '
>
'):gsub('"', '
"
'))
end
function neighbours(ifname)
local info = util.exec("gluon-neighbour-info -d ff02::2:1001 -p 1001 -r nodeinfo -t 3 -i " .. ifname)
local macs = {}
...
...
@@ -32,20 +36,20 @@ io.write("<!DOCTYPE html>\n")
io.write("
<html>
")
io.write("
<head>
")
io.write("
<script
src=
\"/status.js\"
></script>
")
io.write("
<title>
" .. hostname .. "
</title>
")
io.write("
<title>
" ..
escape_html(
hostname
)
.. "
</title>
")
io.write("
</head>
")
io.write("
<body>
")
io.write("
<h1>
" .. hostname .. "
</h1>
")
io.write("
<h1>
" ..
escape_html(
hostname
)
.. "
</h1>
")
io.write("
<pre>
")
io.write("Model: " .. model .. "\n")
io.write("Firmware release: " .. release .. "\n\n")
io.write("Model: " ..
escape_html(
model
)
.. "\n")
io.write("Firmware release: " ..
escape_html(
release
)
.. "\n\n")
io.write(util.trim(sys.exec("uptime | sed 's/^ \+//'")) .. "\n\n")
io.write(sys.exec("ip address show dev br-client") .. "\n")
io.write(sys.exec("free -m") .. "\n")
io.write(sys.exec("df /rom /overlay"))
io.write(
escape_html(
util.trim(sys.exec("uptime | sed 's/^ \+//'"))
)
.. "\n\n")
io.write(
escape_html(
sys.exec("ip address show dev br-client")
)
.. "\n")
io.write(
escape_html(
sys.exec("free -m")
)
.. "\n")
io.write(
escape_html(
sys.exec("df /rom /overlay"))
)
io.write("
</pre>
")
io.write("
<h2>
Neighbours
</h2>
")
...
...
@@ -53,24 +57,23 @@ io.write("<h2>Neighbours</h2>")
local interfaces = util.split(util.trim(util.exec("iw dev | grep IBSS -B 5 | grep Interface | cut -d' ' -f2")))
for _, ifname in ipairs(interfaces) do
io.write("
<h3>
" .. ifname .. "
</h3>
")
io.write("
<h3>
" ..
escape_html(
ifname
)
.. "
</h3>
")
io.write("
<pre>
")
io.write(sys.exec("iw dev " .. ifname .. " link") .. "\n")
io.write(
escape_html(
sys.exec("iw dev " .. ifname .. " link")
)
.. "\n")
for _, line in ipairs(util.split(util.exec("iw dev " .. ifname .. " station dump"))) do
local mac = line:match("^Station (.*) %(on ")
if mac then
io.write("Station
<a
id=
\""
..
ifname
..
"
-
"
..
mac
..
"\"
>
" .. mac .. "
</a>
(on " .. ifname .. ")\n")
io.write("Station
<a
id=
\""
..
escape_html
(
ifname
)
..
"
-
"
..
mac
..
"\"
>
" .. mac .. "
</a>
(on " ..
escape_html(
ifname
)
.. ")\n")
else
io.write(line .. "\n")
io.write(
escape_html(
line
)
.. "\n")
end
end
io.write("
</pre>
")
end
io.write("
</body>
")
io.write("
<script>
"
)
for _, ifname in ipairs(interfaces) do
local macs = neighbours(ifname)
...
...
@@ -86,9 +89,11 @@ for _, ifname in ipairs(interfaces) do
end
if ip and hostname then
io.write(
"
update_node
(
\
""
..
ifname
..
"
-
"
..
mac
..
"
\"
,
\"
"
..
ip
..
"
\"
,
\"
"
..
hostname
..
"
\"
);
"
)
io.write(
"
update_node
(
\
""
..
escape_html
(
ifname
)
..
"
-
"
..
mac
..
"
\"
,
\"
"
..
escape_html
(
ip
)
..
"
\"
,
\"
"
..
escape_html
(
hostname
)
..
"
\"
);
"
)
end
end
end
io
.
write
(
"
</script>
")
io.write("
</body>
")
io.write("
</html>
")
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment