[network-manager-openvpn/jk/import-proto-in-remote] import/export: add missing code for 'remote-random' option



commit 2c73ae48d5f87fcd2e04f5f1e0a452db9f81cf66
Author: Jiří Klimeš <jklimes redhat com>
Date:   Mon May 18 17:00:38 2015 +0200

    import/export: add missing code for 'remote-random' option

 properties/import-export.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/properties/import-export.c b/properties/import-export.c
index 1d9d6fa..68909f2 100644
--- a/properties/import-export.c
+++ b/properties/import-export.c
@@ -66,6 +66,7 @@
 #define SOCKS_PROXY_TAG "socks-proxy "
 #define SOCKS_PROXY_RETRY_TAG "socks-proxy-retry"
 #define REMOTE_TAG "remote "
+#define REMOTE_RANDOM_TAG "remote-random"
 #define RENEG_SEC_TAG "reneg-sec "
 #define RPORT_TAG "rport "
 #define SECRET_TAG "secret "
@@ -566,6 +567,11 @@ do_import (const char *path, char **lines, GError **error)
                        continue;
                }
 
+               if (!strncmp (*line, REMOTE_RANDOM_TAG, strlen (REMOTE_RANDOM_TAG))) {
+                       nm_setting_vpn_add_data_item (s_vpn, NM_OPENVPN_KEY_REMOTE_RANDOM, "yes");
+                       continue;
+               }
+
                if (   !strncmp (*line, PORT_TAG, strlen (PORT_TAG))
                    || !strncmp (*line, RPORT_TAG, strlen (RPORT_TAG))) {
                        if (!strncmp (*line, PORT_TAG, strlen (PORT_TAG)))
@@ -814,6 +820,7 @@ do_export (const char *path, NMConnection *connection, GError **error)
        guint32 reneg = 0;
        gboolean keysize_exists = FALSE;
        guint32 keysize = 0;
+       gboolean randomize_hosts = FALSE;
        const char *proxy_type = NULL;
        const char *proxy_server = NULL;
        const char *proxy_port = NULL;
@@ -940,6 +947,10 @@ do_export (const char *path, NMConnection *connection, GError **error)
        if (value && strlen (value))
                remote_cert_tls = value;
 
+       value = nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_REMOTE_RANDOM);
+       if (value && !strcmp (value, "yes"))
+               randomize_hosts = TRUE;
+
        /* Advanced values end */
 
        fprintf (f, "client\n");
@@ -971,6 +982,9 @@ do_export (const char *path, NMConnection *connection, GError **error)
        }
        g_strfreev (gw_list);
 
+       if (randomize_hosts)
+               fprintf (f, "remote-random\n");
+
        /* Handle PKCS#12 (all certs are the same file) */
        if (   cacert && user_cert && private_key
            && !strcmp (cacert, user_cert) && !strcmp (cacert, private_key))


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