[network-manager-openvpn] core/ui: add '--remote-random' to allow randomizing order of gateways
- From: JiÅÃ KlimeÅ <jklimes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-openvpn] core/ui: add '--remote-random' to allow randomizing order of gateways
- Date: Thu, 29 Mar 2012 13:56:45 +0000 (UTC)
commit cb81bdcea8b043ee8890cf930d88c9e30fc28612
Author: 4garbage <4garbage mail ru>
Date: Thu Mar 29 11:49:11 2012 +0200
core/ui: add '--remote-random' to allow randomizing order of gateways
If the parameter is used, openvpn shuffles the list of gateways to provide a
kind of load-balancing. This commit also allows usage of multiple gateways
(--remote openvpn argument) even if "Randomize remote hosts" is not checked.
Fixed by jklimes
po/ru.po | 3 +++
properties/auth-helpers.c | 13 ++++++++++++-
properties/nm-openvpn-dialog.ui | 19 ++++++++++++++++++-
src/nm-openvpn-service.c | 15 +++++++++++++--
src/nm-openvpn-service.h | 1 +
5 files changed, 47 insertions(+), 4 deletions(-)
---
diff --git a/po/ru.po b/po/ru.po
index 3c6e9c2..a89b8ed 100644
--- a/po/ru.po
+++ b/po/ru.po
@@ -356,6 +356,9 @@ msgstr "ÐÐÑ ÐÐÐÑÐÐÐÐÑÐÐÑ:"
msgid "_Gateway:"
msgstr "_ÐÐÑÐ:"
+msgid "Rando_mize remote hosts"
+msgstr "_ÐÐÑÑÐÐÐÑÐ ÑÐÑÐ"
+
#: ../src/nm-openvpn-service.c:192
#, c-format
msgid "invalid address '%s'"
diff --git a/properties/auth-helpers.c b/properties/auth-helpers.c
index 1e67021..8ced138 100644
--- a/properties/auth-helpers.c
+++ b/properties/auth-helpers.c
@@ -2,7 +2,7 @@
/***************************************************************************
*
* Copyright (C) 2008 - 2010 Dan Williams, <dcbw redhat com>
- * Copyright (C) 2008 - 2011 Red Hat, Inc.
+ * Copyright (C) 2008 - 2012 Red Hat, Inc.
* Copyright (C) 2008 Tambet Ingo, <tambet gmail com>
*
* This program is free software; you can redistribute it and/or modify
@@ -946,6 +946,7 @@ static const char *advanced_keys[] = {
NM_OPENVPN_KEY_TA,
NM_OPENVPN_KEY_RENEG_SECONDS,
NM_OPENVPN_KEY_TLS_REMOTE,
+ NM_OPENVPN_KEY_REMOTE_RANDOM,
NULL
};
@@ -1529,6 +1530,12 @@ advanced_dialog_new (GHashTable *hash, const char *contype)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
}
+ value = g_hash_table_lookup (hash, NM_OPENVPN_KEY_REMOTE_RANDOM);
+ if (value && !strcmp (value, "yes")) {
+ widget = GTK_WIDGET (gtk_builder_get_object (builder, "remote_random_checkbutton"));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
+ }
+
widget = GTK_WIDGET (gtk_builder_get_object (builder, "cipher_combo"));
value = g_hash_table_lookup (hash, NM_OPENVPN_KEY_CIPHER);
populate_cipher_combo (GTK_COMBO_BOX (widget), value);
@@ -1728,6 +1735,10 @@ advanced_dialog_new_hash_from_dialog (GtkWidget *dialog, GError **error)
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
g_hash_table_insert (hash, g_strdup (NM_OPENVPN_KEY_TAP_DEV), g_strdup ("yes"));
+ widget = GTK_WIDGET (gtk_builder_get_object (builder, "remote_random_checkbutton"));
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
+ g_hash_table_insert (hash, g_strdup (NM_OPENVPN_KEY_REMOTE_RANDOM), g_strdup ("yes"));
+
widget = GTK_WIDGET (gtk_builder_get_object (builder, "cipher_combo"));
model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter)) {
diff --git a/properties/nm-openvpn-dialog.ui b/properties/nm-openvpn-dialog.ui
index 6c65cce..937d9a4 100644
--- a/properties/nm-openvpn-dialog.ui
+++ b/properties/nm-openvpn-dialog.ui
@@ -414,6 +414,23 @@
<property name="position">7</property>
</packing>
</child>
+ <child>
+ <object class="GtkCheckButton" id="remote_random_checkbutton">
+ <property name="label" translatable="yes">Rando_mize remote hosts</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="tooltip_text" translatable="yes">Randomize the order of gataways list (remote) as a kind of basic load-balancing measure. config: remote-random</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">8</property>
+ </packing>
+ </child>
</object>
</child>
<child type="tab">
@@ -1089,7 +1106,7 @@ Example: /CN=myvpn.company.com</i></property>
<object class="GtkEntry" id="gateway_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="tooltip_text" translatable="yes">Remote host name or IP address. config: remote</property>
+ <property name="tooltip_text" translatable="yes">Remote host name or IP address. You can specify multiple items for redundancy (use commas to separate the entries). config: remote</property>
</object>
</child>
</object>
diff --git a/src/nm-openvpn-service.c b/src/nm-openvpn-service.c
index 852d3cb..660fd2f 100644
--- a/src/nm-openvpn-service.c
+++ b/src/nm-openvpn-service.c
@@ -111,6 +111,7 @@ static ValidProperty valid_properties[] = {
{ NM_OPENVPN_KEY_PROXY_RETRY, G_TYPE_BOOLEAN, 0, 0, FALSE },
{ NM_OPENVPN_KEY_HTTP_PROXY_USERNAME, G_TYPE_STRING, 0, 0, FALSE },
{ NM_OPENVPN_KEY_REMOTE, G_TYPE_STRING, 0, 0, FALSE },
+ { NM_OPENVPN_KEY_REMOTE_RANDOM, G_TYPE_BOOLEAN, 0, 0, FALSE },
{ NM_OPENVPN_KEY_REMOTE_IP, G_TYPE_STRING, 0, 0, TRUE },
{ NM_OPENVPN_KEY_RENEG_SECONDS, G_TYPE_INT, 0, G_MAXINT, FALSE },
{ NM_OPENVPN_KEY_STATIC_KEY, G_TYPE_STRING, 0, 0, FALSE },
@@ -775,10 +776,20 @@ nm_openvpn_start_openvpn_binary (NMOpenvpnPlugin *plugin,
tmp = nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_REMOTE);
if (tmp && strlen (tmp)) {
- add_openvpn_arg (args, "--remote");
- add_openvpn_arg (args, tmp);
+ char *tok;
+ while ((tok = strsep((char**)&tmp, " ,")) != NULL) {
+ if (strlen(tok)) {
+ add_openvpn_arg (args, "--remote");
+ add_openvpn_arg (args, tok);
+ }
+ }
}
+ /* Remote random */
+ tmp = nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_REMOTE_RANDOM);
+ if (tmp && !strcmp (tmp, "yes"))
+ add_openvpn_arg (args, "--remote-random");
+
tmp = nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_PROXY_TYPE);
tmp2 = nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_PROXY_SERVER);
tmp3 = nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_PROXY_PORT);
diff --git a/src/nm-openvpn-service.h b/src/nm-openvpn-service.h
index c1f27c9..affdc5e 100644
--- a/src/nm-openvpn-service.h
+++ b/src/nm-openvpn-service.h
@@ -56,6 +56,7 @@
#define NM_OPENVPN_KEY_PROXY_RETRY "proxy-retry"
#define NM_OPENVPN_KEY_HTTP_PROXY_USERNAME "http-proxy-username"
#define NM_OPENVPN_KEY_REMOTE "remote"
+#define NM_OPENVPN_KEY_REMOTE_RANDOM "remote-random"
#define NM_OPENVPN_KEY_REMOTE_IP "remote-ip"
#define NM_OPENVPN_KEY_STATIC_KEY "static-key"
#define NM_OPENVPN_KEY_STATIC_KEY_DIRECTION "static-key-direction"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]