Skip to content

Instantly share code, notes, and snippets.

@obeattie
Created August 21, 2011 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save obeattie/1160566 to your computer and use it in GitHub Desktop.
Save obeattie/1160566 to your computer and use it in GitHub Desktop.
Augeas schema for stunnel configuration
(* Stunnel configuration file module for Augeas *)
module StunnelConfig =
autoload xfm
let comment = IniFile.comment IniFile.comment_re IniFile.comment_default
let sep = IniFile.sep "=" "="
let setting = "chroot"
| "compression"
| "debug"
| "EGD"
| "engine"
| "engineCtrl"
| "fips"
| "foreground"
| "output"
| "pid"
| "RNDbytes"
| "RNDfile"
| "RNDoverwrite"
| "service"
| "setgid"
| "setuid"
| "socket"
| "syslog"
| "taskbar"
| "accept"
| "CApath"
| "CAfile"
| "cert"
| "ciphers"
| "client"
| "connect"
| "CRLpath"
| "CRLfile"
| "curve"
| "delay"
| "engineNum"
| "exec"
| "execargs"
| "failover"
| "ident"
| "key"
| "local"
| "OCSP"
| "OCSPflag"
| "options"
| "protocol"
| "protocolAuthentication"
| "protocolHost"
| "protocolPassword"
| "protocolUsername"
| "pty"
| "retry"
| "session"
| "sessiond"
| "sni"
| "sslVersion"
| "stack"
| "TIMEOUTbusy"
| "TIMEOUTclose"
| "TIMEOUTconnect"
| "TIMEOUTidle"
| "transparent"
| "verify"
let entry = IniFile.indented_entry setting sep comment
let empty = IniFile.empty
let title = IniFile.indented_title ( IniFile.record_re - ".anon" )
let record = IniFile.record title entry
let rc_anon = [ label ".anon" . ( entry | empty )+ ]
let lns = rc_anon? . record*
let filter = (incl "/etc/stunnel/stunnel.conf")
. Util.stdexcl
let xfm = transform lns filter
module Test_stunnelconf =
let conf ="; Test stunnel-like config file
; Foo bar baz
cert = /path/1
key = /path/2
sslVersion = SSLv3
; another comment
[service1]
accept = 49999
connect = servicedest:1234
[service2]
accept = 1234
"
test StunnelConfig.lns get conf =
{ ".anon"
{ "#comment" = "Test stunnel-like config file" }
{ "#comment" = "Foo bar baz" }
{ "cert" = "/path/1" }
{ "key" = "/path/2" }
{}
{ "sslVersion" = "SSLv3" }
{}
{ "#comment" = "another comment" }
{}
}
{ "service1"
{ "accept" = "49999" }
{ "connect" = "servicedest:1234" }
{}
}
{ "service2"
{ "accept" = "1234" }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment