[NetworkManager-openvpn] properties: add `tls-cipher` to list of advanced parameters



commit 0b6f410e9f565271d5e942757c5c6d07f34ed51d
Author: Will Rouesnel <wrouesnel wrouesnel com>
Date:   Fri Jul 29 10:13:25 2022 +1000

    properties: add `tls-cipher` to list of advanced parameters
    
    This value being missing from the hash means that if it is added to the
    *.nmconnection file, despite being valid it will be removed if any
    operation triggers the GUI (i.e. like toggling the link active).
    
    This patch adds it to the initial hash table lookup, and includes a
    freetext field under the advanced tab to allow it to be entered.
    
    Users who need this field will find details online, and the tooltip
    text makes how to set it clear.
    
    https://gitlab.gnome.org/GNOME/NetworkManager-openvpn/-/merge_requests/53

 properties/nm-openvpn-dialog.ui | 25 +++++++++++++++++++++++++
 properties/nm-openvpn-editor.c  | 13 +++++++++++++
 2 files changed, 38 insertions(+)
---
diff --git a/properties/nm-openvpn-dialog.ui b/properties/nm-openvpn-dialog.ui
index 24d36f5..9211898 100644
--- a/properties/nm-openvpn-dialog.ui
+++ b/properties/nm-openvpn-dialog.ui
@@ -2249,6 +2249,31 @@ config: extra-certs &lt;file&gt;</property>
                             <property name="top_attach">3</property>
                           </packing>
                         </child>
+                        <child>
+                          <object class="GtkLabel" id="tls_cipher_lbl">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="label" translatable="yes">TLS cipher string</property>
+                            <property name="use_underline">False</property>
+                            <property name="xalign">1</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">0</property>
+                            <property name="top_attach">4</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkEntry" id="tls_cipher">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="tooltip_text" translatable="yes">Set a value for the 
--tls-cipher parameter. This can be useful for working with VPNs using deprecated hashing schemes.</property>
+                            <property name="hexpand">True</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">1</property>
+                            <property name="top_attach">4</property>
+                          </packing>
+                        </child>
                       </object>
                       <packing>
                         <property name="left_attach">0</property>
diff --git a/properties/nm-openvpn-editor.c b/properties/nm-openvpn-editor.c
index 64978f2..46ea74c 100644
--- a/properties/nm-openvpn-editor.c
+++ b/properties/nm-openvpn-editor.c
@@ -808,6 +808,7 @@ static const char *const advanced_keys[] = {
        NM_OPENVPN_KEY_TA,
        NM_OPENVPN_KEY_TAP_DEV,
        NM_OPENVPN_KEY_TA_DIR,
+       NM_OPENVPN_KEY_TLS_CIPHER,
        NM_OPENVPN_KEY_TLS_CRYPT,
        NM_OPENVPN_KEY_TLS_CRYPT_V2,
        NM_OPENVPN_KEY_TLS_REMOTE,
@@ -1853,6 +1854,13 @@ advanced_dialog_new (GHashTable *hash, const char *contype)
        chooser_button_update_file (label, file);
        g_clear_object (&file);
 
+       /* TLS cipher string */
+       value = g_hash_table_lookup (hash, NM_OPENVPN_KEY_TLS_CIPHER);
+       if (value && *value) {
+               widget = GTK_WIDGET (gtk_builder_get_object (builder, "tls_cipher"));
+               gtk_editable_set_text (GTK_EDITABLE (widget), value);
+       }
+
        /* ping check */
        value = g_hash_table_lookup (hash, NM_OPENVPN_KEY_PING);
        _builder_init_optional_spinbutton (builder, "ping_checkbutton", "ping_spinbutton", !!value,
@@ -2335,6 +2343,11 @@ advanced_dialog_new_hash_from_dialog (GtkWidget *dialog)
                g_clear_object (&file);
        }
 
+       entry = GTK_WIDGET (gtk_builder_get_object (builder, "tls_cipher"));
+       value = gtk_editable_get_text (GTK_EDITABLE (entry));
+       if (value && *value)
+               g_hash_table_insert (hash, NM_OPENVPN_KEY_TLS_CIPHER, g_strdup (value));
+
        widget = GTK_WIDGET (gtk_builder_get_object (builder, "ping_checkbutton"));
        if (gtk_check_button_get_active (GTK_CHECK_BUTTON (widget))) {
                int ping_val;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]