Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFS Gluon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
firmware
FFS Gluon
Commits
691f0cb6
Commit
691f0cb6
authored
10 years ago
by
Matthias Schiffer
Browse files
Options
Downloads
Patches
Plain Diff
gluon-status-page: show VPN status (very minimalistic for now)
parent
5ee5cf3e
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
+61
-0
61 additions, 0 deletions
...tatus-page/files/lib/gluon/status-page/www/cgi-bin/status
with
61 additions
and
0 deletions
package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/status
+
61
−
0
View file @
691f0cb6
...
@@ -2,8 +2,10 @@
...
@@ -2,8 +2,10 @@
local util = require("luci.util")
local util = require("luci.util")
local fs = require("luci.fs")
local fs = require("luci.fs")
local ltn12 = require 'luci.ltn12'
local sys = require("luci.sys")
local sys = require("luci.sys")
local json = require("luci.json")
local json = require("luci.json")
local nixio = require 'nixio'
local platform_info = require("platform_info")
local platform_info = require("platform_info")
local hostname = sys.hostname()
local hostname = sys.hostname()
...
@@ -74,6 +76,65 @@ for _, ifname in ipairs(interfaces) do
...
@@ -74,6 +76,65 @@ for _, ifname in ipairs(interfaces) do
io.write("
</pre>
")
io.write("
</pre>
")
end
end
local err, fastd_status = pcall(
function()
local fastd_sock = nixio.socket('unix', 'stream')
assert(fastd_sock:connect('/var/run/fastd.mesh_vpn.socket'))
-- Stop as soon as we see an empty chunk
local function guard_source(src)
return function()
local chunk, err = src()
if not chunk then return nil, err end
if chunk:len() == 0 then return nil end
return chunk
end
end
source = guard_source(ltn12.source.file(fastd_sock))
decoder = json.Decoder()
ltn12.pump.all(source, decoder:sink())
fastd_sock:close()
return decoder:get()
end
)
io.write("
<h2>
VPN status
</h2>
")
io.write("
<pre>
")
if fastd_status then
io.write(string.format("fastd running for %.3f seconds\n", fastd_status.uptime/1000))
local peers = 0
local connections = 0
for key, peer in pairs(fastd_status.peers) do
peers = peers+1
if peer.connection then
connections = connections+1
end
end
io.write(string.format("There are %i peers configured, of which %i are connected:\n\n", peers, connections))
for key, peer in pairs(fastd_status.peers) do
io.write(string.format("%s: ", escape_html(peer.name)))
if peer.connection then
io.write(string.format("connected for %.3f seconds\n", peer.connection.established/1000))
else
io.write("not connected\n")
end
end
else
io.write("fastd not running")
end
io.write("
</pre>
")
io.write("
<script>
"
)
io.write("
<script>
"
)
for _, ifname in ipairs(interfaces) do
for _, ifname in ipairs(interfaces) do
local macs = neighbours(ifname)
local macs = neighbours(ifname)
...
...
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