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
17e50bc6
Commit
17e50bc6
authored
3 years ago
by
Kasalehlia
Browse files
Options
Downloads
Patches
Plain Diff
status-page: Reinstate redirection to own ip on local node request
parent
63201589
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
package/gluon-status-page/luasrc/lib/gluon/status-page/controller/status-page.lua
+37
-1
37 additions, 1 deletion
...e/luasrc/lib/gluon/status-page/controller/status-page.lua
with
37 additions
and
1 deletion
package/gluon-status-page/luasrc/lib/gluon/status-page/controller/status-page.lua
+
37
−
1
View file @
17e50bc6
...
...
@@ -63,7 +63,43 @@ end
entry
({},
call
(
function
(
http
,
renderer
)
local
nodeinfo
=
json
.
parse
(
util
.
exec
(
'exec gluon-neighbour-info -d ::1 -p 1001 -t 1 -c 1 -r nodeinfo'
))
-- TODO: Add a redirect to a local v6 addr for parker
local
node_ip
=
parse_ip
(
http
:
getenv
(
'SERVER_ADDR'
))
if
node_ip
then
if
match
(
node_ip
,
parse_ip
(
site
.
next_node
.
ip6
()),
8
)
then
-- The user has visited the status page via the ipv6 next-node address
-- Redirect the user to a unique ipv6 address to avoid switching nodes
-- if there is an address matching the first 64bit of the requesting address
local
remote_ip
=
parse_ip
(
http
:
getenv
(
'REMOTE_ADDR'
))
if
remote_ip
then
for
_
,
addr
in
ipairs
(
nodeinfo
.
network
.
addresses
)
do
if
match
(
remote_ip
,
parse_ip
(
addr
),
4
)
then
http
:
header
(
'Cache-Control'
,
'no-cache, no-store, must-revalidate'
)
http
:
redirect
(
'http://['
..
addr
..
']'
..
http
:
getenv
(
'REQUEST_URI'
))
http
:
close
()
return
end
end
end
end
if
match
(
node_ip
,
parse_ip
(
site
.
next_node
.
ip4
()),
4
)
then
-- The user has visited the status page via the ipv4 next-node address
-- Redirect the user to our unique ipv4 address to avoid switching nodes
local
process
=
io.popen
(
'ip -br -4 address show br-client'
,
'r'
)
if
process
then
local
output
=
process
:
read
(
'*a'
)
process
:
close
()
if
output
then
local
addr
=
string.match
(
output
,
'%d+%.%d+%.%d+%.%d+'
)
if
addr
then
http
:
header
(
'Cache-Control'
,
'no-cache, no-store, must-revalidate'
)
http
:
redirect
(
'http://'
..
addr
..
http
:
getenv
(
'REQUEST_URI'
))
http
:
close
()
return
end
end
end
end
end
renderer
.
render
(
'status-page'
,
{
nodeinfo
=
nodeinfo
,
site
=
site
},
'gluon-status-page'
)
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