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
3725f7bc
Commit
3725f7bc
authored
9 years ago
by
Matthias Schiffer
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'origin/announce.d'
parents
69d18cc9
9dffb128
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
package/gluon-announce/files/usr/lib/lua/gluon/announce.lua
+25
-7
25 additions, 7 deletions
package/gluon-announce/files/usr/lib/lua/gluon/announce.lua
package/gluon-announced/files/usr/lib/lua/gluon/announced.lua
+23
-6
23 additions, 6 deletions
...age/gluon-announced/files/usr/lib/lua/gluon/announced.lua
with
48 additions
and
13 deletions
package/gluon-announce/files/usr/lib/lua/gluon/announce.lua
+
25
−
7
View file @
3725f7bc
...
...
@@ -10,24 +10,42 @@ local function collect_entry(entry)
if
fs
.
stat
(
entry
,
'type'
)
==
'dir'
then
return
collect_dir
(
entry
)
else
return
setfenv
(
loadfile
(
entry
)
,
_M
)()
return
loadfile
(
entry
)
end
end
function
collect_dir
(
dir
)
local
ret
=
{
[{}]
=
true
}
local
fns
=
{}
for
entry
in
fs
.
dir
(
dir
)
do
if
entry
:
sub
(
1
,
1
)
~=
'.'
then
local
ok
,
val
=
pcall
(
collect_entry
,
dir
..
'/'
..
entry
)
collectgarbage
()
local
fn
,
err
=
collect_entry
(
dir
..
'/'
..
entry
)
if
fn
then
fns
[
entry
]
=
fn
else
io.stderr
:
write
(
err
,
'
\n
'
)
end
end
end
return
function
()
local
ret
=
{
[{}]
=
true
}
for
k
,
v
in
pairs
(
fns
)
do
collectgarbage
()
local
ok
,
val
=
pcall
(
setfenv
(
v
,
_M
))
if
ok
then
ret
[
entry
]
=
val
ret
[
k
]
=
val
else
io.stderr
:
write
(
val
,
'
\n
'
)
end
end
end
return
ret
end
collectgarbage
()
return
ret
end
end
This diff is collapsed.
Click to expand it.
package/gluon-announced/files/usr/lib/lua/gluon/announced.lua
+
23
−
6
View file @
3725f7bc
local
announce
=
require
'gluon.announce'
local
deflate
=
require
'deflate'
local
json
=
require
'luci.jsonc'
local
nixio
=
require
'nixio'
local
fs
=
require
'nixio.fs'
local
memoize
=
{}
local
function
collect
(
type
)
return
announce
.
collect_dir
(
'/lib/gluon/announce/'
..
type
..
'.d'
)
nixio
.
chdir
(
'/lib/gluon/announce/'
)
for
dir
in
fs
.
glob
(
'*.d'
)
do
local
name
=
dir
:
sub
(
1
,
-
3
)
memoize
[
name
]
=
announce
.
collect_dir
(
dir
)
end
local
function
collect
(
type
)
return
memoize
[
type
]
and
memoize
[
type
]()
end
module
(
'gluon.announced'
,
package
.
seeall
)
function
handle_request
(
query
)
if
query
:
match
(
'^nodeinfo$'
)
then
return
json
.
stringify
(
collect
(
'nodeinfo'
))
end
collectgarbage
()
local
m
=
query
:
match
(
'^GET ([a-z ]+)$'
)
local
ret
if
m
then
local
data
=
{}
...
...
@@ -27,7 +35,16 @@ function handle_request(query)
end
if
next
(
data
)
then
return
deflate
.
compress
(
json
.
stringify
(
data
))
ret
=
deflate
.
compress
(
json
.
stringify
(
data
))
end
elseif
query
:
match
(
'^[a-z]+$'
)
then
local
ok
,
data
=
pcall
(
collect
,
query
)
if
ok
then
ret
=
json
.
stringify
(
data
)
end
end
collectgarbage
()
return
ret
end
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