From b1b04a666d141b318b7a39b6d4154e43afb8513f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 31 Mar 2020 00:42:27 +0200 Subject: Update server-main to allow for IPv6. --- module/entry-points/server.scm | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'module/entry-points') diff --git a/module/entry-points/server.scm b/module/entry-points/server.scm index 1a257717..972b89a8 100644 --- a/module/entry-points/server.scm +++ b/module/entry-points/server.scm @@ -104,17 +104,29 @@ (define options '((port (value #t) (single-char #\p)) - (addr (value #t)))) + (addr (value #t)) + (family (value #t) + (predicate ,(lambda (v) (memv (string->symbol (string-upcase v)) + '(INET INET4 INET6))))))) -(define-public (server-main c e args) +(define-public (main args) (define opts (getopt-long args options)) (define port (option-ref opts 'port 8080)) - (define addr (option-ref opts 'addr INADDR_LOOPBACK)) - + (define family (case (string->symbol (string-upcase (option-ref opts 'family "INET6"))) + [(INET INET4) AF_INET] + [(INET6) AF_INET6] + [else (error "That address family is not supported")]) ) + ;; TODO the guile methods wants the ip address in numeric form. This is currently extra impossible + (define addr (option-ref opts 'addr 0)) + + (define-values (c e) + (load-calendars + calendar-files: (cond [(option-ref opts 'file #f) => list] + [else (calendar-files)]) )) (format #t "Starting server on ~a:~a~%I'm ~a, runing from ~a~%" - (number->string addr 16) port + (inet-ntop family addr) port (getpid) (getcwd)) (run-server (make-make-routes c e) -- cgit v1.2.3