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
e4d05e6b
Commit
e4d05e6b
authored
2 years ago
by
aiyion.prime
Committed by
Jan-Niklas Burfeind
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
gluon-mesh-vpn-wireguard: add fastd key migration
parent
759a3436
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
package/gluon-mesh-vpn-wireguard/luasrc/lib/gluon/upgrade/400-mesh-vpn-wireguard
+49
-4
49 additions, 4 deletions
...wireguard/luasrc/lib/gluon/upgrade/400-mesh-vpn-wireguard
with
49 additions
and
4 deletions
package/gluon-mesh-vpn-wireguard/luasrc/lib/gluon/upgrade/400-mesh-vpn-wireguard
+
49
−
4
View file @
e4d05e6b
#!/usr/bin/lua
local
uci
=
require
(
'simple-uci'
).
cursor
()
local
unistd
=
require
'posix.unistd'
local
util
=
require
(
'gluon.util'
)
local
site
=
require
'gluon.site'
local
sp
=
util
.
subprocess
local
wait
=
require
'posix.sys.wait'
local
private_key
=
uci
:
get
(
"network_gluon-old"
,
'wg_mesh'
,
"private_key"
)
local
wg_
private_key
=
uci
:
get
(
"network_gluon-old"
,
'wg_mesh'
,
"private_key"
)
if
not
private_key
or
not
private_key
:
match
(
"^"
..
(
"[%a%d+/]"
):
rep
(
42
)
..
"[AEIMQUYcgkosw480]=$"
)
then
private_key
=
"generate"
local
function
valid_fastd_key
(
fastd_key
)
return
fastd_key
and
fastd_key
:
match
((
'%x'
):
rep
(
64
))
end
local
function
valid_wireguard_key
(
wireguard_key
)
return
wireguard_key
and
wireguard_key
:
match
(
"^"
..
(
"[%a%d+/]"
):
rep
(
42
)
..
"[AEIMQUYcgkosw480]=$"
)
end
local
function
migrate_from_fastd_secret
(
fastd_secret
)
local
options
=
{
stdin
=
sp
.
PIPE
,
stdout
=
sp
.
PIPE
,
}
local
pid
,
pipe
=
sp
.
popen
(
'gluon-hex-to-b64'
,
{},
options
)
if
not
pid
then
return
end
local
inw
=
pipe
.
stdin
local
out
=
pipe
.
stdout
unistd
.
write
(
inw
,
string.format
(
'%s\n'
,
fastd_secret
))
unistd
.
close
(
inw
)
local
wpid
,
status
,
code
=
wait
.
wait
(
pid
)
if
wpid
and
status
==
'exited'
and
code
==
0
then
local
result
=
unistd
.
read
(
out
,
44
)
unistd
.
close
(
out
)
return
result
end
end
if
not
valid_wireguard_key
(
wg_private_key
)
then
local
fastd_secret
=
uci
:
get
(
'fastd'
,
'mesh_vpn'
,
'secret'
)
if
valid_fastd_key
(
fastd_secret
)
then
wg_private_key
=
migrate_from_fastd_secret
(
fastd_secret
)
end
end
if
not
valid_wireguard_key
(
wg_private_key
)
then
wg_private_key
=
"generate"
end
uci
:
section
(
'network'
,
'interface'
,
'wg_mesh'
,
{
proto
=
'wireguard'
,
fwmark
=
1
,
private_key
=
private_key
,
private_key
=
wg_
private_key
,
})
uci
:
section
(
'network'
,
'interface'
,
'mesh_wg_mesh'
,
{
...
...
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