;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017 Julien Lepiller <julien@lepiller.eu>
+;;; Copyright © 2017 Clément Lassieur <clement@lassieur.org>
+;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
(define (uglify-field-name name)
(match name
- ('verbosity "verb")
- (_ (let ((str (symbol->string name)))
- (if (string-suffix? "?" str)
- (substring str 0 (1- (string-length str)))
- str)))))
+ ('verbosity "verb")
+ (_ (let ((str (symbol->string name)))
+ (if (string-suffix? "?" str)
+ (substring str 0 (1- (string-length str)))
+ str)))))
(define (serialize-field field-name val)
(if (eq? field-name 'pid-file)
(format #t "")
(format #t "~a ~a\n" (uglify-field-name field-name) val)))
(define serialize-string serialize-field)
+(define-maybe string)
(define (serialize-boolean field-name val)
(if val
- (serialize-field field-name val)
+ (serialize-field field-name "")
(format #t "")))
(define (ip-mask? val)
#f))
(define (serialize-tls-auth role location)
- (serialize-field 'tls-auth
- (string-append location " " (match role
- ('server "0")
- ('client "1")))))
+ (if location
+ (serialize-field 'tls-auth
+ (string-append location " " (match role
+ ('server "0")
+ ('client "1"))))
+ #f))
(define (tls-auth? val)
(or (eq? val #f)
(string? val)))
(for-each
(lambda (ccd)
(match ccd
- ((name config-string)
- (call-with-output-file
- (string-append #$output "/" name)
- (lambda (port) (display config-string port))))))
+ ((name config-string)
+ (call-with-output-file
+ (string-append #$output "/" name)
+ (lambda (port) (display config-string port))))))
'#$files))))))
(define-syntax define-split-configuration
(key
(string "/etc/openvpn/client.key")
- "The key of the machine the daemon is running on. It must be the whose
+ "The key of the machine the daemon is running on. It must be the key whose
certificate is @code{cert}.")
(comp-lzo?
"Don't close and reopen TUN/TAP device or run up/down scripts across
SIGUSR1 or --ping-restart restarts.")
+ (fast-io?
+ (boolean #f)
+ "(Experimental) Optimize TUN/TAP/UDP I/O writes by avoiding a call to
+poll/epoll/select prior to the write operation.")
+
(verbosity
(number 3)
"Verbosity level."))
"Add an additional layer of HMAC authentication on top of the TLS control
channel to protect against DoS attacks.")
+ (auth-user-pass
+ (maybe-string 'disabled)
+ "Authenticate with server using username/password. The option is a file
+containing username/password on 2 lines. Do not use a file-like object as it
+would be added to the store and readable by any user.")
+
(verify-key-usage?
(key-usage #t)
"Whether to check the server certificate has server usage extension.")
(client-to-client?
(boolean #f)
- "When true, clients are alowed to talk to each other inside the VPN.")
+ "When true, clients are allowed to talk to each other inside the VPN.")
(keepalive
(keepalive '(10 120))
(status
(string "/var/run/openvpn/status")
"The status file. This file shows a small report on current connection. It
-is trunkated and rewritten every minute.")
+is truncated and rewritten every minute.")
(client-config-dir
(openvpn-ccd-list '())
(lambda ()
(serialize-configuration config
(match role
- ('server
- openvpn-server-configuration-fields)
- ('client
- openvpn-client-configuration-fields))))))
+ ('server
+ openvpn-server-configuration-fields)
+ ('client
+ openvpn-client-configuration-fields))))))
(ccd-dir (match role
- ('server (create-ccd-directory
- (openvpn-server-configuration-client-config-dir
- config)))
- ('client #f))))
+ ('server (create-ccd-directory
+ (openvpn-server-configuration-client-config-dir
+ config)))
+ ('client #f))))
(computed-file "openvpn.conf"
#~(begin
(use-modules (ice-9 match))
(call-with-output-file #$output
(lambda (port)
(match '#$role
- ('server (display "" port))
- ('client (display "client\n" port)))
+ ('server (display "" port))
+ ('client (display "client\n" port)))
(display #$config-str port)
(match '#$role
- ('server (display
- (string-append "client-config-dir "
- #$ccd-dir "\n") port))
- ('client (display "" port)))))))))
+ ('server (display
+ (string-append "client-config-dir "
+ #$ccd-dir "\n") port))
+ ('client (display "" port)))))))))
(define (openvpn-shepherd-service role)
(lambda (config)
(let* ((config-file (openvpn-config-file role config))
(pid-file ((match role
- ('server openvpn-server-configuration-pid-file)
- ('client openvpn-client-configuration-pid-file))
+ ('server openvpn-server-configuration-pid-file)
+ ('client openvpn-client-configuration-pid-file))
config))
(openvpn ((match role
- ('server openvpn-server-configuration-openvpn)
- ('client openvpn-client-configuration-openvpn))
+ ('server openvpn-server-configuration-openvpn)
+ ('client openvpn-client-configuration-openvpn))
config))
(log-file (match role
- ('server "/var/log/openvpn-server.log")
- ('client "/var/log/openvpn-client.log"))))
+ ('server "/var/log/openvpn-server.log")
+ ('client "/var/log/openvpn-client.log"))))
(list (shepherd-service
(documentation (string-append "Run the OpenVPN "
(match role
- ('server "server")
- ('client "client"))
+ ('server "server")
+ ('client "client"))
" daemon."))
(provision (match role
- ('server '(vpn-server))
- ('client '(vpn-client))))
+ ('server '(vpn-server))
+ ('client '(vpn-client))))
(requirement '(networking))
(start #~(make-forkexec-constructor
(list (string-append #$openvpn "/sbin/openvpn")
(shell (file-append shadow "/sbin/nologin")))))
(define %openvpn-activation
- #~(mkdir-p "/var/run/openvpn"))
+ #~(begin
+ (use-modules (guix build utils))
+ (mkdir-p "/var/run/openvpn")))
(define openvpn-server-service-type
(service-type (name 'openvpn-server)