diff options
Diffstat (limited to 'battering/services')
-rw-r--r-- | battering/services/opensnitch.scm | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/battering/services/opensnitch.scm b/battering/services/opensnitch.scm index 435e9f7..6f782c1 100644 --- a/battering/services/opensnitch.scm +++ b/battering/services/opensnitch.scm @@ -9,9 +9,9 @@ #:use-module (battering packages opensnitch) #:use-module (srfi srfi-171) - #:export (opensnitchd-configuration + #:export (opensnitch-configuration serialize-json-configuration - opensnitchd-service-type)) + opensnitch-service-type)) ;; Turns lisp-case into PascalCase (define (pascal-field-name field-name) @@ -69,7 +69,7 @@ corresponding to the FIELDS of CONFIG." '#$(list-transduce (base-transducer config) rcons fields) #:pretty #t))))) -(define-configuration opensnitchd-configuration +(define-configuration opensnitch-configuration (opensnitchd (file-like opensnitchd) "Opensnitchd package to use.") @@ -99,11 +99,14 @@ corresponding to the FIELDS of CONFIG." "Duration of the rules created automatically.") (intercept-unknown? (boolean #f) - "Intercept unknown network connections?")) + "Intercept unknown network connections?") + (rules + (list '()) + "List of rules to add in /etc/opensnitchd/rules.")) -(define (opensnitchd-activation config) - "Create the opensnitchd rules and configuration according to CONFIG." - (match-record config <opensnitchd-configuration> (opensnitchd) +(define (opensnitch-activation config) + "Create the opensnitch rules and configuration according to CONFIG." + (match-record config <opensnitch-configuration> (opensnitchd) (with-imported-modules '((guix build utils)) #~(begin (use-modules (guix build utils)) @@ -112,8 +115,8 @@ corresponding to the FIELDS of CONFIG." (copy-file #$(file-append opensnitchd "/etc/system-fw.json") "/etc/opensnitchd/system-fw.json")))))) -(define (opensnitchd-shepherd-service config) - "Return a <shepherd-service> for opensnitchd with CONFIG." +(define (opensnitch-shepherd-service config) + "Return a <shepherd-service> for opensnitch with CONFIG." (let ((default-config (computed-file "opensnitchd-config.json" @@ -121,29 +124,29 @@ corresponding to the FIELDS of CONFIG." (lambda _ #$(serialize-json-configuration config - opensnitchd-configuration-fields)))))) + opensnitch-configuration-fields)))))) (list (shepherd-service (documentation "Opensnitchd daemon.") (requirement '(syslogd loopback)) - (provision '(opensnitchd)) + (provision '(opensnitch)) (start #~(make-forkexec-constructor (list #$(file-append opensnitchd "/bin/opensnitchd") "-config-file" #$default-config))) (stop #~(make-kill-destructor)))))) -(define opensnitchd-service-type +(define opensnitch-service-type (service-type - (name 'opensnitchd) + (name 'opensnitch) (description "Run the Opensnitch application firewall daemon.") (extensions (list (service-extension shepherd-root-service-type - opensnitchd-shepherd-service) + opensnitch-shepherd-service) (service-extension activation-service-type - opensnitchd-activation) + opensnitch-activation) (service-extension profile-service-type (lambda (config) - `(,(opensnitchd-configuration-opensnitchd config)))))) + `(,(opensnitch-configuration-opensnitchd config)))))) (compose identity) - (default-value (opensnitchd-configuration)))) + (default-value (opensnitch-configuration)))) |