|
Packit Service |
a2ae7a |
(*
|
|
Packit Service |
a2ae7a |
Module: Strongswan
|
|
Packit Service |
a2ae7a |
Lens for parsing strongSwan configuration files
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
Authors:
|
|
Packit Service |
a2ae7a |
Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: Reference
|
|
Packit Service |
a2ae7a |
strongswan.conf(5), swanctl.conf(5)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: License
|
|
Packit Service |
a2ae7a |
This file is licensed under the LGPL v2+
|
|
Packit Service |
a2ae7a |
*)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
module Strongswan =
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
autoload xfm
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let ws = del /[\n\t ]*(#[\t ]*\n[\n\t ]*)*/
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let rec conf =
|
|
Packit Service |
a2ae7a |
let keys = /[^\/.\{\}#\n\t ]+/ - /include/
|
|
Packit Service |
a2ae7a |
in let lists = /(crl|oscp)_uris|(local|remote)_(addrs|ts)|vips|pools|(ca)?certs|pubkeys|groups|cert_policy|dns|nbns|dhcp|netmask|server|subnet|split_(in|ex)clude|interfaces_(ignore|use)|preferred/
|
|
Packit Service |
a2ae7a |
in let proposals = /((ah|esp)_)?proposals/
|
|
Packit Service |
a2ae7a |
in let name (pat:lens) (sep:string) =
|
|
Packit Service |
a2ae7a |
pat . Util.del_ws_spc . Util.del_str sep
|
|
Packit Service |
a2ae7a |
in let val = store /[^\n\t ].*/ . Util.del_str "\n" . ws ""
|
|
Packit Service |
a2ae7a |
in let sval = Util.del_ws_spc . val
|
|
Packit Service |
a2ae7a |
in let ival (pat:lens) (end:string) =
|
|
Packit Service |
a2ae7a |
Util.del_opt_ws " " . seq "item" . pat . Util.del_str end
|
|
Packit Service |
a2ae7a |
in let list (l:string) (k:regexp) (v:lens) =
|
|
Packit Service |
a2ae7a |
[ label l . name (store k) "=" . counter "item" .
|
|
Packit Service |
a2ae7a |
[ ival v "," ]* . [ ival v "\n" ] . ws "" ]
|
|
Packit Service |
a2ae7a |
in let alg = seq "alg" . store /[a-z0-9]+/
|
|
Packit Service |
a2ae7a |
in (
|
|
Packit Service |
a2ae7a |
[ Util.del_str "#" . label "#comment" . Util.del_opt_ws " " . val ] |
|
|
Packit Service |
a2ae7a |
[ key "include" . sval ] |
|
|
Packit Service |
a2ae7a |
[ name (key (keys - lists - proposals)) "=" . sval ] |
|
|
Packit Service |
a2ae7a |
list "#list" lists (store /[^\n\t ,][^\n,]*/) |
|
|
Packit Service |
a2ae7a |
list "#proposals" proposals (counter "alg" . [ alg ] . [ Util.del_str "-" . alg ]*) |
|
|
Packit Service |
a2ae7a |
[ name (key keys) "{" . ws "\n" . conf . Util.del_str "}" . ws "\n" ]
|
|
Packit Service |
a2ae7a |
)*
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let lns = ws "" . conf
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let xfm = transform lns (
|
|
Packit Service |
a2ae7a |
incl "/etc/strongswan.d/*.conf" .
|
|
Packit Service |
a2ae7a |
incl "/etc/strongswan.d/**/*.conf" .
|
|
Packit Service |
a2ae7a |
incl "/etc/swanctl/conf.d/*.conf" .
|
|
Packit Service |
a2ae7a |
incl "/etc/swanctl/swanctl.conf"
|
|
Packit Service |
a2ae7a |
)
|