Commit 2ecf18c2 authored by Thomas Haller's avatar Thomas Haller

better support comp-lzo setting

Openvpn understands more options with --comp-lzo:

 1a) --comp-lzo
 1b) --comp-lzo adaptive
 2)  --comp-lzo yes
 3)  --comp-lzo no
 4)  (unspecified)

This already works for a long time, so it's safe to assume
that the openvpn version at hand understands these options
(https://github.com/OpenVPN/openvpn/commit/537073fd55b3e35720e759c5c13e9da128a2b0bb).

Add support for all combinations for import/export and running the
service.

But don't extend the GUI plugin which only shows a checkbox.
When configuring via gnome plugin, only 2) and 4) can be expressed.

https://bugzilla.gnome.org/show_bug.cgi?id=739519
parent 77e722f9
......@@ -1639,7 +1639,12 @@ advanced_dialog_new (GHashTable *hash, const char *contype)
}
value = g_hash_table_lookup (hash, NM_OPENVPN_KEY_COMP_LZO);
if (value && !strcmp (value, "yes")) {
if (NM_IN_STRSET (value, "yes", "adaptive")) {
/* the UI currently only supports "--comp-lzo yes" or omitting the "--comp-lzo"
* flag.
*
* Internally, we also support "--comp-lzo [adaptive]" and "--comp-lzo no"
* which have different meaning for openvpn. */
widget = GTK_WIDGET (gtk_builder_get_object (builder, "lzo_checkbutton"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
}
......@@ -2007,8 +2012,12 @@ advanced_dialog_new_hash_from_dialog (GtkWidget *dialog, GError **error)
}
widget = GTK_WIDGET (gtk_builder_get_object (builder, "lzo_checkbutton"));
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) {
/* we only have a checkbox, which we either map to "--comp-lzo yes" or
* no "--comp-lzo" flag. In the UI, we cannot express "--comp-lzo [adaptive]"
* or "--comp-lzo no". */
g_hash_table_insert (hash, g_strdup (NM_OPENVPN_KEY_COMP_LZO), g_strdup ("yes"));
}
widget = GTK_WIDGET (gtk_builder_get_object (builder, "mssfix_checkbutton"));
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
......
......@@ -906,15 +906,11 @@ do_import (const char *path, const char *contents, gsize contents_len, GError **
if (NM_IN_STRSET (params[0], NMV_OVPN_TAG_COMP_LZO)) {
if (!args_params_check_nargs_minmax (params, 0, 1, &line_error))
goto handle_line_error;
if (params[1]) {
if (nm_streq (params[1], "no"))
continue;
if (!nm_streq (params[1], "yes")) {
line_error = g_strdup_printf (_("unsupported comp-lzo argument"));
goto handle_line_error;
}
if (!NM_IN_STRSET (params[1], NULL, "no", "yes", "adaptive")) {
line_error = g_strdup_printf (_("unsupported comp-lzo argument"));
goto handle_line_error;
}
setting_vpn_add_data_item (s_vpn, NM_OPENVPN_KEY_COMP_LZO, "yes");
setting_vpn_add_data_item (s_vpn, NM_OPENVPN_KEY_COMP_LZO, params[1] ?: "adaptive");
continue;
}
......@@ -1751,8 +1747,9 @@ do_export_create (NMConnection *connection, const char *path, GError **error)
args_write_line_setting_value_int (f, NMV_OVPN_TAG_KEYSIZE, s_vpn, NM_OPENVPN_KEY_KEYSIZE);
if (nm_streq0 (nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_COMP_LZO), "yes"))
args_write_line (f, NMV_OVPN_TAG_COMP_LZO, "yes");
value = nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_COMP_LZO);
if (value)
args_write_line (f, NMV_OVPN_TAG_COMP_LZO, value);
if (nm_streq0 (nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_FLOAT), "yes"))
args_write_line (f, NMV_OVPN_TAG_FLOAT);
......
......@@ -232,7 +232,7 @@ test_tls_import (void)
_check_item (s_vpn, NM_OPENVPN_KEY_CONNECTION_TYPE, NM_OPENVPN_CONTYPE_TLS);
_check_item (s_vpn, NM_OPENVPN_KEY_DEV, "tun");
_check_item (s_vpn, NM_OPENVPN_KEY_PROTO_TCP, NULL);
_check_item (s_vpn, NM_OPENVPN_KEY_COMP_LZO, "yes");
_check_item (s_vpn, NM_OPENVPN_KEY_COMP_LZO, "adaptive");
_check_item (s_vpn, NM_OPENVPN_KEY_FLOAT, "yes");
_check_item (s_vpn, NM_OPENVPN_KEY_RENEG_SECONDS, NULL);
_check_item (s_vpn, NM_OPENVPN_KEY_REMOTE, "173.8.149.245:1194");
......@@ -325,7 +325,7 @@ test_tls_inline_import (void)
_check_item (s_vpn, NM_OPENVPN_KEY_CONNECTION_TYPE, NM_OPENVPN_CONTYPE_TLS);
_check_item (s_vpn, NM_OPENVPN_KEY_DEV, "tun");
_check_item (s_vpn, NM_OPENVPN_KEY_PROTO_TCP, NULL);
_check_item (s_vpn, NM_OPENVPN_KEY_COMP_LZO, "yes");
_check_item (s_vpn, NM_OPENVPN_KEY_COMP_LZO, "adaptive");
_check_item (s_vpn, NM_OPENVPN_KEY_FLOAT, "yes");
_check_item (s_vpn, NM_OPENVPN_KEY_RENEG_SECONDS, NULL);
_check_item (s_vpn, NM_OPENVPN_KEY_REMOTE, "173.8.149.245:1194");
......@@ -419,7 +419,7 @@ test_pkcs12_import (void)
_check_item (s_vpn, NM_OPENVPN_KEY_CONNECTION_TYPE, NM_OPENVPN_CONTYPE_TLS);
_check_item (s_vpn, NM_OPENVPN_KEY_DEV, "tun");
_check_item (s_vpn, NM_OPENVPN_KEY_PROTO_TCP, NULL);
_check_item (s_vpn, NM_OPENVPN_KEY_COMP_LZO, "yes");
_check_item (s_vpn, NM_OPENVPN_KEY_COMP_LZO, "adaptive");
_check_item (s_vpn, NM_OPENVPN_KEY_FLOAT, NULL);
_check_item (s_vpn, NM_OPENVPN_KEY_RENEG_SECONDS, NULL);
_check_item (s_vpn, NM_OPENVPN_KEY_REMOTE, "173.8.149.245:1194");
......
......@@ -105,7 +105,7 @@ static ValidProperty valid_properties[] = {
{ NM_OPENVPN_KEY_CERT, G_TYPE_STRING, 0, 0, FALSE },
{ NM_OPENVPN_KEY_CIPHER, G_TYPE_STRING, 0, 0, FALSE },
{ NM_OPENVPN_KEY_KEYSIZE, G_TYPE_INT, 1, 65535, FALSE },
{ NM_OPENVPN_KEY_COMP_LZO, G_TYPE_BOOLEAN, 0, 0, FALSE },
{ NM_OPENVPN_KEY_COMP_LZO, G_TYPE_STRING, 0, 0, FALSE },
{ NM_OPENVPN_KEY_CONNECTION_TYPE, G_TYPE_STRING, 0, 0, FALSE },
{ NM_OPENVPN_KEY_FLOAT, G_TYPE_BOOLEAN, 0, 0, FALSE },
{ NM_OPENVPN_KEY_FRAGMENT_SIZE, G_TYPE_INT, 0, G_MAXINT, FALSE },
......@@ -1242,8 +1242,10 @@ nm_openvpn_start_openvpn_binary (NMOpenvpnPlugin *plugin,
}
tmp = nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_COMP_LZO);
if (tmp && !strcmp (tmp, "yes"))
if (NM_IN_STRSET (tmp, "yes", "no", "adaptive")) {
add_openvpn_arg (args, "--comp-lzo");
add_openvpn_arg (args, tmp);
}
tmp = nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_FLOAT);
if (tmp && !strcmp (tmp, "yes"))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment