mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-08-05 21:37:15 +02:00
147 lines
3.6 KiB
Diff
147 lines
3.6 KiB
Diff
From f098555c34789313dfc0c8b587883c3d33b4fe03 Mon Sep 17 00:00:00 2001
|
|
From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
|
|
Date: Sun, 4 Feb 2018 23:35:46 +0200
|
|
Subject: [PATCH] new lens: Strongswan
|
|
|
|
---
|
|
lenses/strongswan.aug | 41 +++++++++++++++++++++++++
|
|
lenses/tests/test_strongswan.aug | 65 ++++++++++++++++++++++++++++++++++++++++
|
|
tests/Makefile.am | 1 +
|
|
3 files changed, 107 insertions(+)
|
|
create mode 100644 lenses/strongswan.aug
|
|
create mode 100644 lenses/tests/test_strongswan.aug
|
|
|
|
diff --git a/lenses/strongswan.aug b/lenses/strongswan.aug
|
|
new file mode 100644
|
|
index 00000000..69d112bd
|
|
--- /dev/null
|
|
+++ b/lenses/strongswan.aug
|
|
@@ -0,0 +1,41 @@
|
|
+(*
|
|
+Module: Strongswan
|
|
+ Lens for parsing strongSwan configuration files
|
|
+
|
|
+Authors:
|
|
+ Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
|
|
+
|
|
+About: Reference
|
|
+ strongswan.conf(5)
|
|
+
|
|
+About: License
|
|
+ This file is licensed under the LGPL v2+
|
|
+*)
|
|
+
|
|
+module Strongswan =
|
|
+
|
|
+autoload xfm
|
|
+
|
|
+let ws = del /[\n\t ]*(#[\t ]*\n[\n\t ]*)*/
|
|
+
|
|
+let rec conf =
|
|
+ let name (sep:string) =
|
|
+ key (/[^\/.\{\}#\n\t ]+/ - /include/) . Util.del_ws_spc .
|
|
+ Util.del_str sep
|
|
+ in let val = store /[^\n\t ].*/ . Util.del_str "\n" . ws ""
|
|
+ in let sval = Util.del_ws_spc . val
|
|
+in (
|
|
+ [ Util.del_str "#" . label "#comment" . Util.del_opt_ws " " . val ] |
|
|
+ [ key "include" . sval ] |
|
|
+ [ name "=" . sval ] |
|
|
+ [ name "{" . ws "\n" . conf . Util.del_str "}" . ws "\n" ]
|
|
+)*
|
|
+
|
|
+let lns = ws "" . conf
|
|
+
|
|
+let xfm = transform lns (
|
|
+ incl "/etc/strongswan.d/*.conf" .
|
|
+ incl "/etc/strongswan.d/**/*.conf" .
|
|
+ incl "/etc/swanctl/conf.d/*.conf" .
|
|
+ incl "/etc/swanctl/swanctl.conf"
|
|
+)
|
|
diff --git a/lenses/tests/test_strongswan.aug b/lenses/tests/test_strongswan.aug
|
|
new file mode 100644
|
|
index 00000000..55fe9052
|
|
--- /dev/null
|
|
+++ b/lenses/tests/test_strongswan.aug
|
|
@@ -0,0 +1,65 @@
|
|
+(*
|
|
+ Some of the configuration snippets have been copied from the strongSwan
|
|
+ source tree.
|
|
+*)
|
|
+
|
|
+module Test_Strongswan =
|
|
+
|
|
+(* conf/strongswan.conf *)
|
|
+let default = "
|
|
+# strongswan.conf - strongSwan configuration file
|
|
+#
|
|
+# Refer to the strongswan.conf(5) manpage for details
|
|
+#
|
|
+# Configuration changes should be made in the included files
|
|
+
|
|
+charon {
|
|
+ load_modular = yes
|
|
+ plugins {
|
|
+ include strongswan.d/charon/*.conf
|
|
+ }
|
|
+}
|
|
+
|
|
+include strongswan.d/*.conf
|
|
+"
|
|
+
|
|
+test Strongswan.lns get default =
|
|
+ { "#comment" = "strongswan.conf - strongSwan configuration file" }
|
|
+ { "#comment" = "Refer to the strongswan.conf(5) manpage for details" }
|
|
+ { "#comment" = "Configuration changes should be made in the included files" }
|
|
+ { "charon"
|
|
+ { "load_modular" = "yes" }
|
|
+ { "plugins" { "include" = "strongswan.d/charon/*.conf" } }
|
|
+ }
|
|
+ { "include" = "strongswan.d/*.conf" }
|
|
+
|
|
+(* conf/strongswan.conf.5.head.in *)
|
|
+let man_example = "
|
|
+ a = b
|
|
+ section-one {
|
|
+ somevalue = asdf
|
|
+ subsection {
|
|
+ othervalue = xxx
|
|
+ }
|
|
+ # yei, a comment
|
|
+ yetanother = zz
|
|
+ }
|
|
+ section-two {
|
|
+ x = 12
|
|
+ }
|
|
+"
|
|
+
|
|
+test Strongswan.lns get man_example =
|
|
+ { "a" = "b" }
|
|
+ { "section-one"
|
|
+ { "somevalue" = "asdf" }
|
|
+ { "subsection" { "othervalue" = "xxx" } }
|
|
+ { "#comment" = "yei, a comment" }
|
|
+ { "yetanother" = "zz" }
|
|
+ }
|
|
+ { "section-two" { "x" = "12" } }
|
|
+
|
|
+test Strongswan.lns get "foo { bar = baz\n } quux {}\t#quuux\n" =
|
|
+ { "foo" { "bar" = "baz" } }
|
|
+ { "quux" }
|
|
+ { "#comment" = "quuux" }
|
|
diff --git a/tests/Makefile.am b/tests/Makefile.am
|
|
index 8e035e91..11827fb0 100644
|
|
--- a/tests/Makefile.am
|
|
+++ b/tests/Makefile.am
|
|
@@ -205,6 +205,7 @@ lens_tests = \
|
|
lens-sshd.sh \
|
|
lens-sssd.sh \
|
|
lens-star.sh \
|
|
+ lens-strongswan.sh \
|
|
lens-stunnel.sh \
|
|
lens-subversion.sh \
|
|
lens-sysconfig.sh \
|
|
--
|
|
2.16.1
|
|
|