[NetworkManager-openvpn: 2/4] import-export: add push-peer-info support
- From: Thomas Haller <thaller src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [NetworkManager-openvpn: 2/4] import-export: add push-peer-info support
- Date: Mon, 30 Mar 2020 08:03:54 +0000 (UTC)
commit e6a415cd5773f3206979f8fc24a669c47a0478f9
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Mon Mar 30 08:33:19 2020 +0200
import-export: add push-peer-info support
Makefile.am | 1 +
properties/import-export.c | 10 ++++++++++
properties/tests/conf/push-peer-info.ovpn | 5 +++++
properties/tests/test-import-export.c | 17 +++++++++++++++++
shared/utils.h | 1 +
5 files changed, 34 insertions(+)
---
diff --git a/Makefile.am b/Makefile.am
index ebf250e..2358340 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -310,6 +310,7 @@ EXTRA_DIST += \
properties/tests/conf/keepalive.ovpn \
properties/tests/conf/ping-with-exit.ovpn \
properties/tests/conf/ping-with-restart.ovpn \
+ properties/tests/conf/push-peer-info.ovpn \
properties/tests/conf/route.ovpn \
properties/tests/conf/server-poll-timeout.ovpn \
properties/tests/conf/crl-file.ovpn \
diff --git a/properties/import-export.c b/properties/import-export.c
index 217e78b..151a223 100644
--- a/properties/import-export.c
+++ b/properties/import-export.c
@@ -1193,6 +1193,13 @@ do_import (const char *path, const char *contents, gsize contents_len, GError **
continue;
}
+ if (NM_IN_STRSET (params[0], NMV_OVPN_TAG_PUSH_PEER_INFO)) {
+ if (!args_params_check_nargs_n (params, 0, &line_error))
+ goto handle_line_error;
+ setting_vpn_add_data_item (s_vpn, NM_OPENVPN_KEY_PUSH_PEER_INFO, "yes");
+ continue;
+ }
+
if (NM_IN_STRSET (params[0], NMV_OVPN_TAG_PORT, NMV_OVPN_TAG_RPORT)) {
if (!args_params_check_nargs_n (params, 1, &line_error))
goto handle_line_error;
@@ -1944,6 +1951,9 @@ do_export_create (NMConnection *connection, const char *path, GError **error)
if (nm_streq0 (nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_TUN_IPV6), "yes"))
args_write_line (f, NMV_OVPN_TAG_TUN_IPV6);
+ if (nm_streq0 (nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_PUSH_PEER_INFO), "yes"))
+ args_write_line (f, NMV_OVPN_TAG_PUSH_PEER_INFO);
+
{
gs_free char *cacert_free = NULL, *user_cert_free = NULL, *private_key_free = NULL;
const char *cacert = NULL, *user_cert = NULL, *private_key = NULL;
diff --git a/properties/tests/conf/push-peer-info.ovpn b/properties/tests/conf/push-peer-info.ovpn
new file mode 100644
index 0000000..fb439c4
--- /dev/null
+++ b/properties/tests/conf/push-peer-info.ovpn
@@ -0,0 +1,5 @@
+remote 173.8.149.245 666
+dev tun
+client
+
+push-peer-info
diff --git a/properties/tests/test-import-export.c b/properties/tests/test-import-export.c
index ed63529..367130e 100644
--- a/properties/tests/test-import-export.c
+++ b/properties/tests/test-import-export.c
@@ -997,6 +997,20 @@ test_compress_import (void)
_check_item (s_vpn, NM_OPENVPN_KEY_COMPRESS, "lzo");
}
+static void
+test_push_peer_info_import (void)
+{
+ _CREATE_PLUGIN (plugin);
+ gs_unref_object NMConnection *connection = NULL;
+ NMSettingVpn *s_vpn;
+
+ connection = get_basic_connection (plugin, SRCDIR, "push-peer-info.ovpn");
+
+ s_vpn = nm_connection_get_setting_vpn (connection);
+
+ _check_item (s_vpn, NM_OPENVPN_KEY_PUSH_PEER_INFO, "yes");
+}
+
/*****************************************************************************/
static void
@@ -1182,6 +1196,9 @@ int main (int argc, char **argv)
_add_test_func_simple (test_compress_import);
_add_test_func ("compress-export", test_export_compare, "compress.ovpn", "compress.ovpntest");
+ _add_test_func_simple (test_push_peer_info_import);
+ _add_test_func ("push-peer-info-export", test_export_compare, "push-peer-info.ovpn",
"push-peer-info.ovpntest");
+
_add_test_func_simple (test_args_parse_line);
result = g_test_run ();
diff --git a/shared/utils.h b/shared/utils.h
index d109b0e..f2882cf 100644
--- a/shared/utils.h
+++ b/shared/utils.h
@@ -61,6 +61,7 @@
#define NMV_OVPN_TAG_PKCS12 "pkcs12"
#define NMV_OVPN_TAG_PORT "port"
#define NMV_OVPN_TAG_PROTO "proto"
+#define NMV_OVPN_TAG_PUSH_PEER_INFO "push-peer-info"
#define NMV_OVPN_TAG_REMOTE "remote"
#define NMV_OVPN_TAG_REMOTE_CERT_TLS "remote-cert-tls"
#define NMV_OVPN_TAG_REMOTE_RANDOM "remote-random"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]