-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gluon-mesh-vpn-wireguard: add fastd key migration #2601
Conversation
package/gluon-mesh-vpn-wireguard/luasrc/lib/gluon/upgrade/399-mesh-vpn-wireguard-from-fastd
Outdated
Show resolved
Hide resolved
package/gluon-mesh-vpn-wireguard/luasrc/lib/gluon/upgrade/399-mesh-vpn-wireguard-from-fastd
Outdated
Show resolved
Hide resolved
package/gluon-mesh-vpn-wireguard/luasrc/lib/gluon/upgrade/399-mesh-vpn-wireguard-from-fastd
Outdated
Show resolved
Hide resolved
package/gluon-mesh-vpn-wireguard/luasrc/lib/gluon/upgrade/399-mesh-vpn-wireguard-from-fastd
Outdated
Show resolved
Hide resolved
Other than the commit message which should contain a reference to @NeoRaider A review would be highly appreciated. |
Just a thought, instead of operating on both UCI network_gluon-old and fastd, would it maybe make sense to have something like a generic gluon.mesh_vpn.secret? And derive both the fastd and wireguard secrets from it? As the role based interface configuration is in /etc/config/gluon, too, maybe it would be a nice feature if for making a backup of your node configuration it would be sufficient to copy the high level /etc/config/gluon* files? |
@T-X I think that's a great idea and something I'd gladly implement, Storing the mesh_vpn_secret in config.gluon would be way cleaner though and something I could write for |
aligned the Makefile definition to the existing one |
My preference/expectations for major vs. minor releases would be:
So I'm wondering if it would be doable to do it in a clean(tm) way now? To avoid refactoring it in a minor release? |
I think adding other big changes like where this secret goes to this PR would not help getting it merged before |
as well as the corresponding fastd eky conversion can be removed once freifunk-gluon/gluon#2601 is merged
as well as the corresponding fastd key conversion can be removed once freifunk-gluon/gluon#2601 is merged
as well as the corresponding fastd key conversion can be removed once freifunk-gluon/gluon#2601 is merged
as well as the corresponding fastd key conversion can be removed once freifunk-gluon/gluon#2601 is merged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some cosmetic suggestions...
fprintf(stderr, "Usage: gluon-mesh-vpn-key-translate [-n] <fastd secret>\n"); | ||
fprintf(stderr, "-n do not output the trailing newline\n"); | ||
exit(1); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One call of fprintf would be better and use a macro instead of inline functions like:
#define error(msg, ...) \
do { \
fprintf(stderr, "Error: " msg "\n", ##__VA_ARGS__); \
exit(1); \
} while (0)
I don't think it harms code readability to directly include the error message in the main function instead of hiding it away in a separate one.
return false; | ||
|
||
size_t i; | ||
for (i = 0; i < 32; i++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As "i" is only used in the for loop and is never going to reach size_t, just do
for (int i = 0; i < 32; i++)
package/gluon-mesh-vpn-wireguard/src/gluon-mesh-vpn-key-translate.c
Outdated
Show resolved
Hide resolved
package/gluon-mesh-vpn-wireguard/src/gluon-mesh-vpn-key-translate.c
Outdated
Show resolved
Hide resolved
@CodeFetch thanks for your suggestions. Before I address
though, I'll keep waiting for @NeoRaider to review the general idea, as @blocktrron suggested in the last developer meetup. Leaving the code as is (just right now) has the benefit of it currently running successfully on Once he answers, whether and if - in what form - this can be merged, I'm happy to come back to your suggestions for improvements. |
} | ||
|
||
static inline bool read_key(uint8_t key[32], const char *hexkey) { | ||
if ((strlen(hexkey) != 64) || (strspn(hexkey, "0123456789abcdefABCDEF") != 64)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The braces are superfluous and don't contribute to code readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, there are braces one could've left out regarding precedence;
but I'd disagree on the readability. Both does not really matter though, what does is, that that's not my code, but actually @NeoRaider's, as attributed above.
https://github.com/NeoRaider/fastd/blob/d9dd14045c647736566c959855f154302eeff444/src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.c#L17-L27
But as I said earlier I'd really like to get some basic feedback from neoraider, before I address nitpicks.
Statistically speaking - looking at how my previous PR's went -there will likely be no line left unturned; really those braces will be the least of concerns, once he finds time, I'm afraid.
Not that I do not appreciate the engagement with the PR,
but beautifying is not the stage I'm currently at, yet,
3c7a9f6
to
7921b92
Compare
package/gluon-mesh-vpn-wireguard/src/gluon-mesh-vpn-key-translate.c
Outdated
Show resolved
Hide resolved
package/gluon-mesh-vpn-wireguard/src/gluon-mesh-vpn-key-translate.c
Outdated
Show resolved
Hide resolved
...e/gluon-mesh-vpn-wireguard/luasrc/lib/gluon/upgrade/399-mesh-vpn-fastd-wireguard-key-convert
Outdated
Show resolved
Hide resolved
package/gluon-mesh-vpn-wireguard/src/gluon-mesh-vpn-key-translate.c
Outdated
Show resolved
Hide resolved
package/gluon-mesh-vpn-wireguard/src/gluon-mesh-vpn-key-translate.c
Outdated
Show resolved
Hide resolved
a42950a
to
acce83e
Compare
@NeoRaider I think the c code is fine as it is. |
The Lua code is now reformatted, fixed (was missing |
I hope that's it. Both checks were comparing out of bounds before. Local build is running. Test result incoming. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NeoRaider I could provide you with an image from our community, which currently supports both fastd and WireGuard - so that you could watch the migration in action.
Let me know if that would help you reviewing this.
|
review evening: |
9a7d32a
to
5fb640e
Compare
gluon-hex-to-b64 takes base64 content such as a fastd private key in legacy form via stdin and emits it in base64 encoded (WireGuard) form. Provides basic return codes.
5fb640e
to
276cd0e
Compare
I'd say you merge this, if you're satisfied with the docs as we are? |
freifunk-gluon/gluon#2601 has been merged
freifunk-gluon/gluon#2601 has been merged
freifunk-gluon/gluon#2601 has been merged
This reencodes an existing fastd private key as WireGuards private (X25519).
No key is migrated, when no fastd key exists.
We discussed whether it would be cleaner to put it in its own upgrade file, this would be one way of doing it, although writing to network-old appears bad to me. Open for discussion.
I have not tested the implementation of the upgrade yet.Is tested. It updates missing or invalid WireGuard-keys based on the fastd secret key if it exists.