aboutsummaryrefslogtreecommitdiff
path: root/module/entry-points
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-03-31 00:42:27 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-03-31 00:42:27 +0200
commitb1b04a666d141b318b7a39b6d4154e43afb8513f (patch)
treefca197f951e91c68bee7776fe256813169dc5cbd /module/entry-points
parentImprove server directory listing. (diff)
downloadcalp-b1b04a666d141b318b7a39b6d4154e43afb8513f.tar.gz
calp-b1b04a666d141b318b7a39b6d4154e43afb8513f.tar.xz
Update server-main to allow for IPv6.
Diffstat (limited to 'module/entry-points')
-rw-r--r--module/entry-points/server.scm22
1 files changed, 17 insertions, 5 deletions
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)