luci-app-yggdrasil: support public key in config generation
authorWilliam Fleurant <meshnet@protonmail.com>
Sat, 18 Nov 2023 08:38:47 +0000 (09:38 +0100)
committerWilliam Fleurant <meshnet@protonmail.com>
Sat, 18 Nov 2023 08:38:47 +0000 (09:38 +0100)
Signed-off-by: William Fleurant <meshnet@protonmail.com>
protocols/luci-proto-yggdrasil/htdocs/luci-static/resources/protocol/yggdrasil.js
protocols/luci-proto-yggdrasil/root/usr/libexec/rpcd/luci.yggdrasil

index 3b878799a1d5acc4b15cd7af9100f63075255d2d..849242abfffc15a5877666ad175f83a38242c3f6 100644 (file)
@@ -50,10 +50,12 @@ var cbiKeyPairGenerate = form.DummyValue.extend({
                        'class':'btn',
                        'click':ui.createHandlerFn(this, function(section_id,ev) {
                                var prv = this.section.getUIElement(section_id,'private_key'),
+                                       pub = this.section.getUIElement(section_id,'public_key'),
                                        map = this.map;
 
                                return generateKey().then(function(keypair){
                                        prv.setValue(keypair.priv);
+                                       pub.setValue(keypair.pub);
                                        map.save(null,true);
                                });
                        },section_id)
@@ -189,6 +191,10 @@ return network.registerProtocol('yggdrasil',
                        o.password=true;
                        o.validate=validatePrivateKey;
 
+                       o=s.taboption('general',form.Value,'public_key',_('Public key'),_('The public key for your Yggdrasil node'));
+                       o.optional=true;
+                       o.validate=validatePublicKey;
+
                        s.taboption('general',cbiKeyPairGenerate,'_gen_server_keypair',' ');
 
                        o=s.taboption('advanced',form.Value,'mtu',_('MTU'),_('A default MTU of 65535 is set by Yggdrasil. It is recomended to utilize the default.'));
index d4545277ab069ea01032f07cad7cf322389dffe8..35d6627be7b19ecfc5e24ebda52971f961949eae 100755 (executable)
@@ -16,12 +16,12 @@ case "$1" in
                case "$2" in
                        generateKeyPair)
                                json_load "$(yggdrasil -genconf -json)"
-                               json_get_vars PublicKey PrivateKey
+                               json_get_vars PrivateKey
                                json_cleanup
                                json_init
                                json_add_object "keys"
                                json_add_string "priv" "$PrivateKey"
-                               json_add_string "pub" "$PublicKey"
+                               json_add_string "pub" "${PrivateKey:64}"
                                json_close_object
                                json_dump
                        ;;